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 "cls/rbd/cls_rbd_types.h"
11 #include "librbd/Types.h"
15 namespace librbd
{ class ImageCtx
; }
16 namespace librbd
{ class ImageOptions
; }
22 template <typename
> struct Threads
;
24 namespace image_replayer
{
26 template <typename ImageCtxT
= librbd::ImageCtx
>
27 class CreateImageRequest
{
29 static CreateImageRequest
*create(
30 Threads
<ImageCtxT
> *threads
,
31 librados::IoCtx
&local_io_ctx
,
32 const std::string
&global_image_id
,
33 const std::string
&remote_mirror_uuid
,
34 const std::string
&local_image_name
,
35 const std::string
&local_image_id
,
36 ImageCtxT
*remote_image_ctx
,
37 PoolMetaCache
* pool_meta_cache
,
38 cls::rbd::MirrorImageMode mirror_image_mode
,
40 return new CreateImageRequest(threads
, local_io_ctx
, global_image_id
,
41 remote_mirror_uuid
, local_image_name
,
42 local_image_id
, remote_image_ctx
,
43 pool_meta_cache
, mirror_image_mode
,
48 Threads
<ImageCtxT
> *threads
, librados::IoCtx
&local_io_ctx
,
49 const std::string
&global_image_id
,
50 const std::string
&remote_mirror_uuid
,
51 const std::string
&local_image_name
,
52 const std::string
&local_image_id
,
53 ImageCtxT
*remote_image_ctx
,
54 PoolMetaCache
* pool_meta_cache
,
55 cls::rbd::MirrorImageMode mirror_image_mode
,
64 * <start> * * * * * * * * * * * * * * * * * * * * * * * * * * * *
67 * |\------------> CREATE_IMAGE ---------------------\ * (error)
70 * \-------------> GET_PARENT_GLOBAL_IMAGE_ID * * * | * * * *
73 * GET_LOCAL_PARENT_IMAGE_ID * * * * | * * * *
76 * OPEN_REMOTE_PARENT * * * * * * * | * * * *
82 * CLOSE_REMOTE_PARENT | *
84 * \------------------------> <finish> < * *
88 Threads
<ImageCtxT
> *m_threads
;
89 librados::IoCtx
&m_local_io_ctx
;
90 std::string m_global_image_id
;
91 std::string m_remote_mirror_uuid
;
92 std::string m_local_image_name
;
93 std::string m_local_image_id
;
94 ImageCtxT
*m_remote_image_ctx
;
95 PoolMetaCache
* m_pool_meta_cache
;
96 cls::rbd::MirrorImageMode m_mirror_image_mode
;
99 librados::IoCtx m_remote_parent_io_ctx
;
100 ImageCtxT
*m_remote_parent_image_ctx
= nullptr;
101 cls::rbd::ParentImageSpec m_remote_parent_spec
;
103 librados::IoCtx m_local_parent_io_ctx
;
104 cls::rbd::ParentImageSpec m_local_parent_spec
;
107 std::string m_parent_global_image_id
;
108 std::string m_parent_pool_name
;
112 void handle_create_image(int r
);
114 void get_parent_global_image_id();
115 void handle_get_parent_global_image_id(int r
);
117 void get_local_parent_image_id();
118 void handle_get_local_parent_image_id(int r
);
120 void open_remote_parent_image();
121 void handle_open_remote_parent_image(int r
);
124 void handle_clone_image(int r
);
126 void close_remote_parent_image();
127 void handle_close_remote_parent_image(int r
);
132 int validate_parent();
134 void populate_image_options(librbd::ImageOptions
* image_options
);
138 } // namespace image_replayer
139 } // namespace mirror
142 extern template class rbd::mirror::image_replayer::CreateImageRequest
<librbd::ImageCtx
>;
144 #endif // RBD_MIRROR_IMAGE_REPLAYER_CREATE_IMAGE_REQUEST_H