]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: don't set other if lookup fails in rename
authorSam Lang <sam.lang@inktank.com>
Sat, 23 Mar 2013 19:07:59 +0000 (14:07 -0500)
committerSage Weil <sage@inktank.com>
Sun, 24 Mar 2013 00:30:53 +0000 (17:30 -0700)
On rename, only set the other inode if the
lookup for the destination succeeds, otherwise we hit
a segv in set_other_inode().

Fixes #4517.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
Tested-by: Noah Watkins <jayhawk@cs.ucsc.edu>
src/client/Client.cc

index 792d4a2fdda7074d6f8e8f061122fbd06f2c6288..d1f8564aa8f6e5864b19b38f9068e21ad561e85f 100644 (file)
@@ -7340,10 +7340,12 @@ int Client::_rename(Inode *fromdir, const char *fromname, Inode *todir, const ch
 
   Inode *otherin;
   res = _lookup(todir, toname, &otherin);
-  if (res != 0 && res != -ENOENT)
+  if (res != 0 && res != -ENOENT) {
     goto fail;
-  req->set_other_inode(otherin);
-  req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
+  } else if (res == 0) {
+    req->set_other_inode(otherin);
+    req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
+  }
 
   req->set_inode(todir);