]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: don't reintegrate stray inode to remote snap dentry
authorYan, Zheng <zyan@redhat.com>
Mon, 4 May 2015 06:41:37 +0000 (14:41 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 4 May 2015 09:34:11 +0000 (17:34 +0800)
stray inode are head inodes, we should not rename them to remote
snaps dentries.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/mds/MDCache.cc
src/mds/StrayManager.cc

index 041c691b3a3ad6cddadc72b75d4daa866119dde4..98ce2f9646e838af3fcbfed74afef5f66b9336b3 100644 (file)
@@ -9123,7 +9123,7 @@ void MDCache::scan_stray_dir(dirfrag_t next)
 void MDCache::eval_remote(CDentry *remote_dn)
 {
   assert(remote_dn);
-  dout(10) << "eval_remote " << *remote_dn << dendl;
+  dout(10) << __func__ << " " << *remote_dn << dendl;
 
   CDentry::linkage_t *dnl = remote_dn->get_projected_linkage();
   assert(dnl->is_remote());
@@ -9134,6 +9134,11 @@ void MDCache::eval_remote(CDentry *remote_dn)
     return;
   }
 
+  if (remote_dn->last != CEPH_NOSNAP) {
+    dout(20) << __func__ << ": snap dentry, cannot evaluate" << dendl;
+    return;
+  }
+
   // refers to stray?
   CDentry *primary_dn = in->get_projected_parent_dn();
   assert(primary_dn != NULL);
index 3af6078a86193c5f32aa27e5458cfe695b69dd39..4ca33e8427e34d3f350d1f36d4a8d52e3ec0a042 100644 (file)
@@ -637,23 +637,29 @@ void StrayManager::eval_remote_stray(CDentry *stray_dn, CDentry *remote_dn)
 {
   assert(stray_dn != NULL);
   assert(stray_dn->get_dir()->get_inode()->is_stray());
+  CDentry::linkage_t *stray_dnl = stray_dn->get_projected_linkage();
+  assert(stray_dnl->is_primary());
+  CInode *stray_in = stray_dnl->get_inode();
+  assert(stray_in->inode.nlink >= 1);
+  assert(stray_in->last == CEPH_NOSNAP);
 
   /* If no remote_dn hinted, pick one arbitrarily */
   if (remote_dn == NULL) {
-    CDentry::linkage_t *stray_dnl = stray_dn->get_projected_linkage();
-    assert(stray_dnl->is_primary());
-    CInode *stray_in = stray_dnl->get_inode();
-    assert(stray_in != NULL);
-    assert(stray_in->inode.nlink >= 1);
-
     if (!stray_in->remote_parents.empty()) {
-      remote_dn = *stray_in->remote_parents.begin();
-    } else {
-      dout(20) << __func__
-        << ": not reintegrating (no remote parents in cache)" << dendl;
+      for (compact_set<CDentry*>::iterator p = stray_in->remote_parents.begin();
+          p != stray_in->remote_parents.end();
+          ++p)
+       if ((*p)->last == CEPH_NOSNAP) {
+         remote_dn = *p;
+         break;
+       }
+    }
+    if (!remote_dn) {
+      dout(20) << __func__ << ": not reintegrating (no remote parents in cache)" << dendl;
       return;
     }
   }
+  assert(remote_dn->last == CEPH_NOSNAP);
     // NOTE: we repeat this check in _rename(), since our submission path is racey.
     if (!remote_dn->is_projected()) {
       if (remote_dn->is_auth() && remote_dn->dir->can_auth_pin()) {