if (IS_ERR(mold))
GOTO(out_unlock_parent, rc = PTR_ERR(mold));
+ if (!mdt_object_exists(mold)) {
+ LU_OBJECT_DEBUG(D_INODE, info->mti_env,
+ &mold->mot_obj,
+ "object does not exist");
+ GOTO(out_put_child, rc = -ENOENT);
+ }
+
if (mdt_object_remote(mold)) {
CDEBUG(D_OTHER, "%s: source "DFID" is on the remote MDT\n",
mdt_obd_name(info->mti_mdt), PFID(old_fid));
if (IS_ERR(mold))
GOTO(out_unlock_parents, rc = PTR_ERR(mold));
+ if (!mdt_object_exists(mold)) {
+ LU_OBJECT_DEBUG(D_INODE, info->mti_env,
+ &mold->mot_obj,
+ "object does not exist");
+ GOTO(out_put_old, rc = -ENOENT);
+ }
+
/* Check if @mtgtdir is subdir of @mold, before locking child
* to avoid reverse locking. */
if (mtgtdir != msrcdir) {
if (IS_ERR(mnew))
GOTO(out_put_old, rc = PTR_ERR(mnew));
+ if (!mdt_object_exists(mnew)) {
+ LU_OBJECT_DEBUG(D_INODE, info->mti_env,
+ &mnew->mot_obj,
+ "object does not exist");
+ GOTO(out_put_new, rc = -ENOENT);
+ }
+
if (mdt_object_remote(mnew)) {
struct mdt_body *repbody;