client: don't set other if lookup fails in rename

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>
This commit is contained in:
Sam Lang 2013-03-23 14:07:59 -05:00 committed by Sage Weil
parent 8e6a970c45
commit ece4348807

View 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);