From: Yan, Zheng Date: Mon, 2 Apr 2018 03:26:22 +0000 (+0800) Subject: mds: make stopping mds export strays and subtree at the same time X-Git-Tag: v12.2.6~146^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=abaabece23dc21e7710b02f876fbb78e020ee176;p=ceph.git mds: make stopping mds export strays and subtree at the same time Stopping mds also handle client requests now. Client requests may continue to create strays dentries. So mds should start to export auth subtrees immediately after its state transits to 'stopping' Signed-off-by: "Yan, Zheng" (cherry picked from commit 436a56a2906fb3a3925cbb081342b4544aef5022) --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index f58ae770d3d7..5ae6f347159a 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7510,20 +7510,7 @@ bool MDCache::shutdown_pass() } // empty stray dir - if (!shutdown_export_strays()) { - dout(7) << "waiting for strays to migrate" << dendl; - return false; - } - - // drop our reference to our stray dir inode - for (int i = 0; i < NUM_STRAY; ++i) { - if (strays[i] && - strays[i]->state_test(CInode::STATE_STRAYPINNED)) { - strays[i]->state_clear(CInode::STATE_STRAYPINNED); - strays[i]->put(CInode::PIN_STRAY); - strays[i]->put_stickydirs(); - } - } + bool strays_all_exported = shutdown_export_strays(); // trim cache trim(UINT64_MAX); @@ -7562,6 +7549,11 @@ bool MDCache::shutdown_pass() } } + if (!strays_all_exported) { + dout(7) << "waiting for strays to migrate" << dendl; + return false; + } + if (num_auth_subtree > 0) { dout(7) << "still have " << num_auth_subtree << " auth subtrees" << dendl; show_subtrees(); @@ -7575,6 +7567,16 @@ bool MDCache::shutdown_pass() return false; } + // drop our reference to our stray dir inode + for (int i = 0; i < NUM_STRAY; ++i) { + if (strays[i] && + strays[i]->state_test(CInode::STATE_STRAYPINNED)) { + strays[i]->state_clear(CInode::STATE_STRAYPINNED); + strays[i]->put(CInode::PIN_STRAY); + strays[i]->put_stickydirs(); + } + } + CDir *mydir = myin ? myin->get_dirfrag(frag_t()) : NULL; if (mydir && !mydir->is_subtree_root()) mydir = NULL; @@ -7677,9 +7679,9 @@ bool MDCache::shutdown_export_strays() list dfs; for (int i = 0; i < NUM_STRAY; ++i) { - if (!strays[i]) { + if (!strays[i] || + !strays[i]->state_test(CInode::STATE_STRAYPINNED)) continue; - } strays[i]->get_dirfrags(dfs); }