]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: queue inodes into MDCache::export_pin_queue after setattr is journaled 25522/head
authorXuehan Xu <xuxuehan@360.cn>
Mon, 19 Nov 2018 06:56:50 +0000 (14:56 +0800)
committerNathan Cutler <ncutler@suse.com>
Wed, 12 Dec 2018 21:41:22 +0000 (22:41 +0100)
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 <xuxuehan@360.cn>
(cherry picked from commit 93cbee3dd9c1446a027e7673645a1856ea68637a)

src/mds/CInode.cc
src/mds/CInode.h
src/mds/Server.cc

index 8ba75de12c816b683c3d699c50b484f7b3c172e7..e8c1bc8bc1e3ece37bf17a1cb156ec83e76a2ddd 100644 (file)
@@ -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;
index 6e2b73b076973c806b106a9c957685d2b3b63d78..c7628fee645548d5bb7dc5c382efebd5a43e1b44 100644 (file)
@@ -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; }
index 04a9e3e386b4364cd19b8c3e16a8cc5c3380f680..7d420e3848644b65a99b8fe0da3c2b3d5e7765bc 100644 (file)
@@ -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));