]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
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_RBD_MIRROR_IMAGE_DELETE_TRASH_MOVE_REQUEST_H | |
5 | #define CEPH_RBD_MIRROR_IMAGE_DELETE_TRASH_MOVE_REQUEST_H | |
6 | ||
7 | #include "include/buffer.h" | |
8 | #include "include/rados/librados.hpp" | |
9 | #include "cls/rbd/cls_rbd_types.h" | |
9f95a23c | 10 | #include "librbd/mirror/Types.h" |
11fdf7f2 TL |
11 | #include <string> |
12 | ||
13 | struct Context; | |
f67539c2 TL |
14 | namespace librbd { |
15 | struct ImageCtx; | |
16 | namespace asio { struct ContextWQ; } | |
17 | } // namespace librbd | |
11fdf7f2 TL |
18 | |
19 | namespace rbd { | |
20 | namespace mirror { | |
21 | namespace image_deleter { | |
22 | ||
23 | template <typename ImageCtxT = librbd::ImageCtx> | |
24 | class TrashMoveRequest { | |
25 | public: | |
26 | static TrashMoveRequest* create(librados::IoCtx& io_ctx, | |
27 | const std::string& global_image_id, | |
f67539c2 TL |
28 | bool resync, |
29 | librbd::asio::ContextWQ* op_work_queue, | |
11fdf7f2 TL |
30 | Context* on_finish) { |
31 | return new TrashMoveRequest(io_ctx, global_image_id, resync, op_work_queue, | |
32 | on_finish); | |
33 | } | |
34 | ||
35 | TrashMoveRequest(librados::IoCtx& io_ctx, const std::string& global_image_id, | |
f67539c2 TL |
36 | bool resync, librbd::asio::ContextWQ* op_work_queue, |
37 | Context* on_finish) | |
11fdf7f2 TL |
38 | : m_io_ctx(io_ctx), m_global_image_id(global_image_id), m_resync(resync), |
39 | m_op_work_queue(op_work_queue), m_on_finish(on_finish) { | |
40 | } | |
41 | ||
42 | void send(); | |
43 | ||
44 | private: | |
45 | /* | |
46 | * @verbatim | |
47 | * | |
48 | * <start> | |
49 | * | | |
50 | * v | |
51 | * GET_MIRROR_IMAGE_ID | |
52 | * | | |
53 | * v | |
9f95a23c | 54 | * GET_MIRROR_INFO |
11fdf7f2 TL |
55 | * | |
56 | * v | |
57 | * DISABLE_MIRROR_IMAGE | |
58 | * | | |
59 | * v | |
11fdf7f2 TL |
60 | * OPEN_IMAGE |
61 | * | | |
9f95a23c TL |
62 | * v (skip if not needed) |
63 | * RESET_JOURNAL | |
64 | * | | |
65 | * v (skip if not needed) | |
11fdf7f2 TL |
66 | * ACQUIRE_LOCK |
67 | * | | |
68 | * v | |
69 | * TRASH_MOVE | |
70 | * | | |
71 | * v | |
72 | * REMOVE_MIRROR_IMAGE | |
73 | * | | |
74 | * v | |
75 | * CLOSE_IMAGE | |
76 | * | | |
77 | * v | |
78 | * NOTIFY_TRASH_ADD | |
79 | * | | |
80 | * v | |
81 | * <finish> | |
82 | * | |
83 | * @endverbatim | |
84 | */ | |
85 | ||
86 | librados::IoCtx &m_io_ctx; | |
87 | std::string m_global_image_id; | |
88 | bool m_resync; | |
f67539c2 | 89 | librbd::asio::ContextWQ *m_op_work_queue; |
11fdf7f2 TL |
90 | Context *m_on_finish; |
91 | ||
92 | ceph::bufferlist m_out_bl; | |
93 | std::string m_image_id; | |
9f95a23c TL |
94 | cls::rbd::MirrorImage m_mirror_image; |
95 | librbd::mirror::PromotionState m_promotion_state; | |
96 | std::string m_primary_mirror_uuid; | |
11fdf7f2 TL |
97 | cls::rbd::TrashImageSpec m_trash_image_spec; |
98 | ImageCtxT *m_image_ctx = nullptr;; | |
99 | int m_ret_val = 0; | |
100 | bool m_moved_to_trash = false; | |
101 | ||
102 | void get_mirror_image_id(); | |
103 | void handle_get_mirror_image_id(int r); | |
104 | ||
9f95a23c TL |
105 | void get_mirror_info(); |
106 | void handle_get_mirror_info(int r); | |
11fdf7f2 TL |
107 | |
108 | void disable_mirror_image(); | |
109 | void handle_disable_mirror_image(int r); | |
110 | ||
11fdf7f2 TL |
111 | void open_image(); |
112 | void handle_open_image(int r); | |
113 | ||
9f95a23c TL |
114 | void reset_journal(); |
115 | void handle_reset_journal(int r); | |
116 | ||
11fdf7f2 TL |
117 | void acquire_lock(); |
118 | void handle_acquire_lock(int r); | |
119 | ||
120 | void trash_move(); | |
121 | void handle_trash_move(int r); | |
122 | ||
123 | void remove_mirror_image(); | |
124 | void handle_remove_mirror_image(int r); | |
125 | ||
126 | void close_image(); | |
127 | void handle_close_image(int r); | |
128 | ||
129 | void notify_trash_add(); | |
130 | void handle_notify_trash_add(int r); | |
131 | ||
132 | void finish(int r); | |
133 | ||
134 | }; | |
135 | ||
136 | } // namespace image_deleter | |
137 | } // namespace mirror | |
138 | } // namespace rbd | |
139 | ||
140 | extern template class rbd::mirror::image_deleter::TrashMoveRequest<librbd::ImageCtx>; | |
141 | ||
142 | #endif // CEPH_RBD_MIRROR_IMAGE_DELETE_TRASH_WATCHER_H |