From: Lai Siyao Date: Thu, 8 Jul 2021 08:09:01 +0000 (+0800) Subject: LU-13417 test: mkdir_on_mdt0() in more tests X-Git-Tag: 2.14.53~21 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=618625af42b9ff0427b096996ddf07a327689ec8 LU-13417 test: mkdir_on_mdt0() in more tests 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 Change-Id: Iebc32568b7fc146b658f47c5f5053fd3db24432f Reviewed-on: https://review.whamcloud.com/44315 Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo Reviewed-by: Hongchao Zhang Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/recovery-small.sh b/lustre/tests/recovery-small.sh index c5166e9..a17a8fd 100755 --- a/lustre/tests/recovery-small.sh +++ b/lustre/tests/recovery-small.sh @@ -2253,8 +2253,8 @@ test_110k() { [[ "$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 diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 5f61353..e732ec4 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -2492,7 +2492,7 @@ test_71a () { # 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) diff --git a/lustre/tests/sanity-lfsck.sh b/lustre/tests/sanity-lfsck.sh index 755d823..d8ea43f 100644 --- a/lustre/tests/sanity-lfsck.sh +++ b/lustre/tests/sanity-lfsck.sh @@ -4186,7 +4186,7 @@ test_24() { 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 @@ -4214,7 +4214,7 @@ test_24() { #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) diff --git a/lustre/tests/sanity-pfl.sh b/lustre/tests/sanity-pfl.sh index 36c72bd..5b64432 100644 --- a/lustre/tests/sanity-pfl.sh +++ b/lustre/tests/sanity-pfl.sh @@ -528,7 +528,7 @@ test_8() { 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 || diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index ec556d4..9103aac 100755 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -401,10 +401,9 @@ wait_grace_time() { } 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 @@ -1587,7 +1586,7 @@ test_file_soft() { 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 @@ -3405,7 +3404,7 @@ test_38() { [ "$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 @@ -4299,7 +4298,7 @@ test_66() { 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" diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index 80f78b7..b6fbd57 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -1294,7 +1294,7 @@ test_17b() { #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) diff --git a/lustre/tests/sanity-selinux.sh b/lustre/tests/sanity-selinux.sh index 8349625..90b5b9c 100755 --- a/lustre/tests/sanity-selinux.sh +++ b/lustre/tests/sanity-selinux.sh @@ -120,7 +120,7 @@ test_2a() { 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) @@ -644,7 +644,7 @@ test_21b() { 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 || diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index cca82d1..81053e9 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -5559,7 +5559,7 @@ test_51b() { # cleanup the directory rm -fr $dir - test_mkdir -c1 $dir + mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir $LFS df $LFS df -i @@ -14865,35 +14865,35 @@ test_154f() { [ -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 /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)" @@ -14915,7 +14915,7 @@ test_154f() { 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) @@ -14927,7 +14927,7 @@ test_154f() { 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" && @@ -14947,7 +14947,7 @@ test_154g() $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" @@ -20336,7 +20336,8 @@ test_247f() { 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" @@ -22647,9 +22648,6 @@ test_300g() { 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" diff --git a/lustre/tests/sanityn.sh b/lustre/tests/sanityn.sh index 0ab469b..2a7e2be 100755 --- a/lustre/tests/sanityn.sh +++ b/lustre/tests/sanityn.sh @@ -1576,7 +1576,7 @@ check_pdo_conflict() { 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)) \ @@ -1610,7 +1610,7 @@ run_test 40a "pdirops: create vs others ==============" 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)) \ @@ -1645,7 +1645,7 @@ run_test 40b "pdirops: open|create and others ==============" 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 @@ -1681,7 +1681,7 @@ run_test 40c "pdirops: link and others ==============" 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 @@ -1716,7 +1716,7 @@ run_test 40d "pdirops: unlink and others ==============" 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 @@ -2262,7 +2262,7 @@ test_43j() { [[ $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)) \ diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index bc18328..90031ea 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -10461,10 +10461,25 @@ function restore_opencache() } # 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