]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix handling missing mydir dirfrag 4715/head
authorJohn Spray <john.spray@redhat.com>
Mon, 18 May 2015 15:15:07 +0000 (16:15 +0100)
committerJohn Spray <john.spray@redhat.com>
Mon, 18 May 2015 15:15:07 +0000 (16:15 +0100)
This was broken by 96992466 aka "mds: handle missing mydir dirfrag"

The previous code was mistakenly treating a not-yet-loaded
dirfrag as a non-existent dirfrag, resulting in
inconsistent fragstats even when no objects had
actually been lost.

Fixes: #11641
Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/MDCache.cc

index fbcbbb7c53ae0a45c9886b23b0f26f6971bf971d..0a1596a7278e6ef8ce598866f669545593b37d29 100644 (file)
@@ -638,19 +638,22 @@ void MDCache::populate_mydir()
 
   dout(10) << "populate_mydir " << *mydir << dendl;
 
-  if (mydir->get_version() == 0) {
-    // A fresh dirfrag, we must dirty it before dirtying
-    // any of the strays we create within it.
+  if (!mydir->is_complete()) {
+    mydir->fetch(new C_MDS_RetryOpenRoot(this));
+    return;
+  }
+
+  if (mydir->get_version() == 0 && mydir->state_test(CDir::STATE_BADFRAG)) {
+    // A missing dirfrag, we will recreate it.  Before that, we must dirty
+    // it before dirtying any of the strays we create within it.
+    mds->clog->warn() << "fragment " << mydir->dirfrag() << " was unreadable, "
+      "recreating it now";
     LogSegment *ls = mds->mdlog->get_current_segment();
+    mydir->state_clear(CDir::STATE_BADFRAG);
     mydir->mark_complete();
     mydir->mark_dirty(mydir->pre_dirty(), ls);
   }
 
-  if (!mydir->is_complete()) {
-    mydir->fetch(new C_MDS_RetryOpenRoot(this));
-    return;
-  }    
-
   // open or create stray
   for (int i = 0; i < NUM_STRAY; ++i) {
     stringstream name;