1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_RBD_MIRROR_IMAGE_DELETE_TRASH_MOVE_REQUEST_H
5 #define CEPH_RBD_MIRROR_IMAGE_DELETE_TRASH_MOVE_REQUEST_H
7 #include "include/buffer.h"
8 #include "include/rados/librados.hpp"
9 #include "cls/rbd/cls_rbd_types.h"
10 #include "librbd/mirror/Types.h"
16 namespace asio
{ struct ContextWQ
; }
21 namespace image_deleter
{
23 template <typename ImageCtxT
= librbd::ImageCtx
>
24 class TrashMoveRequest
{
26 static TrashMoveRequest
* create(librados::IoCtx
& io_ctx
,
27 const std::string
& global_image_id
,
29 librbd::asio::ContextWQ
* op_work_queue
,
31 return new TrashMoveRequest(io_ctx
, global_image_id
, resync
, op_work_queue
,
35 TrashMoveRequest(librados::IoCtx
& io_ctx
, const std::string
& global_image_id
,
36 bool resync
, librbd::asio::ContextWQ
* op_work_queue
,
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
) {
57 * DISABLE_MIRROR_IMAGE
62 * v (skip if not needed)
65 * v (skip if not needed)
86 librados::IoCtx
&m_io_ctx
;
87 std::string m_global_image_id
;
89 librbd::asio::ContextWQ
*m_op_work_queue
;
92 ceph::bufferlist m_out_bl
;
93 std::string m_image_id
;
94 cls::rbd::MirrorImage m_mirror_image
;
95 librbd::mirror::PromotionState m_promotion_state
;
96 std::string m_primary_mirror_uuid
;
97 cls::rbd::TrashImageSpec m_trash_image_spec
;
98 ImageCtxT
*m_image_ctx
= nullptr;;
100 bool m_moved_to_trash
= false;
102 void get_mirror_image_id();
103 void handle_get_mirror_image_id(int r
);
105 void get_mirror_info();
106 void handle_get_mirror_info(int r
);
108 void disable_mirror_image();
109 void handle_disable_mirror_image(int r
);
112 void handle_open_image(int r
);
114 void reset_journal();
115 void handle_reset_journal(int r
);
118 void handle_acquire_lock(int r
);
121 void handle_trash_move(int r
);
123 void remove_mirror_image();
124 void handle_remove_mirror_image(int r
);
127 void handle_close_image(int r
);
129 void notify_trash_add();
130 void handle_notify_trash_add(int r
);
136 } // namespace image_deleter
137 } // namespace mirror
140 extern template class rbd::mirror::image_deleter::TrashMoveRequest
<librbd::ImageCtx
>;
142 #endif // CEPH_RBD_MIRROR_IMAGE_DELETE_TRASH_WATCHER_H