it may happen that tgt child for rename is a directory, which is used
as tgt dir for link in parallel, as the result rename locks src child,
tgt child what may deadlock with tgt dir, src file locking of link.
As not dir cannot replace dir, check it before locking the tgt child.
Signed-off-by: Vitaly Fertman <vitaly_fertman@xyratex.com>
Xyratex-bug-id: MRP-1921
Change-Id: If8b91d27e4d978853e4b8fbb025667d22c9d2f02
Reviewed-on: http://review.whamcloud.com/10570
Tested-by: Jenkins
Tested-by: Oleg Drokin <oleg.drokin@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
if (rc)
GOTO(out_unlock_parent, rc);
if (rc)
GOTO(out_unlock_parent, rc);
+ OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_RENAME3, 5);
+
/* step 2: find & lock the source */
lhs = &info->mti_lh[MDT_LH_CHILD];
mdt_lock_reg_init(lhs, LCK_EX);
/* step 2: find & lock the source */
lhs = &info->mti_lh[MDT_LH_CHILD];
mdt_lock_reg_init(lhs, LCK_EX);
GOTO(out_put_new, rc = -EXDEV);
}
GOTO(out_put_new, rc = -EXDEV);
}
+ if (S_ISDIR(lu_object_attr(&mnew->mot_obj)) &&
+ !S_ISDIR(lu_object_attr(&mold->mot_obj)))
+ GOTO(out_put_new, rc = -EISDIR);
+
lh_oldp = &info->mti_lh[MDT_LH_OLD];
mdt_lock_reg_init(lh_oldp, LCK_EX);
rc = mdt_object_lock(info, mold, lh_oldp, MDS_INODELOCK_LOOKUP |
lh_oldp = &info->mti_lh[MDT_LH_OLD];
mdt_lock_reg_init(lh_oldp, LCK_EX);
rc = mdt_object_lock(info, mold, lh_oldp, MDS_INODELOCK_LOOKUP |
}
run_test 55b "rename vs unlink source dir"
}
run_test 55b "rename vs unlink source dir"
+test_55d()
+{
+ touch $DIR/f1
+
+#define OBD_FAIL_MDS_RENAME3 0x155
+ do_facet mds $LCTL set_param fail_loc=0x155
+ mv $DIR/f1 $DIR/d1 &
+ PID1=$!
+ sleep 2
+
+ # while rename is sleeping, create d2, but as a directory
+ mkdir -p $DIR2/d1 || error "(1) mkdir failed"
+
+ # link in reverse locking order
+ ln $DIR2/f1 $DIR2/d1/
+
+ wait $PID1 && error "(2) mv succeeded"
+ lctl dk > ../log1
+ ls -la $DIR/
+ ls -la $DIR/d1
+
+ rm -rf $DIR/d1
+}
+run_test 55d "rename file vs link"
+
test_60() {
[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
{ skip "Need MDS version at least 2.3.0"; return; }
test_60() {
[[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
{ skip "Need MDS version at least 2.3.0"; return; }