Whamcloud - gitweb
LU-13417 test: mkdir_on_mdt0() in more tests 15/44315/8
authorLai Siyao <lai.siyao@whamcloud.com>
Thu, 8 Jul 2021 08:09:01 +0000 (16:09 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 27 Jul 2021 21:36:04 +0000 (21:36 +0000)
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>
lustre/tests/recovery-small.sh
lustre/tests/replay-single.sh
lustre/tests/sanity-lfsck.sh
lustre/tests/sanity-pfl.sh
lustre/tests/sanity-quota.sh
lustre/tests/sanity-scrub.sh
lustre/tests/sanity-selinux.sh
lustre/tests/sanity.sh
lustre/tests/sanityn.sh
lustre/tests/test-framework.sh

index c5166e9..a17a8fd 100755 (executable)
@@ -2253,8 +2253,8 @@ test_110k() {
        [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
                skip "Need MDS version at least 2.12.55"
 
        [[ "$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
        umount $MOUNT
+       stop mds2 || error "stop mds2 failed"
 
 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
        do_facet mds2 lctl set_param fail_loc=0x1103
 
 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
        do_facet mds2 lctl set_param fail_loc=0x1103
index 5f61353..e732ec4 100755 (executable)
@@ -2492,7 +2492,7 @@ test_71a () {
        # set duration to 900 because it takes some time to boot node
        [ "$FAILURE_MODE" = HARD ] && duration=900
 
        # 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)
 
        local elapsed
        local start_ts=$(date +%s)
index 755d823..d8ea43f 100644 (file)
@@ -4186,7 +4186,7 @@ test_24() {
 
        check_mount_and_prep
 
 
        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
 
        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
 
        #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)
                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)
index 36c72bd..5b64432 100644 (file)
@@ -528,7 +528,7 @@ test_8() {
        local parent=$DIR/$tdir
 
        rm -fr $parent
        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 ||
 
        $LFS setstripe -E 2M -c 1 -S 1M -E 16M -c 2 -S 2M \
                -E -1 -c 4 -S 4M $parent ||
index ec556d4..9103aac 100755 (executable)
@@ -401,10 +401,9 @@ wait_grace_time() {
 }
 
 setup_quota_test() {
 }
 
 setup_quota_test() {
-       local mdt=${1:-0}
        wait_delete_completed
        echo "Creating test directory"
        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
        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)
 
        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
 
        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
 
 
        [ "$UID" != 0 ] && skip_env "must run as root" && return
 
-       setup_quota_test || error "setup quota failed with $?"
+       setup_quota_test || error "setup quota failed with $?"
        trap cleanup_quota_test EXIT
 
        # make sure the system is clean
        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
 
        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"
        chown -R $TSTID:$TSTID $testdir
        change_project -sp $TSTPRJID $testdir
        $RUNAS mkdir $testdir/foo || error "failed to mkdir foo"
index 80f78b7..b6fbd57 100644 (file)
@@ -1294,7 +1294,7 @@ test_17b() {
 
 #define OBD_FAIL_OSD_DOTDOT_ENOSPC                     0x19e
        do_facet mds1 $LCTL set_param fail_loc=0x8000019e
 
 #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)
 
        stop mds1
        local devname=$(mdsdevname 1)
 
index 8349625..90b5b9c 100755 (executable)
@@ -120,7 +120,7 @@ test_2a() {
 
        mds_path=${mds_path#/}
 
 
        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)
        mkdir $dirname || error "cannot mkdir $dirname"
 
        local xattrval=$(check_selinux_xattr "mds1" $mds_path)
@@ -644,7 +644,7 @@ test_21b() {
 
        local sepol
 
 
        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 ||
        echo test > $DIR/$tdir/toopen ||
                error "failed to write to $DIR/$tdir/toopen"
        touch $DIR/$tdir/ftoremove ||
index cca82d1..81053e9 100755 (executable)
@@ -5559,7 +5559,7 @@ test_51b() {
        # cleanup the directory
        rm -fr $dir
 
        # cleanup the directory
        rm -fr $dir
 
-       test_mkdir -c1 $dir
+       mkdir_on_mdt -i $((RANDOM % MDSCOUNT)) $dir
 
        $LFS df
        $LFS df -i
 
        $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
        [ -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
        # 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
        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 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" == "$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
        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)"
        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
        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)
 
        # 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
                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" &&
        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"
 
           $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"
        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_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"
        $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_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"
        done
 }
 run_test 300g "check default striped directory for normal directory"
index 0ab469b..2a7e2be 100755 (executable)
@@ -1576,7 +1576,7 @@ check_pdo_conflict() {
 test_40a() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
 
 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)) \
        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
 
 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)) \
        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
 
 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
        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
 
 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
        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
 
 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
        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"
 
        [[ $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)) \
        for i in {1..100}; do
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE         0x167
                do_nodes $(comma_list $(mdts_nodes)) \
index bc18328..90031ea 100755 (executable)
@@ -10461,10 +10461,25 @@ function restore_opencache()
 }
 
 # LU-13417: XXX lots of tests assume the directory to be created under MDT0,
 }
 
 # 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() {
 mkdir_on_mdt0() {
-       $LFS mkdir -i 0 -c 1 $*
+       mkdir_on_mdt -i0 $*
 }
 
 # Wait for nodemap synchronization
 }
 
 # Wait for nodemap synchronization