1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef RBD_MIRROR_IMAGE_REPLAYER_CREATE_IMAGE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_REPLAYER_CREATE_IMAGE_REQUEST_H
7 #include "include/int_types.h"
8 #include "include/types.h"
9 #include "include/rados/librados.hpp"
10 #include "librbd/Types.h"
15 namespace librbd
{ class ImageCtx
; }
19 namespace image_replayer
{
21 template <typename ImageCtxT
= librbd::ImageCtx
>
22 class CreateImageRequest
{
24 static CreateImageRequest
*create(librados::IoCtx
&local_io_ctx
,
25 ContextWQ
*work_queue
,
26 const std::string
&global_image_id
,
27 const std::string
&remote_mirror_uuid
,
28 const std::string
&local_image_name
,
29 ImageCtxT
*remote_image_ctx
,
30 std::string
*local_image_id
,
32 return new CreateImageRequest(local_io_ctx
, work_queue
, global_image_id
,
33 remote_mirror_uuid
, local_image_name
,
34 remote_image_ctx
, local_image_id
, on_finish
);
37 CreateImageRequest(librados::IoCtx
&local_io_ctx
, ContextWQ
*work_queue
,
38 const std::string
&global_image_id
,
39 const std::string
&remote_mirror_uuid
,
40 const std::string
&local_image_name
,
41 ImageCtxT
*remote_image_ctx
,
42 std::string
*local_image_id
,
51 * <start> * * * * * * * * * * * * * * * * * * * * * * * * * * * *
54 * |\------------> CREATE_IMAGE ---------------------\ * (error)
57 * \-------------> GET_PARENT_GLOBAL_IMAGE_ID * * * | * * * *
60 * GET_LOCAL_PARENT_IMAGE_ID * * * * | * * * *
63 * OPEN_REMOTE_PARENT * * * * * * * | * * * *
66 * OPEN_LOCAL_PARENT * * * * * * * | *
69 * SET_LOCAL_PARENT_SNAP * | *
75 * CLOSE_LOCAL_PARENT * | *
78 * CLOSE_REMOTE_PARENT < * * * * * | *
80 * \------------------------> <finish> < * *
84 librados::IoCtx
&m_local_io_ctx
;
85 ContextWQ
*m_work_queue
;
86 std::string m_global_image_id
;
87 std::string m_remote_mirror_uuid
;
88 std::string m_local_image_name
;
89 ImageCtxT
*m_remote_image_ctx
;
90 std::string
*m_local_image_id
;
93 librados::IoCtx m_remote_parent_io_ctx
;
94 ImageCtxT
*m_remote_parent_image_ctx
= nullptr;
95 librbd::ParentSpec m_remote_parent_spec
;
97 librados::IoCtx m_local_parent_io_ctx
;
98 ImageCtxT
*m_local_parent_image_ctx
= nullptr;
99 librbd::ParentSpec m_local_parent_spec
;
102 std::string m_parent_global_image_id
;
103 std::string m_parent_pool_name
;
104 std::string m_parent_snap_name
;
108 void handle_create_image(int r
);
110 void get_parent_global_image_id();
111 void handle_get_parent_global_image_id(int r
);
113 void get_local_parent_image_id();
114 void handle_get_local_parent_image_id(int r
);
116 void open_remote_parent_image();
117 void handle_open_remote_parent_image(int r
);
119 void open_local_parent_image();
120 void handle_open_local_parent_image(int r
);
122 void set_local_parent_snap();
123 void handle_set_local_parent_snap(int r
);
126 void handle_clone_image(int r
);
128 void close_local_parent_image();
129 void handle_close_local_parent_image(int r
);
131 void close_remote_parent_image();
132 void handle_close_remote_parent_image(int r
);
137 int validate_parent();
141 } // namespace image_replayer
142 } // namespace mirror
145 extern template class rbd::mirror::image_replayer::CreateImageRequest
<librbd::ImageCtx
>;
147 #endif // RBD_MIRROR_IMAGE_REPLAYER_CREATE_IMAGE_REQUEST_H