]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: add dump flag for CInode
authordongdong tao <tdd21151186@gmail.com>
Sun, 7 Jan 2018 06:59:44 +0000 (14:59 +0800)
committerdongdong tao <tdd21151186@gmail.com>
Sat, 13 Jan 2018 15:04:25 +0000 (23:04 +0800)
Signed-off-by: dongdong tao <tdd21151186@gmail.com>
src/mds/CInode.cc
src/mds/CInode.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDLog.h

index 32aaa64089437f50261ace66431a292e96bb0229..02f43b1be2c1e834af2b193adea4f44aeb19d912 100644 (file)
@@ -4277,111 +4277,127 @@ bool CInode::validated_data::all_damage_repaired() const
   return !unrepaired;
 }
 
-void CInode::dump(Formatter *f) const
-{
-  InodeStoreBase::dump(f);
-
-  MDSCacheObject::dump(f);
-
-  f->open_object_section("versionlock");
-  versionlock.dump(f);
-  f->close_section();
-
-  f->open_object_section("authlock");
-  authlock.dump(f);
-  f->close_section();
-
-  f->open_object_section("linklock");
-  linklock.dump(f);
-  f->close_section();
-
-  f->open_object_section("dirfragtreelock");
-  dirfragtreelock.dump(f);
-  f->close_section();
-
-  f->open_object_section("filelock");
-  filelock.dump(f);
-  f->close_section();
-
-  f->open_object_section("xattrlock");
-  xattrlock.dump(f);
-  f->close_section();
-
-  f->open_object_section("snaplock");
-  snaplock.dump(f);
-  f->close_section();
-
-  f->open_object_section("nestlock");
-  nestlock.dump(f);
-  f->close_section();
-
-  f->open_object_section("flocklock");
-  flocklock.dump(f);
-  f->close_section();
-
-  f->open_object_section("policylock");
-  policylock.dump(f);
-  f->close_section();
-
-  f->open_array_section("states");
-  MDSCacheObject::dump_states(f);
-  if (state_test(STATE_EXPORTING))
-    f->dump_string("state", "exporting");
-  if (state_test(STATE_OPENINGDIR))
-    f->dump_string("state", "openingdir");
-  if (state_test(STATE_FREEZING))
-    f->dump_string("state", "freezing");
-  if (state_test(STATE_FROZEN))
-    f->dump_string("state", "frozen");
-  if (state_test(STATE_AMBIGUOUSAUTH))
-    f->dump_string("state", "ambiguousauth");
-  if (state_test(STATE_EXPORTINGCAPS))
-    f->dump_string("state", "exportingcaps");
-  if (state_test(STATE_NEEDSRECOVER))
-    f->dump_string("state", "needsrecover");
-  if (state_test(STATE_PURGING))
-    f->dump_string("state", "purging");
-  if (state_test(STATE_DIRTYPARENT))
-    f->dump_string("state", "dirtyparent");
-  if (state_test(STATE_DIRTYRSTAT))
-    f->dump_string("state", "dirtyrstat");
-  if (state_test(STATE_STRAYPINNED))
-    f->dump_string("state", "straypinned");
-  if (state_test(STATE_FROZENAUTHPIN))
-    f->dump_string("state", "frozenauthpin");
-  if (state_test(STATE_DIRTYPOOL))
-    f->dump_string("state", "dirtypool");
-  if (state_test(STATE_ORPHAN))
-    f->dump_string("state", "orphan");
-  if (state_test(STATE_MISSINGOBJS))
-    f->dump_string("state", "missingobjs");
-  f->close_section();
-
-  f->open_array_section("client_caps");
-  for (map<client_t,Capability*>::const_iterator it = client_caps.begin();
-       it != client_caps.end(); ++it) {
-    f->open_object_section("client_cap");
-    f->dump_int("client_id", it->first.v);
-    f->dump_string("pending", ccap_string(it->second->pending()));
-    f->dump_string("issued", ccap_string(it->second->issued()));
-    f->dump_string("wanted", ccap_string(it->second->wanted()));
-    f->dump_int("last_sent", it->second->get_last_sent());
+void CInode::dump(Formatter *f, int flags) const
+{
+  if (flags & DUMP_PATH) {
+    std::string path;
+    make_path_string(path, true);
+    if (path.empty())
+      path = "/";
+    f->dump_string("path", path);
+  }
+
+  if (flags & DUMP_INODE_STORE_BASE)
+    InodeStoreBase::dump(f);
+  
+  if (flags & DUMP_MDS_CACHE_OBJECT)
+    MDSCacheObject::dump(f);
+
+  if (flags & DUMP_LOCKS) {
+    f->open_object_section("versionlock");
+    versionlock.dump(f);
+    f->close_section();
+
+    f->open_object_section("authlock");
+    authlock.dump(f);
+    f->close_section();
+
+    f->open_object_section("linklock");
+    linklock.dump(f);
+    f->close_section();
+
+    f->open_object_section("dirfragtreelock");
+    dirfragtreelock.dump(f);
+    f->close_section();
+
+    f->open_object_section("filelock");
+    filelock.dump(f);
+    f->close_section();
+
+    f->open_object_section("xattrlock");
+    xattrlock.dump(f);
+    f->close_section();
+
+    f->open_object_section("snaplock");
+    snaplock.dump(f);
+    f->close_section();
+
+    f->open_object_section("nestlock");
+    nestlock.dump(f);
+    f->close_section();
+
+    f->open_object_section("flocklock");
+    flocklock.dump(f);
+    f->close_section();
+
+    f->open_object_section("policylock");
+    policylock.dump(f);
     f->close_section();
   }
-  f->close_section();
 
-  f->dump_int("loner", loner_cap.v);
-  f->dump_int("want_loner", want_loner_cap.v);
+  if (flags & DUMP_STATE) {
+    f->open_array_section("states");
+    MDSCacheObject::dump_states(f);
+    if (state_test(STATE_EXPORTING))
+      f->dump_string("state", "exporting");
+    if (state_test(STATE_OPENINGDIR))
+      f->dump_string("state", "openingdir");
+    if (state_test(STATE_FREEZING))
+      f->dump_string("state", "freezing");
+    if (state_test(STATE_FROZEN))
+      f->dump_string("state", "frozen");
+    if (state_test(STATE_AMBIGUOUSAUTH))
+      f->dump_string("state", "ambiguousauth");
+    if (state_test(STATE_EXPORTINGCAPS))
+      f->dump_string("state", "exportingcaps");
+    if (state_test(STATE_NEEDSRECOVER))
+      f->dump_string("state", "needsrecover");
+    if (state_test(STATE_PURGING))
+      f->dump_string("state", "purging");
+    if (state_test(STATE_DIRTYPARENT))
+      f->dump_string("state", "dirtyparent");
+    if (state_test(STATE_DIRTYRSTAT))
+      f->dump_string("state", "dirtyrstat");
+    if (state_test(STATE_STRAYPINNED))
+      f->dump_string("state", "straypinned");
+    if (state_test(STATE_FROZENAUTHPIN))
+      f->dump_string("state", "frozenauthpin");
+    if (state_test(STATE_DIRTYPOOL))
+      f->dump_string("state", "dirtypool");
+    if (state_test(STATE_ORPHAN))
+      f->dump_string("state", "orphan");
+    if (state_test(STATE_MISSINGOBJS))
+      f->dump_string("state", "missingobjs");
+    f->close_section();
+  }
 
-  f->open_array_section("mds_caps_wanted");
-  for (compact_map<int,int>::const_iterator p = mds_caps_wanted.begin();
-       p != mds_caps_wanted.end(); ++p) {
-    f->open_object_section("mds_cap_wanted");
-    f->dump_int("rank", p->first);
-    f->dump_string("cap", ccap_string(p->second));
+  if (flags & DUMP_CAPS) {
+    f->open_array_section("client_caps");
+    for (map<client_t,Capability*>::const_iterator it = client_caps.begin();
+         it != client_caps.end(); ++it) {
+      f->open_object_section("client_cap");
+      f->dump_int("client_id", it->first.v);
+      f->dump_string("pending", ccap_string(it->second->pending()));
+      f->dump_string("issued", ccap_string(it->second->issued()));
+      f->dump_string("wanted", ccap_string(it->second->wanted()));
+      f->dump_int("last_sent", it->second->get_last_sent());
+      f->close_section();
+    }
+    f->close_section();
+
+    f->dump_int("loner", loner_cap.v);
+    f->dump_int("want_loner", want_loner_cap.v);
+
+    f->open_array_section("mds_caps_wanted");
+    for (compact_map<int,int>::const_iterator p = mds_caps_wanted.begin();
+         p != mds_caps_wanted.end(); ++p) {
+      f->open_object_section("mds_cap_wanted");
+      f->dump_int("rank", p->first);
+      f->dump_string("cap", ccap_string(p->second));
+      f->close_section();
+    }
     f->close_section();
   }
-  f->close_section();
 }
 
 /****** Scrub Stuff *****/
index 02edfd443fd5762071067ac1542d7d5f2136c25b..c7ea6ac73f224361640629c6dab49bfec7734ee8 100644 (file)
@@ -196,6 +196,16 @@ class CInode : public MDSCacheObject, public InodeStoreBase, public Counter<CIno
     }
   }
 
+  // -- dump flags --
+  static const int DUMP_INODE_STORE_BASE = (1 << 0);
+  static const int DUMP_MDS_CACHE_OBJECT = (1 << 1);
+  static const int DUMP_LOCKS =            (1 << 2);
+  static const int DUMP_STATE =            (1 << 3);
+  static const int DUMP_CAPS =             (1 << 4);
+  static const int DUMP_PATH =             (1 << 5);
+  static const int DUMP_ALL =              (-1);
+  static const int DUMP_DEFAULT = DUMP_ALL & (~DUMP_PATH);
+
   // -- state --
   static const int STATE_EXPORTING =   (1<<2);   // on nonauth bystander.
   static const int STATE_OPENINGDIR =  (1<<5);
@@ -1096,7 +1106,7 @@ public:
   bool is_exportable(mds_rank_t dest) const;
 
   void print(ostream& out) override;
-  void dump(Formatter *f) const;
+  void dump(Formatter *f, int flags = DUMP_DEFAULT) const;
 
   /**
    * @defgroup Scrubbing and fsck
index 83e52b0421ef8d9e46c3c1d4c9a7fbe11b696869..a8482bde75edb49588f7a1fdc9e00c173a94f1e6 100644 (file)
@@ -5646,13 +5646,8 @@ void MDCache::dump_openfiles(Formatter *f)
       if ((in->last == CEPH_NOSNAP && !in->is_any_caps_wanted())
           || (in->last != CEPH_NOSNAP && in->client_snap_caps.empty())) 
         continue;
-      std::string path;
-      in->make_path_string(path, true);
-      if (path.empty())
-        path = "/"   
       f->open_object_section("file");
-      f->dump_string("path", path);
-      in->dump(f);
+      in->dump(f, CInode::DUMP_PATH | CInode::DUMP_INODE_STORE_BASE | CInode::DUMP_CAPS);
       f->close_section();
     }
   }
index 0914637330dc24be423a4f6cc862517137b1eab7..f05ecb6d3c37dff7ddcccf09396ca52704efa102 100644 (file)
@@ -1178,7 +1178,7 @@ public:
   int dump_cache(const std::string &filename);
   int dump_cache(Formatter *f);
   int dump_cache(const std::string& dump_root, int depth, Formatter *f);
-  
+
   int cache_status(Formatter *f);
 
   void dump_resolve_status(Formatter *f) const;
index 02dc5803056ba7ab811eae408b7f08b2feeab7a0..5579e5abc007bde82ef30359d0d9ea476a437798 100644 (file)
@@ -246,10 +246,6 @@ public:
       return segments[seq];
     return NULL;
   }
-  
-  const std::map<uint64_t,LogSegment*> &get_segments() {
-    return segments;
-  }
 
   bool have_any_segments() const {
     return !segments.empty();