]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: queue inodes into MDCache::export_pin_queue after setattr is journaled 25220/head
authorXuehan Xu <xuxuehan@360.cn>
Mon, 19 Nov 2018 06:56:50 +0000 (14:56 +0800)
committerXuehan Xu <xuxuehan@360.cn>
Tue, 27 Nov 2018 02:06:07 +0000 (10:06 +0800)
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>
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Server.cc

index 40ae4913d8b57d924d94f7f3e8f210d19af6b220..5041427465a82cd6eec355de2a6eae522915c143 100644 (file)
@@ -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;
index 8f69ed31d585e11d59cec5e4cf54454a8d18f93b..aa367b0e33616613600d795168e58b7edf996848 100644 (file)
@@ -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; }
index a26bdd88380797ae3b1077568b544fb431701926..dc953c1db7a6fd730964858fc0741d5a7c4563a9 100644 (file)
@@ -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));