]>
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 CEPH_SCRUB_TYPES_H | |
5 | #define CEPH_SCRUB_TYPES_H | |
6 | ||
7c673cae FG |
7 | #include "osd/osd_types.h" |
8 | ||
7c673cae FG |
9 | // wrappers around scrub types to offer the necessary bits other than |
10 | // the minimal set that the lirados requires | |
11 | struct object_id_wrapper : public librados::object_id_t { | |
12 | object_id_wrapper(const hobject_t& hoid) | |
13 | : object_id_t{hoid.oid.name, hoid.nspace, hoid.get_key(), hoid.snap} | |
14 | {} | |
15 | void encode(bufferlist& bl) const; | |
16 | void decode(bufferlist::iterator& bl); | |
17 | }; | |
18 | ||
19 | WRITE_CLASS_ENCODER(object_id_wrapper) | |
20 | ||
21 | inline void decode(librados::object_id_t& obj, bufferlist::iterator& bp) { | |
22 | reinterpret_cast<object_id_wrapper&>(obj).decode(bp); | |
23 | } | |
24 | ||
25 | struct osd_shard_wrapper : public librados::osd_shard_t { | |
26 | void encode(bufferlist& bl) const; | |
27 | void decode(bufferlist::iterator& bp); | |
28 | }; | |
29 | ||
30 | WRITE_CLASS_ENCODER(osd_shard_wrapper) | |
31 | ||
32 | namespace librados { | |
33 | inline void decode(librados::osd_shard_t& shard, bufferlist::iterator& bp) { | |
34 | reinterpret_cast<osd_shard_wrapper&>(shard).decode(bp); | |
35 | } | |
36 | } | |
37 | ||
38 | struct shard_info_wrapper : public librados::shard_info_t { | |
39 | public: | |
40 | shard_info_wrapper() = default; | |
41 | shard_info_wrapper(const ScrubMap::object& object) { | |
42 | set_object(object); | |
43 | } | |
44 | void set_object(const ScrubMap::object& object); | |
45 | void set_missing() { | |
46 | errors |= err_t::SHARD_MISSING; | |
47 | } | |
94b18763 FG |
48 | void set_omap_digest_mismatch_info() { |
49 | errors |= err_t::OMAP_DIGEST_MISMATCH_INFO; | |
7c673cae | 50 | } |
94b18763 FG |
51 | void set_size_mismatch_info() { |
52 | errors |= err_t::SIZE_MISMATCH_INFO; | |
7c673cae | 53 | } |
94b18763 FG |
54 | void set_data_digest_mismatch_info() { |
55 | errors |= err_t::DATA_DIGEST_MISMATCH_INFO; | |
7c673cae FG |
56 | } |
57 | void set_read_error() { | |
58 | errors |= err_t::SHARD_READ_ERR; | |
59 | } | |
60 | void set_stat_error() { | |
61 | errors |= err_t::SHARD_STAT_ERR; | |
62 | } | |
63 | void set_ec_hash_mismatch() { | |
64 | errors |= err_t::SHARD_EC_HASH_MISMATCH; | |
65 | } | |
66 | void set_ec_size_mismatch() { | |
67 | errors |= err_t::SHARD_EC_SIZE_MISMATCH; | |
68 | } | |
94b18763 FG |
69 | void set_info_missing() { |
70 | errors |= err_t::INFO_MISSING; | |
7c673cae | 71 | } |
94b18763 FG |
72 | void set_info_corrupted() { |
73 | errors |= err_t::INFO_CORRUPTED; | |
7c673cae | 74 | } |
94b18763 FG |
75 | void set_snapset_missing() { |
76 | errors |= err_t::SNAPSET_MISSING; | |
7c673cae | 77 | } |
94b18763 FG |
78 | void set_snapset_corrupted() { |
79 | errors |= err_t::SNAPSET_CORRUPTED; | |
7c673cae | 80 | } |
94b18763 FG |
81 | void set_obj_size_info_mismatch() { |
82 | errors |= err_t::OBJ_SIZE_INFO_MISMATCH; | |
83 | } | |
84 | void set_hinfo_missing() { | |
85 | errors |= err_t::HINFO_MISSING; | |
86 | } | |
87 | void set_hinfo_corrupted() { | |
88 | errors |= err_t::HINFO_CORRUPTED; | |
b5b8bbf5 | 89 | } |
1adf2230 AA |
90 | bool only_data_digest_mismatch_info() const { |
91 | return errors == err_t::DATA_DIGEST_MISMATCH_INFO; | |
92 | } | |
93 | void clear_data_digest_mismatch_info() { | |
94 | errors &= ~err_t::DATA_DIGEST_MISMATCH_INFO; | |
95 | } | |
7c673cae FG |
96 | void encode(bufferlist& bl) const; |
97 | void decode(bufferlist::iterator& bp); | |
98 | }; | |
99 | ||
100 | WRITE_CLASS_ENCODER(shard_info_wrapper) | |
101 | ||
102 | namespace librados { | |
103 | inline void decode(librados::shard_info_t& shard, | |
104 | bufferlist::iterator& bp) { | |
105 | reinterpret_cast<shard_info_wrapper&>(shard).decode(bp); | |
106 | } | |
107 | } | |
108 | ||
109 | struct inconsistent_obj_wrapper : librados::inconsistent_obj_t { | |
110 | inconsistent_obj_wrapper(const hobject_t& hoid); | |
111 | ||
112 | void set_object_info_inconsistency() { | |
113 | errors |= obj_err_t::OBJECT_INFO_INCONSISTENCY; | |
114 | } | |
115 | void set_omap_digest_mismatch() { | |
116 | errors |= obj_err_t::OMAP_DIGEST_MISMATCH; | |
117 | } | |
118 | void set_data_digest_mismatch() { | |
119 | errors |= obj_err_t::DATA_DIGEST_MISMATCH; | |
120 | } | |
121 | void set_size_mismatch() { | |
122 | errors |= obj_err_t::SIZE_MISMATCH; | |
123 | } | |
124 | void set_attr_value_mismatch() { | |
125 | errors |= obj_err_t::ATTR_VALUE_MISMATCH; | |
126 | } | |
127 | void set_attr_name_mismatch() { | |
128 | errors |= obj_err_t::ATTR_NAME_MISMATCH; | |
129 | } | |
3a9019d9 FG |
130 | void set_snapset_inconsistency() { |
131 | errors |= obj_err_t::SNAPSET_INCONSISTENCY; | |
132 | } | |
94b18763 FG |
133 | void set_hinfo_inconsistency() { |
134 | errors |= obj_err_t::HINFO_INCONSISTENCY; | |
135 | } | |
7c673cae FG |
136 | void add_shard(const pg_shard_t& pgs, const shard_info_wrapper& shard); |
137 | void set_auth_missing(const hobject_t& hoid, | |
138 | const map<pg_shard_t, ScrubMap*>&, | |
139 | map<pg_shard_t, shard_info_wrapper>&, | |
b5b8bbf5 FG |
140 | int &shallow_errors, int &deep_errors, |
141 | const pg_shard_t &primary); | |
7c673cae FG |
142 | void set_version(uint64_t ver) { version = ver; } |
143 | void encode(bufferlist& bl) const; | |
144 | void decode(bufferlist::iterator& bp); | |
145 | }; | |
146 | ||
147 | WRITE_CLASS_ENCODER(inconsistent_obj_wrapper) | |
148 | ||
149 | inline void decode(librados::inconsistent_obj_t& obj, | |
150 | bufferlist::iterator& bp) { | |
151 | reinterpret_cast<inconsistent_obj_wrapper&>(obj).decode(bp); | |
152 | } | |
153 | ||
154 | struct inconsistent_snapset_wrapper : public librados::inconsistent_snapset_t { | |
155 | inconsistent_snapset_wrapper() = default; | |
156 | inconsistent_snapset_wrapper(const hobject_t& head); | |
157 | void set_headless(); | |
158 | // soid claims that it is a head or a snapdir, but its SS_ATTR | |
159 | // is missing. | |
94b18763 FG |
160 | void set_snapset_missing(); |
161 | void set_info_missing(); | |
162 | void set_snapset_corrupted(); | |
163 | void set_info_corrupted(); | |
7c673cae FG |
164 | // snapset with missing clone |
165 | void set_clone_missing(snapid_t); | |
166 | // Clones that are there | |
167 | void set_clone(snapid_t); | |
168 | // the snapset is not consistent with itself | |
94b18763 | 169 | void set_snapset_error(); |
7c673cae FG |
170 | // soid.snap inconsistent with snapset |
171 | void set_head_mismatch(); | |
172 | void set_size_mismatch(); | |
173 | ||
174 | void encode(bufferlist& bl) const; | |
175 | void decode(bufferlist::iterator& bp); | |
176 | }; | |
177 | ||
178 | WRITE_CLASS_ENCODER(inconsistent_snapset_wrapper) | |
179 | ||
180 | namespace librados { | |
181 | inline void decode(librados::inconsistent_snapset_t& snapset, | |
182 | bufferlist::iterator& bp) { | |
183 | reinterpret_cast<inconsistent_snapset_wrapper&>(snapset).decode(bp); | |
184 | } | |
185 | } | |
186 | ||
187 | struct scrub_ls_arg_t { | |
188 | uint32_t interval; | |
189 | uint32_t get_snapsets; | |
190 | librados::object_id_t start_after; | |
191 | uint64_t max_return; | |
192 | void encode(bufferlist& bl) const; | |
193 | void decode(bufferlist::iterator& bl); | |
194 | }; | |
195 | ||
196 | WRITE_CLASS_ENCODER(scrub_ls_arg_t); | |
197 | ||
198 | struct scrub_ls_result_t { | |
199 | epoch_t interval; | |
200 | std::vector<bufferlist> vals; | |
201 | void encode(bufferlist& bl) const; | |
202 | void decode(bufferlist::iterator& bl); | |
203 | }; | |
204 | ||
205 | WRITE_CLASS_ENCODER(scrub_ls_result_t); | |
206 | ||
207 | #endif |