From 383d521af3d9135fec65b488942b099344dfceb1 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Fri, 5 May 2017 19:10:27 -0400 Subject: [PATCH] mds: handle export pin on unjournaled directory Signed-off-by: Patrick Donnelly --- src/mds/CDir.cc | 13 ++++--------- src/mds/CInode.cc | 13 ++++++++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 979b8caae5c19..cf82a57a45ccc 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -1231,10 +1231,7 @@ void CDir::add_waiter(uint64_t tag, MDSInternalContextBase *c) } } - if (tag & WAIT_CREATED) { - assert(state_test(STATE_CREATING)); - assert(state_test(STATE_FRAGMENTING)); - } + assert(!(tag & WAIT_CREATED) || state_test(STATE_CREATING)); MDSCacheObject::add_waiter(tag, c); } @@ -1349,11 +1346,9 @@ void CDir::mark_new(LogSegment *ls) ls->new_dirfrags.push_back(&item_new); state_clear(STATE_CREATING); - if (state_test(CDir::STATE_FRAGMENTING)) { - list ls; - take_waiting(CDir::WAIT_CREATED, ls); - cache->mds->queue_waiters(ls); - } + list waiters; + take_waiting(CDir::WAIT_CREATED, waiters); + cache->mds->queue_waiters(waiters); } void CDir::mark_clean() diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 4566d7885c7fd..50ff269f67e96 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -4417,14 +4417,21 @@ private: void CInode::maybe_export_pin() { if (g_conf->mds_bal_export_pin && is_dir() && is_normal()) { - dout(20) << "maybe_export_pin " << *this << dendl; - mds_rank_t pin = get_projected_inode()->export_pin; + mds_rank_t pin = get_export_pin(false); + dout(20) << "maybe_export_pin export_pin=" << pin << " on " << *this << dendl; if (pin == mdcache->mds->get_nodeid()) { for (auto it = dirfrags.begin(); it != dirfrags.end(); it++) { CDir *cd = it->second; + dout(20) << "dirfrag: " << *cd << dendl; + if (cd->state_test(CDir::STATE_CREATING)) { + /* inode is not journaled yet */ + cd->add_waiter(CDir::WAIT_CREATED, new C_CInode_ExportPin(this)); + dout(15) << "aux subtree pin of " << *cd << " delayed for finished creation" << dendl; + continue; + } if (cd->state_test(CDir::STATE_AUXSUBTREE)) continue; CDir *subtree = mdcache->get_subtree_root(cd); - if (!subtree) continue; + assert(subtree); if (subtree->is_ambiguous_auth()) { subtree->add_waiter(MDSCacheObject::WAIT_SINGLEAUTH, new C_CInode_ExportPin(this)); dout(15) << "aux subtree pin of " << *cd << " delayed for single auth on subtree " << *subtree << dendl; -- 2.39.5