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