]>
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 LIBRBD_TYPES_H | |
5 | #define LIBRBD_TYPES_H | |
6 | ||
7 | #include "include/types.h" | |
8 | #include "cls/rbd/cls_rbd_types.h" | |
9 | #include <string> | |
10 | ||
11 | namespace librbd { | |
12 | ||
13 | /** @brief Unique identification of a parent in clone relationship. | |
14 | * Cloning an image creates a child image that keeps a reference | |
15 | * to its parent. This allows copy-on-write images. */ | |
16 | struct ParentSpec { | |
17 | int64_t pool_id; | |
18 | std::string image_id; | |
19 | snapid_t snap_id; | |
20 | ||
21 | ParentSpec() : pool_id(-1), snap_id(CEPH_NOSNAP) { | |
22 | } | |
23 | ParentSpec(int64_t pool_id, std::string image_id, snapid_t snap_id) | |
24 | : pool_id(pool_id), image_id(image_id), snap_id(snap_id) { | |
25 | } | |
26 | ||
27 | bool operator==(const ParentSpec &other) { | |
28 | return ((this->pool_id == other.pool_id) && | |
29 | (this->image_id == other.image_id) && | |
30 | (this->snap_id == other.snap_id)); | |
31 | } | |
32 | bool operator!=(const ParentSpec &other) { | |
33 | return !(*this == other); | |
34 | } | |
35 | }; | |
36 | ||
37 | /// Full information about an image's parent. | |
38 | struct ParentInfo { | |
39 | /// Identification of the parent. | |
40 | ParentSpec spec; | |
41 | ||
42 | /** @brief Where the portion of data shared with the child image ends. | |
43 | * Since images can be resized multiple times, the portion of data shared | |
44 | * with the child image is not necessarily min(parent size, child size). | |
45 | * If the child image is first shrunk and then enlarged, the common portion | |
46 | * will be shorter. */ | |
47 | uint64_t overlap; | |
48 | ||
49 | ParentInfo() : overlap(0) { | |
50 | } | |
51 | }; | |
52 | ||
53 | struct SnapInfo { | |
54 | std::string name; | |
55 | cls::rbd::SnapshotNamespace snap_namespace; | |
56 | uint64_t size; | |
57 | ParentInfo parent; | |
58 | uint8_t protection_status; | |
59 | uint64_t flags; | |
60 | utime_t timestamp; | |
61 | SnapInfo(std::string _name, | |
62 | const cls::rbd::SnapshotNamespace &_snap_namespace, | |
63 | uint64_t _size, const ParentInfo &_parent, | |
64 | uint8_t _protection_status, uint64_t _flags, utime_t _timestamp) | |
65 | : name(_name), snap_namespace(_snap_namespace), size(_size), | |
66 | parent(_parent), protection_status(_protection_status), flags(_flags), | |
67 | timestamp(_timestamp) { | |
68 | } | |
69 | }; | |
70 | ||
71 | } // namespace librbd | |
72 | ||
73 | #endif // LIBRBD_TYPES_H |