Replace mkdir with mkdir_on_mdt0() in several tests.
Update recovery-small test_110k() in case there are opened files on
MDT1 which would cause umount stall.
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: Iebc32568b7fc146b658f47c5f5053fd3db24432f
Reviewed-on: https://review.whamcloud.com/44315
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
[[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
skip "Need MDS version at least 2.12.55"
- stop mds2 || error "stop mds2 failed"
umount $MOUNT
+ stop mds2 || error "stop mds2 failed"
#define OBD_FAIL_FLD_QUERY_REQ 0x1103
do_facet mds2 lctl set_param fail_loc=0x1103
# set duration to 900 because it takes some time to boot node
[ "$FAILURE_MODE" = HARD ] && duration=900
- mkdir -p $DIR/$tdir
+ mkdir_on_mdt0 $DIR/$tdir
local elapsed
local start_ts=$(date +%s)
check_mount_and_prep
- $LFS mkdir -i 1 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0"
+ mkdir_on_mdt -i1 $DIR/$tdir/d0 || error "(1) Fail to mkdir d0"
mkdir $DIR/$tdir/d0/guard || error "(1) Fail to mkdir guard"
$LFS path2fid $DIR/$tdir/d0/guard
#define OBD_FAIL_LFSCK_MUL_REF 0x1622
do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1622
- $LFS mkdir -i 0 $DIR/$tdir/d0/dummy/foo ||
+ mkdir_on_mdt -i0 $DIR/$tdir/d0/dummy/foo ||
error "(4) Fail to mkdir $DIR/$tdir/d0/dummy/foo"
$LFS path2fid $DIR/$tdir/d0/dummy/foo
local cfid=$($LFS path2fid $DIR/$tdir/d0/dummy/foo)
local parent=$DIR/$tdir
rm -fr $parent
- test_mkdir $parent
+ mkdir_on_mdt0 $parent
$LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
-E -1 -c 4 -S 4M $parent ||
}
setup_quota_test() {
- local mdt=${1:-0}
wait_delete_completed
echo "Creating test directory"
- $LFS mkdir -i $mdt -c 1 $DIR/$tdir || return 1
+ mkdir_on_mdt0 $DIR/$tdir || return 1
chmod 0777 $DIR/$tdir || return 2
# always clear fail_loc in case of fail_loc isn't cleared
# properly when previous test failed
local SOFT_LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
- setup_quota_test 0
+ setup_quota_test
trap cleanup_quota_test EXIT
is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
[ "$UID" != 0 ] && skip_env "must run as root" && return
- setup_quota_test 0 || error "setup quota failed with $?"
+ setup_quota_test || error "setup quota failed with $?"
trap cleanup_quota_test EXIT
# make sure the system is clean
stack_trap "do_facet mds1 $LCTL set_param mdt.*.enable_chprojid_gid=0" \
EXIT
- test_mkdir -i 0 -c 1 $testdir || error "failed to mkdir"
+ mkdir_on_mdt0 $testdir || error "failed to mkdir"
chown -R $TSTID:$TSTID $testdir
change_project -sp $TSTPRJID $testdir
$RUNAS mkdir $testdir/foo || error "failed to mkdir foo"
#define OBD_FAIL_OSD_DOTDOT_ENOSPC 0x19e
do_facet mds1 $LCTL set_param fail_loc=0x8000019e
- mkdir $DIR/$tdir && error "mkdir should fail"
+ mkdir_on_mdt0 $DIR/$tdir && error "mkdir should fail"
stop mds1
local devname=$(mdsdevname 1)
mds_path=${mds_path#/}
- $LFS setdirstripe -i0 -c1 ${DIR}/$tdir || error "create dir failed"
+ mkdir_on_mdt0 ${DIR}/$tdir || error "create dir failed"
mkdir $dirname || error "cannot mkdir $dirname"
local xattrval=$(check_selinux_xattr "mds1" $mds_path)
local sepol
- mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+ mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
echo test > $DIR/$tdir/toopen ||
error "failed to write to $DIR/$tdir/toopen"
touch $DIR/$tdir/ftoremove ||
# cleanup the directory
rm -fr $dir
- test_mkdir -c1 $dir
+ mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
$LFS df
$LFS df -i
[ -n "$FILESET" ] && skip "SKIP due to FILESET set"
# create parent directory on a single MDT to avoid cross-MDT hardlinks
- test_mkdir -p -c1 $DIR/$tdir/d
+ mkdir_on_mdt0 $DIR/$tdir
# test dirs inherit from its stripe
- mkdir -p $DIR/$tdir/d/foo1 || error "mkdir error"
- mkdir -p $DIR/$tdir/d/foo2 || error "mkdir error"
- cp /etc/hosts $DIR/$tdir/d/foo1/$tfile
- ln $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/link
+ mkdir -p $DIR/$tdir/foo1 || error "mkdir error"
+ mkdir -p $DIR/$tdir/foo2 || error "mkdir error"
+ cp /etc/hosts $DIR/$tdir/foo1/$tfile
+ ln $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/link
touch $DIR/f
# get fid of parents
- local FID0=$($LFS path2fid $DIR/$tdir/d)
- local FID1=$($LFS path2fid $DIR/$tdir/d/foo1)
- local FID2=$($LFS path2fid $DIR/$tdir/d/foo2)
+ local FID0=$($LFS path2fid $DIR/$tdir)
+ local FID1=$($LFS path2fid $DIR/$tdir/foo1)
+ local FID2=$($LFS path2fid $DIR/$tdir/foo2)
local FID3=$($LFS path2fid $DIR)
# check that path2fid --parents returns expected <parent_fid>/name
# 1) test for a directory (single parent)
- local parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1)
+ local parent=$($LFS path2fid --parents $DIR/$tdir/foo1)
[ "$parent" == "$FID0/foo1" ] ||
error "expected parent: $FID0/foo1, got: $parent"
# 2) test for a file with nlink > 1 (multiple parents)
- parent=$($LFS path2fid --parents $DIR/$tdir/d/foo1/$tfile)
+ parent=$($LFS path2fid --parents $DIR/$tdir/foo1/$tfile)
echo "$parent" | grep -F "$FID1/$tfile" ||
error "$FID1/$tfile not returned in parent list"
echo "$parent" | grep -F "$FID2/link" ||
error "$FID2/link not returned in parent list"
# 3) get parent by fid
- local file_fid=$($LFS path2fid $DIR/$tdir/d/foo1/$tfile)
+ local file_fid=$($LFS path2fid $DIR/$tdir/foo1/$tfile)
parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
echo "$parent" | grep -F "$FID1/$tfile" ||
error "$FID1/$tfile not returned in parent list (by fid)"
lctl set_param llite.*.xattr_cache 1
# 6.1) linkea update on rename
- mv $DIR/$tdir/d/foo1/$tfile $DIR/$tdir/d/foo2/$tfile.moved
+ mv $DIR/$tdir/foo1/$tfile $DIR/$tdir/foo2/$tfile.moved
# get parents by fid
parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
error "$FID2/$tfile.moved is not in parent list"
# 6.2) linkea update on unlink
- rm -f $DIR/$tdir/d/foo2/link
+ rm -f $DIR/$tdir/foo2/link
parent=$($LFS path2fid --parents $MOUNT/.lustre/fid/$file_fid)
# foo2/link should no longer be returned in parent list
echo "$parent" | grep -F "$FID2/link" &&
$CLIENT_VERSION -gt $(version_code 2.6.99) ]] ||
skip "Need MDS version at least 2.6.92"
- mkdir -p $DIR/$tdir
+ mkdir_on_mdt0 $DIR/$tdir
llapi_fid_test -d $DIR/$tdir
}
run_test 154g "various llapi FID tests"
mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
$LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote ||
error "mkdir remote failed"
- mkdir $DIR/$tdir/remote/subdir || error "mkdir remote/subdir failed"
+ $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir/remote/subdir ||
+ error "mkdir remote/subdir failed"
$LFS mkdir -i 0 -c $MDSCOUNT $DIR/$tdir/striped ||
error "mkdir striped failed"
mkdir $DIR/$tdir/striped/subdir || error "mkdir striped/subdir failed"
stripe_count=$($LFS getdirstripe -c $dir)
[ $stripe_count -eq 0 ] ||
error "expect 1 get $stripe_count for $dir"
- stripe_index=$($LFS getdirstripe -i $dir)
- [ $stripe_index -eq 0 ] ||
- error "expect 0 get $stripe_index for $dir"
done
}
run_test 300g "check default striped directory for normal directory"
test_40a() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir $DIR2/$tdir
+ mkdir_on_mdt0 $DIR2/$tdir
pdo_lru_clear
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
do_nodes $(comma_list $(mdts_nodes)) \
test_40b() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir $DIR2/$tdir
+ mkdir_on_mdt0 $DIR2/$tdir
pdo_lru_clear
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
do_nodes $(comma_list $(mdts_nodes)) \
test_40c() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir $DIR2/$tdir
+ mkdir_on_mdt0 $DIR2/$tdir
pdo_lru_clear
touch $DIR1/$tdir/$tfile
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
test_40d() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir $DIR2/$tdir
+ mkdir_on_mdt0 $DIR2/$tdir
pdo_lru_clear
touch $DIR1/$tdir/$tfile
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
test_40e() {
remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir $DIR2/$tdir
+ mkdir_on_mdt0 $DIR2/$tdir
pdo_lru_clear
touch $DIR1/$tdir/$tfile
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK 0x145
[[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
skip "Need MDS version newer than 2.13.52"
- mkdir $DIR1/$tdir
+ mkdir_on_mdt0 $DIR1/$tdir
for i in {1..100}; do
#define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE 0x167
do_nodes $(comma_list $(mdts_nodes)) \
}
# LU-13417: XXX lots of tests assume the directory to be created under MDT0,
-# using this function to create directory under MDT0 explicitly.
-# Don't use it in new tests, and remove it from old tests.
+# created on MDT0, use this function to create directory on specific MDT
+# explicitly, and set default LMV to create subdirs on the same MDT too.
+mkdir_on_mdt() {
+ local mdt
+ local OPTIND=1
+
+ while getopts "i:" opt $*; do
+ case $opt in
+ i) mdt=$OPTARG;;
+ esac
+ done
+
+ shift $((OPTIND - 1))
+
+ $LFS mkdir -i $mdt -c 1 $*
+}
+
mkdir_on_mdt0() {
- $LFS mkdir -i 0 -c 1 $*
+ mkdir_on_mdt -i0 $*
}
# Wait for nodemap synchronization