]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add dump inode command
authortaodd <tdd21151186@gmail.com>
Thu, 14 Jun 2018 13:13:46 +0000 (21:13 +0800)
committertaodd <tdd21151186@gmail.com>
Fri, 15 Jun 2018 05:24:09 +0000 (13:24 +0800)
dump inode with an specific inode number
this is useful when we only known the inode number.

Signed-off-by: dongdong tao <tdd21151186@gmail.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h

index 43628c36655eefe9db747f59780c0fa869a27f8b..26d76c52a098b8aa67dafcd2c1ee4cb7f5c60d03 100644 (file)
@@ -12829,3 +12829,13 @@ void MDCache::clear_dirty_bits_for_stray(CInode* diri) {
   }
 }
 
+bool MDCache::dump_inode(Formatter *f, uint64_t number) {
+  CInode *in = get_inode(number);
+  if (!in) {
+    return false;
+  }
+  f->open_object_section("inode");
+  in->dump(f, CInode::DUMP_DEFAULT | CInode::DUMP_PATH);
+  f->close_section();
+  return true;
+}
index 1b2379d7816b5f35eaddbaeecf3bfb5e34fa9371..cfe656a803b12d7853579f054ea70acfe695b005 100644 (file)
@@ -543,6 +543,7 @@ public:
 
   void clean_open_file_lists();
   void dump_openfiles(Formatter *f);
+  bool dump_inode(Formatter *f, uint64_t number);
 protected:
   // [rejoin]
   bool rejoins_pending;
index 0bc7cf68d911342cf1a35de714bc9f30e7f0dd98..c40a3cb00683e6bc6e63542311031b440d0a1e76 100644 (file)
@@ -323,6 +323,12 @@ void MDSDaemon::set_up_admin_socket()
                                      asok_hook,
                                      "List the opening files and their caps");
   assert(r == 0);
+  r = admin_socket->register_command("dump inode",
+                                    "dump inode " 
+                                     "name=number,type=CephInt,req=true",
+                                    asok_hook,
+                                    "dump inode by inode number");
+  assert(r == 0);
 }
 
 void MDSDaemon::clean_up_admin_socket()
index 10cfc04a2143e4a78b5753611ad4685e53490d3e..22112143def01e41e01206728244fd6a1f9a898a 100644 (file)
@@ -2127,6 +2127,8 @@ bool MDSRankDispatcher::handle_asok_command(std::string_view command,
     command_dirfrag_ls(cmdmap, ss, f);
   } else if (command == "openfiles ls") {
     command_openfiles_ls(f);
+  } else if (command == "dump inode") {
+    command_dump_inode(f, cmdmap, ss);
   } else {
     return false;
   }
@@ -2657,6 +2659,22 @@ void MDSRank::command_openfiles_ls(Formatter *f)
   mdcache->dump_openfiles(f);
 }
 
+void MDSRank::command_dump_inode(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss)
+{
+  Mutex::Locker l(mds_lock);
+  int64_t number;
+  bool got = cmd_getval(g_ceph_context, cmdmap, "number", number);
+  if (!got) {
+    ss << "missing inode number";
+    return;
+  }
+  
+  bool success = mdcache->dump_inode(f, number);
+  if (!success) {
+    ss << "dump inode failed, wrong inode number or the inode is not cached";
+  }
+}
+
 void MDSRank::dump_status(Formatter *f) const
 {
   if (state == MDSMap::STATE_REPLAY ||
index 60a624bebf86e9867b7f3df60d636a9e3ac7272d..69a40ce3fda22723ef78aea1ee7ba5f4b67318dc 100644 (file)
@@ -464,6 +464,7 @@ class MDSRank {
         std::ostream &ss);
     void command_openfiles_ls(Formatter *f);
     void command_dump_tree(const cmdmap_t &cmdmap, std::ostream &ss, Formatter *f);
+    void command_dump_inode(Formatter *f, const cmdmap_t &cmdmap, std::ostream &ss);
 
   protected:
     Messenger    *messenger;