]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: forbid fragmenting dirfrag while scrub in progress 8180/head
authorYan, Zheng <zyan@redhat.com>
Fri, 18 Mar 2016 02:16:37 +0000 (10:16 +0800)
committerYan, Zheng <zyan@redhat.com>
Fri, 18 Mar 2016 02:16:37 +0000 (10:16 +0800)
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/CInode.cc
src/mds/CInode.h
src/mds/MDCache.cc

index 28a1b1a240e9c85a9dbd243ad205ab017528dc4a..423be9689301941ad01a3ab2c7d8dfe5e46b7ccc 100644 (file)
@@ -4173,12 +4173,10 @@ void CInode::scrub_initialize(CDentry *scrub_parent,
                              MDSInternalContextBase *f)
 {
   dout(20) << __func__ << " with scrub_version " << get_version() << dendl;
-  assert(!scrub_infop || !scrub_infop->scrub_in_progress);
+  assert(!scrub_is_in_progress());
   scrub_info();
   if (!scrub_infop)
     scrub_infop = new scrub_info_t();
-  else
-    assert(!scrub_infop->scrub_in_progress);
 
   if (get_projected_inode()->is_dir()) {
     // fill in dirfrag_stamps with initial state
@@ -4210,7 +4208,7 @@ void CInode::scrub_initialize(CDentry *scrub_parent,
 int CInode::scrub_dirfrag_next(frag_t* out_dirfrag)
 {
   dout(20) << __func__ << dendl;
-  assert(scrub_infop && scrub_infop->scrub_in_progress);
+  assert(scrub_is_in_progress());
 
   if (!is_dir()) {
     return -ENOTDIR;
@@ -4258,7 +4256,7 @@ void CInode::scrub_dirfrags_scrubbing(list<frag_t>* out_dirfrags)
 void CInode::scrub_dirfrag_finished(frag_t dirfrag)
 {
   dout(20) << __func__ << " on frag " << dirfrag << dendl;
-  assert(scrub_infop && scrub_infop->scrub_in_progress);
+  assert(scrub_is_in_progress());
 
   std::map<frag_t, scrub_stamp_info_t>::iterator i =
       scrub_infop->dirfrag_stamps.find(dirfrag);
@@ -4271,7 +4269,7 @@ void CInode::scrub_dirfrag_finished(frag_t dirfrag)
 
 void CInode::scrub_finished(MDSInternalContextBase **c) {
   dout(20) << __func__ << dendl;
-  assert(scrub_info()->scrub_in_progress);
+  assert(scrub_is_in_progress());
   for (std::map<frag_t, scrub_stamp_info_t>::iterator i =
       scrub_infop->dirfrag_stamps.begin();
       i != scrub_infop->dirfrag_stamps.end();
index 5ff343a013f685377bf5ddb399b45fbce9e86a09..c3fe65aaaff00b59fcc36b0e3458d930d02b8e21 100644 (file)
@@ -288,6 +288,10 @@ public:
       scrub_info_create();
     return scrub_infop;
   }
+
+  bool scrub_is_in_progress() const {
+    return (scrub_infop && scrub_infop->scrub_in_progress);
+  }
   /**
    * Start scrubbing on this inode. That could be very short if it's
    * a file, or take a long time if we're recursively scrubbing a directory.
index 9eec056905c77e51c7ff6e97c4bc02739b4d8fd1..d9e59018f618c5059ae479472feddab8fe8836e5 100644 (file)
@@ -10569,6 +10569,11 @@ bool MDCache::can_fragment(CInode *diri, list<CDir*>& dirs)
     return false;
   }
 
+  if (diri->scrub_is_in_progress()) {
+    dout(7) << "can_fragment: scrub in progress" << dendl;
+    return false;
+  }
+
   for (list<CDir*>::iterator p = dirs.begin(); p != dirs.end(); ++p) {
     CDir *dir = *p;
     if (dir->state_test(CDir::STATE_FRAGMENTING)) {