]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
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_REPLAYER_SNAPSHOT_APPLY_IMAGE_STATE_REQUEST_H | |
5 | #define RBD_MIRROR_IMAGE_REPLAYER_SNAPSHOT_APPLY_IMAGE_STATE_REQUEST_H | |
6 | ||
7 | #include "common/ceph_mutex.h" | |
8 | #include "librbd/mirror/snapshot/Types.h" | |
9 | #include <map> | |
10 | #include <string> | |
11 | ||
12 | struct Context; | |
13 | ||
14 | namespace librbd { | |
15 | ||
16 | struct ImageCtx; | |
17 | ||
18 | } // namespace librbd | |
19 | ||
20 | namespace rbd { | |
21 | namespace mirror { | |
22 | namespace image_replayer { | |
23 | namespace snapshot { | |
24 | ||
25 | template <typename> class EventPreprocessor; | |
26 | template <typename> class ReplayStatusFormatter; | |
27 | template <typename> class StateBuilder; | |
28 | ||
29 | template <typename ImageCtxT> | |
30 | class ApplyImageStateRequest { | |
31 | public: | |
32 | static ApplyImageStateRequest* create( | |
33 | const std::string& local_mirror_uuid, | |
34 | const std::string& remote_mirror_uuid, | |
35 | ImageCtxT* local_image_ctx, | |
36 | ImageCtxT* remote_image_ctx, | |
37 | librbd::mirror::snapshot::ImageState image_state, | |
38 | Context* on_finish) { | |
39 | return new ApplyImageStateRequest(local_mirror_uuid, remote_mirror_uuid, | |
40 | local_image_ctx, remote_image_ctx, | |
41 | image_state, on_finish); | |
42 | } | |
43 | ||
44 | ApplyImageStateRequest( | |
45 | const std::string& local_mirror_uuid, | |
46 | const std::string& remote_mirror_uuid, | |
47 | ImageCtxT* local_image_ctx, | |
48 | ImageCtxT* remote_image_ctx, | |
49 | librbd::mirror::snapshot::ImageState image_state, | |
50 | Context* on_finish); | |
51 | ||
52 | void send(); | |
53 | ||
54 | private: | |
55 | /** | |
56 | * @verbatim | |
57 | * | |
58 | * <start> | |
59 | * | | |
60 | * v | |
61 | * RENAME_IMAGE | |
62 | * | | |
63 | * | /---------\ | |
64 | * | | | | |
65 | * v v | | |
66 | * UPDATE_FEATURES -----/ | |
67 | * | | |
68 | * v | |
69 | * GET_IMAGE_META | |
70 | * | | |
71 | * | /---------\ | |
72 | * | | | | |
73 | * v v | | |
74 | * UPDATE_IMAGE_META ---/ | |
75 | * | | |
76 | * | /---------\ | |
77 | * | | | | |
78 | * v v | | |
79 | * UNPROTECT_SNAPSHOT | | |
80 | * | | | |
81 | * v | | |
82 | * REMOVE_SNAPSHOT | | |
83 | * | | | |
84 | * v | | |
85 | * PROTECT_SNAPSHOT | | |
86 | * | | | |
87 | * v | | |
88 | * RENAME_SNAPSHOT -----/ | |
89 | * | | |
90 | * v | |
91 | * SET_SNAPSHOT_LIMIT | |
92 | * | | |
93 | * v | |
94 | * <finish> | |
95 | * | |
96 | * @endverbatim | |
97 | */ | |
98 | ||
99 | std::string m_local_mirror_uuid; | |
100 | std::string m_remote_mirror_uuid; | |
101 | ImageCtxT* m_local_image_ctx; | |
102 | ImageCtxT* m_remote_image_ctx; | |
103 | librbd::mirror::snapshot::ImageState m_image_state; | |
104 | Context* m_on_finish; | |
105 | ||
106 | std::map<uint64_t, uint64_t> m_local_to_remote_snap_ids; | |
107 | ||
108 | uint64_t m_features = 0; | |
109 | ||
110 | std::map<std::string, bufferlist> m_metadata; | |
111 | ||
112 | uint64_t m_prev_snap_id = 0; | |
113 | std::string m_snap_name; | |
114 | ||
115 | void rename_image(); | |
116 | void handle_rename_image(int r); | |
117 | ||
118 | void update_features(); | |
119 | void handle_update_features(int r); | |
120 | ||
121 | void get_image_meta(); | |
122 | void handle_get_image_meta(int r); | |
123 | ||
124 | void update_image_meta(); | |
125 | void handle_update_image_meta(int r); | |
126 | ||
127 | void unprotect_snapshot(); | |
128 | void handle_unprotect_snapshot(int r); | |
129 | ||
130 | void remove_snapshot(); | |
131 | void handle_remove_snapshot(int r); | |
132 | ||
133 | void protect_snapshot(); | |
134 | void handle_protect_snapshot(int r); | |
135 | ||
136 | void rename_snapshot(); | |
137 | void handle_rename_snapshot(int r); | |
138 | ||
139 | void set_snapshot_limit(); | |
140 | void handle_set_snapshot_limit(int r); | |
141 | ||
142 | void finish(int r); | |
143 | ||
144 | uint64_t compute_remote_snap_id(uint64_t snap_id); | |
145 | void compute_local_to_remote_snap_ids(); | |
146 | }; | |
147 | ||
148 | } // namespace snapshot | |
149 | } // namespace image_replayer | |
150 | } // namespace mirror | |
151 | } // namespace rbd | |
152 | ||
153 | extern template class rbd::mirror::image_replayer::snapshot::ApplyImageStateRequest<librbd::ImageCtx>; | |
154 | ||
155 | #endif // RBD_MIRROR_IMAGE_REPLAYER_SNAPSHOT_APPLY_IMAGE_STATE_REQUEST_H |