]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSCacheObject.cc
update sources to v12.1.2
[ceph.git] / ceph / src / mds / MDSCacheObject.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "MDSCacheObject.h"
5 #include "MDSContext.h"
6 #include "common/Formatter.h"
7
8 uint64_t MDSCacheObject::last_wait_seq = 0;
9
10 void MDSCacheObject::finish_waiting(uint64_t mask, int result) {
11 list<MDSInternalContextBase*> finished;
12 take_waiting(mask, finished);
13 finish_contexts(g_ceph_context, finished, result);
14 }
15
16 void MDSCacheObject::dump(Formatter *f) const
17 {
18 f->dump_bool("is_auth", is_auth());
19
20 // Fields only meaningful for auth
21 f->open_object_section("auth_state");
22 {
23 f->open_object_section("replicas");
24 const compact_map<mds_rank_t,unsigned>& replicas = get_replicas();
25 for (compact_map<mds_rank_t,unsigned>::const_iterator i = replicas.begin();
26 i != replicas.end(); ++i) {
27 std::ostringstream rank_str;
28 rank_str << i->first;
29 f->dump_int(rank_str.str().c_str(), i->second);
30 }
31 f->close_section();
32 }
33 f->close_section(); // auth_state
34
35 // Fields only meaningful for replica
36 f->open_object_section("replica_state");
37 {
38 f->open_array_section("authority");
39 f->dump_int("first", authority().first);
40 f->dump_int("second", authority().second);
41 f->close_section();
42 f->dump_unsigned("replica_nonce", get_replica_nonce());
43 }
44 f->close_section(); // replica_state
45
46 f->dump_int("auth_pins", auth_pins);
47 f->dump_int("nested_auth_pins", nested_auth_pins);
48 f->dump_bool("is_frozen", is_frozen());
49 f->dump_bool("is_freezing", is_freezing());
50
51 #ifdef MDS_REF_SET
52 f->open_object_section("pins");
53 for(std::map<int, int>::const_iterator it = ref_map.begin();
54 it != ref_map.end(); ++it) {
55 f->dump_int(pin_name(it->first), it->second);
56 }
57 f->close_section();
58 #endif
59 f->dump_int("nref", ref);
60 }
61
62 /*
63 * Use this in subclasses when printing their specialized
64 * states too.
65 */
66 void MDSCacheObject::dump_states(Formatter *f) const
67 {
68 if (state_test(STATE_AUTH)) f->dump_string("state", "auth");
69 if (state_test(STATE_DIRTY)) f->dump_string("state", "dirty");
70 if (state_test(STATE_NOTIFYREF)) f->dump_string("state", "notifyref");
71 if (state_test(STATE_REJOINING)) f->dump_string("state", "rejoining");
72 if (state_test(STATE_REJOINUNDEF))
73 f->dump_string("state", "rejoinundef");
74 }
75