]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: explicitly output error msg for dump cache asok command 15592/head
authorZhi Zhang <willzzhang@tencent.com>
Fri, 9 Jun 2017 06:39:00 +0000 (14:39 +0800)
committerZhi Zhang <willzzhang@tencent.com>
Mon, 12 Jun 2017 02:42:58 +0000 (10:42 +0800)
Signed-off-by: Zhi Zhang <zhangz.david@outlook.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSRank.cc

index b03e0ac4aae595b2e5e43d27b7c993a8b902582f..cc9553a943d4a66f549a7d9a4df9d22c624598ac 100644 (file)
@@ -11844,26 +11844,26 @@ void MDCache::show_cache()
   }
 }
 
-void MDCache::dump_cache(std::string const &file_name)
+int MDCache::dump_cache(std::string const &file_name)
 {
-  dump_cache(file_name.c_str(), NULL);
+  return dump_cache(file_name.c_str(), NULL);
 }
 
-void MDCache::dump_cache(Formatter *f)
+int MDCache::dump_cache(Formatter *f)
 {
-  dump_cache(NULL, f);
+  return dump_cache(NULL, f);
 }
 
-void MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
+int MDCache::dump_cache(const string& dump_root, int depth, Formatter *f)
 {
-  dump_cache(NULL, f, dump_root, depth);
+  return dump_cache(NULL, f, dump_root, depth);
 }
 
 /**
  * Dump the metadata cache, either to a Formatter, if
  * provided, else to a plain text file.
  */
-void MDCache::dump_cache(const char *fn, Formatter *f,
+int MDCache::dump_cache(const char *fn, Formatter *f,
                         const string& dump_root, int depth)
 {
   int r = 0;
@@ -11883,7 +11883,7 @@ void MDCache::dump_cache(const char *fn, Formatter *f,
     fd = ::open(fn, O_WRONLY|O_CREAT|O_EXCL, 0600);
     if (fd < 0) {
       derr << "failed to open " << fn << ": " << cpp_strerror(errno) << dendl;
-      return;
+      return errno;
     }
   }
 
@@ -11985,6 +11985,7 @@ void MDCache::dump_cache(const char *fn, Formatter *f,
   } else {
     ::close(fd);
   }
+  return r;
 }
 
 
index ca3cdff76d9860e78d48b187e6219cb0557c0757..c38f0ed0b9f406e3683246caef67ffe9422e57de 100644 (file)
@@ -1116,14 +1116,14 @@ public:
   void discard_delayed_expire(CDir *dir);
 
 protected:
-  void dump_cache(const char *fn, Formatter *f,
+  int dump_cache(const char *fn, Formatter *f,
                  const std::string& dump_root = "",
                  int depth = -1);
 public:
-  void dump_cache() {dump_cache(NULL, NULL);}
-  void dump_cache(const std::string &filename);
-  void dump_cache(Formatter *f);
-  void dump_cache(const std::string& dump_root, int depth, Formatter *f);
+  int dump_cache() { return dump_cache(NULL, NULL); }
+  int dump_cache(const std::string &filename);
+  int dump_cache(Formatter *f);
+  int dump_cache(const std::string& dump_root, int depth, Formatter *f);
 
   void dump_resolve_status(Formatter *f) const;
   void dump_rejoin_status(Formatter *f) const;
index ff3fcbc64c6c0acd24f202cf4ea7cf0dd34d2d88..6d75054adcfb9966260ba10ae3659d2076ef97be 100644 (file)
@@ -1919,10 +1919,15 @@ bool MDSRankDispatcher::handle_asok_command(
   } else if (command == "dump cache") {
     Mutex::Locker l(mds_lock);
     string path;
+    int r;
     if(!cmd_getval(g_ceph_context, cmdmap, "path", path)) {
-      mdcache->dump_cache(f);
+      r = mdcache->dump_cache(f);
     } else {
-      mdcache->dump_cache(path);
+      r = mdcache->dump_cache(path);
+    }
+
+    if (r != 0) {
+      ss << "Failed to dump cache: " << cpp_strerror(r);
     }
   } else if (command == "dump tree") {
     string root;
@@ -1932,7 +1937,10 @@ bool MDSRankDispatcher::handle_asok_command(
       depth = -1;
     {
       Mutex::Locker l(mds_lock);
-      mdcache->dump_cache(root, depth, f);
+      int r = mdcache->dump_cache(root, depth, f);
+      if (r != 0) {
+        ss << "Failed to dump tree: " << cpp_strerror(r);
+      }
     }
   } else if (command == "force_readonly") {
     Mutex::Locker l(mds_lock);