From 93cbee3dd9c1446a027e7673645a1856ea68637a 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 --- 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 40ae4913d8b..5041427465a 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -417,7 +417,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); @@ -4857,7 +4860,6 @@ void CInode::set_export_pin(mds_rank_t rank) ceph_assert(is_dir()); ceph_assert(is_projected()); get_projected_inode()->export_pin = rank; - maybe_export_pin(true); } mds_rank_t CInode::get_export_pin(bool inherit) const @@ -4871,15 +4873,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 8f69ed31d58..aa367b0e336 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -758,6 +758,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; } CDentry* get_projected_parent_dn() { return !projected_parent.empty() ? projected_parent.back() : parent; } diff --git a/src/mds/Server.cc b/src/mds/Server.cc index a26bdd88380..dc953c1db7a 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -6699,8 +6699,6 @@ void Server::_unlink_local(MDRequestRef& mdr, CDentry *dn, CDentry *straydn) if (in->is_dir()) { ceph_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