From fcbf3bfc8d335204117679bbba210363703127f0 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Tue, 11 Apr 2017 17:15:56 +0800 Subject: [PATCH] mds: export subtrees in stray inode to auth mds of its parent inode Signed-off-by: "Yan, Zheng" --- src/mds/MDCache.cc | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index eee9c0a61abe..f157e097a101 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -6460,14 +6460,27 @@ bool MDCache::trim(int max, int count) p != subtrees.end();) { CDir *dir = p->first; ++p; - if (!dir->is_auth() && !dir->get_inode()->is_auth()) { - // don't trim subtree root if its auth MDS is recovering. - // This simplify the cache rejoin code. - if (dir->is_subtree_root() && - rejoin_ack_gather.count(dir->get_dir_auth().first)) - continue; - if (dir->get_num_ref() == 1) // subtree pin + CInode *diri = dir->get_inode(); + if (dir->is_auth()) { + if (!diri->is_auth() && !diri->is_base() && + dir->get_num_head_items() == 0) { + if (dir->state_test(CDir::STATE_EXPORTING) || + dir->is_freezing() || dir->is_frozen()) + continue; + + migrator->export_empty_import(dir); + } + } else { + if (!diri->is_auth()) { + if (dir->get_num_ref() > 1) // only subtree pin + continue; + // don't trim subtree root if its auth MDS is recovering. + // This simplify the cache rejoin code. + if (dir->is_subtree_root() && + rejoin_ack_gather.count(dir->get_dir_auth().first)) + continue; trim_dirfrag(dir, 0, expiremap); + } } } @@ -6629,10 +6642,6 @@ bool MDCache::trim_dentry(CDentry *dn, map& expiremap if (clear_complete) dir->state_clear(CDir::STATE_COMPLETE); - // reexport? - if (dir->get_num_head_items() == 0 && dir->is_subtree_root()) - migrator->export_empty_import(dir); - if (mds->logger) mds->logger->inc(l_mds_inodes_expired); return false; } -- 2.47.3