]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap: improve osdmap flag dumping in json
authorSage Weil <sage@redhat.com>
Fri, 1 Dec 2017 15:24:27 +0000 (09:24 -0600)
committerSage Weil <sage@redhat.com>
Sat, 2 Dec 2017 03:16:22 +0000 (21:16 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSDMap.cc
src/osd/OSDMap.h

index e06dafca4ec144a9abb969e643d2f1cad21d9b96..4588a34ab4418df51cc1bc95f183260b2717a177 100644 (file)
@@ -1224,6 +1224,15 @@ void OSDMap::get_out_osds(set<int32_t>& ls) const
   }
 }
 
+void OSDMap::get_flag_set(set<string> *flagset) const
+{
+  for (unsigned i = 0; i < sizeof(flags) * 8; ++i) {
+    if (flags & (1<<i)) {
+      flagset->insert(get_flag_string(flags & (1<<i)));
+    }
+  }
+}
+
 void OSDMap::calc_state_set(int state, set<string>& st)
 {
   unsigned t = state;
@@ -2752,6 +2761,14 @@ void OSDMap::dump(Formatter *f) const
   f->dump_stream("created") << get_created();
   f->dump_stream("modified") << get_modified();
   f->dump_string("flags", get_flag_string());
+  f->dump_unsigned("flags_num", flags);
+  f->open_array_section("flags_set");
+  set<string> flagset;
+  get_flag_set(&flagset);
+  for (auto p : flagset) {
+    f->dump_string("flag", p);
+  }
+  f->close_section();
   f->dump_unsigned("crush_version", get_crush_version());
   f->dump_float("full_ratio", full_ratio);
   f->dump_float("backfillfull_ratio", backfillfull_ratio);
index 948d0132af1627e45b17411551ecad47d87b42a3..0deaae4d7c0d28597bbff413eaf15b8932416787 100644 (file)
@@ -667,6 +667,8 @@ public:
   void set_flag(int f) { flags |= f; }
   void clear_flag(int f) { flags &= ~f; }
 
+  void get_flag_set(set<string> *flagset) const;
+
   static void calc_state_set(int state, set<string>& st);
 
   int get_state(int o) const {