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