]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/rbd_mirror/image_sync/SnapshotCreateRequest.h
update sources to 12.2.10
[ceph.git] / ceph / src / tools / rbd_mirror / image_sync / SnapshotCreateRequest.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_SNAPSHOT_CREATE_REQUEST_H
5 #define RBD_MIRROR_IMAGE_SYNC_SNAPSHOT_CREATE_REQUEST_H
6
7 #include "include/int_types.h"
8 #include "include/rados/librados.hpp"
9 #include "common/snap_types.h"
10 #include "librbd/ImageCtx.h"
11 #include "librbd/Types.h"
12 #include "librbd/journal/TypeTraits.h"
13 #include <map>
14 #include <set>
15 #include <string>
16 #include <tuple>
17
18 class Context;
19
20 namespace rbd {
21 namespace mirror {
22 namespace image_sync {
23
24 template <typename ImageCtxT = librbd::ImageCtx>
25 class SnapshotCreateRequest {
26 public:
27 static SnapshotCreateRequest* create(ImageCtxT *local_image_ctx,
28 const std::string &snap_name,
29 const cls::rbd::SnapshotNamespace &snap_namespace,
30 uint64_t size,
31 const librbd::ParentSpec &parent_spec,
32 uint64_t parent_overlap,
33 Context *on_finish) {
34 return new SnapshotCreateRequest(local_image_ctx, snap_name, snap_namespace, size,
35 parent_spec, parent_overlap, on_finish);
36 }
37
38 SnapshotCreateRequest(ImageCtxT *local_image_ctx,
39 const std::string &snap_name,
40 const cls::rbd::SnapshotNamespace &snap_namespace,
41 uint64_t size,
42 const librbd::ParentSpec &parent_spec,
43 uint64_t parent_overlap, Context *on_finish);
44
45 void send();
46
47 private:
48 /**
49 * @verbatim
50 *
51 * <start>
52 * |
53 * v (skip if not needed)
54 * SET_SIZE
55 * |
56 * v (skip if not needed)
57 * REMOVE_PARENT
58 * |
59 * v (skip if not needed)
60 * SET_PARENT
61 * |
62 * v
63 * CREATE_SNAP
64 * |
65 * v (skip if not needed)
66 * CREATE_OBJECT_MAP
67 * |
68 * v
69 * <finish>
70 *
71 * @endverbatim
72 */
73
74 ImageCtxT *m_local_image_ctx;
75 std::string m_snap_name;
76 cls::rbd::SnapshotNamespace m_snap_namespace;
77 uint64_t m_size;
78 librbd::ParentSpec m_parent_spec;
79 uint64_t m_parent_overlap;
80 Context *m_on_finish;
81
82 void send_set_size();
83 void handle_set_size(int r);
84
85 void send_remove_parent();
86 void handle_remove_parent(int r);
87
88 void send_set_parent();
89 void handle_set_parent(int r);
90
91 void send_snap_create();
92 void handle_snap_create(int r);
93
94 void send_create_object_map();
95 void handle_create_object_map(int r);
96
97 Context *start_local_op(int *r);
98
99 void finish(int r);
100 };
101
102 } // namespace image_sync
103 } // namespace mirror
104 } // namespace rbd
105
106 extern template class rbd::mirror::image_sync::SnapshotCreateRequest<librbd::ImageCtx>;
107
108 #endif // RBD_MIRROR_IMAGE_SYNC_SNAPSHOT_CREATE_REQUEST_H