From 9ed491989a95b58ca583d7caf1cdc5a6ebd5f2a6 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 18 May 2015 16:15:07 +0100 Subject: [PATCH] mds: fix handling missing mydir dirfrag 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 --- src/mds/MDCache.cc | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index fbcbbb7c53a..0a1596a7278 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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; -- 2.47.3