]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/object_map/UpdateRequest.h
update sources to v12.1.0
[ceph.git] / ceph / src / librbd / object_map / UpdateRequest.h
CommitLineData
7c673cae
FG
1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2// vim: ts=8 sw=2 smarttab
3
4#ifndef CEPH_LIBRBD_OBJECT_MAP_UPDATE_REQUEST_H
5#define CEPH_LIBRBD_OBJECT_MAP_UPDATE_REQUEST_H
6
7#include "include/int_types.h"
8#include "librbd/object_map/Request.h"
9#include "common/bit_vector.hpp"
31f18b77
FG
10#include "common/zipkin_trace.h"
11#include "librbd/Utils.h"
7c673cae
FG
12#include <boost/optional.hpp>
13
14class Context;
15
16namespace librbd {
17
18class ImageCtx;
19
20namespace object_map {
21
22template <typename ImageCtxT = librbd::ImageCtx>
23class UpdateRequest : public Request {
24public:
25 static UpdateRequest *create(ImageCtx &image_ctx,
26 ceph::BitVector<2> *object_map,
27 uint64_t snap_id, uint64_t start_object_no,
28 uint64_t end_object_no, uint8_t new_state,
29 const boost::optional<uint8_t> &current_state,
31f18b77 30 const ZTracer::Trace &parent_trace,
7c673cae
FG
31 Context *on_finish) {
32 return new UpdateRequest(image_ctx, object_map, snap_id, start_object_no,
33 end_object_no, new_state, current_state,
31f18b77 34 parent_trace, on_finish);
7c673cae
FG
35 }
36
37 UpdateRequest(ImageCtx &image_ctx, ceph::BitVector<2> *object_map,
38 uint64_t snap_id, uint64_t start_object_no,
39 uint64_t end_object_no, uint8_t new_state,
40 const boost::optional<uint8_t> &current_state,
31f18b77 41 const ZTracer::Trace &parent_trace, Context *on_finish)
7c673cae
FG
42 : Request(image_ctx, snap_id, on_finish), m_object_map(*object_map),
43 m_start_object_no(start_object_no), m_end_object_no(end_object_no),
31f18b77
FG
44 m_new_state(new_state), m_current_state(current_state),
45 m_trace(util::create_trace(image_ctx, "update object map", parent_trace))
7c673cae 46 {
31f18b77
FG
47 m_trace.event("start");
48 }
49 virtual ~UpdateRequest() {
50 m_trace.event("finish");
7c673cae
FG
51 }
52
53 void send() override;
54
55protected:
56 void finish_request() override;
57
58private:
59 ceph::BitVector<2> &m_object_map;
60 uint64_t m_start_object_no;
61 uint64_t m_end_object_no;
62 uint8_t m_new_state;
63 boost::optional<uint8_t> m_current_state;
31f18b77 64 ZTracer::Trace m_trace;
7c673cae
FG
65};
66
67} // namespace object_map
68} // namespace librbd
69
70extern template class librbd::object_map::UpdateRequest<librbd::ImageCtx>;
71
72#endif // CEPH_LIBRBD_OBJECT_MAP_UPDATE_REQUEST_H