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: v13.1.0~358^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=436a56a2906fb3a3925cbb081342b4544aef5022;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" --- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index b24c00040f8c..3b3ada4ad2e9 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -7613,20 +7613,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); @@ -7665,6 +7652,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(); @@ -7678,6 +7670,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; @@ -7780,9 +7782,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); }