]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: and 'recursive/repair' options to scrub_path asok command
authorYan, Zheng <zyan@redhat.com>
Fri, 11 Dec 2015 13:56:15 +0000 (21:56 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 7 Mar 2016 07:59:13 +0000 (15:59 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/MDSRank.h
src/mds/ScrubHeader.h
src/mds/ScrubStack.cc

index f49970046e370ffbed2c79c130d71185e3665135..ec4b80ce31bdd2065985328717c9f74e1055d19e 100644 (file)
@@ -3088,7 +3088,9 @@ bool CDir::scrub_local()
     scrub_infop->last_local.time = ceph_clock_now(g_ceph_context);
     scrub_infop->last_local.version = get_projected_version();
     scrub_infop->last_scrub_dirty = true;
-  } else {
+  } else if (inode->scrub_infop &&
+            inode->scrub_infop->header &&
+            inode->scrub_infop->header->repair) {
     cache->repair_dirfrag_stats(this, NULL);
   }
   return rval;
index 52ff4827db502cdbbc8b745e3783b79d4e834f79..ad4ee4529ead11794c923d7915d711c5d86717e2 100644 (file)
@@ -3942,7 +3942,10 @@ next:
          !nest_info.same_sums(in->inode.rstat)) {
         results->raw_stats.error_str
          << "freshly-calculated rstats don't match existing ones";
-       in->mdcache->repair_inode_stats(in, NULL);
+       if (in->scrub_infop &&
+           in->scrub_infop->header &&
+           in->scrub_infop->header->repair)
+         in->mdcache->repair_inode_stats(in, NULL);
        goto next;
       }
       results->raw_stats.passed = true;
index 2626ec08940375f18b907a82ec03841fae03c029..bdadc6d1f7168f33628cc2901de6930f8d0d84bf 100644 (file)
@@ -11707,7 +11707,7 @@ public:
 void MDCache::enqueue_scrub(
     const string& path,
     const std::string &tag,
-    bool recursive,
+    bool recursive, bool repair,
     Formatter *f, Context *fin)
 {
   dout(10) << __func__ << path << dendl;
@@ -11719,6 +11719,7 @@ void MDCache::enqueue_scrub(
   ScrubHeaderRef &header = cs->header;
   header->tag = tag;
   header->recursive = recursive;
+  header->repair = repair;
   header->formatter = f;
 
   mdr->internal_op_finish = cs;
index 30a382a49c10101a28bdbc2dde0399869cbc7422..b6d1253dea90547710e61f86728ca1eb12340bc4 100644 (file)
@@ -1149,7 +1149,7 @@ public:
    * Create and start an OP_ENQUEUE_SCRUB
    */
   void enqueue_scrub(const string& path, const std::string &tag,
-                     bool recursive, Formatter *f, Context *fin);
+                     bool recursive, bool repair, Formatter *f, Context *fin);
   void repair_inode_stats(CInode *diri, Context *fin);
   void repair_dirfrag_stats(CDir *dir, Context *fin);
 };
index 6a50659b48fee6dee2ecddfdc945029640a8b022..3451819382e41666e6740a019e1a31880a50eb97 100644 (file)
@@ -246,7 +246,8 @@ void MDSDaemon::set_up_admin_socket()
                                     "show slowest recent ops");
   assert(r == 0);
   r = admin_socket->register_command("scrub_path",
-                                     "scrub_path name=path,type=CephString",
+                                    "scrub_path name=path,type=CephString "
+                                    "name=scrubops,type=CephChoices,strings=recursive|repair,n=N,req=false",
                                      asok_hook,
                                      "scrub an inode and output results");
   assert(r == 0);
