]>
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 | #include "mdstypes.h" | |
5 | #include "MDSContext.h" | |
6 | #include "common/Formatter.h" | |
9f95a23c | 7 | #include "common/StackStringStream.h" |
7c673cae FG |
8 | |
9 | const mds_gid_t MDS_GID_NONE = mds_gid_t(0); | |
7c673cae FG |
10 | |
11 | ||
12 | /* | |
13 | * frag_info_t | |
14 | */ | |
15 | ||
16 | void frag_info_t::encode(bufferlist &bl) const | |
17 | { | |
18 | ENCODE_START(3, 2, bl); | |
11fdf7f2 TL |
19 | encode(version, bl); |
20 | encode(mtime, bl); | |
21 | encode(nfiles, bl); | |
22 | encode(nsubdirs, bl); | |
23 | encode(change_attr, bl); | |
7c673cae FG |
24 | ENCODE_FINISH(bl); |
25 | } | |
26 | ||
11fdf7f2 | 27 | void frag_info_t::decode(bufferlist::const_iterator &bl) |
7c673cae FG |
28 | { |
29 | DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); | |
11fdf7f2 TL |
30 | decode(version, bl); |
31 | decode(mtime, bl); | |
32 | decode(nfiles, bl); | |
33 | decode(nsubdirs, bl); | |
7c673cae | 34 | if (struct_v >= 3) |
11fdf7f2 | 35 | decode(change_attr, bl); |
7c673cae FG |
36 | else |
37 | change_attr = 0; | |
38 | DECODE_FINISH(bl); | |
39 | } | |
40 | ||
41 | void frag_info_t::dump(Formatter *f) const | |
42 | { | |
43 | f->dump_unsigned("version", version); | |
44 | f->dump_stream("mtime") << mtime; | |
45 | f->dump_unsigned("num_files", nfiles); | |
46 | f->dump_unsigned("num_subdirs", nsubdirs); | |
9f95a23c | 47 | f->dump_unsigned("change_attr", change_attr); |
7c673cae FG |
48 | } |
49 | ||
9f95a23c | 50 | void frag_info_t::generate_test_instances(std::list<frag_info_t*>& ls) |
7c673cae FG |
51 | { |
52 | ls.push_back(new frag_info_t); | |
53 | ls.push_back(new frag_info_t); | |
54 | ls.back()->version = 1; | |
55 | ls.back()->mtime = utime_t(2, 3); | |
56 | ls.back()->nfiles = 4; | |
57 | ls.back()->nsubdirs = 5; | |
58 | } | |
59 | ||
60 | ostream& operator<<(ostream &out, const frag_info_t &f) | |
61 | { | |
62 | if (f == frag_info_t()) | |
63 | return out << "f()"; | |
64 | out << "f(v" << f.version; | |
65 | if (f.mtime != utime_t()) | |
66 | out << " m" << f.mtime; | |
67 | if (f.nfiles || f.nsubdirs) | |
68 | out << " " << f.size() << "=" << f.nfiles << "+" << f.nsubdirs; | |
69 | out << ")"; | |
70 | return out; | |
71 | } | |
72 | ||
73 | ||
74 | /* | |
75 | * nest_info_t | |
76 | */ | |
77 | ||
78 | void nest_info_t::encode(bufferlist &bl) const | |
79 | { | |
80 | ENCODE_START(3, 2, bl); | |
11fdf7f2 TL |
81 | encode(version, bl); |
82 | encode(rbytes, bl); | |
83 | encode(rfiles, bl); | |
84 | encode(rsubdirs, bl); | |
7c673cae FG |
85 | { |
86 | // removed field | |
87 | int64_t ranchors = 0; | |
11fdf7f2 | 88 | encode(ranchors, bl); |
7c673cae | 89 | } |
11fdf7f2 TL |
90 | encode(rsnaps, bl); |
91 | encode(rctime, bl); | |
7c673cae FG |
92 | ENCODE_FINISH(bl); |
93 | } | |
94 | ||
11fdf7f2 | 95 | void nest_info_t::decode(bufferlist::const_iterator &bl) |
7c673cae FG |
96 | { |
97 | DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); | |
11fdf7f2 TL |
98 | decode(version, bl); |
99 | decode(rbytes, bl); | |
100 | decode(rfiles, bl); | |
101 | decode(rsubdirs, bl); | |
7c673cae FG |
102 | { |
103 | int64_t ranchors; | |
11fdf7f2 | 104 | decode(ranchors, bl); |
7c673cae | 105 | } |
11fdf7f2 TL |
106 | decode(rsnaps, bl); |
107 | decode(rctime, bl); | |
7c673cae FG |
108 | DECODE_FINISH(bl); |
109 | } | |
110 | ||
111 | void nest_info_t::dump(Formatter *f) const | |
112 | { | |
113 | f->dump_unsigned("version", version); | |
114 | f->dump_unsigned("rbytes", rbytes); | |
115 | f->dump_unsigned("rfiles", rfiles); | |
116 | f->dump_unsigned("rsubdirs", rsubdirs); | |
11fdf7f2 | 117 | f->dump_unsigned("rsnaps", rsnaps); |
7c673cae FG |
118 | f->dump_stream("rctime") << rctime; |
119 | } | |
120 | ||
9f95a23c | 121 | void nest_info_t::generate_test_instances(std::list<nest_info_t*>& ls) |
7c673cae FG |
122 | { |
123 | ls.push_back(new nest_info_t); | |
124 | ls.push_back(new nest_info_t); | |
125 | ls.back()->version = 1; | |
126 | ls.back()->rbytes = 2; | |
127 | ls.back()->rfiles = 3; | |
128 | ls.back()->rsubdirs = 4; | |
11fdf7f2 | 129 | ls.back()->rsnaps = 6; |
7c673cae FG |
130 | ls.back()->rctime = utime_t(7, 8); |
131 | } | |
132 | ||
133 | ostream& operator<<(ostream &out, const nest_info_t &n) | |
134 | { | |
135 | if (n == nest_info_t()) | |
136 | return out << "n()"; | |
137 | out << "n(v" << n.version; | |
138 | if (n.rctime != utime_t()) | |
139 | out << " rc" << n.rctime; | |
140 | if (n.rbytes) | |
141 | out << " b" << n.rbytes; | |
11fdf7f2 TL |
142 | if (n.rsnaps) |
143 | out << " rs" << n.rsnaps; | |
7c673cae FG |
144 | if (n.rfiles || n.rsubdirs) |
145 | out << " " << n.rsize() << "=" << n.rfiles << "+" << n.rsubdirs; | |
146 | out << ")"; | |
147 | return out; | |
148 | } | |
149 | ||
150 | /* | |
151 | * quota_info_t | |
152 | */ | |
153 | void quota_info_t::dump(Formatter *f) const | |
154 | { | |
155 | f->dump_int("max_bytes", max_bytes); | |
156 | f->dump_int("max_files", max_files); | |
157 | } | |
158 | ||
9f95a23c | 159 | void quota_info_t::generate_test_instances(std::list<quota_info_t *>& ls) |
7c673cae FG |
160 | { |
161 | ls.push_back(new quota_info_t); | |
162 | ls.push_back(new quota_info_t); | |
163 | ls.back()->max_bytes = 16; | |
164 | ls.back()->max_files = 16; | |
165 | } | |
166 | ||
167 | ostream& operator<<(ostream &out, const quota_info_t &n) | |
168 | { | |
169 | out << "quota(" | |
170 | << "max_bytes = " << n.max_bytes | |
171 | << " max_files = " << n.max_files | |
172 | << ")"; | |
173 | return out; | |
174 | } | |
175 | ||
176 | /* | |
177 | * client_writeable_range_t | |
178 | */ | |
179 | ||
180 | void client_writeable_range_t::encode(bufferlist &bl) const | |
181 | { | |
182 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
183 | encode(range.first, bl); |
184 | encode(range.last, bl); | |
185 | encode(follows, bl); | |
7c673cae FG |
186 | ENCODE_FINISH(bl); |
187 | } | |
188 | ||
11fdf7f2 | 189 | void client_writeable_range_t::decode(bufferlist::const_iterator& bl) |
7c673cae FG |
190 | { |
191 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); | |
11fdf7f2 TL |
192 | decode(range.first, bl); |
193 | decode(range.last, bl); | |
194 | decode(follows, bl); | |
7c673cae FG |
195 | DECODE_FINISH(bl); |
196 | } | |
197 | ||
198 | void client_writeable_range_t::dump(Formatter *f) const | |
199 | { | |
200 | f->open_object_section("byte range"); | |
201 | f->dump_unsigned("first", range.first); | |
202 | f->dump_unsigned("last", range.last); | |
203 | f->close_section(); | |
204 | f->dump_unsigned("follows", follows); | |
205 | } | |
206 | ||
9f95a23c | 207 | void client_writeable_range_t::generate_test_instances(std::list<client_writeable_range_t*>& ls) |
7c673cae FG |
208 | { |
209 | ls.push_back(new client_writeable_range_t); | |
210 | ls.push_back(new client_writeable_range_t); | |
211 | ls.back()->range.first = 123; | |
212 | ls.back()->range.last = 456; | |
213 | ls.back()->follows = 12; | |
214 | } | |
215 | ||
216 | ostream& operator<<(ostream& out, const client_writeable_range_t& r) | |
217 | { | |
218 | return out << r.range.first << '-' << r.range.last << "@" << r.follows; | |
219 | } | |
220 | ||
221 | /* | |
222 | * inline_data_t | |
223 | */ | |
224 | void inline_data_t::encode(bufferlist &bl) const | |
225 | { | |
11fdf7f2 TL |
226 | using ceph::encode; |
227 | encode(version, bl); | |
7c673cae | 228 | if (blp) |
11fdf7f2 | 229 | encode(*blp, bl); |
7c673cae | 230 | else |
11fdf7f2 | 231 | encode(bufferlist(), bl); |
7c673cae | 232 | } |
11fdf7f2 | 233 | void inline_data_t::decode(bufferlist::const_iterator &p) |
7c673cae | 234 | { |
11fdf7f2 TL |
235 | using ceph::decode; |
236 | decode(version, p); | |
7c673cae | 237 | uint32_t inline_len; |
11fdf7f2 | 238 | decode(inline_len, p); |
7c673cae | 239 | if (inline_len > 0) |
11fdf7f2 | 240 | decode_nohead(inline_len, get_data(), p); |
7c673cae FG |
241 | else |
242 | free_data(); | |
243 | } | |
244 | ||
7c673cae FG |
245 | |
246 | /* | |
247 | * fnode_t | |
248 | */ | |
249 | void fnode_t::encode(bufferlist &bl) const | |
250 | { | |
251 | ENCODE_START(4, 3, bl); | |
11fdf7f2 TL |
252 | encode(version, bl); |
253 | encode(snap_purged_thru, bl); | |
254 | encode(fragstat, bl); | |
255 | encode(accounted_fragstat, bl); | |
256 | encode(rstat, bl); | |
257 | encode(accounted_rstat, bl); | |
258 | encode(damage_flags, bl); | |
259 | encode(recursive_scrub_version, bl); | |
260 | encode(recursive_scrub_stamp, bl); | |
261 | encode(localized_scrub_version, bl); | |
262 | encode(localized_scrub_stamp, bl); | |
7c673cae FG |
263 | ENCODE_FINISH(bl); |
264 | } | |
265 | ||
11fdf7f2 | 266 | void fnode_t::decode(bufferlist::const_iterator &bl) |
7c673cae FG |
267 | { |
268 | DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); | |
11fdf7f2 TL |
269 | decode(version, bl); |
270 | decode(snap_purged_thru, bl); | |
271 | decode(fragstat, bl); | |
272 | decode(accounted_fragstat, bl); | |
273 | decode(rstat, bl); | |
274 | decode(accounted_rstat, bl); | |
7c673cae | 275 | if (struct_v >= 3) { |
11fdf7f2 | 276 | decode(damage_flags, bl); |
7c673cae FG |
277 | } |
278 | if (struct_v >= 4) { | |
11fdf7f2 TL |
279 | decode(recursive_scrub_version, bl); |
280 | decode(recursive_scrub_stamp, bl); | |
281 | decode(localized_scrub_version, bl); | |
282 | decode(localized_scrub_stamp, bl); | |
7c673cae FG |
283 | } |
284 | DECODE_FINISH(bl); | |
285 | } | |
286 | ||
287 | void fnode_t::dump(Formatter *f) const | |
288 | { | |
289 | f->dump_unsigned("version", version); | |
290 | f->dump_unsigned("snap_purged_thru", snap_purged_thru); | |
291 | ||
292 | f->open_object_section("fragstat"); | |
293 | fragstat.dump(f); | |
294 | f->close_section(); | |
295 | ||
296 | f->open_object_section("accounted_fragstat"); | |
297 | accounted_fragstat.dump(f); | |
298 | f->close_section(); | |
299 | ||
300 | f->open_object_section("rstat"); | |
301 | rstat.dump(f); | |
302 | f->close_section(); | |
303 | ||
304 | f->open_object_section("accounted_rstat"); | |
305 | accounted_rstat.dump(f); | |
306 | f->close_section(); | |
307 | } | |
308 | ||
9f95a23c | 309 | void fnode_t::generate_test_instances(std::list<fnode_t*>& ls) |
7c673cae FG |
310 | { |
311 | ls.push_back(new fnode_t); | |
312 | ls.push_back(new fnode_t); | |
313 | ls.back()->version = 1; | |
314 | ls.back()->snap_purged_thru = 2; | |
315 | list<frag_info_t*> fls; | |
316 | frag_info_t::generate_test_instances(fls); | |
317 | ls.back()->fragstat = *fls.back(); | |
318 | ls.back()->accounted_fragstat = *fls.front(); | |
319 | list<nest_info_t*> nls; | |
320 | nest_info_t::generate_test_instances(nls); | |
321 | ls.back()->rstat = *nls.front(); | |
322 | ls.back()->accounted_rstat = *nls.back(); | |
323 | } | |
324 | ||
325 | ||
326 | /* | |
327 | * old_rstat_t | |
328 | */ | |
329 | void old_rstat_t::encode(bufferlist& bl) const | |
330 | { | |
331 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
332 | encode(first, bl); |
333 | encode(rstat, bl); | |
334 | encode(accounted_rstat, bl); | |
7c673cae FG |
335 | ENCODE_FINISH(bl); |
336 | } | |
337 | ||
11fdf7f2 | 338 | void old_rstat_t::decode(bufferlist::const_iterator& bl) |
7c673cae FG |
339 | { |
340 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); | |
11fdf7f2 TL |
341 | decode(first, bl); |
342 | decode(rstat, bl); | |
343 | decode(accounted_rstat, bl); | |
7c673cae FG |
344 | DECODE_FINISH(bl); |
345 | } | |
346 | ||
347 | void old_rstat_t::dump(Formatter *f) const | |
348 | { | |
349 | f->dump_unsigned("snapid", first); | |
350 | f->open_object_section("rstat"); | |
351 | rstat.dump(f); | |
352 | f->close_section(); | |
353 | f->open_object_section("accounted_rstat"); | |
354 | accounted_rstat.dump(f); | |
355 | f->close_section(); | |
356 | } | |
357 | ||
9f95a23c | 358 | void old_rstat_t::generate_test_instances(std::list<old_rstat_t*>& ls) |
7c673cae FG |
359 | { |
360 | ls.push_back(new old_rstat_t()); | |
361 | ls.push_back(new old_rstat_t()); | |
362 | ls.back()->first = 12; | |
363 | list<nest_info_t*> nls; | |
364 | nest_info_t::generate_test_instances(nls); | |
365 | ls.back()->rstat = *nls.back(); | |
366 | ls.back()->accounted_rstat = *nls.front(); | |
367 | } | |
368 | ||
11fdf7f2 TL |
369 | /* |
370 | * feature_bitset_t | |
371 | */ | |
372 | feature_bitset_t::feature_bitset_t(unsigned long value) | |
373 | { | |
374 | if (value) { | |
375 | for (size_t i = 0; i < sizeof(value) * 8; i += bits_per_block) { | |
376 | _vec.push_back((block_type)(value >> i)); | |
377 | } | |
378 | } | |
379 | } | |
380 | ||
381 | feature_bitset_t::feature_bitset_t(const vector<size_t>& array) | |
382 | { | |
383 | if (!array.empty()) { | |
384 | size_t n = array.back(); | |
385 | n += bits_per_block; | |
386 | n /= bits_per_block; | |
387 | _vec.resize(n, 0); | |
388 | ||
389 | size_t last = 0; | |
390 | for (auto& bit : array) { | |
391 | if (bit > last) | |
392 | last = bit; | |
393 | else | |
394 | ceph_assert(bit == last); | |
395 | _vec[bit / bits_per_block] |= (block_type)1 << (bit % bits_per_block); | |
396 | } | |
397 | } | |
398 | } | |
399 | ||
400 | feature_bitset_t& feature_bitset_t::operator-=(const feature_bitset_t& other) | |
401 | { | |
402 | for (size_t i = 0; i < _vec.size(); ++i) { | |
403 | if (i >= other._vec.size()) | |
404 | break; | |
405 | _vec[i] &= ~other._vec[i]; | |
406 | } | |
407 | return *this; | |
408 | } | |
409 | ||
410 | void feature_bitset_t::encode(bufferlist& bl) const { | |
411 | using ceph::encode; | |
412 | using ceph::encode_nohead; | |
413 | uint32_t len = _vec.size() * sizeof(block_type); | |
414 | encode(len, bl); | |
415 | encode_nohead(_vec, bl); | |
416 | } | |
417 | ||
418 | void feature_bitset_t::decode(bufferlist::const_iterator &p) { | |
419 | using ceph::decode; | |
420 | using ceph::decode_nohead; | |
421 | uint32_t len; | |
422 | decode(len, p); | |
423 | ||
424 | _vec.clear(); | |
425 | if (len >= sizeof(block_type)) | |
426 | decode_nohead(len / sizeof(block_type), _vec, p); | |
427 | ||
428 | if (len % sizeof(block_type)) { | |
429 | ceph_le64 buf{}; | |
430 | p.copy(len % sizeof(block_type), (char*)&buf); | |
431 | _vec.push_back((block_type)buf); | |
432 | } | |
433 | } | |
434 | ||
9f95a23c TL |
435 | void feature_bitset_t::dump(Formatter *f) const { |
436 | CachedStackStringStream css; | |
437 | print(*css); | |
438 | f->dump_string("feature_bits", css->strv()); | |
439 | } | |
440 | ||
11fdf7f2 TL |
441 | void feature_bitset_t::print(ostream& out) const |
442 | { | |
443 | std::ios_base::fmtflags f(out.flags()); | |
92f5a8d4 | 444 | out << "0x"; |
11fdf7f2 TL |
445 | for (int i = _vec.size() - 1; i >= 0; --i) |
446 | out << std::setfill('0') << std::setw(sizeof(block_type) * 2) | |
447 | << std::hex << _vec[i]; | |
448 | out.flags(f); | |
449 | } | |
450 | ||
9f95a23c TL |
451 | /* |
452 | * metric_spec_t | |
453 | */ | |
454 | void metric_spec_t::encode(bufferlist& bl) const { | |
455 | using ceph::encode; | |
456 | ENCODE_START(1, 1, bl); | |
457 | encode(metric_flags, bl); | |
458 | ENCODE_FINISH(bl); | |
459 | } | |
460 | ||
461 | void metric_spec_t::decode(bufferlist::const_iterator &p) { | |
462 | using ceph::decode; | |
463 | DECODE_START(1, p); | |
464 | decode(metric_flags, p); | |
465 | DECODE_FINISH(p); | |
466 | } | |
467 | ||
468 | void metric_spec_t::dump(Formatter *f) const { | |
469 | f->dump_object("metric_flags", metric_flags); | |
470 | } | |
471 | ||
472 | void metric_spec_t::print(ostream& out) const | |
473 | { | |
474 | out << "{metric_flags: '" << metric_flags << "'}"; | |
475 | } | |
476 | ||
11fdf7f2 TL |
477 | /* |
478 | * client_metadata_t | |
479 | */ | |
480 | void client_metadata_t::encode(bufferlist& bl) const | |
481 | { | |
9f95a23c | 482 | ENCODE_START(3, 1, bl); |
11fdf7f2 TL |
483 | encode(kv_map, bl); |
484 | encode(features, bl); | |
9f95a23c | 485 | encode(metric_spec, bl); |
11fdf7f2 TL |
486 | ENCODE_FINISH(bl); |
487 | } | |
488 | ||
489 | void client_metadata_t::decode(bufferlist::const_iterator& p) | |
490 | { | |
9f95a23c | 491 | DECODE_START(3, p); |
11fdf7f2 TL |
492 | decode(kv_map, p); |
493 | if (struct_v >= 2) | |
494 | decode(features, p); | |
9f95a23c TL |
495 | if (struct_v >= 3) { |
496 | decode(metric_spec, p); | |
497 | } | |
11fdf7f2 TL |
498 | DECODE_FINISH(p); |
499 | } | |
500 | ||
501 | void client_metadata_t::dump(Formatter *f) const | |
502 | { | |
9f95a23c TL |
503 | f->dump_object("client_features", features); |
504 | f->dump_object("metric_spec", metric_spec); | |
92f5a8d4 TL |
505 | for (const auto& [name, val] : kv_map) |
506 | f->dump_string(name.c_str(), val); | |
11fdf7f2 TL |
507 | } |
508 | ||
7c673cae FG |
509 | /* |
510 | * session_info_t | |
511 | */ | |
512 | void session_info_t::encode(bufferlist& bl, uint64_t features) const | |
513 | { | |
11fdf7f2 TL |
514 | ENCODE_START(7, 7, bl); |
515 | encode(inst, bl, features); | |
516 | encode(completed_requests, bl); | |
517 | encode(prealloc_inos, bl); // hacky, see below. | |
518 | encode(used_inos, bl); | |
519 | encode(completed_flushes, bl); | |
520 | encode(auth_name, bl); | |
521 | encode(client_metadata, bl); | |
7c673cae FG |
522 | ENCODE_FINISH(bl); |
523 | } | |
524 | ||
11fdf7f2 | 525 | void session_info_t::decode(bufferlist::const_iterator& p) |
7c673cae | 526 | { |
11fdf7f2 TL |
527 | DECODE_START_LEGACY_COMPAT_LEN(7, 2, 2, p); |
528 | decode(inst, p); | |
7c673cae FG |
529 | if (struct_v <= 2) { |
530 | set<ceph_tid_t> s; | |
11fdf7f2 | 531 | decode(s, p); |
7c673cae FG |
532 | while (!s.empty()) { |
533 | completed_requests[*s.begin()] = inodeno_t(); | |
534 | s.erase(s.begin()); | |
535 | } | |
536 | } else { | |
11fdf7f2 | 537 | decode(completed_requests, p); |
7c673cae | 538 | } |
11fdf7f2 TL |
539 | decode(prealloc_inos, p); |
540 | decode(used_inos, p); | |
7c673cae FG |
541 | prealloc_inos.insert(used_inos); |
542 | used_inos.clear(); | |
11fdf7f2 TL |
543 | if (struct_v >= 4 && struct_v < 7) { |
544 | decode(client_metadata.kv_map, p); | |
7c673cae FG |
545 | } |
546 | if (struct_v >= 5) { | |
11fdf7f2 | 547 | decode(completed_flushes, p); |
7c673cae FG |
548 | } |
549 | if (struct_v >= 6) { | |
11fdf7f2 TL |
550 | decode(auth_name, p); |
551 | } | |
552 | if (struct_v >= 7) { | |
553 | decode(client_metadata, p); | |
7c673cae FG |
554 | } |
555 | DECODE_FINISH(p); | |
556 | } | |
557 | ||
558 | void session_info_t::dump(Formatter *f) const | |
559 | { | |
560 | f->dump_stream("inst") << inst; | |
561 | ||
562 | f->open_array_section("completed_requests"); | |
92f5a8d4 | 563 | for (const auto& [tid, ino] : completed_requests) { |
7c673cae | 564 | f->open_object_section("request"); |
92f5a8d4 TL |
565 | f->dump_unsigned("tid", tid); |
566 | f->dump_stream("created_ino") << ino; | |
7c673cae FG |
567 | f->close_section(); |
568 | } | |
569 | f->close_section(); | |
570 | ||
571 | f->open_array_section("prealloc_inos"); | |
92f5a8d4 | 572 | for (const auto& [start, len] : prealloc_inos) { |
7c673cae | 573 | f->open_object_section("ino_range"); |
9f95a23c | 574 | f->dump_stream("start") << start; |
92f5a8d4 | 575 | f->dump_unsigned("length", len); |
7c673cae FG |
576 | f->close_section(); |
577 | } | |
578 | f->close_section(); | |
579 | ||
580 | f->open_array_section("used_inos"); | |
92f5a8d4 | 581 | for (const auto& [start, len] : used_inos) { |
7c673cae | 582 | f->open_object_section("ino_range"); |
9f95a23c | 583 | f->dump_stream("start") << start; |
92f5a8d4 | 584 | f->dump_unsigned("length", len); |
7c673cae FG |
585 | f->close_section(); |
586 | } | |
587 | f->close_section(); | |
588 | ||
92f5a8d4 | 589 | f->dump_object("client_metadata", client_metadata); |
7c673cae FG |
590 | } |
591 | ||
9f95a23c | 592 | void session_info_t::generate_test_instances(std::list<session_info_t*>& ls) |
7c673cae FG |
593 | { |
594 | ls.push_back(new session_info_t); | |
595 | ls.push_back(new session_info_t); | |
596 | ls.back()->inst = entity_inst_t(entity_name_t::MDS(12), entity_addr_t()); | |
597 | ls.back()->completed_requests.insert(make_pair(234, inodeno_t(111222))); | |
598 | ls.back()->completed_requests.insert(make_pair(237, inodeno_t(222333))); | |
599 | ls.back()->prealloc_inos.insert(333, 12); | |
600 | ls.back()->prealloc_inos.insert(377, 112); | |
601 | // we can't add used inos; they're cleared on decode | |
602 | } | |
603 | ||
604 | ||
605 | /* | |
606 | * string_snap_t | |
607 | */ | |
608 | void string_snap_t::encode(bufferlist& bl) const | |
609 | { | |
610 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
611 | encode(name, bl); |
612 | encode(snapid, bl); | |
7c673cae FG |
613 | ENCODE_FINISH(bl); |
614 | } | |
615 | ||
11fdf7f2 | 616 | void string_snap_t::decode(bufferlist::const_iterator& bl) |
7c673cae FG |
617 | { |
618 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); | |
11fdf7f2 TL |
619 | decode(name, bl); |
620 | decode(snapid, bl); | |
7c673cae FG |
621 | DECODE_FINISH(bl); |
622 | } | |
623 | ||
624 | void string_snap_t::dump(Formatter *f) const | |
625 | { | |
626 | f->dump_string("name", name); | |
627 | f->dump_unsigned("snapid", snapid); | |
628 | } | |
629 | ||
9f95a23c | 630 | void string_snap_t::generate_test_instances(std::list<string_snap_t*>& ls) |
7c673cae FG |
631 | { |
632 | ls.push_back(new string_snap_t); | |
633 | ls.push_back(new string_snap_t); | |
634 | ls.back()->name = "foo"; | |
635 | ls.back()->snapid = 123; | |
636 | ls.push_back(new string_snap_t); | |
637 | ls.back()->name = "bar"; | |
638 | ls.back()->snapid = 456; | |
639 | } | |
640 | ||
641 | ||
642 | /* | |
643 | * MDSCacheObjectInfo | |
644 | */ | |
645 | void MDSCacheObjectInfo::encode(bufferlist& bl) const | |
646 | { | |
647 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
648 | encode(ino, bl); |
649 | encode(dirfrag, bl); | |
650 | encode(dname, bl); | |
651 | encode(snapid, bl); | |
7c673cae FG |
652 | ENCODE_FINISH(bl); |
653 | } | |
654 | ||
11fdf7f2 | 655 | void MDSCacheObjectInfo::decode(bufferlist::const_iterator& p) |
7c673cae FG |
656 | { |
657 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p); | |
11fdf7f2 TL |
658 | decode(ino, p); |
659 | decode(dirfrag, p); | |
660 | decode(dname, p); | |
661 | decode(snapid, p); | |
7c673cae FG |
662 | DECODE_FINISH(p); |
663 | } | |
664 | ||
665 | void MDSCacheObjectInfo::dump(Formatter *f) const | |
666 | { | |
667 | f->dump_unsigned("ino", ino); | |
668 | f->dump_stream("dirfrag") << dirfrag; | |
669 | f->dump_string("name", dname); | |
670 | f->dump_unsigned("snapid", snapid); | |
671 | } | |
672 | ||
9f95a23c | 673 | void MDSCacheObjectInfo::generate_test_instances(std::list<MDSCacheObjectInfo*>& ls) |
7c673cae FG |
674 | { |
675 | ls.push_back(new MDSCacheObjectInfo); | |
676 | ls.push_back(new MDSCacheObjectInfo); | |
677 | ls.back()->ino = 1; | |
678 | ls.back()->dirfrag = dirfrag_t(2, 3); | |
679 | ls.back()->dname = "fooname"; | |
680 | ls.back()->snapid = CEPH_NOSNAP; | |
681 | ls.push_back(new MDSCacheObjectInfo); | |
682 | ls.back()->ino = 121; | |
683 | ls.back()->dirfrag = dirfrag_t(222, 0); | |
684 | ls.back()->dname = "bar foo"; | |
685 | ls.back()->snapid = 21322; | |
686 | } | |
687 | ||
688 | /* | |
689 | * mds_table_pending_t | |
690 | */ | |
691 | void mds_table_pending_t::encode(bufferlist& bl) const | |
692 | { | |
693 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
694 | encode(reqid, bl); |
695 | encode(mds, bl); | |
696 | encode(tid, bl); | |
7c673cae FG |
697 | ENCODE_FINISH(bl); |
698 | } | |
699 | ||
11fdf7f2 | 700 | void mds_table_pending_t::decode(bufferlist::const_iterator& bl) |
7c673cae FG |
701 | { |
702 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); | |
11fdf7f2 TL |
703 | decode(reqid, bl); |
704 | decode(mds, bl); | |
705 | decode(tid, bl); | |
7c673cae FG |
706 | DECODE_FINISH(bl); |
707 | } | |
708 | ||
709 | void mds_table_pending_t::dump(Formatter *f) const | |
710 | { | |
711 | f->dump_unsigned("reqid", reqid); | |
712 | f->dump_unsigned("mds", mds); | |
713 | f->dump_unsigned("tid", tid); | |
714 | } | |
715 | ||
9f95a23c | 716 | void mds_table_pending_t::generate_test_instances(std::list<mds_table_pending_t*>& ls) |
7c673cae FG |
717 | { |
718 | ls.push_back(new mds_table_pending_t); | |
719 | ls.push_back(new mds_table_pending_t); | |
720 | ls.back()->reqid = 234; | |
721 | ls.back()->mds = 2; | |
722 | ls.back()->tid = 35434; | |
723 | } | |
724 | ||
725 | ||
726 | /* | |
727 | * inode_load_vec_t | |
728 | */ | |
729 | void inode_load_vec_t::encode(bufferlist &bl) const | |
730 | { | |
731 | ENCODE_START(2, 2, bl); | |
94b18763 | 732 | for (const auto &i : vec) { |
11fdf7f2 | 733 | encode(i, bl); |
94b18763 | 734 | } |
7c673cae FG |
735 | ENCODE_FINISH(bl); |
736 | } | |
737 | ||
11fdf7f2 | 738 | void inode_load_vec_t::decode(bufferlist::const_iterator &p) |
7c673cae FG |
739 | { |
740 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p); | |
94b18763 | 741 | for (auto &i : vec) { |
11fdf7f2 | 742 | decode(i, p); |
94b18763 | 743 | } |
7c673cae FG |
744 | DECODE_FINISH(p); |
745 | } | |
746 | ||
11fdf7f2 | 747 | void inode_load_vec_t::dump(Formatter *f) const |
7c673cae FG |
748 | { |
749 | f->open_array_section("Decay Counters"); | |
94b18763 | 750 | for (const auto &i : vec) { |
7c673cae | 751 | f->open_object_section("Decay Counter"); |
94b18763 | 752 | i.dump(f); |
7c673cae FG |
753 | f->close_section(); |
754 | } | |
755 | f->close_section(); | |
756 | } | |
757 | ||
9f95a23c | 758 | void inode_load_vec_t::generate_test_instances(std::list<inode_load_vec_t*>& ls) |
7c673cae | 759 | { |
11fdf7f2 | 760 | ls.push_back(new inode_load_vec_t(DecayRate())); |
7c673cae FG |
761 | } |
762 | ||
763 | ||
764 | /* | |
765 | * dirfrag_load_vec_t | |
766 | */ | |
767 | void dirfrag_load_vec_t::dump(Formatter *f) const | |
768 | { | |
769 | f->open_array_section("Decay Counters"); | |
94b18763 | 770 | for (const auto &i : vec) { |
7c673cae | 771 | f->open_object_section("Decay Counter"); |
94b18763 | 772 | i.dump(f); |
7c673cae FG |
773 | f->close_section(); |
774 | } | |
775 | f->close_section(); | |
776 | } | |
777 | ||
11fdf7f2 | 778 | void dirfrag_load_vec_t::dump(Formatter *f, const DecayRate& rate) const |
28e407b8 | 779 | { |
11fdf7f2 TL |
780 | f->dump_float("meta_load", meta_load()); |
781 | f->dump_float("IRD", get(META_POP_IRD).get()); | |
782 | f->dump_float("IWR", get(META_POP_IWR).get()); | |
783 | f->dump_float("READDIR", get(META_POP_READDIR).get()); | |
784 | f->dump_float("FETCH", get(META_POP_FETCH).get()); | |
785 | f->dump_float("STORE", get(META_POP_STORE).get()); | |
28e407b8 AA |
786 | } |
787 | ||
11fdf7f2 | 788 | void dirfrag_load_vec_t::generate_test_instances(std::list<dirfrag_load_vec_t*>& ls) |
7c673cae | 789 | { |
11fdf7f2 | 790 | ls.push_back(new dirfrag_load_vec_t(DecayRate())); |
7c673cae FG |
791 | } |
792 | ||
793 | /* | |
794 | * mds_load_t | |
795 | */ | |
796 | void mds_load_t::encode(bufferlist &bl) const { | |
797 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
798 | encode(auth, bl); |
799 | encode(all, bl); | |
800 | encode(req_rate, bl); | |
801 | encode(cache_hit_rate, bl); | |
802 | encode(queue_len, bl); | |
803 | encode(cpu_load_avg, bl); | |
7c673cae FG |
804 | ENCODE_FINISH(bl); |
805 | } | |
806 | ||
11fdf7f2 | 807 | void mds_load_t::decode(bufferlist::const_iterator &bl) { |
7c673cae | 808 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); |
11fdf7f2 TL |
809 | decode(auth, bl); |
810 | decode(all, bl); | |
811 | decode(req_rate, bl); | |
812 | decode(cache_hit_rate, bl); | |
813 | decode(queue_len, bl); | |
814 | decode(cpu_load_avg, bl); | |
7c673cae FG |
815 | DECODE_FINISH(bl); |
816 | } | |
817 | ||
818 | void mds_load_t::dump(Formatter *f) const | |
819 | { | |
820 | f->dump_float("request rate", req_rate); | |
821 | f->dump_float("cache hit rate", cache_hit_rate); | |
822 | f->dump_float("queue length", queue_len); | |
823 | f->dump_float("cpu load", cpu_load_avg); | |
824 | f->open_object_section("auth dirfrag"); | |
825 | auth.dump(f); | |
826 | f->close_section(); | |
827 | f->open_object_section("all dirfrags"); | |
828 | all.dump(f); | |
829 | f->close_section(); | |
830 | } | |
831 | ||
11fdf7f2 | 832 | void mds_load_t::generate_test_instances(std::list<mds_load_t*>& ls) |
7c673cae | 833 | { |
11fdf7f2 | 834 | ls.push_back(new mds_load_t(DecayRate())); |
7c673cae FG |
835 | } |
836 | ||
837 | /* | |
838 | * cap_reconnect_t | |
839 | */ | |
840 | void cap_reconnect_t::encode(bufferlist& bl) const { | |
841 | ENCODE_START(2, 1, bl); | |
842 | encode_old(bl); // extract out when something changes | |
11fdf7f2 | 843 | encode(snap_follows, bl); |
7c673cae FG |
844 | ENCODE_FINISH(bl); |
845 | } | |
846 | ||
847 | void cap_reconnect_t::encode_old(bufferlist& bl) const { | |
11fdf7f2 TL |
848 | using ceph::encode; |
849 | encode(path, bl); | |
7c673cae | 850 | capinfo.flock_len = flockbl.length(); |
11fdf7f2 TL |
851 | encode(capinfo, bl); |
852 | encode_nohead(flockbl, bl); | |
7c673cae FG |
853 | } |
854 | ||
11fdf7f2 TL |
855 | void cap_reconnect_t::decode(bufferlist::const_iterator& bl) { |
856 | DECODE_START(2, bl); | |
7c673cae FG |
857 | decode_old(bl); // extract out when something changes |
858 | if (struct_v >= 2) | |
11fdf7f2 | 859 | decode(snap_follows, bl); |
7c673cae FG |
860 | DECODE_FINISH(bl); |
861 | } | |
862 | ||
11fdf7f2 TL |
863 | void cap_reconnect_t::decode_old(bufferlist::const_iterator& bl) { |
864 | using ceph::decode; | |
865 | decode(path, bl); | |
866 | decode(capinfo, bl); | |
867 | decode_nohead(capinfo.flock_len, flockbl, bl); | |
7c673cae FG |
868 | } |
869 | ||
870 | void cap_reconnect_t::dump(Formatter *f) const | |
871 | { | |
872 | f->dump_string("path", path); | |
873 | f->dump_int("cap_id", capinfo.cap_id); | |
874 | f->dump_string("cap wanted", ccap_string(capinfo.wanted)); | |
875 | f->dump_string("cap issued", ccap_string(capinfo.issued)); | |
876 | f->dump_int("snaprealm", capinfo.snaprealm); | |
877 | f->dump_int("path base ino", capinfo.pathbase); | |
878 | f->dump_string("has file locks", capinfo.flock_len ? "true" : "false"); | |
879 | } | |
880 | ||
9f95a23c | 881 | void cap_reconnect_t::generate_test_instances(std::list<cap_reconnect_t*>& ls) |
7c673cae FG |
882 | { |
883 | ls.push_back(new cap_reconnect_t); | |
884 | ls.back()->path = "/test/path"; | |
885 | ls.back()->capinfo.cap_id = 1; | |
886 | } | |
887 | ||
11fdf7f2 TL |
888 | /* |
889 | * snaprealm_reconnect_t | |
890 | */ | |
891 | void snaprealm_reconnect_t::encode(bufferlist& bl) const { | |
892 | ENCODE_START(1, 1, bl); | |
893 | encode_old(bl); // extract out when something changes | |
894 | ENCODE_FINISH(bl); | |
895 | } | |
896 | ||
897 | void snaprealm_reconnect_t::encode_old(bufferlist& bl) const { | |
898 | using ceph::encode; | |
899 | encode(realm, bl); | |
900 | } | |
901 | ||
902 | void snaprealm_reconnect_t::decode(bufferlist::const_iterator& bl) { | |
903 | DECODE_START(1, bl); | |
904 | decode_old(bl); // extract out when something changes | |
905 | DECODE_FINISH(bl); | |
906 | } | |
907 | ||
908 | void snaprealm_reconnect_t::decode_old(bufferlist::const_iterator& bl) { | |
909 | using ceph::decode; | |
910 | decode(realm, bl); | |
911 | } | |
912 | ||
913 | void snaprealm_reconnect_t::dump(Formatter *f) const | |
914 | { | |
915 | f->dump_int("ino", realm.ino); | |
916 | f->dump_int("seq", realm.seq); | |
917 | f->dump_int("parent", realm.parent); | |
918 | } | |
919 | ||
9f95a23c | 920 | void snaprealm_reconnect_t::generate_test_instances(std::list<snaprealm_reconnect_t*>& ls) |
11fdf7f2 TL |
921 | { |
922 | ls.push_back(new snaprealm_reconnect_t); | |
923 | ls.back()->realm.ino = 0x10000000001ULL; | |
924 | ls.back()->realm.seq = 2; | |
925 | ls.back()->realm.parent = 1; | |
926 | } |