1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H
7 #include "librbd/image/TypeTraits.h"
16 class ProgressContext;
20 template<typename ImageCtxT = ImageCtx>
23 // mock unit testing support
24 typedef ::librbd::image::TypeTraits<ImageCtxT> TypeTraits;
25 typedef typename TypeTraits::ContextWQ ContextWQ;
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,
34 return new RemoveRequest(ioctx, image_name, image_id, force,
35 from_trash_remove, prog_ctx, op_work_queue,
48 * OPEN IMAGE------------------\
51 * error CHECK EXCLUSIVE LOCK---\ |
52 * /-------<-------\ | | |
55 * | | AQUIRE EXCLUSIVE LOCK | |
57 * | |------<-------/ | | |
59 * | | VALIDATE IMAGE REMOVAL<-/ |
61 * | \------<--------/ | |
69 * \--------->------------------>CLOSE IMAGE |
72 * /------<--------\ REMOVE HEADER<--------------/
74 * | |-------<-------/ |
78 * | |-------<-------/ |
80 * v ^ REMOVE OBJECTMAP
82 * | |-------<-------/ |
84 * | | REMOVE MIRROR IMAGE
86 * | |-------<-------/ |
88 * | | REMOVE ID OBJECT
90 * | |-------<-------/ |
94 * | \-------<-------/ |
96 * \------------------>------------<finish>
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,
106 librados::IoCtx &m_ioctx;
107 std::string m_image_name;
108 std::string m_image_id;
110 bool m_from_trash_remove;
111 ProgressContext &m_prog_ctx;
112 ContextWQ *m_op_work_queue;
113 Context *m_on_finish;
116 std::string m_header_oid;
117 bool m_old_format = false;
118 bool m_unknown_format = true;
119 ImageCtxT *m_image_ctx;
121 decltype(m_image_ctx->exclusive_lock) m_exclusive_lock = nullptr;
125 std::list<obj_watch_t> m_watchers;
126 std::list<obj_watch_t> m_mirror_watchers;
129 void handle_open_image(int r);
131 void send_journal_remove();
132 void handle_journal_remove(int r);
134 void send_object_map_remove();
135 void handle_object_map_remove(int r);
137 void mirror_image_remove();
138 void handle_mirror_image_remove(int r);
140 void check_exclusive_lock();
142 void acquire_exclusive_lock();
143 void handle_exclusive_lock(int r);
144 void handle_exclusive_lock_force(int r);
146 void validate_image_removal();
147 void check_image_snaps();
149 void list_image_watchers();
150 void handle_list_image_watchers(int r);
152 void get_mirror_image();
153 void handle_get_mirror_image(int r);
155 void list_mirror_watchers();
156 void handle_list_mirror_watchers(int r);
158 void check_image_watchers();
161 void handle_check_group(int r);
164 void handle_trim_image(int r);
167 void handle_remove_child(int r);
169 void send_disable_mirror();
170 void handle_disable_mirror(int r);
172 void send_close_image(int r);
173 void handle_send_close_image(int r);
175 void remove_header();
176 void handle_remove_header(int r);
178 void remove_header_v2();
179 void handle_remove_header_v2(int r);
183 void remove_v1_image();
184 void handle_remove_v1_image(int r);
186 void remove_v2_image();
188 void dir_get_image_id();
189 void handle_dir_get_image_id(int r);
191 void dir_get_image_name();
192 void handle_dir_get_image_name(int r);
194 void remove_id_object();
195 void handle_remove_id_object(int r);
197 void dir_remove_image();
198 void handle_dir_remove_image(int r);
204 } // namespace librbd
206 extern template class librbd::image::RemoveRequest<librbd::ImageCtx>;
208 #endif // CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H