]> 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)
committerPrashant D <pdhange@redhat.com>
Tue, 19 Mar 2019 23:52:26 +0000 (19:52 -0400)
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>
(cherry picked from commit f3d484b8dff0e522fc056cf71b29422bbb647fc4)

src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h

index d28a98185e3b225498bed5cef9ca4367d6dceaa4..40bf2f4b8a2a803da5d54406c26e8d3c8c57c794 100644 (file)
@@ -13078,3 +13078,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 c8e4f34c6f19e5f04224eefed286f17eddc152c0..536e8e7acc582c2f6058420ed4b84873141bdd4d 100644 (file)
@@ -545,6 +545,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 de118eebd337cad2437c485c20a60fce48abcca4..b0a605957e41d4707d138ea6dd2345e8187c0901 100644 (file)
@@ -328,6 +328,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 bd376ebb43cc4dc39597162f4661e07c21a89dd5..0964f5d57ab2101c2cc1b9c98722636eac74cf11 100644 (file)
@@ -2578,6 +2578,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;
   }
@@ -3000,6 +3002,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 3837536ddfafd3607e3f6663fd19f9d4d00f22bc..1124d405c830f3ec417d140b65b7a8b553a88262 100644 (file)
@@ -485,6 +485,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);
 
     void cache_drop_send_reply(Formatter *f, C_MDS_Send_Command_Reply *reply, int r);
     void command_cache_drop(uint64_t timeout, Formatter *f, Context *on_finish);