]>
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" | |
11fdf7f2 TL |
9 | #include "deep_copy/Types.h" |
10 | #include <map> | |
7c673cae FG |
11 | #include <string> |
12 | ||
13 | namespace librbd { | |
14 | ||
b32b8144 FG |
15 | // Performance counters |
16 | enum { | |
17 | l_librbd_first = 26000, | |
18 | ||
19 | l_librbd_rd, // read ops | |
20 | l_librbd_rd_bytes, // bytes read | |
21 | l_librbd_rd_latency, // average latency | |
22 | l_librbd_wr, | |
23 | l_librbd_wr_bytes, | |
24 | l_librbd_wr_latency, | |
25 | l_librbd_discard, | |
26 | l_librbd_discard_bytes, | |
27 | l_librbd_discard_latency, | |
28 | l_librbd_flush, | |
11fdf7f2 | 29 | l_librbd_flush_latency, |
b32b8144 | 30 | |
b32b8144 FG |
31 | l_librbd_ws, |
32 | l_librbd_ws_bytes, | |
33 | l_librbd_ws_latency, | |
34 | ||
35 | l_librbd_cmp, | |
36 | l_librbd_cmp_bytes, | |
37 | l_librbd_cmp_latency, | |
38 | ||
39 | l_librbd_snap_create, | |
40 | l_librbd_snap_remove, | |
41 | l_librbd_snap_rollback, | |
42 | l_librbd_snap_rename, | |
43 | ||
44 | l_librbd_notify, | |
45 | l_librbd_resize, | |
46 | ||
47 | l_librbd_readahead, | |
48 | l_librbd_readahead_bytes, | |
49 | ||
50 | l_librbd_invalidate_cache, | |
51 | ||
52 | l_librbd_opened_time, | |
53 | l_librbd_lock_acquired_time, | |
54 | ||
55 | l_librbd_last, | |
56 | }; | |
57 | ||
11fdf7f2 | 58 | typedef std::map<uint64_t, uint64_t> SnapSeqs; |
7c673cae FG |
59 | |
60 | /// Full information about an image's parent. | |
11fdf7f2 | 61 | struct ParentImageInfo { |
7c673cae | 62 | /// Identification of the parent. |
11fdf7f2 | 63 | cls::rbd::ParentImageSpec spec; |
7c673cae FG |
64 | |
65 | /** @brief Where the portion of data shared with the child image ends. | |
66 | * Since images can be resized multiple times, the portion of data shared | |
67 | * with the child image is not necessarily min(parent size, child size). | |
68 | * If the child image is first shrunk and then enlarged, the common portion | |
69 | * will be shorter. */ | |
11fdf7f2 | 70 | uint64_t overlap = 0; |
7c673cae FG |
71 | }; |
72 | ||
73 | struct SnapInfo { | |
74 | std::string name; | |
75 | cls::rbd::SnapshotNamespace snap_namespace; | |
76 | uint64_t size; | |
11fdf7f2 | 77 | ParentImageInfo parent; |
7c673cae FG |
78 | uint8_t protection_status; |
79 | uint64_t flags; | |
80 | utime_t timestamp; | |
81 | SnapInfo(std::string _name, | |
82 | const cls::rbd::SnapshotNamespace &_snap_namespace, | |
11fdf7f2 | 83 | uint64_t _size, const ParentImageInfo &_parent, |
7c673cae FG |
84 | uint8_t _protection_status, uint64_t _flags, utime_t _timestamp) |
85 | : name(_name), snap_namespace(_snap_namespace), size(_size), | |
86 | parent(_parent), protection_status(_protection_status), flags(_flags), | |
87 | timestamp(_timestamp) { | |
88 | } | |
89 | }; | |
90 | ||
11fdf7f2 TL |
91 | enum { |
92 | OPEN_FLAG_SKIP_OPEN_PARENT = 1 << 0, | |
93 | OPEN_FLAG_OLD_FORMAT = 1 << 1, | |
94 | OPEN_FLAG_IGNORE_MIGRATING = 1 << 2 | |
95 | }; | |
96 | ||
9f95a23c TL |
97 | enum ImageReadOnlyFlag { |
98 | IMAGE_READ_ONLY_FLAG_USER = 1 << 0, | |
99 | IMAGE_READ_ONLY_FLAG_NON_PRIMARY = 1 << 1, | |
100 | }; | |
101 | ||
11fdf7f2 TL |
102 | struct MigrationInfo { |
103 | int64_t pool_id = -1; | |
104 | std::string pool_namespace; | |
105 | std::string image_name; | |
106 | std::string image_id; | |
107 | deep_copy::SnapMap snap_map; | |
108 | uint64_t overlap = 0; | |
109 | bool flatten = false; | |
110 | ||
111 | MigrationInfo() { | |
112 | } | |
113 | MigrationInfo(int64_t pool_id, const std::string& pool_namespace, | |
114 | const std::string& image_name, const std::string& image_id, | |
115 | const deep_copy::SnapMap &snap_map, uint64_t overlap, | |
116 | bool flatten) | |
117 | : pool_id(pool_id), pool_namespace(pool_namespace), image_name(image_name), | |
118 | image_id(image_id), snap_map(snap_map), overlap(overlap), | |
119 | flatten(flatten) { | |
120 | } | |
121 | ||
122 | bool empty() const { | |
123 | return pool_id == -1; | |
124 | } | |
125 | }; | |
126 | ||
7c673cae FG |
127 | } // namespace librbd |
128 | ||
129 | #endif // LIBRBD_TYPES_H |