]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSCacheObject.cc
update sources to ceph Nautilus 14.2.1
[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 MDSContext::vec 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 for (const auto &it : get_replicas()) {
25 std::ostringstream rank_str;
26 rank_str << it.first;
27 f->dump_int(rank_str.str().c_str(), it.second);
28 }
29 f->close_section();
30 }
31 f->close_section(); // auth_state
32
33 // Fields only meaningful for replica
34 f->open_object_section("replica_state");
35 {
36 f->open_array_section("authority");
37 f->dump_int("first", authority().first);
38 f->dump_int("second", authority().second);
39 f->close_section();
40 f->dump_unsigned("replica_nonce", get_replica_nonce());
41 }
42 f->close_section(); // replica_state
43
44 f->dump_int("auth_pins", auth_pins);
45 f->dump_bool("is_frozen", is_frozen());
46 f->dump_bool("is_freezing", is_freezing());
47
48 #ifdef MDS_REF_SET
49 f->open_object_section("pins");
50 for(const auto& p : ref_map) {
51 f->dump_int(pin_name(p.first).data(), p.second);
52 }
53 f->close_section();
54 #endif
55 f->dump_int("nref", ref);
56 }
57
58 /*
59 * Use this in subclasses when printing their specialized
60 * states too.
61 */
62 void MDSCacheObject::dump_states(Formatter *f) const
63 {
64 if (state_test(STATE_AUTH)) f->dump_string("state", "auth");
65 if (state_test(STATE_DIRTY)) f->dump_string("state", "dirty");
66 if (state_test(STATE_NOTIFYREF)) f->dump_string("state", "notifyref");
67 if (state_test(STATE_REJOINING)) f->dump_string("state", "rejoining");
68 if (state_test(STATE_REJOINUNDEF))
69 f->dump_string("state", "rejoinundef");
70 }
71