GOTO(out, rc = 1);
if (parent)
mdd_object_put(env, parent);
- parent = mdd_object_find(env, mdd, pfid);
-
- /* cross-ref parent */
- if (parent == NULL) {
- if (pf != NULL)
- *pf = *pfid;
- GOTO(out, rc = -EREMOTE);
- } else if (IS_ERR(parent))
- GOTO(out, rc = PTR_ERR(parent));
- p1 = parent;
+
+ parent = mdd_object_find(env, mdd, pfid);
+ if (IS_ERR(parent)) {
+ GOTO(out, rc = PTR_ERR(parent));
+ } else if (mdd_object_exists(parent) < 0) {
+ /*FIXME: Because of the restriction of rename in Phase I.
+ * If the parent is remote, we just assumed lf is not the
+ * parent of P1 for now */
+ GOTO(out, rc = 0);
+ }
+ p1 = parent;
}
EXIT;
out:
if (IS_ERR(ms))
GOTO(out_unlock_parent, rc = PTR_ERR(ms));
+ if (mdt_object_exists(ms) < 0) {
+ mdt_object_put(info->mti_env, ms);
+ CERROR("Target directory "DFID" is on another MDT\n",
+ PFID(rr->rr_fid1));
+ GOTO(out_unlock_parent, rc = -EXDEV);
+ }
+
rc = mdt_object_lock(info, ms, lhs, MDS_INODELOCK_UPDATE,
MDT_CROSS_LOCK);
if (rc != 0) {
GOTO(out_put_target, rc);
/* get and save correct version after locking */
mdt_version_get_save(info, mtgtdir, 1);
- }
+ } else if (rc < 0) {
+ CERROR("Source dir "DFID" target dir "DFID
+ "on different MDTs\n", PFID(rr->rr_fid1),
+ PFID(rr->rr_fid2));
+ GOTO(out_put_target, rc = -EXDEV);
+ }
}
/* step 3: find & lock the old object. */
if (lu_fid_eq(old_fid, rr->rr_fid1) || lu_fid_eq(old_fid, rr->rr_fid2))
GOTO(out_unlock_target, rc = -EINVAL);
- mold = mdt_object_find(info->mti_env, info->mti_mdt, old_fid);
- if (IS_ERR(mold))
- GOTO(out_unlock_target, rc = PTR_ERR(mold));
+ mold = mdt_object_find(info->mti_env, info->mti_mdt, old_fid);
+ if (IS_ERR(mold))
+ GOTO(out_unlock_target, rc = PTR_ERR(mold));
+ if (mdt_object_exists(mold) < 0) {
+ mdt_object_put(info->mti_env, mold);
+ CERROR("Source child "DFID" is on another MDT\n", PFID(old_fid));
+ GOTO(out_unlock_target, rc = -EXDEV);
+ }
if (mdt_object_obf(mold)) {
mdt_object_put(info->mti_env, mold);
GOTO(out_unlock_old, rc = -EPERM);
}
+ if (mdt_object_exists(mnew) < 0) {
+ mdt_object_put(info->mti_env, mnew);
+ CERROR("Source child "DFID" is on another MDT\n",
+ PFID(new_fid));
+ GOTO(out_unlock_old, rc = -EXDEV);
+ }
+
rc = mdt_object_lock(info, mnew, lh_newp,
MDS_INODELOCK_FULL, MDT_CROSS_LOCK);
if (rc != 0) {