]>
git.proxmox.com Git - ceph.git/blob - ceph/src/librbd/image/RemoveRequest.h
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 "include/rados/librados.hpp"
8 #include "librbd/ImageCtx.h"
9 #include "librbd/image/TypeTraits.h"
10 #include "common/Timer.h"
18 class ProgressContext
;
22 template<typename ImageCtxT
= ImageCtx
>
25 // mock unit testing support
26 typedef ::librbd::image::TypeTraits
<ImageCtxT
> TypeTraits
;
27 typedef typename
TypeTraits::ContextWQ ContextWQ
;
29 static RemoveRequest
*create(librados::IoCtx
&ioctx
,
30 const std::string
&image_name
,
31 const std::string
&image_id
,
32 bool force
, bool from_trash_remove
,
33 ProgressContext
&prog_ctx
,
34 ContextWQ
*op_work_queue
,
36 return new RemoveRequest(ioctx
, image_name
, image_id
, force
,
37 from_trash_remove
, prog_ctx
, op_work_queue
,
41 static RemoveRequest
*create(librados::IoCtx
&ioctx
, ImageCtxT
*image_ctx
,
42 bool force
, bool from_trash_remove
,
43 ProgressContext
&prog_ctx
,
44 ContextWQ
*op_work_queue
,
46 return new RemoveRequest(ioctx
, image_ctx
, force
, from_trash_remove
,
47 prog_ctx
, op_work_queue
, on_finish
);
59 * (skip if already opened) OPEN IMAGE------------------\
62 * PRE REMOVE IMAGE * * * |
65 * (skip if invalid data pool) TRIM IMAGE * * * * * |
71 * CLOSE IMAGE < * * * * |
74 * /------<--------\ REMOVE HEADER<--------------/
76 * | |-------<-------/ |
80 * | |-------<-------/ |
82 * v ^ REMOVE OBJECTMAP
84 * | |-------<-------/ |
86 * | | REMOVE MIRROR IMAGE
88 * | |-------<-------/ |
90 * | | REMOVE ID OBJECT
92 * | |-------<-------/ |
96 * | \-------<-------/ |
98 * \------------------>------------<finish>
103 RemoveRequest(librados::IoCtx
&ioctx
, const std::string
&image_name
,
104 const std::string
&image_id
, bool force
, bool from_trash_remove
,
105 ProgressContext
&prog_ctx
, ContextWQ
*op_work_queue
,
108 RemoveRequest(librados::IoCtx
&ioctx
, ImageCtxT
*image_ctx
, bool force
,
109 bool from_trash_remove
, ProgressContext
&prog_ctx
,
110 ContextWQ
*op_work_queue
, Context
*on_finish
);
112 librados::IoCtx
&m_ioctx
;
113 std::string m_image_name
;
114 std::string m_image_id
;
115 ImageCtxT
*m_image_ctx
= nullptr;
117 bool m_from_trash_remove
;
118 ProgressContext
&m_prog_ctx
;
119 ContextWQ
*m_op_work_queue
;
120 Context
*m_on_finish
;
123 std::string m_header_oid
;
124 bool m_old_format
= false;
125 bool m_unknown_format
= true;
127 librados::IoCtx m_parent_io_ctx
;
129 decltype(m_image_ctx
->exclusive_lock
) m_exclusive_lock
= nullptr;
133 std::list
<obj_watch_t
> m_watchers
;
135 std::map
<uint64_t, SnapInfo
> m_snap_infos
;
138 void handle_open_image(int r
);
140 void send_journal_remove();
141 void handle_journal_remove(int r
);
143 void send_object_map_remove();
144 void handle_object_map_remove(int r
);
146 void mirror_image_remove();
147 void handle_mirror_image_remove(int r
);
149 void pre_remove_image();
150 void handle_pre_remove_image(int r
);
153 void handle_trim_image(int r
);
156 void handle_detach_child(int r
);
158 void send_disable_mirror();
159 void handle_disable_mirror(int r
);
161 void send_close_image(int r
);
162 void handle_send_close_image(int r
);
164 void remove_header();
165 void handle_remove_header(int r
);
167 void remove_header_v2();
168 void handle_remove_header_v2(int r
);
172 void remove_v1_image();
173 void handle_remove_v1_image(int r
);
175 void remove_v2_image();
177 void dir_get_image_id();
178 void handle_dir_get_image_id(int r
);
180 void dir_get_image_name();
181 void handle_dir_get_image_name(int r
);
183 void remove_id_object();
184 void handle_remove_id_object(int r
);
186 void dir_remove_image();
187 void handle_dir_remove_image(int r
);
193 } // namespace librbd
195 extern template class librbd::image::RemoveRequest
<librbd::ImageCtx
>;
197 #endif // CEPH_LIBRBD_IMAGE_REMOVE_REQUEST_H