]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
4 | #ifndef CEPH_CLS_RBD_TYPES_H | |
5 | #define CEPH_CLS_RBD_TYPES_H | |
6 | ||
7 | #include <boost/variant.hpp> | |
8 | #include "include/int_types.h" | |
9 | #include "include/buffer.h" | |
10 | #include "include/encoding.h" | |
11 | #include "include/stringify.h" | |
12 | #include "include/utime.h" | |
9f95a23c | 13 | #include "msg/msg_types.h" |
7c673cae FG |
14 | #include <iosfwd> |
15 | #include <string> | |
11fdf7f2 | 16 | #include <set> |
7c673cae FG |
17 | |
18 | #define RBD_GROUP_REF "rbd_group_ref" | |
19 | ||
20 | namespace ceph { class Formatter; } | |
21 | ||
22 | namespace cls { | |
23 | namespace rbd { | |
24 | ||
25 | static const uint32_t MAX_OBJECT_MAP_OBJECT_COUNT = 256000000; | |
f67539c2 | 26 | static const std::string RBD_GROUP_IMAGE_KEY_PREFIX = "image_"; |
7c673cae | 27 | |
11fdf7f2 TL |
28 | enum DirectoryState { |
29 | DIRECTORY_STATE_READY = 0, | |
30 | DIRECTORY_STATE_ADD_DISABLED = 1 | |
31 | }; | |
32 | ||
f67539c2 | 33 | inline void encode(DirectoryState state, ceph::buffer::list& bl, |
11fdf7f2 TL |
34 | uint64_t features=0) |
35 | { | |
36 | ceph::encode(static_cast<uint8_t>(state), bl); | |
37 | } | |
38 | ||
f67539c2 | 39 | inline void decode(DirectoryState &state, ceph::buffer::list::const_iterator& it) |
11fdf7f2 TL |
40 | { |
41 | uint8_t int_state; | |
42 | ceph::decode(int_state, it); | |
43 | state = static_cast<DirectoryState>(int_state); | |
44 | } | |
45 | ||
7c673cae FG |
46 | enum MirrorMode { |
47 | MIRROR_MODE_DISABLED = 0, | |
48 | MIRROR_MODE_IMAGE = 1, | |
49 | MIRROR_MODE_POOL = 2 | |
50 | }; | |
51 | ||
52 | enum GroupImageLinkState { | |
53 | GROUP_IMAGE_LINK_STATE_ATTACHED, | |
54 | GROUP_IMAGE_LINK_STATE_INCOMPLETE | |
55 | }; | |
56 | ||
f67539c2 | 57 | inline void encode(const GroupImageLinkState &state, ceph::buffer::list& bl, |
7c673cae FG |
58 | uint64_t features=0) |
59 | { | |
11fdf7f2 TL |
60 | using ceph::encode; |
61 | encode(static_cast<uint8_t>(state), bl); | |
7c673cae FG |
62 | } |
63 | ||
f67539c2 | 64 | inline void decode(GroupImageLinkState &state, ceph::buffer::list::const_iterator& it) |
7c673cae FG |
65 | { |
66 | uint8_t int_state; | |
11fdf7f2 TL |
67 | using ceph::decode; |
68 | decode(int_state, it); | |
7c673cae FG |
69 | state = static_cast<GroupImageLinkState>(int_state); |
70 | } | |
71 | ||
9f95a23c TL |
72 | enum MirrorPeerDirection { |
73 | MIRROR_PEER_DIRECTION_RX = 0, | |
74 | MIRROR_PEER_DIRECTION_TX = 1, | |
75 | MIRROR_PEER_DIRECTION_RX_TX = 2 | |
76 | }; | |
77 | ||
78 | std::ostream& operator<<(std::ostream& os, | |
79 | MirrorPeerDirection mirror_peer_direction); | |
80 | ||
7c673cae FG |
81 | struct MirrorPeer { |
82 | MirrorPeer() { | |
83 | } | |
9f95a23c TL |
84 | MirrorPeer(const std::string &uuid, |
85 | MirrorPeerDirection mirror_peer_direction, | |
86 | const std::string& site_name, | |
87 | const std::string& client_name, | |
88 | const std::string& mirror_uuid) | |
89 | : uuid(uuid), mirror_peer_direction(mirror_peer_direction), | |
90 | site_name(site_name), client_name(client_name), | |
91 | mirror_uuid(mirror_uuid) { | |
7c673cae FG |
92 | } |
93 | ||
94 | std::string uuid; | |
9f95a23c TL |
95 | |
96 | MirrorPeerDirection mirror_peer_direction = MIRROR_PEER_DIRECTION_RX_TX; | |
97 | std::string site_name; | |
98 | std::string client_name; // RX property | |
99 | std::string mirror_uuid; | |
100 | utime_t last_seen; | |
7c673cae FG |
101 | |
102 | inline bool is_valid() const { | |
9f95a23c TL |
103 | switch (mirror_peer_direction) { |
104 | case MIRROR_PEER_DIRECTION_TX: | |
105 | break; | |
106 | case MIRROR_PEER_DIRECTION_RX: | |
107 | case MIRROR_PEER_DIRECTION_RX_TX: | |
108 | if (client_name.empty()) { | |
109 | return false; | |
110 | } | |
111 | break; | |
112 | default: | |
113 | return false; | |
114 | } | |
115 | return (!uuid.empty() && !site_name.empty()); | |
7c673cae FG |
116 | } |
117 | ||
f67539c2 TL |
118 | void encode(ceph::buffer::list &bl) const; |
119 | void decode(ceph::buffer::list::const_iterator &it); | |
120 | void dump(ceph::Formatter *f) const; | |
7c673cae FG |
121 | |
122 | static void generate_test_instances(std::list<MirrorPeer*> &o); | |
123 | ||
124 | bool operator==(const MirrorPeer &rhs) const; | |
9f95a23c TL |
125 | bool operator!=(const MirrorPeer &rhs) const { |
126 | return (!(*this == rhs)); | |
127 | } | |
7c673cae FG |
128 | }; |
129 | ||
130 | std::ostream& operator<<(std::ostream& os, const MirrorMode& mirror_mode); | |
131 | std::ostream& operator<<(std::ostream& os, const MirrorPeer& peer); | |
132 | ||
133 | WRITE_CLASS_ENCODER(MirrorPeer); | |
134 | ||
9f95a23c TL |
135 | enum MirrorImageMode { |
136 | MIRROR_IMAGE_MODE_JOURNAL = 0, | |
137 | MIRROR_IMAGE_MODE_SNAPSHOT = 1, | |
138 | }; | |
139 | ||
7c673cae FG |
140 | enum MirrorImageState { |
141 | MIRROR_IMAGE_STATE_DISABLING = 0, | |
142 | MIRROR_IMAGE_STATE_ENABLED = 1, | |
143 | MIRROR_IMAGE_STATE_DISABLED = 2, | |
9f95a23c | 144 | MIRROR_IMAGE_STATE_CREATING = 3, |
7c673cae FG |
145 | }; |
146 | ||
147 | struct MirrorImage { | |
9f95a23c TL |
148 | MirrorImage() { |
149 | } | |
150 | MirrorImage(MirrorImageMode mode, const std::string &global_image_id, | |
151 | MirrorImageState state) | |
152 | : mode(mode), global_image_id(global_image_id), state(state) { | |
153 | } | |
7c673cae | 154 | |
9f95a23c | 155 | MirrorImageMode mode = MIRROR_IMAGE_MODE_JOURNAL; |
7c673cae FG |
156 | std::string global_image_id; |
157 | MirrorImageState state = MIRROR_IMAGE_STATE_DISABLING; | |
158 | ||
f67539c2 TL |
159 | void encode(ceph::buffer::list &bl) const; |
160 | void decode(ceph::buffer::list::const_iterator &it); | |
161 | void dump(ceph::Formatter *f) const; | |
7c673cae FG |
162 | |
163 | static void generate_test_instances(std::list<MirrorImage*> &o); | |
164 | ||
165 | bool operator==(const MirrorImage &rhs) const; | |
166 | bool operator<(const MirrorImage &rhs) const; | |
167 | }; | |
168 | ||
9f95a23c | 169 | std::ostream& operator<<(std::ostream& os, const MirrorImageMode& mirror_mode); |
7c673cae FG |
170 | std::ostream& operator<<(std::ostream& os, const MirrorImageState& mirror_state); |
171 | std::ostream& operator<<(std::ostream& os, const MirrorImage& mirror_image); | |
172 | ||
173 | WRITE_CLASS_ENCODER(MirrorImage); | |
174 | ||
175 | enum MirrorImageStatusState { | |
176 | MIRROR_IMAGE_STATUS_STATE_UNKNOWN = 0, | |
177 | MIRROR_IMAGE_STATUS_STATE_ERROR = 1, | |
178 | MIRROR_IMAGE_STATUS_STATE_SYNCING = 2, | |
179 | MIRROR_IMAGE_STATUS_STATE_STARTING_REPLAY = 3, | |
180 | MIRROR_IMAGE_STATUS_STATE_REPLAYING = 4, | |
181 | MIRROR_IMAGE_STATUS_STATE_STOPPING_REPLAY = 5, | |
182 | MIRROR_IMAGE_STATUS_STATE_STOPPED = 6, | |
183 | }; | |
184 | ||
f67539c2 | 185 | inline void encode(const MirrorImageStatusState &state, ceph::buffer::list& bl, |
7c673cae FG |
186 | uint64_t features=0) |
187 | { | |
11fdf7f2 TL |
188 | using ceph::encode; |
189 | encode(static_cast<uint8_t>(state), bl); | |
7c673cae FG |
190 | } |
191 | ||
9f95a23c | 192 | inline void decode(MirrorImageStatusState &state, |
f67539c2 | 193 | ceph::buffer::list::const_iterator& it) |
7c673cae FG |
194 | { |
195 | uint8_t int_state; | |
11fdf7f2 TL |
196 | using ceph::decode; |
197 | decode(int_state, it); | |
7c673cae FG |
198 | state = static_cast<MirrorImageStatusState>(int_state); |
199 | } | |
200 | ||
9f95a23c TL |
201 | std::ostream& operator<<(std::ostream& os, const MirrorImageStatusState& state); |
202 | ||
203 | struct MirrorImageSiteStatus { | |
204 | static const std::string LOCAL_MIRROR_UUID; | |
205 | ||
206 | MirrorImageSiteStatus() {} | |
207 | MirrorImageSiteStatus(const std::string& mirror_uuid, | |
208 | MirrorImageStatusState state, | |
209 | const std::string &description) | |
210 | : mirror_uuid(mirror_uuid), state(state), description(description) { | |
211 | } | |
7c673cae | 212 | |
9f95a23c | 213 | std::string mirror_uuid = LOCAL_MIRROR_UUID; |
7c673cae FG |
214 | MirrorImageStatusState state = MIRROR_IMAGE_STATUS_STATE_UNKNOWN; |
215 | std::string description; | |
216 | utime_t last_update; | |
217 | bool up = false; | |
218 | ||
f67539c2 TL |
219 | void encode_meta(uint8_t version, ceph::buffer::list &bl) const; |
220 | void decode_meta(uint8_t version, ceph::buffer::list::const_iterator &it); | |
9f95a23c | 221 | |
f67539c2 TL |
222 | void encode(ceph::buffer::list &bl) const; |
223 | void decode(ceph::buffer::list::const_iterator &it); | |
224 | void dump(ceph::Formatter *f) const; | |
7c673cae FG |
225 | |
226 | std::string state_to_string() const; | |
227 | ||
9f95a23c | 228 | bool operator==(const MirrorImageSiteStatus &rhs) const; |
7c673cae | 229 | |
9f95a23c | 230 | static void generate_test_instances(std::list<MirrorImageSiteStatus*> &o); |
7c673cae | 231 | }; |
9f95a23c | 232 | WRITE_CLASS_ENCODER(MirrorImageSiteStatus); |
7c673cae | 233 | |
9f95a23c TL |
234 | std::ostream& operator<<(std::ostream& os, const MirrorImageSiteStatus& status); |
235 | ||
236 | struct MirrorImageSiteStatusOnDisk : cls::rbd::MirrorImageSiteStatus { | |
237 | entity_inst_t origin; | |
7c673cae | 238 | |
9f95a23c TL |
239 | MirrorImageSiteStatusOnDisk() { |
240 | } | |
241 | MirrorImageSiteStatusOnDisk(const cls::rbd::MirrorImageSiteStatus &status) : | |
242 | cls::rbd::MirrorImageSiteStatus(status) { | |
243 | } | |
244 | ||
f67539c2 TL |
245 | void encode_meta(ceph::buffer::list &bl, uint64_t features) const; |
246 | void decode_meta(ceph::buffer::list::const_iterator &it); | |
9f95a23c | 247 | |
f67539c2 TL |
248 | void encode(ceph::buffer::list &bl, uint64_t features) const; |
249 | void decode(ceph::buffer::list::const_iterator &it); | |
9f95a23c TL |
250 | |
251 | static void generate_test_instances( | |
252 | std::list<MirrorImageSiteStatusOnDisk*> &o); | |
253 | }; | |
254 | WRITE_CLASS_ENCODER_FEATURES(MirrorImageSiteStatusOnDisk) | |
255 | ||
256 | struct MirrorImageStatus { | |
257 | typedef std::list<MirrorImageSiteStatus> MirrorImageSiteStatuses; | |
258 | ||
259 | MirrorImageStatus() {} | |
260 | MirrorImageStatus(const MirrorImageSiteStatuses& statuses) | |
261 | : mirror_image_site_statuses(statuses) { | |
262 | } | |
263 | ||
264 | MirrorImageSiteStatuses mirror_image_site_statuses; | |
265 | ||
266 | int get_local_mirror_image_site_status(MirrorImageSiteStatus* status) const; | |
267 | ||
f67539c2 TL |
268 | void encode(ceph::buffer::list &bl) const; |
269 | void decode(ceph::buffer::list::const_iterator &it); | |
270 | void dump(ceph::Formatter *f) const; | |
9f95a23c TL |
271 | |
272 | bool operator==(const MirrorImageStatus& rhs) const; | |
273 | ||
274 | static void generate_test_instances(std::list<MirrorImageStatus*> &o); | |
275 | }; | |
7c673cae FG |
276 | WRITE_CLASS_ENCODER(MirrorImageStatus); |
277 | ||
9f95a23c TL |
278 | std::ostream& operator<<(std::ostream& os, const MirrorImageStatus& status); |
279 | ||
11fdf7f2 TL |
280 | struct ParentImageSpec { |
281 | int64_t pool_id = -1; | |
282 | std::string pool_namespace; | |
283 | std::string image_id; | |
284 | snapid_t snap_id = CEPH_NOSNAP; | |
285 | ||
286 | ParentImageSpec() { | |
287 | } | |
288 | ParentImageSpec(int64_t pool_id, const std::string& pool_namespace, | |
289 | const std::string& image_id, snapid_t snap_id) | |
290 | : pool_id(pool_id), pool_namespace(pool_namespace), image_id(image_id), | |
291 | snap_id(snap_id) { | |
292 | } | |
293 | ||
294 | bool exists() const { | |
295 | return (pool_id >= 0 && !image_id.empty() && snap_id != CEPH_NOSNAP); | |
296 | } | |
297 | ||
298 | bool operator==(const ParentImageSpec& rhs) const { | |
299 | return ((pool_id == rhs.pool_id) && | |
300 | (pool_namespace == rhs.pool_namespace) && | |
301 | (image_id == rhs.image_id) && | |
302 | (snap_id == rhs.snap_id)); | |
303 | } | |
304 | ||
305 | bool operator!=(const ParentImageSpec& rhs) const { | |
306 | return !(*this == rhs); | |
307 | } | |
308 | ||
f67539c2 TL |
309 | void encode(ceph::buffer::list &bl) const; |
310 | void decode(ceph::buffer::list::const_iterator &it); | |
311 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
312 | |
313 | static void generate_test_instances(std::list<ParentImageSpec*> &o); | |
314 | }; | |
315 | ||
316 | WRITE_CLASS_ENCODER(ParentImageSpec); | |
317 | ||
9f95a23c TL |
318 | std::ostream& operator<<(std::ostream& os, const ParentImageSpec& rhs); |
319 | ||
11fdf7f2 TL |
320 | struct ChildImageSpec { |
321 | int64_t pool_id = -1; | |
322 | std::string pool_namespace; | |
323 | std::string image_id; | |
324 | ||
325 | ChildImageSpec() {} | |
326 | ChildImageSpec(int64_t pool_id, const std::string& pool_namespace, | |
327 | const std::string& image_id) | |
328 | : pool_id(pool_id), pool_namespace(pool_namespace), image_id(image_id) { | |
329 | } | |
330 | ||
f67539c2 TL |
331 | void encode(ceph::buffer::list &bl) const; |
332 | void decode(ceph::buffer::list::const_iterator &it); | |
333 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
334 | |
335 | static void generate_test_instances(std::list<ChildImageSpec*> &o); | |
336 | ||
337 | inline bool operator==(const ChildImageSpec& rhs) const { | |
338 | return (pool_id == rhs.pool_id && | |
339 | pool_namespace == rhs.pool_namespace && | |
340 | image_id == rhs.image_id); | |
341 | } | |
342 | inline bool operator<(const ChildImageSpec& rhs) const { | |
343 | if (pool_id != rhs.pool_id) { | |
344 | return pool_id < rhs.pool_id; | |
345 | } | |
346 | if (pool_namespace != rhs.pool_namespace) { | |
347 | return pool_namespace < rhs.pool_namespace; | |
348 | } | |
349 | return image_id < rhs.image_id; | |
350 | } | |
351 | }; | |
352 | WRITE_CLASS_ENCODER(ChildImageSpec); | |
353 | ||
9f95a23c TL |
354 | std::ostream& operator<<(std::ostream& os, const ChildImageSpec& rhs); |
355 | ||
11fdf7f2 TL |
356 | typedef std::set<ChildImageSpec> ChildImageSpecs; |
357 | ||
7c673cae FG |
358 | struct GroupImageSpec { |
359 | GroupImageSpec() {} | |
360 | ||
361 | GroupImageSpec(const std::string &image_id, int64_t pool_id) | |
362 | : image_id(image_id), pool_id(pool_id) {} | |
363 | ||
364 | static int from_key(const std::string &image_key, GroupImageSpec *spec); | |
365 | ||
366 | std::string image_id; | |
367 | int64_t pool_id = -1; | |
368 | ||
f67539c2 TL |
369 | void encode(ceph::buffer::list &bl) const; |
370 | void decode(ceph::buffer::list::const_iterator &it); | |
371 | void dump(ceph::Formatter *f) const; | |
7c673cae | 372 | |
11fdf7f2 TL |
373 | static void generate_test_instances(std::list<GroupImageSpec*> &o); |
374 | ||
7c673cae FG |
375 | std::string image_key(); |
376 | ||
377 | }; | |
7c673cae FG |
378 | WRITE_CLASS_ENCODER(GroupImageSpec); |
379 | ||
380 | struct GroupImageStatus { | |
381 | GroupImageStatus() {} | |
382 | GroupImageStatus(const std::string &image_id, | |
383 | int64_t pool_id, | |
384 | GroupImageLinkState state) | |
385 | : spec(image_id, pool_id), state(state) {} | |
386 | ||
387 | GroupImageStatus(GroupImageSpec spec, | |
388 | GroupImageLinkState state) | |
389 | : spec(spec), state(state) {} | |
390 | ||
391 | GroupImageSpec spec; | |
392 | GroupImageLinkState state = GROUP_IMAGE_LINK_STATE_INCOMPLETE; | |
393 | ||
f67539c2 TL |
394 | void encode(ceph::buffer::list &bl) const; |
395 | void decode(ceph::buffer::list::const_iterator &it); | |
396 | void dump(ceph::Formatter *f) const; | |
7c673cae | 397 | |
11fdf7f2 TL |
398 | static void generate_test_instances(std::list<GroupImageStatus*> &o); |
399 | ||
7c673cae FG |
400 | std::string state_to_string() const; |
401 | }; | |
402 | ||
403 | WRITE_CLASS_ENCODER(GroupImageStatus); | |
404 | ||
405 | struct GroupSpec { | |
406 | GroupSpec() {} | |
407 | GroupSpec(const std::string &group_id, int64_t pool_id) | |
408 | : group_id(group_id), pool_id(pool_id) {} | |
409 | ||
410 | std::string group_id; | |
411 | int64_t pool_id = -1; | |
412 | ||
f67539c2 TL |
413 | void encode(ceph::buffer::list &bl) const; |
414 | void decode(ceph::buffer::list::const_iterator &it); | |
415 | void dump(ceph::Formatter *f) const; | |
7c673cae | 416 | bool is_valid() const; |
11fdf7f2 TL |
417 | |
418 | static void generate_test_instances(std::list<GroupSpec *> &o); | |
7c673cae FG |
419 | }; |
420 | ||
421 | WRITE_CLASS_ENCODER(GroupSpec); | |
422 | ||
423 | enum SnapshotNamespaceType { | |
9f95a23c TL |
424 | SNAPSHOT_NAMESPACE_TYPE_USER = 0, |
425 | SNAPSHOT_NAMESPACE_TYPE_GROUP = 1, | |
426 | SNAPSHOT_NAMESPACE_TYPE_TRASH = 2, | |
427 | SNAPSHOT_NAMESPACE_TYPE_MIRROR = 3, | |
7c673cae FG |
428 | }; |
429 | ||
430 | struct UserSnapshotNamespace { | |
11fdf7f2 TL |
431 | static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = |
432 | SNAPSHOT_NAMESPACE_TYPE_USER; | |
7c673cae FG |
433 | |
434 | UserSnapshotNamespace() {} | |
435 | ||
f67539c2 TL |
436 | void encode(ceph::buffer::list& bl) const {} |
437 | void decode(ceph::buffer::list::const_iterator& it) {} | |
7c673cae | 438 | |
f67539c2 | 439 | void dump(ceph::Formatter *f) const {} |
7c673cae FG |
440 | |
441 | inline bool operator==(const UserSnapshotNamespace& usn) const { | |
442 | return true; | |
443 | } | |
444 | ||
445 | inline bool operator<(const UserSnapshotNamespace& usn) const { | |
446 | return false; | |
447 | } | |
11fdf7f2 TL |
448 | }; |
449 | ||
450 | struct GroupSnapshotNamespace { | |
451 | static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = | |
452 | SNAPSHOT_NAMESPACE_TYPE_GROUP; | |
453 | ||
454 | GroupSnapshotNamespace() {} | |
455 | ||
456 | GroupSnapshotNamespace(int64_t _group_pool, | |
f67539c2 TL |
457 | const std::string &_group_id, |
458 | const std::string &_group_snapshot_id) | |
11fdf7f2 TL |
459 | : group_id(_group_id), group_pool(_group_pool), |
460 | group_snapshot_id(_group_snapshot_id) {} | |
461 | ||
f67539c2 | 462 | std::string group_id; |
11fdf7f2 | 463 | int64_t group_pool = 0; |
f67539c2 | 464 | std::string group_snapshot_id; |
11fdf7f2 | 465 | |
f67539c2 TL |
466 | void encode(ceph::buffer::list& bl) const; |
467 | void decode(ceph::buffer::list::const_iterator& it); | |
11fdf7f2 | 468 | |
f67539c2 | 469 | void dump(ceph::Formatter *f) const; |
11fdf7f2 TL |
470 | |
471 | inline bool operator==(const GroupSnapshotNamespace& gsn) const { | |
472 | return group_pool == gsn.group_pool && | |
473 | group_id == gsn.group_id && | |
474 | group_snapshot_id == gsn.group_snapshot_id; | |
475 | } | |
7c673cae | 476 | |
11fdf7f2 | 477 | inline bool operator<(const GroupSnapshotNamespace& gsn) const { |
20effc67 TL |
478 | if (group_pool != gsn.group_pool) { |
479 | return group_pool < gsn.group_pool; | |
11fdf7f2 | 480 | } |
20effc67 TL |
481 | if (group_id != gsn.group_id) { |
482 | return group_id < gsn.group_id; | |
483 | } | |
484 | return group_snapshot_id < gsn.group_snapshot_id; | |
11fdf7f2 | 485 | } |
7c673cae FG |
486 | }; |
487 | ||
11fdf7f2 TL |
488 | struct TrashSnapshotNamespace { |
489 | static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = | |
490 | SNAPSHOT_NAMESPACE_TYPE_TRASH; | |
491 | ||
492 | std::string original_name; | |
493 | SnapshotNamespaceType original_snapshot_namespace_type = | |
494 | SNAPSHOT_NAMESPACE_TYPE_USER; | |
495 | ||
496 | TrashSnapshotNamespace() {} | |
497 | TrashSnapshotNamespace(SnapshotNamespaceType original_snapshot_namespace_type, | |
498 | const std::string& original_name) | |
499 | : original_name(original_name), | |
500 | original_snapshot_namespace_type(original_snapshot_namespace_type) {} | |
501 | ||
f67539c2 TL |
502 | void encode(ceph::buffer::list& bl) const; |
503 | void decode(ceph::buffer::list::const_iterator& it); | |
504 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
505 | |
506 | inline bool operator==(const TrashSnapshotNamespace& usn) const { | |
507 | return true; | |
508 | } | |
509 | inline bool operator<(const TrashSnapshotNamespace& usn) const { | |
510 | return false; | |
511 | } | |
512 | }; | |
7c673cae | 513 | |
9f95a23c TL |
514 | enum MirrorSnapshotState { |
515 | MIRROR_SNAPSHOT_STATE_PRIMARY = 0, | |
516 | MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED = 1, | |
517 | MIRROR_SNAPSHOT_STATE_NON_PRIMARY = 2, | |
518 | MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED = 3, | |
519 | }; | |
520 | ||
f67539c2 | 521 | inline void encode(const MirrorSnapshotState &state, ceph::buffer::list& bl, |
9f95a23c TL |
522 | uint64_t features=0) { |
523 | using ceph::encode; | |
524 | encode(static_cast<uint8_t>(state), bl); | |
525 | } | |
526 | ||
f67539c2 | 527 | inline void decode(MirrorSnapshotState &state, ceph::buffer::list::const_iterator& it) { |
9f95a23c TL |
528 | using ceph::decode; |
529 | uint8_t int_state; | |
530 | decode(int_state, it); | |
531 | state = static_cast<MirrorSnapshotState>(int_state); | |
532 | } | |
533 | ||
534 | std::ostream& operator<<(std::ostream& os, MirrorSnapshotState type); | |
535 | ||
536 | typedef std::map<uint64_t, uint64_t> SnapSeqs; | |
537 | ||
538 | struct MirrorSnapshotNamespace { | |
539 | static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = | |
540 | SNAPSHOT_NAMESPACE_TYPE_MIRROR; | |
541 | ||
542 | MirrorSnapshotState state = MIRROR_SNAPSHOT_STATE_NON_PRIMARY; | |
543 | bool complete = false; | |
544 | std::set<std::string> mirror_peer_uuids; | |
545 | ||
546 | std::string primary_mirror_uuid; | |
1911f103 TL |
547 | union { |
548 | snapid_t primary_snap_id = CEPH_NOSNAP; | |
549 | snapid_t clean_since_snap_id; | |
550 | }; | |
9f95a23c TL |
551 | uint64_t last_copied_object_number = 0; |
552 | SnapSeqs snap_seqs; | |
553 | ||
554 | MirrorSnapshotNamespace() { | |
555 | } | |
556 | MirrorSnapshotNamespace(MirrorSnapshotState state, | |
557 | const std::set<std::string> &mirror_peer_uuids, | |
558 | const std::string& primary_mirror_uuid, | |
559 | snapid_t primary_snap_id) | |
560 | : state(state), mirror_peer_uuids(mirror_peer_uuids), | |
561 | primary_mirror_uuid(primary_mirror_uuid), | |
562 | primary_snap_id(primary_snap_id) { | |
563 | } | |
564 | MirrorSnapshotNamespace(MirrorSnapshotState state, | |
565 | const std::set<std::string> &mirror_peer_uuids, | |
566 | const std::string& primary_mirror_uuid, | |
567 | snapid_t primary_snap_id, | |
568 | bool complete, | |
569 | uint64_t last_copied_object_number, | |
570 | const SnapSeqs& snap_seqs) | |
571 | : state(state), complete(complete), mirror_peer_uuids(mirror_peer_uuids), | |
572 | primary_mirror_uuid(primary_mirror_uuid), | |
573 | primary_snap_id(primary_snap_id), | |
574 | last_copied_object_number(last_copied_object_number), | |
575 | snap_seqs(snap_seqs) { | |
576 | } | |
577 | ||
578 | inline bool is_primary() const { | |
579 | return (state == MIRROR_SNAPSHOT_STATE_PRIMARY || | |
580 | state == MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED); | |
581 | } | |
582 | ||
583 | inline bool is_non_primary() const { | |
584 | return (state == MIRROR_SNAPSHOT_STATE_NON_PRIMARY || | |
585 | state == MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED); | |
586 | } | |
587 | ||
588 | inline bool is_demoted() const { | |
589 | return (state == MIRROR_SNAPSHOT_STATE_PRIMARY_DEMOTED || | |
590 | state == MIRROR_SNAPSHOT_STATE_NON_PRIMARY_DEMOTED); | |
591 | } | |
592 | ||
593 | inline bool is_orphan() const { | |
594 | return (is_non_primary() && | |
595 | primary_mirror_uuid.empty() && | |
596 | primary_snap_id == CEPH_NOSNAP); | |
597 | } | |
598 | ||
f67539c2 TL |
599 | void encode(ceph::buffer::list& bl) const; |
600 | void decode(ceph::buffer::list::const_iterator& it); | |
9f95a23c | 601 | |
f67539c2 | 602 | void dump(ceph::Formatter *f) const; |
9f95a23c TL |
603 | |
604 | inline bool operator==(const MirrorSnapshotNamespace& rhs) const { | |
605 | return state == rhs.state && | |
606 | complete == rhs.complete && | |
607 | mirror_peer_uuids == rhs.mirror_peer_uuids && | |
608 | primary_mirror_uuid == rhs.primary_mirror_uuid && | |
609 | primary_snap_id == rhs.primary_snap_id && | |
610 | last_copied_object_number == rhs.last_copied_object_number && | |
611 | snap_seqs == rhs.snap_seqs; | |
612 | } | |
613 | ||
614 | inline bool operator<(const MirrorSnapshotNamespace& rhs) const { | |
615 | if (state != rhs.state) { | |
616 | return state < rhs.state; | |
617 | } else if (complete != rhs.complete) { | |
618 | return complete < rhs.complete; | |
619 | } else if (mirror_peer_uuids != rhs.mirror_peer_uuids) { | |
620 | return mirror_peer_uuids < rhs.mirror_peer_uuids; | |
621 | } else if (primary_mirror_uuid != rhs.primary_mirror_uuid) { | |
622 | return primary_mirror_uuid < rhs.primary_mirror_uuid; | |
623 | } else if (primary_snap_id != rhs.primary_snap_id) { | |
624 | return primary_snap_id < rhs.primary_snap_id; | |
625 | } else if (last_copied_object_number != rhs.last_copied_object_number) { | |
626 | return last_copied_object_number < rhs.last_copied_object_number; | |
627 | } else { | |
628 | return snap_seqs < rhs.snap_seqs; | |
629 | } | |
630 | } | |
631 | }; | |
632 | ||
7c673cae | 633 | struct UnknownSnapshotNamespace { |
11fdf7f2 TL |
634 | static const SnapshotNamespaceType SNAPSHOT_NAMESPACE_TYPE = |
635 | static_cast<SnapshotNamespaceType>(-1); | |
7c673cae FG |
636 | |
637 | UnknownSnapshotNamespace() {} | |
638 | ||
f67539c2 TL |
639 | void encode(ceph::buffer::list& bl) const {} |
640 | void decode(ceph::buffer::list::const_iterator& it) {} | |
641 | void dump(ceph::Formatter *f) const {} | |
11fdf7f2 | 642 | |
7c673cae FG |
643 | inline bool operator==(const UnknownSnapshotNamespace& gsn) const { |
644 | return true; | |
645 | } | |
646 | ||
11fdf7f2 | 647 | inline bool operator<(const UnknownSnapshotNamespace& gsn) const { |
7c673cae FG |
648 | return false; |
649 | } | |
650 | }; | |
651 | ||
11fdf7f2 TL |
652 | std::ostream& operator<<(std::ostream& os, const SnapshotNamespaceType& type); |
653 | std::ostream& operator<<(std::ostream& os, const UserSnapshotNamespace& ns); | |
654 | std::ostream& operator<<(std::ostream& os, const GroupSnapshotNamespace& ns); | |
655 | std::ostream& operator<<(std::ostream& os, const TrashSnapshotNamespace& ns); | |
9f95a23c | 656 | std::ostream& operator<<(std::ostream& os, const MirrorSnapshotNamespace& ns); |
7c673cae FG |
657 | std::ostream& operator<<(std::ostream& os, const UnknownSnapshotNamespace& ns); |
658 | ||
11fdf7f2 TL |
659 | typedef boost::variant<UserSnapshotNamespace, |
660 | GroupSnapshotNamespace, | |
661 | TrashSnapshotNamespace, | |
9f95a23c | 662 | MirrorSnapshotNamespace, |
11fdf7f2 TL |
663 | UnknownSnapshotNamespace> SnapshotNamespaceVariant; |
664 | ||
665 | struct SnapshotNamespace : public SnapshotNamespaceVariant { | |
666 | SnapshotNamespace() { | |
667 | } | |
668 | ||
669 | template <typename T> | |
670 | SnapshotNamespace(T&& t) : SnapshotNamespaceVariant(std::forward<T>(t)) { | |
671 | } | |
672 | ||
f67539c2 TL |
673 | void encode(ceph::buffer::list& bl) const; |
674 | void decode(ceph::buffer::list::const_iterator& it); | |
675 | void dump(ceph::Formatter *f) const; | |
7c673cae | 676 | |
11fdf7f2 | 677 | static void generate_test_instances(std::list<SnapshotNamespace*> &o); |
7c673cae | 678 | |
11fdf7f2 TL |
679 | inline bool operator==(const SnapshotNamespaceVariant& sn) const { |
680 | return static_cast<const SnapshotNamespaceVariant&>(*this) == sn; | |
681 | } | |
682 | inline bool operator<(const SnapshotNamespaceVariant& sn) const { | |
683 | return static_cast<const SnapshotNamespaceVariant&>(*this) < sn; | |
684 | } | |
9f95a23c TL |
685 | inline bool operator!=(const SnapshotNamespaceVariant& sn) const { |
686 | return !(*this == sn); | |
687 | } | |
11fdf7f2 TL |
688 | }; |
689 | WRITE_CLASS_ENCODER(SnapshotNamespace); | |
7c673cae | 690 | |
11fdf7f2 TL |
691 | SnapshotNamespaceType get_snap_namespace_type( |
692 | const SnapshotNamespace& snapshot_namespace); | |
7c673cae | 693 | |
11fdf7f2 TL |
694 | struct SnapshotInfo { |
695 | snapid_t id = CEPH_NOSNAP; | |
696 | cls::rbd::SnapshotNamespace snapshot_namespace = {UserSnapshotNamespace{}}; | |
697 | std::string name; | |
698 | uint64_t image_size = 0; | |
699 | utime_t timestamp; | |
700 | uint32_t child_count = 0; | |
7c673cae | 701 | |
11fdf7f2 TL |
702 | SnapshotInfo() { |
703 | } | |
704 | SnapshotInfo(snapid_t id, | |
705 | const cls::rbd::SnapshotNamespace& snapshot_namespace, | |
706 | const std::string& name, uint64_t image_size, | |
707 | const utime_t& timestamp, uint32_t child_count) | |
708 | : id(id), snapshot_namespace(snapshot_namespace), | |
709 | name(name), image_size(image_size), timestamp(timestamp), | |
710 | child_count(child_count) { | |
711 | } | |
7c673cae | 712 | |
f67539c2 TL |
713 | void encode(ceph::buffer::list& bl) const; |
714 | void decode(ceph::buffer::list::const_iterator& it); | |
715 | void dump(ceph::Formatter *f) const; | |
7c673cae | 716 | |
11fdf7f2 TL |
717 | static void generate_test_instances(std::list<SnapshotInfo*> &o); |
718 | }; | |
719 | WRITE_CLASS_ENCODER(SnapshotInfo); | |
7c673cae | 720 | |
11fdf7f2 TL |
721 | enum GroupSnapshotState { |
722 | GROUP_SNAPSHOT_STATE_INCOMPLETE = 0, | |
723 | GROUP_SNAPSHOT_STATE_COMPLETE = 1, | |
7c673cae | 724 | }; |
7c673cae | 725 | |
f67539c2 | 726 | inline void encode(const GroupSnapshotState &state, ceph::buffer::list& bl, uint64_t features=0) |
11fdf7f2 TL |
727 | { |
728 | using ceph::encode; | |
729 | encode(static_cast<uint8_t>(state), bl); | |
730 | } | |
731 | ||
f67539c2 | 732 | inline void decode(GroupSnapshotState &state, ceph::buffer::list::const_iterator& it) |
11fdf7f2 TL |
733 | { |
734 | using ceph::decode; | |
735 | uint8_t int_state; | |
736 | decode(int_state, it); | |
737 | state = static_cast<GroupSnapshotState>(int_state); | |
738 | } | |
739 | ||
740 | struct ImageSnapshotSpec { | |
741 | int64_t pool; | |
f67539c2 | 742 | std::string image_id; |
11fdf7f2 TL |
743 | snapid_t snap_id; |
744 | ||
745 | ImageSnapshotSpec() {} | |
746 | ImageSnapshotSpec(int64_t _pool, | |
f67539c2 | 747 | std::string _image_id, |
11fdf7f2 TL |
748 | snapid_t _snap_id) : pool(_pool), |
749 | image_id(_image_id), | |
750 | snap_id(_snap_id) {} | |
751 | ||
f67539c2 TL |
752 | void encode(ceph::buffer::list& bl) const; |
753 | void decode(ceph::buffer::list::const_iterator& it); | |
11fdf7f2 | 754 | |
f67539c2 | 755 | void dump(ceph::Formatter *f) const; |
11fdf7f2 TL |
756 | |
757 | static void generate_test_instances(std::list<ImageSnapshotSpec *> &o); | |
758 | }; | |
759 | WRITE_CLASS_ENCODER(ImageSnapshotSpec); | |
760 | ||
761 | struct GroupSnapshot { | |
762 | std::string id; | |
763 | std::string name; | |
764 | GroupSnapshotState state = GROUP_SNAPSHOT_STATE_INCOMPLETE; | |
765 | ||
766 | GroupSnapshot() {} | |
767 | GroupSnapshot(std::string _id, | |
768 | std::string _name, | |
769 | GroupSnapshotState _state) : id(_id), | |
770 | name(_name), | |
771 | state(_state) {} | |
772 | ||
f67539c2 | 773 | std::vector<ImageSnapshotSpec> snaps; |
11fdf7f2 | 774 | |
f67539c2 TL |
775 | void encode(ceph::buffer::list& bl) const; |
776 | void decode(ceph::buffer::list::const_iterator& it); | |
777 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
778 | |
779 | static void generate_test_instances(std::list<GroupSnapshot *> &o); | |
780 | }; | |
781 | WRITE_CLASS_ENCODER(GroupSnapshot); | |
7c673cae FG |
782 | enum TrashImageSource { |
783 | TRASH_IMAGE_SOURCE_USER = 0, | |
11fdf7f2 TL |
784 | TRASH_IMAGE_SOURCE_MIRRORING = 1, |
785 | TRASH_IMAGE_SOURCE_MIGRATION = 2, | |
786 | TRASH_IMAGE_SOURCE_REMOVING = 3, | |
9f95a23c | 787 | TRASH_IMAGE_SOURCE_USER_PARENT= 4, |
7c673cae FG |
788 | }; |
789 | ||
11fdf7f2 TL |
790 | inline std::ostream& operator<<(std::ostream& os, |
791 | const TrashImageSource& source) { | |
792 | switch (source) { | |
793 | case TRASH_IMAGE_SOURCE_USER: | |
794 | os << "user"; | |
795 | break; | |
796 | case TRASH_IMAGE_SOURCE_MIRRORING: | |
797 | os << "mirroring"; | |
798 | break; | |
799 | case TRASH_IMAGE_SOURCE_MIGRATION: | |
800 | os << "migration"; | |
801 | break; | |
802 | case TRASH_IMAGE_SOURCE_REMOVING: | |
803 | os << "removing"; | |
804 | break; | |
805 | default: | |
806 | os << "unknown (" << static_cast<uint32_t>(source) << ")"; | |
807 | break; | |
808 | } | |
809 | return os; | |
810 | } | |
811 | ||
f67539c2 | 812 | inline void encode(const TrashImageSource &source, ceph::buffer::list& bl, |
7c673cae FG |
813 | uint64_t features=0) |
814 | { | |
11fdf7f2 TL |
815 | using ceph::encode; |
816 | encode(static_cast<uint8_t>(source), bl); | |
7c673cae FG |
817 | } |
818 | ||
f67539c2 | 819 | inline void decode(TrashImageSource &source, ceph::buffer::list::const_iterator& it) |
7c673cae FG |
820 | { |
821 | uint8_t int_source; | |
11fdf7f2 TL |
822 | using ceph::decode; |
823 | decode(int_source, it); | |
7c673cae FG |
824 | source = static_cast<TrashImageSource>(int_source); |
825 | } | |
826 | ||
11fdf7f2 TL |
827 | enum TrashImageState { |
828 | TRASH_IMAGE_STATE_NORMAL = 0, | |
829 | TRASH_IMAGE_STATE_MOVING = 1, | |
830 | TRASH_IMAGE_STATE_REMOVING = 2, | |
831 | TRASH_IMAGE_STATE_RESTORING = 3 | |
832 | }; | |
833 | ||
f67539c2 | 834 | inline void encode(const TrashImageState &state, ceph::buffer::list &bl) |
11fdf7f2 TL |
835 | { |
836 | using ceph::encode; | |
837 | encode(static_cast<uint8_t>(state), bl); | |
838 | } | |
839 | ||
f67539c2 | 840 | inline void decode(TrashImageState &state, ceph::buffer::list::const_iterator &it) |
11fdf7f2 TL |
841 | { |
842 | uint8_t int_state; | |
843 | using ceph::decode; | |
844 | decode(int_state, it); | |
845 | state = static_cast<TrashImageState>(int_state); | |
846 | } | |
847 | ||
7c673cae FG |
848 | struct TrashImageSpec { |
849 | TrashImageSource source = TRASH_IMAGE_SOURCE_USER; | |
850 | std::string name; | |
851 | utime_t deletion_time; // time of deletion | |
852 | utime_t deferment_end_time; | |
11fdf7f2 | 853 | TrashImageState state = TRASH_IMAGE_STATE_NORMAL; |
7c673cae FG |
854 | |
855 | TrashImageSpec() {} | |
856 | TrashImageSpec(TrashImageSource source, const std::string &name, | |
11fdf7f2 TL |
857 | const utime_t& deletion_time, |
858 | const utime_t& deferment_end_time) | |
859 | : source(source), name(name), deletion_time(deletion_time), | |
860 | deferment_end_time(deferment_end_time) { | |
861 | } | |
7c673cae | 862 | |
f67539c2 TL |
863 | void encode(ceph::buffer::list &bl) const; |
864 | void decode(ceph::buffer::list::const_iterator& it); | |
865 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
866 | |
867 | inline bool operator==(const TrashImageSpec& rhs) const { | |
868 | return (source == rhs.source && | |
869 | name == rhs.name && | |
870 | deletion_time == rhs.deletion_time && | |
871 | deferment_end_time == rhs.deferment_end_time); | |
872 | } | |
7c673cae FG |
873 | }; |
874 | WRITE_CLASS_ENCODER(TrashImageSpec); | |
875 | ||
11fdf7f2 TL |
876 | struct MirrorImageMap { |
877 | MirrorImageMap() { | |
878 | } | |
879 | ||
880 | MirrorImageMap(const std::string &instance_id, utime_t mapped_time, | |
f67539c2 | 881 | const ceph::buffer::list &data) |
11fdf7f2 TL |
882 | : instance_id(instance_id), |
883 | mapped_time(mapped_time), | |
884 | data(data) { | |
885 | } | |
886 | ||
887 | std::string instance_id; | |
888 | utime_t mapped_time; | |
f67539c2 | 889 | ceph::buffer::list data; |
11fdf7f2 | 890 | |
f67539c2 TL |
891 | void encode(ceph::buffer::list &bl) const; |
892 | void decode(ceph::buffer::list::const_iterator &it); | |
893 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
894 | |
895 | static void generate_test_instances(std::list<MirrorImageMap*> &o); | |
896 | ||
897 | bool operator==(const MirrorImageMap &rhs) const; | |
898 | bool operator<(const MirrorImageMap &rhs) const; | |
899 | }; | |
900 | ||
901 | std::ostream& operator<<(std::ostream& os, const MirrorImageMap &image_map); | |
902 | ||
903 | WRITE_CLASS_ENCODER(MirrorImageMap); | |
904 | ||
905 | enum MigrationHeaderType { | |
906 | MIGRATION_HEADER_TYPE_SRC = 1, | |
907 | MIGRATION_HEADER_TYPE_DST = 2, | |
908 | }; | |
909 | ||
f67539c2 | 910 | inline void encode(const MigrationHeaderType &type, ceph::buffer::list& bl) { |
11fdf7f2 TL |
911 | using ceph::encode; |
912 | encode(static_cast<uint8_t>(type), bl); | |
913 | } | |
914 | ||
f67539c2 | 915 | inline void decode(MigrationHeaderType &type, ceph::buffer::list::const_iterator& it) { |
11fdf7f2 TL |
916 | uint8_t int_type; |
917 | using ceph::decode; | |
918 | decode(int_type, it); | |
919 | type = static_cast<MigrationHeaderType>(int_type); | |
920 | } | |
921 | ||
922 | enum MigrationState { | |
923 | MIGRATION_STATE_ERROR = 0, | |
924 | MIGRATION_STATE_PREPARING = 1, | |
925 | MIGRATION_STATE_PREPARED = 2, | |
926 | MIGRATION_STATE_EXECUTING = 3, | |
927 | MIGRATION_STATE_EXECUTED = 4, | |
f91f0fd5 | 928 | MIGRATION_STATE_ABORTING = 5, |
11fdf7f2 TL |
929 | }; |
930 | ||
f67539c2 | 931 | inline void encode(const MigrationState &state, ceph::buffer::list& bl) { |
11fdf7f2 TL |
932 | using ceph::encode; |
933 | encode(static_cast<uint8_t>(state), bl); | |
934 | } | |
935 | ||
f67539c2 | 936 | inline void decode(MigrationState &state, ceph::buffer::list::const_iterator& it) { |
11fdf7f2 TL |
937 | uint8_t int_state; |
938 | using ceph::decode; | |
939 | decode(int_state, it); | |
940 | state = static_cast<MigrationState>(int_state); | |
941 | } | |
942 | ||
943 | std::ostream& operator<<(std::ostream& os, | |
944 | const MigrationState& migration_state); | |
945 | ||
946 | struct MigrationSpec { | |
947 | MigrationHeaderType header_type = MIGRATION_HEADER_TYPE_SRC; | |
948 | int64_t pool_id = -1; | |
949 | std::string pool_namespace; | |
950 | std::string image_name; | |
951 | std::string image_id; | |
f67539c2 | 952 | std::string source_spec; |
11fdf7f2 TL |
953 | std::map<uint64_t, uint64_t> snap_seqs; |
954 | uint64_t overlap = 0; | |
955 | bool flatten = false; | |
956 | bool mirroring = false; | |
9f95a23c | 957 | MirrorImageMode mirror_image_mode = MIRROR_IMAGE_MODE_JOURNAL; |
11fdf7f2 TL |
958 | MigrationState state = MIGRATION_STATE_ERROR; |
959 | std::string state_description; | |
960 | ||
961 | MigrationSpec() { | |
962 | } | |
963 | MigrationSpec(MigrationHeaderType header_type, int64_t pool_id, | |
964 | const std::string& pool_namespace, | |
f67539c2 TL |
965 | const std::string& image_name, const std::string &image_id, |
966 | const std::string& source_spec, | |
11fdf7f2 | 967 | const std::map<uint64_t, uint64_t> &snap_seqs, uint64_t overlap, |
9f95a23c TL |
968 | bool mirroring, MirrorImageMode mirror_image_mode, bool flatten, |
969 | MigrationState state, const std::string &state_description) | |
11fdf7f2 TL |
970 | : header_type(header_type), pool_id(pool_id), |
971 | pool_namespace(pool_namespace), image_name(image_name), | |
f67539c2 TL |
972 | image_id(image_id), source_spec(source_spec), snap_seqs(snap_seqs), |
973 | overlap(overlap), flatten(flatten), mirroring(mirroring), | |
9f95a23c | 974 | mirror_image_mode(mirror_image_mode), state(state), |
11fdf7f2 TL |
975 | state_description(state_description) { |
976 | } | |
977 | ||
f67539c2 TL |
978 | void encode(ceph::buffer::list &bl) const; |
979 | void decode(ceph::buffer::list::const_iterator& it); | |
980 | void dump(ceph::Formatter *f) const; | |
11fdf7f2 TL |
981 | |
982 | static void generate_test_instances(std::list<MigrationSpec*> &o); | |
983 | ||
984 | inline bool operator==(const MigrationSpec& ms) const { | |
985 | return header_type == ms.header_type && pool_id == ms.pool_id && | |
986 | pool_namespace == ms.pool_namespace && image_name == ms.image_name && | |
f67539c2 TL |
987 | image_id == ms.image_id && source_spec == ms.source_spec && |
988 | snap_seqs == ms.snap_seqs && overlap == ms.overlap && | |
989 | flatten == ms.flatten && mirroring == ms.mirroring && | |
990 | mirror_image_mode == ms.mirror_image_mode && state == ms.state && | |
991 | state_description == ms.state_description; | |
11fdf7f2 TL |
992 | } |
993 | }; | |
994 | ||
995 | std::ostream& operator<<(std::ostream& os, const MigrationSpec& migration_spec); | |
996 | ||
997 | WRITE_CLASS_ENCODER(MigrationSpec); | |
998 | ||
999 | enum AssertSnapcSeqState { | |
1000 | ASSERT_SNAPC_SEQ_GT_SNAPSET_SEQ = 0, | |
1001 | ASSERT_SNAPC_SEQ_LE_SNAPSET_SEQ = 1, | |
1002 | }; | |
1003 | ||
f67539c2 | 1004 | inline void encode(const AssertSnapcSeqState &state, ceph::buffer::list& bl) { |
11fdf7f2 TL |
1005 | using ceph::encode; |
1006 | encode(static_cast<uint8_t>(state), bl); | |
1007 | } | |
1008 | ||
f67539c2 | 1009 | inline void decode(AssertSnapcSeqState &state, ceph::buffer::list::const_iterator& it) { |
11fdf7f2 TL |
1010 | uint8_t int_state; |
1011 | using ceph::decode; | |
1012 | decode(int_state, it); | |
1013 | state = static_cast<AssertSnapcSeqState>(int_state); | |
1014 | } | |
1015 | ||
1016 | std::ostream& operator<<(std::ostream& os, const AssertSnapcSeqState& state); | |
1017 | ||
9f95a23c TL |
1018 | void sanitize_entity_inst(entity_inst_t* entity_inst); |
1019 | ||
7c673cae FG |
1020 | } // namespace rbd |
1021 | } // namespace cls | |
1022 | ||
7c673cae | 1023 | #endif // CEPH_CLS_RBD_TYPES_H |