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_CLONE_REQUEST_H
5 #define CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H
7 #include "cls/rbd/cls_rbd_types.h"
8 #include "common/config_fwd.h"
9 #include "librbd/internal.h"
10 #include "include/rbd/librbd.hpp"
14 using librados::IoCtx
;
18 namespace asio
{ struct ContextWQ
; }
22 template <typename ImageCtxT
= ImageCtx
>
25 static CloneRequest
*create(
26 ConfigProxy
& config
, IoCtx
& parent_io_ctx
,
27 const std::string
& parent_image_id
,
28 const std::string
& parent_snap_name
,
29 const cls::rbd::SnapshotNamespace
& parent_snap_namespace
,
30 uint64_t parent_snap_id
,
31 IoCtx
&c_ioctx
, const std::string
&c_name
,
32 const std::string
&c_id
, ImageOptions c_options
,
33 cls::rbd::MirrorImageMode mirror_image_mode
,
34 const std::string
&non_primary_global_image_id
,
35 const std::string
&primary_mirror_uuid
,
36 asio::ContextWQ
*op_work_queue
, Context
*on_finish
) {
37 return new CloneRequest(config
, parent_io_ctx
, parent_image_id
,
38 parent_snap_name
, parent_snap_namespace
,
39 parent_snap_id
, c_ioctx
, c_name
, c_id
, c_options
,
40 mirror_image_mode
, non_primary_global_image_id
,
41 primary_mirror_uuid
, op_work_queue
, on_finish
);
44 CloneRequest(ConfigProxy
& config
, IoCtx
& parent_io_ctx
,
45 const std::string
& parent_image_id
,
46 const std::string
& parent_snap_name
,
47 const cls::rbd::SnapshotNamespace
& parent_snap_namespace
,
48 uint64_t parent_snap_id
,
49 IoCtx
&c_ioctx
, const std::string
&c_name
,
50 const std::string
&c_id
, ImageOptions c_options
,
51 cls::rbd::MirrorImageMode mirror_image_mode
,
52 const std::string
&non_primary_global_image_id
,
53 const std::string
&primary_mirror_uuid
,
54 asio::ContextWQ
*op_work_queue
, Context
*on_finish
);
68 * VALIDATE CHILD <finish>
71 * CREATE CHILD * * * * * * * * * > CLOSE PARENT
74 * OPEN CHILD * * * * * * * * * * > REMOVE CHILD
77 * ATTACH PARENT * * * * * * * * > CLOSE CHILD
80 * ATTACH CHILD * * * * * * * * * * * *
83 * COPY META DATA * * * * * * * * * * ^
85 * v (skip if not needed) *
86 * GET MIRROR MODE * * * * * * * * * ^
88 * v (skip if not needed) *
89 * SET MIRROR ENABLED * * * * * * * * *
103 ConfigProxy
& m_config
;
104 IoCtx
&m_parent_io_ctx
;
105 std::string m_parent_image_id
;
106 std::string m_parent_snap_name
;
107 cls::rbd::SnapshotNamespace m_parent_snap_namespace
;
108 uint64_t m_parent_snap_id
;
109 ImageCtxT
*m_parent_image_ctx
;
115 cls::rbd::ParentImageSpec m_pspec
;
117 cls::rbd::MirrorMode m_mirror_mode
= cls::rbd::MIRROR_MODE_DISABLED
;
118 cls::rbd::MirrorImageMode m_mirror_image_mode
;
119 const std::string m_non_primary_global_image_id
;
120 const std::string m_primary_mirror_uuid
;
121 NoOpProgressContext m_no_op
;
122 asio::ContextWQ
*m_op_work_queue
;
123 Context
*m_on_finish
;
126 uint64_t m_clone_format
= 2;
127 bool m_use_p_features
;
133 void validate_options();
136 void handle_open_parent(int r
);
138 void validate_parent();
140 void validate_child();
141 void handle_validate_child(int r
);
144 void handle_create_child(int r
);
147 void handle_open_child(int r
);
149 void attach_parent();
150 void handle_attach_parent(int r
);
153 void handle_attach_child(int r
);
155 void copy_metadata();
156 void handle_copy_metadata(int r
);
158 void get_mirror_mode();
159 void handle_get_mirror_mode(int r
);
161 void enable_mirror();
162 void handle_enable_mirror(int r
);
165 void handle_close_child(int r
);
168 void handle_remove_child(int r
);
171 void handle_close_parent(int r
);
173 void complete(int r
);
179 extern template class librbd::image::CloneRequest
<librbd::ImageCtx
>;
181 #endif // CEPH_LIBRBD_IMAGE_CLONE_REQUEST_H