]>
Commit | Line | Data |
---|---|---|
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 | // Performance counters | |
14 | enum { | |
15 | l_librbd_first = 26000, | |
16 | ||
17 | l_librbd_rd, // read ops | |
18 | l_librbd_rd_bytes, // bytes read | |
19 | l_librbd_rd_latency, // average latency | |
20 | l_librbd_wr, | |
21 | l_librbd_wr_bytes, | |
22 | l_librbd_wr_latency, | |
23 | l_librbd_discard, | |
24 | l_librbd_discard_bytes, | |
25 | l_librbd_discard_latency, | |
26 | l_librbd_flush, | |
27 | ||
28 | l_librbd_aio_flush, | |
29 | l_librbd_aio_flush_latency, | |
30 | l_librbd_ws, | |
31 | l_librbd_ws_bytes, | |
32 | l_librbd_ws_latency, | |
33 | ||
34 | l_librbd_cmp, | |
35 | l_librbd_cmp_bytes, | |
36 | l_librbd_cmp_latency, | |
37 | ||
38 | l_librbd_snap_create, | |
39 | l_librbd_snap_remove, | |
40 | l_librbd_snap_rollback, | |
41 | l_librbd_snap_rename, | |
42 | ||
43 | l_librbd_notify, | |
44 | l_librbd_resize, | |
45 | ||
46 | l_librbd_readahead, | |
47 | l_librbd_readahead_bytes, | |
48 | ||
49 | l_librbd_invalidate_cache, | |
50 | ||
51 | l_librbd_opened_time, | |
52 | l_librbd_lock_acquired_time, | |
53 | ||
54 | l_librbd_last, | |
55 | }; | |
56 | ||
57 | /** @brief Unique identification of a parent in clone relationship. | |
58 | * Cloning an image creates a child image that keeps a reference | |
59 | * to its parent. This allows copy-on-write images. */ | |
60 | struct ParentSpec { | |
61 | int64_t pool_id; | |
62 | std::string image_id; | |
63 | snapid_t snap_id; | |
64 | ||
65 | ParentSpec() : pool_id(-1), snap_id(CEPH_NOSNAP) { | |
66 | } | |
67 | ParentSpec(int64_t pool_id, std::string image_id, snapid_t snap_id) | |
68 | : pool_id(pool_id), image_id(image_id), snap_id(snap_id) { | |
69 | } | |
70 | ||
71 | bool operator==(const ParentSpec &other) { | |
72 | return ((this->pool_id == other.pool_id) && | |
73 | (this->image_id == other.image_id) && | |
74 | (this->snap_id == other.snap_id)); | |
75 | } | |
76 | bool operator!=(const ParentSpec &other) { | |
77 | return !(*this == other); | |
78 | } | |
79 | }; | |
80 | ||
81 | /// Full information about an image's parent. | |
82 | struct ParentInfo { | |
83 | /// Identification of the parent. | |
84 | ParentSpec spec; | |
85 | ||
86 | /** @brief Where the portion of data shared with the child image ends. | |
87 | * Since images can be resized multiple times, the portion of data shared | |
88 | * with the child image is not necessarily min(parent size, child size). | |
89 | * If the child image is first shrunk and then enlarged, the common portion | |
90 | * will be shorter. */ | |
91 | uint64_t overlap; | |
92 | ||
93 | ParentInfo() : overlap(0) { | |
94 | } | |
95 | }; | |
96 | ||
97 | struct SnapInfo { | |
98 | std::string name; | |
99 | cls::rbd::SnapshotNamespace snap_namespace; | |
100 | uint64_t size; | |
101 | ParentInfo parent; | |
102 | uint8_t protection_status; | |
103 | uint64_t flags; | |
104 | utime_t timestamp; | |
105 | SnapInfo(std::string _name, | |
106 | const cls::rbd::SnapshotNamespace &_snap_namespace, | |
107 | uint64_t _size, const ParentInfo &_parent, | |
108 | uint8_t _protection_status, uint64_t _flags, utime_t _timestamp) | |
109 | : name(_name), snap_namespace(_snap_namespace), size(_size), | |
110 | parent(_parent), protection_status(_protection_status), flags(_flags), | |
111 | timestamp(_timestamp) { | |
112 | } | |
113 | }; | |
114 | ||
115 | } // namespace librbd | |
116 | ||
117 | #endif // LIBRBD_TYPES_H |