]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/mdstypes.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 #include "MDSContext.h"
6 #include "common/Formatter.h"
8 const mds_gid_t MDS_GID_NONE
= mds_gid_t(0);
9 const mds_rank_t MDS_RANK_NONE
= mds_rank_t(-1);
16 void frag_info_t::encode(bufferlist
&bl
) const
18 ENCODE_START(3, 2, bl
);
19 ::encode(version
, bl
);
22 ::encode(nsubdirs
, bl
);
23 ::encode(change_attr
, bl
);
27 void frag_info_t::decode(bufferlist::iterator
&bl
)
29 DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl
);
30 ::decode(version
, bl
);
33 ::decode(nsubdirs
, bl
);
35 ::decode(change_attr
, bl
);
41 void frag_info_t::dump(Formatter
*f
) const
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
);
49 void frag_info_t::generate_test_instances(list
<frag_info_t
*>& ls
)
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;
59 ostream
& operator<<(ostream
&out
, const frag_info_t
&f
)
61 if (f
== frag_info_t())
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
;
77 void nest_info_t::encode(bufferlist
&bl
) const
79 ENCODE_START(3, 2, bl
);
80 ::encode(version
, bl
);
83 ::encode(rsubdirs
, bl
);
87 ::encode(ranchors
, bl
);
89 ::encode(rsnaprealms
, bl
);
94 void nest_info_t::decode(bufferlist::iterator
&bl
)
96 DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl
);
97 ::decode(version
, bl
);
100 ::decode(rsubdirs
, bl
);
103 ::decode(ranchors
, bl
);
105 ::decode(rsnaprealms
, bl
);
106 ::decode(rctime
, bl
);
110 void nest_info_t::dump(Formatter
*f
) const
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
;
120 void nest_info_t::generate_test_instances(list
<nest_info_t
*>& ls
)
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);
132 ostream
& operator<<(ostream
&out
, const nest_info_t
&n
)
134 if (n
== nest_info_t())
136 out
<< "n(v" << n
.version
;
137 if (n
.rctime
!= utime_t())
138 out
<< " rc" << n
.rctime
;
140 out
<< " b" << n
.rbytes
;
142 out
<< " sr" << n
.rsnaprealms
;
143 if (n
.rfiles
|| n
.rsubdirs
)
144 out
<< " " << n
.rsize() << "=" << n
.rfiles
<< "+" << n
.rsubdirs
;
152 void quota_info_t::dump(Formatter
*f
) const
154 f
->dump_int("max_bytes", max_bytes
);
155 f
->dump_int("max_files", max_files
);
158 void quota_info_t::generate_test_instances(list
<quota_info_t
*>& ls
)
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;
166 ostream
& operator<<(ostream
&out
, const quota_info_t
&n
)
169 << "max_bytes = " << n
.max_bytes
170 << " max_files = " << n
.max_files
176 * client_writeable_range_t
179 void client_writeable_range_t::encode(bufferlist
&bl
) const
181 ENCODE_START(2, 2, bl
);
182 ::encode(range
.first
, bl
);
183 ::encode(range
.last
, bl
);
184 ::encode(follows
, bl
);
188 void client_writeable_range_t::decode(bufferlist::iterator
& bl
)
190 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
191 ::decode(range
.first
, bl
);
192 ::decode(range
.last
, bl
);
193 ::decode(follows
, bl
);
197 void client_writeable_range_t::dump(Formatter
*f
) const
199 f
->open_object_section("byte range");
200 f
->dump_unsigned("first", range
.first
);
201 f
->dump_unsigned("last", range
.last
);
203 f
->dump_unsigned("follows", follows
);
206 void client_writeable_range_t::generate_test_instances(list
<client_writeable_range_t
*>& ls
)
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;
215 ostream
& operator<<(ostream
& out
, const client_writeable_range_t
& r
)
217 return out
<< r
.range
.first
<< '-' << r
.range
.last
<< "@" << r
.follows
;
223 void inline_data_t::encode(bufferlist
&bl
) const
225 ::encode(version
, bl
);
229 ::encode(bufferlist(), bl
);
231 void inline_data_t::decode(bufferlist::iterator
&p
)
233 ::decode(version
, p
);
235 ::decode(inline_len
, p
);
237 ::decode_nohead(inline_len
, get_data(), p
);
246 void fnode_t::encode(bufferlist
&bl
) const
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
);
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
);
263 void fnode_t::decode(bufferlist::iterator
&bl
)
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
);
271 ::decode(accounted_rstat
, bl
);
273 ::decode(damage_flags
, bl
);
276 ::decode(recursive_scrub_version
, bl
);
277 ::decode(recursive_scrub_stamp
, bl
);
278 ::decode(localized_scrub_version
, bl
);
279 ::decode(localized_scrub_stamp
, bl
);
284 void fnode_t::dump(Formatter
*f
) const
286 f
->dump_unsigned("version", version
);
287 f
->dump_unsigned("snap_purged_thru", snap_purged_thru
);
289 f
->open_object_section("fragstat");
293 f
->open_object_section("accounted_fragstat");
294 accounted_fragstat
.dump(f
);
297 f
->open_object_section("rstat");
301 f
->open_object_section("accounted_rstat");
302 accounted_rstat
.dump(f
);
306 void fnode_t::generate_test_instances(list
<fnode_t
*>& ls
)
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();
326 void old_rstat_t::encode(bufferlist
& bl
) const
328 ENCODE_START(2, 2, bl
);
331 ::encode(accounted_rstat
, bl
);
335 void old_rstat_t::decode(bufferlist::iterator
& bl
)
337 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
340 ::decode(accounted_rstat
, bl
);
344 void old_rstat_t::dump(Formatter
*f
) const
346 f
->dump_unsigned("snapid", first
);
347 f
->open_object_section("rstat");
350 f
->open_object_section("accounted_rstat");
351 accounted_rstat
.dump(f
);
355 void old_rstat_t::generate_test_instances(list
<old_rstat_t
*>& ls
)
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();
369 void session_info_t::encode(bufferlist
& bl
, uint64_t features
) const
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
);
382 void session_info_t::decode(bufferlist::iterator
& p
)
384 DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, p
);
390 completed_requests
[*s
.begin()] = inodeno_t();
394 ::decode(completed_requests
, p
);
396 ::decode(prealloc_inos
, p
);
397 ::decode(used_inos
, p
);
398 prealloc_inos
.insert(used_inos
);
401 ::decode(client_metadata
, p
);
404 ::decode(completed_flushes
, p
);
407 ::decode(auth_name
, p
);
412 void session_info_t::dump(Formatter
*f
) const
414 f
->dump_stream("inst") << inst
;
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();
420 f
->open_object_section("request");
421 f
->dump_unsigned("tid", p
->first
);
422 f
->dump_stream("created_ino") << p
->second
;
427 f
->open_array_section("prealloc_inos");
428 for (interval_set
<inodeno_t
>::const_iterator p
= prealloc_inos
.begin();
429 p
!= prealloc_inos
.end();
431 f
->open_object_section("ino_range");
432 f
->dump_unsigned("start", p
.get_start());
433 f
->dump_unsigned("length", p
.get_len());
438 f
->open_array_section("used_inos");
439 for (interval_set
<inodeno_t
>::const_iterator p
= prealloc_inos
.begin();
440 p
!= prealloc_inos
.end();
442 f
->open_object_section("ino_range");
443 f
->dump_unsigned("start", p
.get_start());
444 f
->dump_unsigned("length", p
.get_len());
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
);
455 void session_info_t::generate_test_instances(list
<session_info_t
*>& ls
)
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
471 void string_snap_t::encode(bufferlist
& bl
) const
473 ENCODE_START(2, 2, bl
);
475 ::encode(snapid
, bl
);
479 void string_snap_t::decode(bufferlist::iterator
& bl
)
481 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
483 ::decode(snapid
, bl
);
487 void string_snap_t::dump(Formatter
*f
) const
489 f
->dump_string("name", name
);
490 f
->dump_unsigned("snapid", snapid
);
493 void string_snap_t::generate_test_instances(list
<string_snap_t
*>& ls
)
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;
508 void MDSCacheObjectInfo::encode(bufferlist
& bl
) const
510 ENCODE_START(2, 2, bl
);
512 ::encode(dirfrag
, bl
);
514 ::encode(snapid
, bl
);
518 void MDSCacheObjectInfo::decode(bufferlist::iterator
& p
)
520 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p
);
522 ::decode(dirfrag
, p
);
528 void MDSCacheObjectInfo::dump(Formatter
*f
) const
530 f
->dump_unsigned("ino", ino
);
531 f
->dump_stream("dirfrag") << dirfrag
;
532 f
->dump_string("name", dname
);
533 f
->dump_unsigned("snapid", snapid
);
536 void MDSCacheObjectInfo::generate_test_instances(list
<MDSCacheObjectInfo
*>& ls
)
538 ls
.push_back(new MDSCacheObjectInfo
);
539 ls
.push_back(new MDSCacheObjectInfo
);
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;
552 * mds_table_pending_t
554 void mds_table_pending_t::encode(bufferlist
& bl
) const
556 ENCODE_START(2, 2, bl
);
563 void mds_table_pending_t::decode(bufferlist::iterator
& bl
)
565 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
572 void mds_table_pending_t::dump(Formatter
*f
) const
574 f
->dump_unsigned("reqid", reqid
);
575 f
->dump_unsigned("mds", mds
);
576 f
->dump_unsigned("tid", tid
);
579 void mds_table_pending_t::generate_test_instances(list
<mds_table_pending_t
*>& ls
)
581 ls
.push_back(new mds_table_pending_t
);
582 ls
.push_back(new mds_table_pending_t
);
583 ls
.back()->reqid
= 234;
585 ls
.back()->tid
= 35434;
592 void inode_load_vec_t::encode(bufferlist
&bl
) const
594 ENCODE_START(2, 2, bl
);
595 for (const auto &i
: vec
) {
601 void inode_load_vec_t::decode(const utime_t
&t
, bufferlist::iterator
&p
)
603 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, p
);
604 for (auto &i
: vec
) {
610 void inode_load_vec_t::dump(Formatter
*f
)
612 f
->open_array_section("Decay Counters");
613 for (const auto &i
: vec
) {
614 f
->open_object_section("Decay Counter");
621 void inode_load_vec_t::generate_test_instances(list
<inode_load_vec_t
*>& ls
)
624 ls
.push_back(new inode_load_vec_t(sample
));
631 void dirfrag_load_vec_t::dump(Formatter
*f
) const
633 f
->open_array_section("Decay Counters");
634 for (const auto &i
: vec
) {
635 f
->open_object_section("Decay Counter");
642 void dirfrag_load_vec_t::dump(Formatter
*f
, utime_t now
, const DecayRate
& rate
)
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
));
652 void dirfrag_load_vec_t::generate_test_instances(list
<dirfrag_load_vec_t
*>& ls
)
655 ls
.push_back(new dirfrag_load_vec_t(sample
));
661 void mds_load_t::encode(bufferlist
&bl
) const {
662 ENCODE_START(2, 2, bl
);
665 ::encode(req_rate
, bl
);
666 ::encode(cache_hit_rate
, bl
);
667 ::encode(queue_len
, bl
);
668 ::encode(cpu_load_avg
, bl
);
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
);
683 void mds_load_t::dump(Formatter
*f
) const
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");
692 f
->open_object_section("all dirfrags");
697 void mds_load_t::generate_test_instances(list
<mds_load_t
*>& ls
)
700 ls
.push_back(new mds_load_t(sample
));
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
);
713 void cap_reconnect_t::encode_old(bufferlist
& bl
) const {
715 capinfo
.flock_len
= flockbl
.length();
716 ::encode(capinfo
, bl
);
717 ::encode_nohead(flockbl
, bl
);
720 void cap_reconnect_t::decode(bufferlist::iterator
& bl
) {
722 decode_old(bl
); // extract out when something changes
724 ::decode(snap_follows
, bl
);
728 void cap_reconnect_t::decode_old(bufferlist::iterator
& bl
) {
730 ::decode(capinfo
, bl
);
731 ::decode_nohead(capinfo
.flock_len
, flockbl
, bl
);
734 void cap_reconnect_t::dump(Formatter
*f
) const
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");
745 void cap_reconnect_t::generate_test_instances(list
<cap_reconnect_t
*>& ls
)
747 ls
.push_back(new cap_reconnect_t
);
748 ls
.back()->path
= "/test/path";
749 ls
.back()->capinfo
.cap_id
= 1;
752 ostream
& operator<<(ostream
&out
, const mds_role_t
&role
)
754 out
<< role
.fscid
<< ":" << role
.rank
;