]> git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/object_map/DiffRequest.h
31a7a1bea25056fd51c101a86b049a2210892c7d
[ceph.git] / ceph / src / librbd / object_map / DiffRequest.h
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_DIFF_REQUEST_H
5 #define CEPH_LIBRBD_OBJECT_MAP_DIFF_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "common/bit_vector.hpp"
9 #include "common/ceph_mutex.h"
10 #include "librbd/object_map/Types.h"
11 #include <set>
12
13 struct Context;
14
15 namespace librbd {
16
17 struct ImageCtx;
18
19 namespace object_map {
20
21 template <typename ImageCtxT>
22 class DiffRequest {
23 public:
24 static DiffRequest* create(ImageCtxT* image_ctx, uint64_t snap_id_start,
25 uint64_t snap_id_end,
26 BitVector<2>* object_diff_state,
27 Context* on_finish) {
28 return new DiffRequest(image_ctx, snap_id_start, snap_id_end,
29 object_diff_state, on_finish);
30 }
31
32 DiffRequest(ImageCtxT* image_ctx, uint64_t snap_id_start,
33 uint64_t snap_id_end, BitVector<2>* object_diff_state,
34 Context* on_finish)
35 : m_image_ctx(image_ctx), m_snap_id_start(snap_id_start),
36 m_snap_id_end(snap_id_end), m_object_diff_state(object_diff_state),
37 m_on_finish(on_finish) {
38 }
39
40 void send();
41
42 private:
43 /**
44 * @verbatim
45 *
46 * <start>
47 * |
48 * | /---------\
49 * | | |
50 * v v |
51 * LOAD_OBJECT_MAP ---/
52 * |
53 * v
54 * <finish>
55 *
56 * @endverbatim
57 */
58 ImageCtxT* m_image_ctx;
59 uint64_t m_snap_id_start;
60 uint64_t m_snap_id_end;
61 BitVector<2>* m_object_diff_state;
62 Context* m_on_finish;
63
64 std::set<uint64_t> m_snap_ids;
65 uint64_t m_current_snap_id = 0;
66 bool m_ignore_enoent = false;
67
68 uint64_t m_current_size = 0;
69
70 BitVector<2> m_object_map;
71 BitVector<2> m_prev_object_map;
72 bool m_prev_object_map_valid = false;
73
74 bufferlist m_out_bl;
75
76 void load_object_map(std::shared_lock<ceph::shared_mutex>* image_locker);
77 void handle_load_object_map(int r);
78
79 void finish(int r);
80
81 };
82
83 } // namespace object_map
84 } // namespace librbd
85
86 extern template class librbd::object_map::DiffRequest<librbd::ImageCtx>;
87
88 #endif // CEPH_LIBRBD_OBJECT_MAP_DIFF_REQUEST_H