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