]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/rados/rados_types.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / include / rados / rados_types.hpp
CommitLineData
7c673cae
FG
1#ifndef CEPH_RADOS_TYPES_HPP
2#define CEPH_RADOS_TYPES_HPP
3
4#include <map>
5#include <utility>
6#include <vector>
7#include <stdint.h>
8#include <string>
9
10#include "buffer.h"
11#include "rados_types.h"
12
13namespace librados {
14
15typedef uint64_t snap_t;
16
17enum {
18 SNAP_HEAD = (uint64_t)(-2),
19 SNAP_DIR = (uint64_t)(-1)
20};
21
22struct clone_info_t {
23 snap_t cloneid;
24 std::vector<snap_t> snaps; // ascending
25 std::vector< std::pair<uint64_t,uint64_t> > overlap; // with next newest
26 uint64_t size;
27 clone_info_t() : cloneid(0), size(0) {}
28};
29
30struct snap_set_t {
31 std::vector<clone_info_t> clones; // ascending
32 snap_t seq; // newest snapid seen by the object
33 snap_set_t() : seq(0) {}
34};
35
36struct object_id_t {
37 std::string name;
38 std::string nspace;
39 std::string locator;
40 snap_t snap = 0;
41 object_id_t() = default;
42 object_id_t(const std::string& name,
43 const std::string& nspace,
44 const std::string& locator,
45 snap_t snap)
46 : name(name),
47 nspace(nspace),
48 locator(locator),
49 snap(snap)
50 {}
51};
52
53struct err_t {
54 enum : uint64_t {
55 SHARD_MISSING = 1 << 1,
56 SHARD_STAT_ERR = 1 << 2,
57 SHARD_READ_ERR = 1 << 3,
94b18763
FG
58 DATA_DIGEST_MISMATCH_OI = 1 << 9, // Old
59 DATA_DIGEST_MISMATCH_INFO = 1 << 9,
60 OMAP_DIGEST_MISMATCH_OI = 1 << 10, // Old
61 OMAP_DIGEST_MISMATCH_INFO = 1 << 10,
62 SIZE_MISMATCH_OI = 1 << 11, // Old
63 SIZE_MISMATCH_INFO = 1 << 11,
7c673cae
FG
64 SHARD_EC_HASH_MISMATCH = 1 << 12,
65 SHARD_EC_SIZE_MISMATCH = 1 << 13,
94b18763
FG
66 OI_ATTR_MISSING = 1 << 14, // Old
67 INFO_MISSING = 1 << 14,
68 OI_ATTR_CORRUPTED = 1 << 15, // Old
69 INFO_CORRUPTED = 1 << 15,
70 SS_ATTR_MISSING = 1 << 16, // Old
71 SNAPSET_MISSING = 1 << 16,
72 SS_ATTR_CORRUPTED = 1 << 17, // Old
73 SNAPSET_CORRUPTED = 1 << 17,
74 OBJ_SIZE_OI_MISMATCH = 1 << 18, // Old
75 OBJ_SIZE_INFO_MISMATCH = 1 << 18,
76 HINFO_MISSING = 1 << 19,
77 HINFO_CORRUPTED = 1 << 20
7c673cae
FG
78 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
79 };
80 uint64_t errors = 0;
94b18763
FG
81 static constexpr uint64_t SHALLOW_ERRORS = SHARD_MISSING|SHARD_STAT_ERR|SIZE_MISMATCH_INFO|INFO_MISSING|INFO_CORRUPTED|SNAPSET_MISSING|SNAPSET_CORRUPTED|OBJ_SIZE_INFO_MISMATCH|HINFO_MISSING|HINFO_CORRUPTED;
82 static constexpr uint64_t DEEP_ERRORS = SHARD_READ_ERR|DATA_DIGEST_MISMATCH_INFO|OMAP_DIGEST_MISMATCH_INFO|SHARD_EC_HASH_MISMATCH|SHARD_EC_SIZE_MISMATCH;
7c673cae
FG
83 bool has_shard_missing() const {
84 return errors & SHARD_MISSING;
85 }
86 bool has_stat_error() const {
87 return errors & SHARD_STAT_ERR;
88 }
89 bool has_read_error() const {
90 return errors & SHARD_READ_ERR;
91 }
94b18763 92 bool has_data_digest_mismatch_oi() const { // Compatibility
7c673cae
FG
93 return errors & DATA_DIGEST_MISMATCH_OI;
94 }
94b18763
FG
95 bool has_data_digest_mismatch_info() const {
96 return errors & DATA_DIGEST_MISMATCH_INFO;
97 }
98 bool has_omap_digest_mismatch_oi() const { // Compatibility
7c673cae
FG
99 return errors & OMAP_DIGEST_MISMATCH_OI;
100 }
94b18763
FG
101 bool has_omap_digest_mismatch_info() const {
102 return errors & OMAP_DIGEST_MISMATCH_INFO;
103 }
104 bool has_size_mismatch_oi() const { // Compatibility
7c673cae
FG
105 return errors & SIZE_MISMATCH_OI;
106 }
94b18763
FG
107 bool has_size_mismatch_info() const {
108 return errors & SIZE_MISMATCH_INFO;
109 }
7c673cae
FG
110 bool has_ec_hash_error() const {
111 return errors & SHARD_EC_HASH_MISMATCH;
112 }
113 bool has_ec_size_error() const {
114 return errors & SHARD_EC_SIZE_MISMATCH;
115 }
94b18763 116 bool has_oi_attr_missing() const { // Compatibility
7c673cae
FG
117 return errors & OI_ATTR_MISSING;
118 }
94b18763
FG
119 bool has_info_missing() const {
120 return errors & INFO_MISSING;
121 }
122 bool has_oi_attr_corrupted() const { // Compatibility
7c673cae
FG
123 return errors & OI_ATTR_CORRUPTED;
124 }
94b18763
FG
125 bool has_info_corrupted() const {
126 return errors & INFO_CORRUPTED;
127 }
128 bool has_ss_attr_missing() const { // Compatibility
7c673cae
FG
129 return errors & SS_ATTR_MISSING;
130 }
94b18763
FG
131 bool has_snapset_missing() const {
132 return errors & SNAPSET_MISSING;
133 }
134 bool has_ss_attr_corrupted() const { // Compatibility
7c673cae
FG
135 return errors & SS_ATTR_CORRUPTED;
136 }
94b18763
FG
137 bool has_snapset_corrupted() const {
138 return errors & SNAPSET_CORRUPTED;
139 }
7c673cae
FG
140 bool has_shallow_errors() const {
141 return errors & SHALLOW_ERRORS;
142 }
143 bool has_deep_errors() const {
144 return errors & DEEP_ERRORS;
145 }
94b18763 146 bool has_obj_size_oi_mismatch() const { // Compatibility
b5b8bbf5 147 return errors & OBJ_SIZE_OI_MISMATCH;
94b18763
FG
148 }
149 bool has_obj_size_info_mismatch() const {
150 return errors & OBJ_SIZE_INFO_MISMATCH;
151 }
152 bool has_hinfo_missing() const {
153 return errors & HINFO_MISSING;
154 }
155 bool has_hinfo_corrupted() const {
156 return errors & HINFO_CORRUPTED;
b5b8bbf5 157 }
7c673cae
FG
158};
159
160struct shard_info_t : err_t {
161 std::map<std::string, ceph::bufferlist> attrs;
162 uint64_t size = -1;
163 bool omap_digest_present = false;
164 uint32_t omap_digest = 0;
165 bool data_digest_present = false;
166 uint32_t data_digest = 0;
167 bool selected_oi = false;
b5b8bbf5 168 bool primary = false;
7c673cae
FG
169};
170
171struct osd_shard_t {
172 int32_t osd;
173 int8_t shard;
174};
175
176inline bool operator<(const osd_shard_t &lhs, const osd_shard_t &rhs) {
177 if (lhs.osd < rhs.osd)
178 return true;
179 else if (lhs.osd > rhs.osd)
180 return false;
181 else
182 return lhs.shard < rhs.shard;
183}
184
185struct obj_err_t {
186 enum : uint64_t {
187 OBJECT_INFO_INCONSISTENCY = 1 << 1,
188 // XXX: Can an older rados binary work if these bits stay the same?
189 DATA_DIGEST_MISMATCH = 1 << 4,
190 OMAP_DIGEST_MISMATCH = 1 << 5,
191 SIZE_MISMATCH = 1 << 6,
192 ATTR_VALUE_MISMATCH = 1 << 7,
193 ATTR_NAME_MISMATCH = 1 << 8,
3a9019d9 194 SNAPSET_INCONSISTENCY = 1 << 9,
94b18763 195 HINFO_INCONSISTENCY = 1 << 10,
eafe8130 196 SIZE_TOO_LARGE = 1 << 11,
7c673cae
FG
197 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
198 };
199 uint64_t errors = 0;
eafe8130
TL
200 static constexpr uint64_t SHALLOW_ERRORS = OBJECT_INFO_INCONSISTENCY|SIZE_MISMATCH|ATTR_VALUE_MISMATCH
201 |ATTR_NAME_MISMATCH|SNAPSET_INCONSISTENCY|HINFO_INCONSISTENCY|SIZE_TOO_LARGE;
7c673cae
FG
202 static constexpr uint64_t DEEP_ERRORS = DATA_DIGEST_MISMATCH|OMAP_DIGEST_MISMATCH;
203 bool has_object_info_inconsistency() const {
204 return errors & OBJECT_INFO_INCONSISTENCY;
205 }
206 bool has_data_digest_mismatch() const {
207 return errors & DATA_DIGEST_MISMATCH;
208 }
209 bool has_omap_digest_mismatch() const {
210 return errors & OMAP_DIGEST_MISMATCH;
211 }
212 bool has_size_mismatch() const {
213 return errors & SIZE_MISMATCH;
214 }
215 bool has_attr_value_mismatch() const {
216 return errors & ATTR_VALUE_MISMATCH;
217 }
218 bool has_attr_name_mismatch() const {
219 return errors & ATTR_NAME_MISMATCH;
220 }
221 bool has_shallow_errors() const {
222 return errors & SHALLOW_ERRORS;
223 }
224 bool has_deep_errors() const {
225 return errors & DEEP_ERRORS;
226 }
3a9019d9
FG
227 bool has_snapset_inconsistency() const {
228 return errors & SNAPSET_INCONSISTENCY;
229 }
94b18763
FG
230 bool has_hinfo_inconsistency() const {
231 return errors & HINFO_INCONSISTENCY;
232 }
eafe8130
TL
233 bool has_size_too_large() const {
234 return errors & SIZE_TOO_LARGE;
235 }
7c673cae
FG
236};
237
238struct inconsistent_obj_t : obj_err_t {
239 inconsistent_obj_t() = default;
240 inconsistent_obj_t(const object_id_t& object)
241 : object{object}, version(0)
242 {}
243 object_id_t object;
244 uint64_t version; // XXX: Redundant with object info attr
245 std::map<osd_shard_t, shard_info_t> shards;
246 err_t union_shards;
247};
248
249struct inconsistent_snapset_t {
250 inconsistent_snapset_t() = default;
251 inconsistent_snapset_t(const object_id_t& head)
252 : object{head}
253 {}
254 enum {
255 SNAPSET_MISSING = 1 << 0,
256 SNAPSET_CORRUPTED = 1 << 1,
257 CLONE_MISSING = 1 << 2,
94b18763 258 SNAP_ERROR = 1 << 3,
11fdf7f2 259 HEAD_MISMATCH = 1 << 4, // Unused
7c673cae
FG
260 HEADLESS_CLONE = 1 << 5,
261 SIZE_MISMATCH = 1 << 6,
94b18763
FG
262 OI_MISSING = 1 << 7, // Old
263 INFO_MISSING = 1 << 7,
264 OI_CORRUPTED = 1 << 8, // Old
265 INFO_CORRUPTED = 1 << 8,
7c673cae
FG
266 EXTRA_CLONES = 1 << 9,
267 };
268 uint64_t errors = 0;
269 object_id_t object;
270 // Extra clones
271 std::vector<snap_t> clones;
272 std::vector<snap_t> missing;
94b18763 273 ceph::bufferlist ss_bl;
7c673cae 274
94b18763 275 bool ss_attr_missing() const { // Compatibility
7c673cae
FG
276 return errors & SNAPSET_MISSING;
277 }
94b18763
FG
278 bool snapset_missing() const {
279 return errors & SNAPSET_MISSING;
280 }
281 bool ss_attr_corrupted() const { // Compatibility
282 return errors & SNAPSET_CORRUPTED;
283 }
284 bool snapset_corrupted() const {
7c673cae
FG
285 return errors & SNAPSET_CORRUPTED;
286 }
287 bool clone_missing() const {
288 return errors & CLONE_MISSING;
289 }
94b18763
FG
290 bool snapset_mismatch() const { // Compatibility
291 return errors & SNAP_ERROR;
292 }
293 bool snapset_error() const {
294 return errors & SNAP_ERROR;
7c673cae 295 }
11fdf7f2
TL
296 bool head_mismatch() const { // Compatibility
297 return false;
7c673cae
FG
298 }
299 bool headless() const {
300 return errors & HEADLESS_CLONE;
301 }
302 bool size_mismatch() const {
303 return errors & SIZE_MISMATCH;
304 }
94b18763 305 bool oi_attr_missing() const { // Compatibility
7c673cae
FG
306 return errors & OI_MISSING;
307 }
94b18763
FG
308 bool info_missing() const {
309 return errors & INFO_MISSING;
310 }
311 bool oi_attr_corrupted() const { // Compatibility
7c673cae
FG
312 return errors & OI_CORRUPTED;
313 }
94b18763
FG
314 bool info_corrupted() const {
315 return errors & INFO_CORRUPTED;
316 }
7c673cae
FG
317 bool extra_clones() const {
318 return errors & EXTRA_CLONES;
319 }
320};
321
322/**
323 * @var all_nspaces
324 * Pass as nspace argument to IoCtx::set_namespace()
325 * before calling nobjects_begin() to iterate
326 * through all objects in all namespaces.
327 */
328const std::string all_nspaces(LIBRADOS_ALL_NSPACES);
329
f67539c2
TL
330struct notify_ack_t {
331 uint64_t notifier_id;
332 uint64_t cookie;
333 ceph::bufferlist payload_bl;
334};
335
336struct notify_timeout_t {
337 uint64_t notifier_id;
338 uint64_t cookie;
339};
7c673cae
FG
340}
341#endif