]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Save straydn in mdr so it's consistent across retry attempts.
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 15 Dec 2010 18:56:18 +0000 (10:56 -0800)
committerSage Weil <sage@newdream.net>
Wed, 15 Dec 2010 21:07:25 +0000 (13:07 -0800)
Otherwise, we could choose new stray dirs and fail to get all
the locks we needed (while leaving old strays locked forever!).

Signed-off-by: Greg Farnum <gregf@hq.newdream.net>
src/mds/MDCache.h
src/mds/Server.cc

index 957dceb2273e9724dcb493adac108f66bfbc7866..7b2b94998e5c32abccf40ec9c7739547dc2eda9c 100644 (file)
@@ -259,6 +259,7 @@ struct MDRequest : public Mutation {
 
   // store up to two sets of dn vectors, inode pointers, for request path1 and path2.
   vector<CDentry*> dn[2];
+  CDentry *straydn;
   CInode *in[2];
   snapid_t snapid;
 
@@ -323,7 +324,7 @@ struct MDRequest : public Mutation {
   MDRequest() : 
     ref(1),
     session(0), item_session_request(this),
-    client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
+    client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
     alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
     slave_request(0),
     internal_op(-1),
@@ -334,7 +335,7 @@ struct MDRequest : public Mutation {
     Mutation(ri),
     ref(1),
     session(0), item_session_request(this),
-    client_request(req), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
+    client_request(req), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
     alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
     slave_request(0),
     internal_op(-1),
@@ -345,7 +346,7 @@ struct MDRequest : public Mutation {
     Mutation(ri, by),
     ref(1),
     session(0), item_session_request(this),
-    client_request(0), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
+    client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
     alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
     slave_request(0),
     internal_op(-1),
index 35af027dc6ea294f7e0b079f2a5b0db458b98102..c02526ac5e226777e856cef3801babc8a30a07fb 100644 (file)
@@ -4045,12 +4045,16 @@ void Server::handle_client_unlink(MDRequest *mdr)
     }
   }
 
-  CDentry *straydn = 0;
-  if (dnl->is_primary()) {
+  // -- create stray dentry? --
+  CDentry *straydn = mdr->straydn;
+  if (dnl->is_primary() && !straydn) {
     straydn = mdcache->get_or_create_stray_dentry(dnl->get_inode());
-    mdr->pin(straydn);  // pin it.
-    dout(10) << " straydn is " << *straydn << dendl;
+    mdr->pin(straydn);
+    mdr->straydn = straydn;
   }
+  if (straydn)
+    dout(10) << " straydn is " << *straydn << dendl;
+
 
   // lock
   set<SimpleLock*> rdlocks, wrlocks, xlocks;
@@ -4499,12 +4503,14 @@ void Server::handle_client_rename(MDRequest *mdr)
     dout(10) << " this is a link merge" << dendl;
 
   // -- create stray dentry? --
-  CDentry *straydn = 0;
-  if (destdnl->is_primary() && !linkmerge) {
+  CDentry *straydn = mdr->straydn;
+  if (destdnl->is_primary() && !linkmerge && !straydn) {
     straydn = mdcache->get_or_create_stray_dentry(destdnl->get_inode());
     mdr->pin(straydn);
-    dout(10) << "straydn is " << *straydn << dendl;
+    mdr->straydn = straydn;
   }
+  if (straydn)
+    dout(10) << " straydn is " << *straydn << dendl;
 
   // -- prepare witness list --
   /*