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_MIRROR_ENABLE_REQUEST_H
5 #define CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H
7 #include "include/buffer_fwd.h"
8 #include "include/rados/librados_fwd.hpp"
9 #include "include/rbd/librbd.hpp"
10 #include "cls/rbd/cls_rbd_types.h"
11 #include "librbd/ImageCtx.h"
12 #include "librbd/mirror/Types.h"
22 template <typename ImageCtxT
= ImageCtx
>
25 static EnableRequest
*create(ImageCtxT
*image_ctx
,
26 cls::rbd::MirrorImageMode mode
,
27 const std::string
&non_primary_global_image_id
,
28 bool image_clean
, Context
*on_finish
) {
29 return new EnableRequest(image_ctx
->md_ctx
, image_ctx
->id
, image_ctx
, mode
,
30 non_primary_global_image_id
, image_clean
,
31 image_ctx
->op_work_queue
, on_finish
);
33 static EnableRequest
*create(librados::IoCtx
&io_ctx
,
34 const std::string
&image_id
,
35 cls::rbd::MirrorImageMode mode
,
36 const std::string
&non_primary_global_image_id
,
37 bool image_clean
, ContextWQ
*op_work_queue
,
39 return new EnableRequest(io_ctx
, image_id
, nullptr, mode
,
40 non_primary_global_image_id
, image_clean
,
41 op_work_queue
, on_finish
);
53 * GET_MIRROR_IMAGE * * * * * * *
55 * v (skip if not needed) *
56 * GET_TAG_OWNER * * * * * * * *
58 * v (skip if not needed) *
61 * v (skip if not needed) *
62 * CREATE_PRIMARY_SNAPSHOT * * *
64 * v (skip of not opened) *
67 * v (skip if not needed) *
68 * ENABLE_NON_PRIMARY_FEATURE *
70 * v (skip if not needed) *
71 * IMAGE_STATE_UPDATE * * * * * *
74 * <finish> < * * * * * * * * *
79 EnableRequest(librados::IoCtx
&io_ctx
, const std::string
&image_id
,
80 ImageCtxT
* image_ctx
, cls::rbd::MirrorImageMode mode
,
81 const std::string
&non_primary_global_image_id
,
82 bool image_clean
, ContextWQ
*op_work_queue
, Context
*on_finish
);
84 librados::IoCtx
&m_io_ctx
;
85 std::string m_image_id
;
86 ImageCtxT
* m_image_ctx
;
87 cls::rbd::MirrorImageMode m_mode
;
88 std::string m_non_primary_global_image_id
;
90 ContextWQ
*m_op_work_queue
;
93 CephContext
*m_cct
= nullptr;
95 cls::rbd::MirrorImage m_mirror_image
;
98 bool m_close_image
= false;
100 bool m_is_primary
= false;
101 uint64_t m_snap_id
= CEPH_NOSNAP
;
103 void get_mirror_image();
104 void handle_get_mirror_image(int r
);
106 void get_tag_owner();
107 void handle_get_tag_owner(int r
);
110 void handle_open_image(int r
);
112 void create_primary_snapshot();
113 void handle_create_primary_snapshot(int r
);
116 void handle_close_image(int r
);
118 void enable_non_primary_feature();
119 void handle_enable_non_primary_feature(int r
);
121 void image_state_update();
122 void handle_image_state_update(int r
);
127 } // namespace mirror
128 } // namespace librbd
130 extern template class librbd::mirror::EnableRequest
<librbd::ImageCtx
>;
132 #endif // CEPH_LIBRBD_MIRROR_ENABLE_REQUEST_H