]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix stray replica push on _rename_prepare_witness()
authorSage Weil <sage@newdream.net>
Fri, 1 Oct 2010 19:43:20 +0000 (12:43 -0700)
committerSage Weil <sage@newdream.net>
Fri, 1 Oct 2010 19:52:43 +0000 (12:52 -0700)
We need to push all parents of the straydn to the target.  This changed
a while back with the mdsdir stuff but this bit of code wasn't updated.
Updated to mirror send_dentry_unlink().

This fixes a crash like:
mds/MDCache.cc: In function 'void MDCache::adjust_subtree_auth(CDir*, std::pair<int, int>, bool)':
mds/MDCache.cc:644: FAILED assert(root)
 ceph version 0.22~rc (0e67718a365b42969e785f544ea3b4258bb2407f)
 1: (MDCache::add_replica_dir(ceph::buffer::list::iterator&, CInode*, int, std::list<Context*, std::allocator<Context*> >&)+0x1c1) [0x536a91]
 2: (MDCache::add_replica_stray(ceph::buffer::list&, int)+0xdb) [0x536fab]
 3: (Server::handle_slave_rename_prep(MDRequest*)+0x1113) [0x4d5c33]
 4: (Server::dispatch_slave_request(MDRequest*)+0x21b) [0x4de80b]
 5: (Server::handle_slave_request(MMDSSlaveRequest*)+0x145) [0x4e1955]
 6: (MDS::_dispatch(Message*)+0x2598) [0x49e038]
...

Signed-off-by: Sage Weil <sage@newdream.net>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/Server.cc

index 176c150293806c6aaec79baa16b409ae9df16b5a..0abe20e39c7417d2b97be46097c6e8d14aafd6e2 100644 (file)
@@ -8142,7 +8142,17 @@ CInode *MDCache::add_replica_inode(bufferlist::iterator& p, CDentry *dn, list<Co
   return in;
 }
 
-    
+void MDCache::replicate_stray(CDentry *straydn, int who, bufferlist& bl)
+{
+  replicate_inode(get_myin(), who, bl);
+  replicate_dir(straydn->get_dir()->inode->get_parent_dn()->get_dir(), who, bl);
+  replicate_dentry(straydn->get_dir()->inode->get_parent_dn(), who, bl);
+  replicate_inode(straydn->get_dir()->inode, who, bl);
+  replicate_dir(straydn->get_dir(), who, bl);
+  replicate_dentry(straydn, who, bl);
+}
+   
 CDentry *MDCache::add_replica_stray(bufferlist &bl, int from)
 {
   list<Context*> finished;
@@ -8317,14 +8327,8 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn)
        it != dn->replicas_end();
        it++) {
     MDentryUnlink *unlink = new MDentryUnlink(dn->get_dir()->dirfrag(), dn->name);
-    if (straydn) {
-      replicate_inode(get_myin(), it->first, unlink->straybl);
-      replicate_dir(straydn->get_dir()->inode->get_parent_dn()->get_dir(), it->first, unlink->straybl);
-      replicate_dentry(straydn->get_dir()->inode->get_parent_dn(), it->first, unlink->straybl);
-      replicate_inode(straydn->get_dir()->inode, it->first, unlink->straybl);
-      replicate_dir(straydn->get_dir(), it->first, unlink->straybl);
-      replicate_dentry(straydn, it->first, unlink->straybl);
-    }
+    if (straydn)
+      replicate_stray(straydn, it->first, unlink->straybl);
     mds->send_message_mds(unlink, it->first);
   }
 }
index 5d2b7e284a97dc7b152930c212f7e6ea310e1689..086caa3df34318cc6390b6520bba7fcf3865e99a 100644 (file)
@@ -1048,6 +1048,8 @@ public:
   CDir* forge_replica_dir(CInode *diri, frag_t fg, int from);
   CDentry *add_replica_dentry(bufferlist::iterator& p, CDir *dir, list<Context*>& finished);
   CInode *add_replica_inode(bufferlist::iterator& p, CDentry *dn, list<Context*>& finished);
+
+  void replicate_stray(CDentry *straydn, int who, bufferlist& bl);
   CDentry *add_replica_stray(bufferlist &bl, int from);
 
   // -- namespace --
index 7466e1c08aed9070d77d61892e8837ca358294eb..c2e83e8bcd0a0f455388a5763dffb0fff6cafb80 100644 (file)
@@ -4659,11 +4659,8 @@ void Server::_rename_prepare_witness(MDRequest *mdr, int who, CDentry *srcdn, CD
   destdn->make_path(req->destdnpath);
   req->now = mdr->now;
   
-  if (straydn) {
-    mdcache->replicate_inode(straydn->get_dir()->inode, who, req->stray);
-    mdcache->replicate_dir(straydn->get_dir(), who, req->stray);
-    mdcache->replicate_dentry(straydn, who, req->stray);
-  }
+  if (straydn)
+    mdcache->replicate_stray(straydn, who, req->stray);
   
   // srcdn auth will verify our current witness list is sufficient
   req->witnesses = mdr->more()->witnessed;