]> git.proxmox.com Git - ceph.git/blame - ceph/src/librbd/image/RemoveRequest.h
update sources to v12.1.0
[ceph.git] / ceph / src / librbd / image / RemoveRequest.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_IMAGE_REMOVE_REQUEST_H
5#define CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H
6
7#include "librbd/image/TypeTraits.h"
8
9class Context;
10class ContextWQ;
11class SafeTimer;
12
13namespace librbd {
14
15class ImageCtx;
16class ProgressContext;
17
18namespace image {
19
20template<typename ImageCtxT = ImageCtx>
21class RemoveRequest {
22private:
23 // mock unit testing support
24 typedef ::librbd::image::TypeTraits<ImageCtxT> TypeTraits;
25 typedef typename TypeTraits::ContextWQ ContextWQ;
26public:
27 static RemoveRequest *create(librados::IoCtx &ioctx,
28 const std::string &image_name,
29 const std::string &image_id,
30 bool force, bool from_trash_remove,
31 ProgressContext &prog_ctx,
32 ContextWQ *op_work_queue,
33 Context *on_finish) {
34 return new RemoveRequest(ioctx, image_name, image_id, force,
35 from_trash_remove, prog_ctx, op_work_queue,
36 on_finish);
37 }
38
39 void send();
40
41private:
42 /**
43 * @verbatim
44 *
45 * <start>
46 * |
47 * v
48 * OPEN IMAGE------------------\
49 * | |
50 * v |
51 * error CHECK EXCLUSIVE LOCK---\ |
52 * /-------<-------\ | | |
53 * | | | (acquired)|
54 * | | v | |
55 * | | AQUIRE EXCLUSIVE LOCK | |
56 * | | / | | |
57 * | |------<-------/ | | |
58 * | | v | |
59 * | | VALIDATE IMAGE REMOVAL<-/ |
60 * | | / | v
61 * | \------<--------/ | |
62 * | v |
63 * | TRIM IMAGE |
64 * | | |
65 * v v |
66 * | REMOVE CHILD |
67 * | | |
68 * | v v
69 * \--------->------------------>CLOSE IMAGE |
70 * | |
71 * error v |
72 * /------<--------\ REMOVE HEADER<--------------/
73 * | | / |
74 * | |-------<-------/ |
75 * | | v
76 * | | REMOVE JOURNAL
77 * | | / |
78 * | |-------<-------/ |
79 * | | v
80 * v ^ REMOVE OBJECTMAP
81 * | | / |
82 * | |-------<-------/ |
83 * | | v
84 * | | REMOVE MIRROR IMAGE
85 * | | / |
86 * | |-------<-------/ |
87 * | | v
88 * | | REMOVE ID OBJECT
89 * | | / |
90 * | |-------<-------/ |
91 * | | v
92 * | | REMOVE IMAGE
93 * | | / |
94 * | \-------<-------/ |
95 * | v
96 * \------------------>------------<finish>
97 *
98 * @endverbatim
99 */
100
101 RemoveRequest(librados::IoCtx &ioctx, const std::string &image_name,
102 const std::string &image_id, bool force, bool from_trash_remove,
103 ProgressContext &prog_ctx, ContextWQ *op_work_queue,
104 Context *on_finish);
105
106 librados::IoCtx &m_ioctx;
107 std::string m_image_name;
108 std::string m_image_id;
109 bool m_force;
110 bool m_from_trash_remove;
111 ProgressContext &m_prog_ctx;
112 ContextWQ *m_op_work_queue;
113 Context *m_on_finish;
114
115 CephContext *m_cct;
116 std::string m_header_oid;
117 bool m_old_format = false;
118 bool m_unknown_format = true;
119 ImageCtxT *m_image_ctx;
120
31f18b77
FG
121 decltype(m_image_ctx->exclusive_lock) m_exclusive_lock = nullptr;
122
7c673cae
FG
123 int m_ret_val = 0;
124 bufferlist m_out_bl;
125 std::list<obj_watch_t> m_watchers;
31f18b77 126 std::list<obj_watch_t> m_mirror_watchers;
7c673cae
FG
127
128 void open_image();
31f18b77 129 void handle_open_image(int r);
7c673cae
FG
130
131 void send_journal_remove();
31f18b77 132 void handle_journal_remove(int r);
7c673cae
FG
133
134 void send_object_map_remove();
31f18b77 135 void handle_object_map_remove(int r);
7c673cae
FG
136
137 void mirror_image_remove();
31f18b77 138 void handle_mirror_image_remove(int r);
7c673cae
FG
139
140 void check_exclusive_lock();
141
142 void acquire_exclusive_lock();
31f18b77
FG
143 void handle_exclusive_lock(int r);
144 void handle_exclusive_lock_force(int r);
7c673cae
FG
145
146 void validate_image_removal();
147 void check_image_snaps();
148
31f18b77
FG
149 void list_image_watchers();
150 void handle_list_image_watchers(int r);
151
152 void get_mirror_image();
153 void handle_get_mirror_image(int r);
154
155 void list_mirror_watchers();
156 void handle_list_mirror_watchers(int r);
157
7c673cae 158 void check_image_watchers();
7c673cae 159
31f18b77
FG
160 void check_group();
161 void handle_check_group(int r);
7c673cae
FG
162
163 void trim_image();
31f18b77 164 void handle_trim_image(int r);
7c673cae
FG
165
166 void remove_child();
31f18b77 167 void handle_remove_child(int r);
7c673cae
FG
168
169 void send_disable_mirror();
31f18b77 170 void handle_disable_mirror(int r);
7c673cae
FG
171
172 void send_close_image(int r);
31f18b77 173 void handle_send_close_image(int r);
7c673cae
FG
174
175 void remove_header();
31f18b77 176 void handle_remove_header(int r);
7c673cae
FG
177
178 void remove_header_v2();
31f18b77 179 void handle_remove_header_v2(int r);
7c673cae
FG
180
181 void remove_image();
182
183 void remove_v1_image();
184 void handle_remove_v1_image(int r);
185
186 void remove_v2_image();
187
188 void dir_get_image_id();
31f18b77 189 void handle_dir_get_image_id(int r);
7c673cae
FG
190
191 void dir_get_image_name();
31f18b77 192 void handle_dir_get_image_name(int r);
7c673cae
FG
193
194 void remove_id_object();
31f18b77 195 void handle_remove_id_object(int r);
7c673cae
FG
196
197 void dir_remove_image();
31f18b77
FG
198 void handle_dir_remove_image(int r);
199
200 void finish(int r);
7c673cae
FG
201};
202
203} // namespace image
204} // namespace librbd
205
206extern template class librbd::image::RemoveRequest<librbd::ImageCtx>;
207
208#endif // CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H