1 #ifndef CEPH_RADOS_TYPES_HPP
2 #define CEPH_RADOS_TYPES_HPP
11 #include "rados_types.h"
15 typedef uint64_t snap_t;
18 SNAP_HEAD = (uint64_t)(-2),
19 SNAP_DIR = (uint64_t)(-1)
24 std::vector<snap_t> snaps; // ascending
25 std::vector< std::pair<uint64_t,uint64_t> > overlap; // with next newest
27 clone_info_t() : cloneid(0), size(0) {}
31 std::vector<clone_info_t> clones; // ascending
32 snap_t seq; // newest snapid seen by the object
33 snap_set_t() : seq(0) {}
41 object_id_t() = default;
42 object_id_t(const std::string& name,
43 const std::string& nspace,
44 const std::string& locator,
55 SHARD_MISSING = 1 << 1,
56 SHARD_STAT_ERR = 1 << 2,
57 SHARD_READ_ERR = 1 << 3,
58 DATA_DIGEST_MISMATCH_OI = 1 << 9,
59 OMAP_DIGEST_MISMATCH_OI = 1 << 10,
60 SIZE_MISMATCH_OI = 1 << 11,
61 SHARD_EC_HASH_MISMATCH = 1 << 12,
62 SHARD_EC_SIZE_MISMATCH = 1 << 13,
63 OI_ATTR_MISSING = 1 << 14,
64 OI_ATTR_CORRUPTED = 1 << 15,
65 SS_ATTR_MISSING = 1 << 16,
66 SS_ATTR_CORRUPTED = 1 << 17,
67 OBJ_SIZE_OI_MISMATCH = 1 << 18
68 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
71 static constexpr uint64_t SHALLOW_ERRORS = SHARD_MISSING|SHARD_STAT_ERR|SIZE_MISMATCH_OI|OI_ATTR_MISSING|OI_ATTR_CORRUPTED|SS_ATTR_MISSING|SS_ATTR_CORRUPTED|OBJ_SIZE_OI_MISMATCH;
72 static constexpr uint64_t DEEP_ERRORS = SHARD_READ_ERR|DATA_DIGEST_MISMATCH_OI|OMAP_DIGEST_MISMATCH_OI|SHARD_EC_HASH_MISMATCH|SHARD_EC_SIZE_MISMATCH;
73 bool has_shard_missing() const {
74 return errors & SHARD_MISSING;
76 bool has_stat_error() const {
77 return errors & SHARD_STAT_ERR;
79 bool has_read_error() const {
80 return errors & SHARD_READ_ERR;
82 bool has_data_digest_mismatch_oi() const {
83 return errors & DATA_DIGEST_MISMATCH_OI;
85 bool has_omap_digest_mismatch_oi() const {
86 return errors & OMAP_DIGEST_MISMATCH_OI;
88 bool has_size_mismatch_oi() const {
89 return errors & SIZE_MISMATCH_OI;
91 bool has_ec_hash_error() const {
92 return errors & SHARD_EC_HASH_MISMATCH;
94 bool has_ec_size_error() const {
95 return errors & SHARD_EC_SIZE_MISMATCH;
97 bool has_oi_attr_missing() const {
98 return errors & OI_ATTR_MISSING;
100 bool has_oi_attr_corrupted() const {
101 return errors & OI_ATTR_CORRUPTED;
103 bool has_ss_attr_missing() const {
104 return errors & SS_ATTR_MISSING;
106 bool has_ss_attr_corrupted() const {
107 return errors & SS_ATTR_CORRUPTED;
109 bool has_shallow_errors() const {
110 return errors & SHALLOW_ERRORS;
112 bool has_deep_errors() const {
113 return errors & DEEP_ERRORS;
115 bool has_obj_size_oi_mismatch() const {
116 return errors & OBJ_SIZE_OI_MISMATCH;
120 struct shard_info_t : err_t {
121 std::map<std::string, ceph::bufferlist> attrs;
123 bool omap_digest_present = false;
124 uint32_t omap_digest = 0;
125 bool data_digest_present = false;
126 uint32_t data_digest = 0;
127 bool selected_oi = false;
128 bool primary = false;
136 inline bool operator<(const osd_shard_t &lhs, const osd_shard_t &rhs) {
137 if (lhs.osd < rhs.osd)
139 else if (lhs.osd > rhs.osd)
142 return lhs.shard < rhs.shard;
147 OBJECT_INFO_INCONSISTENCY = 1 << 1,
148 // XXX: Can an older rados binary work if these bits stay the same?
149 DATA_DIGEST_MISMATCH = 1 << 4,
150 OMAP_DIGEST_MISMATCH = 1 << 5,
151 SIZE_MISMATCH = 1 << 6,
152 ATTR_VALUE_MISMATCH = 1 << 7,
153 ATTR_NAME_MISMATCH = 1 << 8,
154 SNAPSET_INCONSISTENCY = 1 << 9,
155 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
158 static constexpr uint64_t SHALLOW_ERRORS = OBJECT_INFO_INCONSISTENCY|SIZE_MISMATCH|ATTR_VALUE_MISMATCH|ATTR_NAME_MISMATCH|SNAPSET_INCONSISTENCY;
159 static constexpr uint64_t DEEP_ERRORS = DATA_DIGEST_MISMATCH|OMAP_DIGEST_MISMATCH;
160 bool has_object_info_inconsistency() const {
161 return errors & OBJECT_INFO_INCONSISTENCY;
163 bool has_data_digest_mismatch() const {
164 return errors & DATA_DIGEST_MISMATCH;
166 bool has_omap_digest_mismatch() const {
167 return errors & OMAP_DIGEST_MISMATCH;
169 bool has_size_mismatch() const {
170 return errors & SIZE_MISMATCH;
172 bool has_attr_value_mismatch() const {
173 return errors & ATTR_VALUE_MISMATCH;
175 bool has_attr_name_mismatch() const {
176 return errors & ATTR_NAME_MISMATCH;
178 bool has_shallow_errors() const {
179 return errors & SHALLOW_ERRORS;
181 bool has_deep_errors() const {
182 return errors & DEEP_ERRORS;
184 bool has_snapset_inconsistency() const {
185 return errors & SNAPSET_INCONSISTENCY;
189 struct inconsistent_obj_t : obj_err_t {
190 inconsistent_obj_t() = default;
191 inconsistent_obj_t(const object_id_t& object)
192 : object{object}, version(0)
195 uint64_t version; // XXX: Redundant with object info attr
196 std::map<osd_shard_t, shard_info_t> shards;
200 struct inconsistent_snapset_t {
201 inconsistent_snapset_t() = default;
202 inconsistent_snapset_t(const object_id_t& head)
206 SNAPSET_MISSING = 1 << 0,
207 SNAPSET_CORRUPTED = 1 << 1,
208 CLONE_MISSING = 1 << 2,
209 SNAP_MISMATCH = 1 << 3,
210 HEAD_MISMATCH = 1 << 4,
211 HEADLESS_CLONE = 1 << 5,
212 SIZE_MISMATCH = 1 << 6,
214 OI_CORRUPTED = 1 << 8,
215 EXTRA_CLONES = 1 << 9,
220 std::vector<snap_t> clones;
221 std::vector<snap_t> missing;
223 bool ss_attr_missing() const {
224 return errors & SNAPSET_MISSING;
226 bool ss_attr_corrupted() const {
227 return errors & SNAPSET_CORRUPTED;
229 bool clone_missing() const {
230 return errors & CLONE_MISSING;
232 bool snapset_mismatch() const {
233 return errors & SNAP_MISMATCH;
235 bool head_mismatch() const {
236 return errors & HEAD_MISMATCH;
238 bool headless() const {
239 return errors & HEADLESS_CLONE;
241 bool size_mismatch() const {
242 return errors & SIZE_MISMATCH;
244 bool oi_attr_missing() const {
245 return errors & OI_MISSING;
247 bool oi_attr_corrupted() const {
248 return errors & OI_CORRUPTED;
250 bool extra_clones() const {
251 return errors & EXTRA_CLONES;
257 * Pass as nspace argument to IoCtx::set_namespace()
258 * before calling nobjects_begin() to iterate
259 * through all objects in all namespaces.
261 const std::string all_nspaces(LIBRADOS_ALL_NSPACES);