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 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
70 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;
71 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;
72 bool has_shard_missing() const {
73 return errors & SHARD_MISSING;
75 bool has_stat_error() const {
76 return errors & SHARD_STAT_ERR;
78 bool has_read_error() const {
79 return errors & SHARD_READ_ERR;
81 bool has_data_digest_mismatch_oi() const {
82 return errors & DATA_DIGEST_MISMATCH_OI;
84 bool has_omap_digest_mismatch_oi() const {
85 return errors & OMAP_DIGEST_MISMATCH_OI;
87 bool has_size_mismatch_oi() const {
88 return errors & SIZE_MISMATCH_OI;
90 bool has_ec_hash_error() const {
91 return errors & SHARD_EC_HASH_MISMATCH;
93 bool has_ec_size_error() const {
94 return errors & SHARD_EC_SIZE_MISMATCH;
96 bool has_oi_attr_missing() const {
97 return errors & OI_ATTR_MISSING;
99 bool has_oi_attr_corrupted() const {
100 return errors & OI_ATTR_CORRUPTED;
102 bool has_ss_attr_missing() const {
103 return errors & SS_ATTR_MISSING;
105 bool has_ss_attr_corrupted() const {
106 return errors & SS_ATTR_CORRUPTED;
108 bool has_shallow_errors() const {
109 return errors & SHALLOW_ERRORS;
111 bool has_deep_errors() const {
112 return errors & DEEP_ERRORS;
116 struct shard_info_t : err_t {
117 std::map<std::string, ceph::bufferlist> attrs;
119 bool omap_digest_present = false;
120 uint32_t omap_digest = 0;
121 bool data_digest_present = false;
122 uint32_t data_digest = 0;
123 bool selected_oi = false;
131 inline bool operator<(const osd_shard_t &lhs, const osd_shard_t &rhs) {
132 if (lhs.osd < rhs.osd)
134 else if (lhs.osd > rhs.osd)
137 return lhs.shard < rhs.shard;
142 OBJECT_INFO_INCONSISTENCY = 1 << 1,
143 // XXX: Can an older rados binary work if these bits stay the same?
144 DATA_DIGEST_MISMATCH = 1 << 4,
145 OMAP_DIGEST_MISMATCH = 1 << 5,
146 SIZE_MISMATCH = 1 << 6,
147 ATTR_VALUE_MISMATCH = 1 << 7,
148 ATTR_NAME_MISMATCH = 1 << 8,
149 // When adding more here add to either SHALLOW_ERRORS or DEEP_ERRORS
152 static constexpr uint64_t SHALLOW_ERRORS = OBJECT_INFO_INCONSISTENCY|SIZE_MISMATCH|ATTR_VALUE_MISMATCH|ATTR_NAME_MISMATCH;
153 static constexpr uint64_t DEEP_ERRORS = DATA_DIGEST_MISMATCH|OMAP_DIGEST_MISMATCH;
154 bool has_object_info_inconsistency() const {
155 return errors & OBJECT_INFO_INCONSISTENCY;
157 bool has_data_digest_mismatch() const {
158 return errors & DATA_DIGEST_MISMATCH;
160 bool has_omap_digest_mismatch() const {
161 return errors & OMAP_DIGEST_MISMATCH;
163 bool has_size_mismatch() const {
164 return errors & SIZE_MISMATCH;
166 bool has_attr_value_mismatch() const {
167 return errors & ATTR_VALUE_MISMATCH;
169 bool has_attr_name_mismatch() const {
170 return errors & ATTR_NAME_MISMATCH;
172 bool has_shallow_errors() const {
173 return errors & SHALLOW_ERRORS;
175 bool has_deep_errors() const {
176 return errors & DEEP_ERRORS;
180 struct inconsistent_obj_t : obj_err_t {
181 inconsistent_obj_t() = default;
182 inconsistent_obj_t(const object_id_t& object)
183 : object{object}, version(0)
186 uint64_t version; // XXX: Redundant with object info attr
187 std::map<osd_shard_t, shard_info_t> shards;
191 struct inconsistent_snapset_t {
192 inconsistent_snapset_t() = default;
193 inconsistent_snapset_t(const object_id_t& head)
197 SNAPSET_MISSING = 1 << 0,
198 SNAPSET_CORRUPTED = 1 << 1,
199 CLONE_MISSING = 1 << 2,
200 SNAP_MISMATCH = 1 << 3,
201 HEAD_MISMATCH = 1 << 4,
202 HEADLESS_CLONE = 1 << 5,
203 SIZE_MISMATCH = 1 << 6,
205 OI_CORRUPTED = 1 << 8,
206 EXTRA_CLONES = 1 << 9,
211 std::vector<snap_t> clones;
212 std::vector<snap_t> missing;
214 bool ss_attr_missing() const {
215 return errors & SNAPSET_MISSING;
217 bool ss_attr_corrupted() const {
218 return errors & SNAPSET_CORRUPTED;
220 bool clone_missing() const {
221 return errors & CLONE_MISSING;
223 bool snapset_mismatch() const {
224 return errors & SNAP_MISMATCH;
226 bool head_mismatch() const {
227 return errors & HEAD_MISMATCH;
229 bool headless() const {
230 return errors & HEADLESS_CLONE;
232 bool size_mismatch() const {
233 return errors & SIZE_MISMATCH;
235 bool oi_attr_missing() const {
236 return errors & OI_MISSING;
238 bool oi_attr_corrupted() const {
239 return errors & OI_CORRUPTED;
241 bool extra_clones() const {
242 return errors & EXTRA_CLONES;
248 * Pass as nspace argument to IoCtx::set_namespace()
249 * before calling nobjects_begin() to iterate
250 * through all objects in all namespaces.
252 const std::string all_nspaces(LIBRADOS_ALL_NSPACES);