]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_sync/SyncPointCreateRequest.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / tools / rbd_mirror / image_sync / SyncPointCreateRequest.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #ifndef RBD_MIRROR_IMAGE_SYNC_SYNC_POINT_CREATE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_SYNC_SYNC_POINT_CREATE_REQUEST_H
6
7 #include "librbd/journal/Types.h"
8 #include "librbd/journal/TypeTraits.h"
9 #include <string>
10
11 class Context;
12 namespace journal { class Journaler; }
13 namespace librbd { class ImageCtx; }
14 namespace librbd { namespace journal { struct MirrorPeerClientMeta; } }
15
16 namespace rbd {
17 namespace mirror {
18 namespace image_sync {
19
20 template <typename ImageCtxT = librbd::ImageCtx>
21 class SyncPointCreateRequest {
22 public:
23 typedef librbd::journal::TypeTraits<ImageCtxT> TypeTraits;
24 typedef typename TypeTraits::Journaler Journaler;
25 typedef librbd::journal::MirrorPeerClientMeta MirrorPeerClientMeta;
26 typedef librbd::journal::MirrorPeerSyncPoint MirrorPeerSyncPoint;
27
28 static SyncPointCreateRequest* create(ImageCtxT *remote_image_ctx,
29 const std::string &mirror_uuid,
30 Journaler *journaler,
31 MirrorPeerClientMeta *client_meta,
32 Context *on_finish) {
33 return new SyncPointCreateRequest(remote_image_ctx, mirror_uuid, journaler,
34 client_meta, on_finish);
35 }
36
37 SyncPointCreateRequest(ImageCtxT *remote_image_ctx,
38 const std::string &mirror_uuid, Journaler *journaler,
39 MirrorPeerClientMeta *client_meta, Context *on_finish);
40
41 void send();
42
43 private:
44 /**
45 * @verbatim
46 *
47 * <start>
48 * |
49 * v
50 * UPDATE_CLIENT < . .
51 * | .
52 * v .
53 * REFRESH_IMAGE .
54 * | . (repeat on EEXIST)
55 * v .
56 * CREATE_SNAP . . . .
57 * |
58 * v
59 * REFRESH_IMAGE
60 * |
61 * v
62 * <finish>
63 *
64 * @endverbatim
65 */
66
67 ImageCtxT *m_remote_image_ctx;
68 std::string m_mirror_uuid;
69 Journaler *m_journaler;
70 MirrorPeerClientMeta *m_client_meta;
71 Context *m_on_finish;
72
73 MirrorPeerClientMeta m_client_meta_copy;
74
75 void send_update_client();
76 void handle_update_client(int r);
77
78 void send_refresh_image();
79 void handle_refresh_image(int r);
80
81 void send_create_snap();
82 void handle_create_snap(int r);
83
84 void send_final_refresh_image();
85 void handle_final_refresh_image(int r);
86
87 void finish(int r);
88 };
89
90 } // namespace image_sync
91 } // namespace mirror
92 } // namespace rbd
93
94 extern template class rbd::mirror::image_sync::SyncPointCreateRequest<librbd::ImageCtx>;
95
96 #endif // RBD_MIRROR_IMAGE_SYNC_SYNC_POINT_CREATE_REQUEST_H