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