From: Yan, Zheng Date: Thu, 1 May 2014 21:22:35 +0000 (+0800) Subject: mds: remove mdsdir in the final step of shutdown MDS X-Git-Tag: v0.80~5^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e597068b4d5d3455b79db25d0a2bb80a87c03cd2;p=ceph.git mds: remove mdsdir in the final step of shutdown MDS Otherwise we may get bad subtree map if we restart the MDS before the shutdown process finishes. Signed-off-by: Yan, Zheng --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 49f33080f5bf..71a4b3383f47 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7289,17 +7289,12 @@ bool MDCache::shutdown_pass() return false; } - // make mydir subtree go away - if (myin) { - CDir *mydir = myin->get_dirfrag(frag_t()); - if (mydir && mydir->is_subtree_root()) { - adjust_subtree_auth(mydir, CDIR_AUTH_UNKNOWN); - remove_subtree(mydir); - } - } - + CDir *mydir = myin ? myin->get_dirfrag(frag_t()) : NULL; + if (mydir && !mydir->is_subtree_root()) + mydir = NULL; + // subtrees map not empty yet? - if (!subtrees.empty()) { + if (subtrees.size() > (mydir ? 1 : 0)) { dout(7) << "still have " << num_subtrees() << " subtrees" << dendl; show_subtrees(); migrator->show_importing(); @@ -7308,10 +7303,16 @@ bool MDCache::shutdown_pass() show_cache(); return false; } - assert(subtrees.empty()); assert(!migrator->is_exporting()); assert(!migrator->is_importing()); + // make mydir subtree go away + if (mydir) { + adjust_subtree_auth(mydir, CDIR_AUTH_UNKNOWN); + remove_subtree(mydir); + } + assert(subtrees.empty()); + // (only do this once!) if (!mds->mdlog->is_capped()) { dout(7) << "capping the log" << dendl;