From cb95482a3021d821159f8ec931dc330baececcb3 Mon Sep 17 00:00:00 2001 From: Xuehan Xu Date: Mon, 19 Nov 2018 14:56:50 +0800 Subject: [PATCH] mds: queue inodes into MDCache::export_pin_queue after setattr is journaled This makes sure that, when doing inodes' migration, their "export_pin" is indeed the mds it should be pinned to. Fixes: http://tracker.ceph.com/issues/37368 Signed-off-by: Xuehan Xu (cherry picked from commit 93cbee3dd9c1446a027e7673645a1856ea68637a) --- src/mds/CInode.cc | 13 +++++++------ src/mds/CInode.h | 1 + src/mds/Server.cc | 2 -- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 8ba75de12c81..e8c1bc8bc1e3 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -420,7 +420,10 @@ void CInode::pop_and_dirty_projected_inode(LogSegment *ls) int64_t old_pool = inode.layout.pool_id; mark_dirty(front.inode.version, ls); + bool new_export_pin = inode.export_pin != front.inode.export_pin; inode = front.inode; + if (new_export_pin) + maybe_export_pin(true); if (inode.is_backtrace_updated()) mark_dirty_parent(ls, old_pool != inode.layout.pool_id); @@ -4514,7 +4517,6 @@ void CInode::set_export_pin(mds_rank_t rank) assert(is_dir()); assert(is_projected()); get_projected_inode()->export_pin = rank; - maybe_export_pin(true); } mds_rank_t CInode::get_export_pin(bool inherit) const @@ -4528,15 +4530,14 @@ mds_rank_t CInode::get_export_pin(bool inherit) const while (true) { if (in->is_system()) break; - const CDentry *pdn = in->get_projected_parent_dn(); + const CDentry *pdn = in->get_parent_dn(); if (!pdn) break; - const mempool_inode *pi = in->get_projected_inode(); // ignore export pin for unlinked directory - if (pi->nlink == 0) + if (in->get_inode().nlink == 0) break; - if (pi->export_pin >= 0) - return pi->export_pin; + if (in->get_inode().export_pin >= 0) + return in->get_inode().export_pin; if (!inherit) break; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 6e2b73b07697..c7628fee6455 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -736,6 +736,7 @@ public: int d_type() const { return IFTODT(inode.mode); } mempool_inode& get_inode() { return inode; } + const mempool_inode& get_inode() const { return inode; } CDentry* get_parent_dn() { return parent; } const CDentry* get_parent_dn() const { return parent; } const CDentry* get_projected_parent_dn() const { return !projected_parent.empty() ? projected_parent.back() : parent; } diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 04a9e3e386b4..7d420e384864 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -6158,8 +6158,6 @@ void Server::_unlink_local(MDRequestRef& mdr, CDentry *dn, CDentry *straydn) if (in->is_dir()) { assert(straydn); mdcache->project_subtree_rename(in, dn->get_dir(), straydn->get_dir()); - - in->maybe_export_pin(true); } journal_and_reply(mdr, 0, dn, le, new C_MDS_unlink_local_finish(this, mdr, dn, straydn)); -- 2.47.3