From 26dd9e82ad1c770fc803dd14f311296e64cd7e98 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Fri, 5 May 2017 11:35:16 +0800 Subject: [PATCH] mds: handle aux subtree when splitting/merging dirfrag Signed-off-by: "Yan, Zheng" --- src/mds/CDir.cc | 14 +++++++++++--- src/mds/CDir.h | 1 + src/mds/MDCache.cc | 5 ++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index cf82a57a45c..9ffe8f1db4a 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1012,7 +1012,16 @@ void CDir::merge(list& subs, list& waiters, bool { dout(10) << "merge " << subs << dendl; - set_dir_auth(subs.front()->get_dir_auth()); + mds_authority_t new_auth = CDIR_AUTH_DEFAULT; + for (auto dir : subs) { + if (dir->get_dir_auth() != CDIR_AUTH_DEFAULT || + dir->get_dir_auth() != new_auth) { + assert(new_auth == CDIR_AUTH_DEFAULT); + new_auth = dir->get_dir_auth(); + } + } + + set_dir_auth(new_auth); prepare_new_fragment(replay); nest_info_t rstatdiff; @@ -1021,8 +1030,7 @@ void CDir::merge(list& subs, list& waiters, bool version_t rstat_version = inode->get_projected_inode()->rstat.version; version_t dirstat_version = inode->get_projected_inode()->dirstat.version; - for (list::iterator p = subs.begin(); p != subs.end(); ++p) { - CDir *dir = *p; + for (auto dir : subs) { dout(10) << " subfrag " << dir->get_frag() << " " << *dir << dendl; assert(!dir->is_auth() || dir->is_complete() || replay); diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 447ca3cb8a6..4a788b0cb26 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -137,6 +137,7 @@ public: (STATE_DIRTY| STATE_EXPORTBOUND | STATE_IMPORTBOUND | + STATE_AUXSUBTREE | STATE_REJOINUNDEF); // -- rep spec -- diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 4954fdc22ea..b9057a7ebe9 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -10631,8 +10631,10 @@ void MDCache::adjust_dir_fragments(CInode *diri, subtrees[parent_subtree].erase(dir); for (list::iterator p = resultfrags.begin(); p != resultfrags.end(); - ++p) + ++p) { + assert((*p)->is_subtree_root()); subtrees[parent_subtree].insert(*p); + } } // adjust my bounds. @@ -10686,6 +10688,7 @@ void MDCache::adjust_dir_fragments(CInode *diri, diri->add_dirfrag(f); if (was_subtree) { + assert(f->is_subtree_root()); subtrees[f].swap(new_bounds); if (parent_subtree) subtrees[parent_subtree].insert(f); -- 2.39.5