index 42315fffeced5db275436c75859cdc7d0f7635c0..7256fec47d26558a173daabea894f88b441b5d51 100644 (file)
@@ -1734,8 +1734,10 @@ bool MDSRankDispatcher::handle_asok_command(
     }
   } else if (command == "scrub_path") {
     string path;
+    vector<string> scrubop_vec;
+    cmd_getval(g_ceph_context, cmdmap, "scrubops", scrubop_vec);
     cmd_getval(g_ceph_context, cmdmap, "path", path);
-    command_scrub_path(f, path);
+    command_scrub_path(f, path, scrubop_vec);
   } else if (command == "tag path") {
     string path;
     cmd_getval(g_ceph_context, cmdmap, "path", path);
@@ -1874,12 +1876,20 @@ void MDSRankDispatcher::dump_sessions(const SessionFilter &filter, Formatter *f)
   f->close_section(); //sessions
 }
 
-void MDSRank::command_scrub_path(Formatter *f, const string& path)
+void MDSRank::command_scrub_path(Formatter *f, const string& path, vector<string>& scrubop_vec)
 {
+  bool recursive = false;
+  bool repair = false;
+  for (vector<string>::iterator i = scrubop_vec.begin() ; i != scrubop_vec.end(); ++i) {
+    if (*i == "recursive")
+      recursive = true;
+    else if (*i == "repair")
+      repair = true;
+  }
   C_SaferCond scond;
   {
     Mutex::Locker l(mds_lock);
-    mdcache->enqueue_scrub(path, "", false, f, &scond);
+    mdcache->enqueue_scrub(path, "", recursive, repair, f, &scond);
   }
   scond.wait();
   // scrub_dentry() finishers will dump the data for us; we're done!
@@ -1891,7 +1901,7 @@ void MDSRank::command_tag_path(Formatter *f,
   C_SaferCond scond;
   {
     Mutex::Locker l(mds_lock);
-    mdcache->enqueue_scrub(path, tag, true, f, &scond);
+    mdcache->enqueue_scrub(path, tag, true, false, f, &scond);
   }
   scond.wait();
 }
index a11f3b943eac813278d01fd3a569fb810fdaf70a..e4f4f1dfe28ef41db1917d4bebdb850756580bcc 100644 (file)
@@ -364,7 +364,7 @@ class MDSRank {
 
   protected:
     void dump_clientreplay_status(Formatter *f) const;
-    void command_scrub_path(Formatter *f, const string& path);
+    void command_scrub_path(Formatter *f, const string& path, vector<string>& scrubop_vec);
     void command_tag_path(Formatter *f, const string& path,
                           const string &tag);
     void command_flush_path(Formatter *f, const string& path);
index 46783ed680f93ec85ffd75572ca30ba8e9bb7072..35d355695e31df2a4d467ffa98bc0ec3e0d18647 100644 (file)
@@ -17,6 +17,7 @@ public:
   std::string tag;
 
   bool recursive;
+  bool repair;
   Formatter *formatter;
 };
 typedef ceph::shared_ptr<ScrubHeader> ScrubHeaderRef;
index f99b3ed6035eb00e2b0e14151161e6c928ece31f..158d6735d1fbd55f417c343c21e85c2bf5261694 100644 (file)
@@ -227,11 +227,6 @@ void ScrubStack::scrub_dir_dentry(CDentry *dn,
   if (all_frags_done) {
     assert (!*added_children); // can't do this if children are still pending
 
-    if (!dn->scrub_info()->on_finish) {
-      scrubs_in_progress++;
-      dn->scrub_set_finisher(&scrub_kick);
-    }
-
     // OK, so now I can... fire off a validate on the dir inode, and
     // when it completes, come through here again, noticing that we've
     // set a flag to indicate the the validate happened, and 
@@ -301,6 +296,11 @@ void ScrubStack::scrub_dir_dentry_final(CDentry *dn)
   // FIXME: the magic-constructing scrub_info() is going to leave
   // an unneeded scrub_infop lying around here
   if (!dn->scrub_info()->dentry_children_done) {
+    if (!dn->scrub_info()->on_finish) {
+      scrubs_in_progress++;
+      dn->scrub_set_finisher(&scrub_kick);
+    }
+
     dn->scrub_children_finished();
     CInode *in = dn->get_projected_inode();
     C_InodeValidated *fin = new C_InodeValidated(mdcache->mds, this, dn);