Whamcloud - gitweb
LU-13417 test: add mkdir_on_mdt0() 89/43489/7
authorLai Siyao <lai.siyao@whamcloud.com>
Wed, 28 Apr 2021 14:36:24 +0000 (22:36 +0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 30 Jun 2021 03:15:44 +0000 (03:15 +0000)
Once default LMV is set on ROOT, and default stripe offset is "-1",
mkdir may not create directory on MDT0, but it's a premise for many
tests. Add a function mkdir_on_mdt0() to create directory on MDT0
by "lfs mkdir -i 0".

Replace mkdir with mkdir_on_mdt0() for such tests in sanity.sh and
sanityn.sh.

Test-Parameters: trivial testlist=sanityn
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Change-Id: I6155d036e6b28153d0bdbdbc01088bd68ee9e0af
Reviewed-on: https://review.whamcloud.com/43489
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Nunez <jnunez@whamcloud.com>
lustre/tests/sanity.sh
lustre/tests/sanityn.sh
lustre/tests/test-framework.sh

index 96a4e65..6861224 100755 (executable)
@@ -1835,7 +1835,7 @@ __exhaust_precreations() {
        local FAILIDX=${3:-$OSTIDX}
        local ofacet=ost$((OSTIDX + 1))
 
-       test_mkdir -p -c1 $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        local mdtidx=$($LFS getstripe -m $DIR/$tdir)
        local mfacet=mds$((mdtidx + 1))
        echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
@@ -1991,7 +1991,7 @@ test_27q() {
        reset_enospc
        rm -f $DIR/$tdir/$tfile
 
-       test_mkdir $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        $MCREATE $DIR/$tdir/$tfile || error "mcreate $DIR/$tdir/$tfile failed"
        $TRUNCATE $DIR/$tdir/$tfile 80000000 ||
                error "truncate $DIR/$tdir/$tfile failed"
@@ -4766,7 +4766,7 @@ test_39l() {
        local atime_diff=$(do_facet $SINGLEMDS \
                                lctl get_param -n mdd.*MDT0000*.atime_diff)
        rm -rf $DIR/$tdir
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
 
        # test setting directory atime to future
        touch -a -d @$TEST_39_ATIME $DIR/$tdir
@@ -13886,7 +13886,7 @@ test_134a() {
        [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
                skip "Need MDS version at least 2.7.54"
 
-       mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+       mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
        cancel_lru_locks mdc
 
        local nsdir="ldlm.namespaces.*-MDT0000-mdc-*"
@@ -13922,7 +13922,7 @@ test_134b() {
        [[ $MDS1_VERSION -lt $(version_code 2.7.54) ]] &&
                skip "Need MDS version at least 2.7.54"
 
-       mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+       mkdir_on_mdt0 $DIR/$tdir || error "failed to create $DIR/$tdir"
        cancel_lru_locks mdc
 
        local low_wm=$(do_facet mds1 $LCTL get_param -n \
@@ -15283,6 +15283,8 @@ test_160a() {
        changelog_users $SINGLEMDS | grep -q $cl_user ||
                error "User $cl_user not found in changelog_users"
 
+       mkdir_on_mdt0 $DIR/$tdir
+
        # change something
        test_mkdir -p $DIR/$tdir/pics/2008/zachy
        changelog_clear 0 || error "changelog_clear failed"
@@ -17189,7 +17191,7 @@ test_183() { # LU-2275
        [[ $MDS1_VERSION -lt $(version_code 2.3.56) ]] &&
                skip "Need MDS version at least 2.3.56"
 
-       mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
+       mkdir_on_mdt0 $DIR/$tdir || error "creating dir $DIR/$tdir"
        echo aaa > $DIR/$tdir/$tfile
 
 #define OBD_FAIL_MDS_NEGATIVE_POSITIVE  0x148
@@ -17781,7 +17783,7 @@ test_205a() { # Job stats
 
        local cmd
        # mkdir
-       cmd="mkdir $DIR/$tdir"
+       cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir"
        verify_jobstats "$cmd" "$SINGLEMDS"
        # rmdir
        cmd="rmdir $DIR/$tdir"
@@ -17822,7 +17824,7 @@ test_205a() { # Job stats
        [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
                "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
                        "0" $left
-       cmd="mkdir $DIR/$tdir.expire"
+       cmd="$LFS mkdir -i 0 -c 1 $DIR/$tdir.expire"
        verify_jobstats "$cmd" "$SINGLEMDS"
        [ $(do_facet $SINGLEMDS lctl get_param *.*.job_stats |
            grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
@@ -18313,7 +18315,7 @@ test_220() { #LU-325
        local OSTIDX=0
 
        # create on MDT0000 so the last_id and next_id are correct
-       mkdir $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        local OST=$($LFS df $DIR | awk '/OST:'$OSTIDX'/ { print $1 }')
        OST=${OST%_UUID}
 
@@ -19193,7 +19195,7 @@ test_230e() {
        local a_fid
        local b_fid
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        mkdir $DIR/$tdir/migrate_dir
        mkdir $DIR/$tdir/other_dir
        touch $DIR/$tdir/migrate_dir/a
@@ -20045,7 +20047,7 @@ run_test 241b "dio vs dio"
 test_242() {
        remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        touch $DIR/$tdir/$tfile
 
        #define OBD_FAIL_MDS_READPAGE_PACK      0x105
@@ -20237,7 +20239,7 @@ test_247f() {
                grep -q subtree ||
                skip "Fileset feature is not supported"
 
-       mkdir $DIR/$tdir || error "mkdir $tdir 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"
@@ -21015,7 +21017,7 @@ test_256() {
        changelog_register || error "changelog_register failed"
 
        rm -rf $DIR/$tdir
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
 
        changelog_clear 0 || error "changelog_clear failed"
 
@@ -21166,7 +21168,7 @@ test_270a() {
        local dom=$DIR/$tdir/dom_file
        local tmp=$DIR/$tdir/tmp_file
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
 
        # basic checks for DoM component creation
        $LFS setstripe -E 1024K -E 2048K -L mdt $dom 2>/dev/null &&
@@ -22305,7 +22307,7 @@ test_300c() {
 
        local file_count
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        $LFS setdirstripe -i 0 -c 2 $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
@@ -22515,7 +22517,7 @@ test_300g() {
        local stripe_count
        local stripe_index
 
-       mkdir $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        mkdir $DIR/$tdir/normal_dir
 
        #Checking when client cache stripe index
@@ -22855,7 +22857,7 @@ test_300p() {
        [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
 
        #define OBD_FAIL_OUT_ENOSPC     0x1704
        do_facet mds2 lctl set_param fail_loc=0x80001704
@@ -25657,7 +25659,7 @@ test_803a() {
        [ $MDS1_VERSION -lt $(version_code 2.10.54) ] &&
                skip "MDS needs to be newer than 2.10.54"
 
-       mkdir -p $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        # Create some objects on all MDTs to trigger related logs objects
        for idx in $(seq $MDSCOUNT); do
                $LFS mkdir -c $MDSCOUNT -i $((idx % $MDSCOUNT)) \
@@ -25852,7 +25854,7 @@ test_805() {
        fi
        do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
        trap cleanup_805 EXIT
-       mkdir $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        $LFS setstripe -E 1M -c2 -E 4M -c2 -E -1 -c2 $DIR/$tdir ||
                error "Can't set PFL layout"
        createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
@@ -26000,7 +26002,7 @@ test_807() {
        stack_trap "restore_lustre_params < $save; rm -f $save" EXIT
 
        rm -rf $DIR/$tdir || error "rm $tdir failed"
-       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+       mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
        touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
        $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
        $TRUNCATE $DIR/$tdir/trunc 1048576 ||
index ca804b6..6e37031 100755 (executable)
@@ -1107,7 +1107,7 @@ test_33c() {
 
        local sync_count
 
-       mkdir $DIR/$tdir
+       mkdir_on_mdt0 $DIR/$tdir
        sync_all_data
        do_facet mds1 "lctl set_param -n mdt.*.sync_count=0"
        # do twice in case transaction is committed before unlock, see LU-8200
@@ -1164,7 +1164,7 @@ test_33d() {
                skip "DNE CoS not supported"
 
        # remote directory create
-       op_trigger_cos "mkdir $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
+       op_trigger_cos "$LFS mkdir -i 0 $DIR/$tdir" "$LFS mkdir -i 1 $DIR/$tdir/subdir"
        # remote directory unlink
        op_trigger_cos "$LFS mkdir -i 1 $DIR/$tdir" "rmdir $DIR/$tdir"
        # striped directory create
@@ -1575,25 +1575,26 @@ check_pdo_conflict() {
 # test 40: check non-blocking operations
 test_40a() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+       mkdir $DIR2/$tdir
        pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       touch $DIR2
-       mkdir $DIR1/$tfile &
+       mkdir $DIR1/$tdir/$tfile &
        PID1=$!; pdo_sched
-       touch $DIR2/$tfile-2
+       touch $DIR2/$tdir/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
-       mkdir $DIR2/$tfile-3
+       mkdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "mkdir is blocked"
-       link $DIR2/$tfile-2 $DIR2/$tfile-4
+       link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
        check_pdo_conflict $PID1 || error "link is blocked"
-       mv $DIR2/$tfile-2 $DIR2/$tfile-5
+       mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
        check_pdo_conflict $PID1 || error "rename is blocked"
-       stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
+       stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
        check_pdo_conflict $PID1 || error "getattr is blocked"
-       rm $DIR2/$tfile-4 $DIR2/$tfile-5
-       rmdir $DIR2/$tfile-3
+       rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
+       rmdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "unlink is blocked"
 
        #  all operations above shouldn't wait the first one
@@ -1601,32 +1602,34 @@ test_40a() {
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0 2>/dev/null || true"
        wait $PID1
-       rm -rf $DIR/$tfile*
+       rm -rf $DIR/$tdir
        return 0
 }
 run_test 40a "pdirops: create vs others =============="
 
 test_40b() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+       mkdir $DIR2/$tdir
        pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       touch $DIR1/$tfile &
+       touch $DIR1/$tdir/$tfile &
        PID1=$!; pdo_sched
        # open|create
-       touch $DIR2/$tfile-2
+       touch $DIR2/$tdir/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
-       mkdir $DIR2/$tfile-3
+       mkdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "mkdir is blocked"
-       link $DIR2/$tfile-2 $DIR2/$tfile-4
+       link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
        check_pdo_conflict $PID1 || error "link is blocked"
-       mv $DIR2/$tfile-2 $DIR2/$tfile-5
+       mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
        check_pdo_conflict $PID1 || error "rename is blocked"
-       stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
+       stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
        check_pdo_conflict $PID1 || error "getattr is blocked"
-       rm $DIR2/$tfile-4 $DIR2/$tfile-5
-       rmdir $DIR2/$tfile-3
+       rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
+       rmdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "unlink is blocked"
        # all operations above shouldn't wait the first one
 
@@ -1634,33 +1637,35 @@ test_40b() {
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0 2>/dev/null || true"
        wait $PID1
-       rm -rf $DIR/$tfile*
+       rm -rf $DIR/$tdir
        return 0
 }
 run_test 40b "pdirops: open|create and others =============="
 
 test_40c() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+       mkdir $DIR2/$tdir
        pdo_lru_clear
-       touch $DIR1/$tfile
+       touch $DIR1/$tdir/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       link $DIR1/$tfile $DIR1/$tfile-0 &
+       link $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
        PID1=$!; pdo_sched
        # open|create
-       touch $DIR2/$tfile-2
+       touch $DIR2/$tdir/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
-       mkdir $DIR2/$tfile-3
+       mkdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "mkdir is blocked"
-       link $DIR2/$tfile-2 $DIR2/$tfile-4
+       link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
        check_pdo_conflict $PID1 || error "link is blocked"
-       mv $DIR2/$tfile-2 $DIR2/$tfile-5
+       mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
        check_pdo_conflict $PID1 || error "rename is blocked"
-       stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
+       stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
        check_pdo_conflict $PID1 || error "getattr is blocked"
-       rm $DIR2/$tfile-4 $DIR2/$tfile-5
-       rmdir $DIR2/$tfile-3
+       rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
+       rmdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "unlink is blocked"
 
         # all operations above shouldn't wait the first one
@@ -1668,33 +1673,35 @@ test_40c() {
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0 2>/dev/null || true"
        wait $PID1
-       rm -rf $DIR/$tfile*
+       rm -rf $DIR/$tdir
        return 0
 }
 run_test 40c "pdirops: link and others =============="
 
 test_40d() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+       mkdir $DIR2/$tdir
        pdo_lru_clear
-       touch $DIR1/$tfile
+       touch $DIR1/$tdir/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       rm $DIR1/$tfile &
+       rm $DIR1/$tdir/$tfile &
        PID1=$!; pdo_sched
        # open|create
-       touch $DIR2/$tfile-2
+       touch $DIR2/$tdir/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
-       mkdir $DIR2/$tfile-3
+       mkdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "mkdir is blocked"
-       link $DIR2/$tfile-2 $DIR2/$tfile-4
+       link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
        check_pdo_conflict $PID1 || error "link is blocked"
-       mv $DIR2/$tfile-2 $DIR2/$tfile-5
+       mv $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-5
        check_pdo_conflict $PID1 || error "rename is blocked"
-       stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
+       stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
        check_pdo_conflict $PID1 || error "getattr is blocked"
-       rm $DIR2/$tfile-4 $DIR2/$tfile-5
-       rmdir $DIR2/$tfile-3
+       rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-5
+       rmdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "unlink is blocked"
 
        # all operations above shouldn't wait the first one
@@ -1708,24 +1715,26 @@ run_test 40d "pdirops: unlink and others =============="
 
 test_40e() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+
+       mkdir $DIR2/$tdir
        pdo_lru_clear
-       touch $DIR1/$tfile
+       touch $DIR1/$tdir/$tfile
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       mv $DIR1/$tfile $DIR1/$tfile-0 &
+       mv $DIR1/$tdir/$tfile $DIR1/$tdir/$tfile-0 &
        PID1=$!; pdo_sched
        # open|create
-       touch $DIR2/$tfile-2
+       touch $DIR2/$tdir/$tfile-2
        check_pdo_conflict $PID1 || error "create is blocked"
-       mkdir $DIR2/$tfile-3
+       mkdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "mkdir is blocked"
-       link $DIR2/$tfile-2 $DIR2/$tfile-4
+       link $DIR2/$tdir/$tfile-2 $DIR2/$tdir/$tfile-4
        check_pdo_conflict $PID1 || error "link is blocked"
-       stat $DIR2/$tfile-3 $DIR2/$tfile-4 > /dev/null
+       stat $DIR2/$tdir/$tfile-3 $DIR2/$tdir/$tfile-4 > /dev/null
        check_pdo_conflict $PID1 || error "getattr is blocked"
-       rm $DIR2/$tfile-4 $DIR2/$tfile-2
-       rmdir $DIR2/$tfile-3
+       rm $DIR2/$tdir/$tfile-4 $DIR2/$tdir/$tfile-2
+       rmdir $DIR2/$tdir/$tfile-3
        check_pdo_conflict $PID1 || error "unlink is blocked"
 
        # all operations above shouldn't wait the first one
@@ -1733,7 +1742,7 @@ test_40e() {
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0 2>/dev/null || true"
        wait $PID1
-       rm -rf $DIR/$tfile*
+       rm -rf $DIR/$tdir
        return 0
 }
 run_test 40e "pdirops: rename and others =============="
@@ -2048,20 +2057,20 @@ test_42f() {
 run_test 42f "pdirops: mkdir and rename (src) =============="
 
 test_42g() {
+       mkdir_on_mdt0 $DIR1/$tdir
        pdo_lru_clear
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_PDO_LOCK    0x145
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0x80000145 2>/dev/null || true"
-       mkdir $DIR1/$tfile &
+       mkdir $DIR1/$tdir/$tfile &
        PID1=$! ; pdo_sched
-       stat $DIR2/$tfile > /dev/null &
+       stat $DIR2/$tdir/$tfile > /dev/null &
        PID2=$! ; pdo_sched
        do_nodes $(comma_list $(mdts_nodes)) \
                "lctl set_param -n fail_loc=0 2>/dev/null || true"
        check_pdo_conflict $PID1 && { wait $PID1; error "getattr isn't blocked"; }
        wait $PID2 ; [ $? -eq 0 ] || error "stat must succeed"
-       rm -rf $DIR/$tfile*
-       return 0
+       rm -rf $DIR/$tdir
 }
 run_test 42g "pdirops: mkdir vs getattr =============="
 
@@ -2253,19 +2262,20 @@ test_43j() {
        [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] &&
                skip "Need MDS version newer than 2.13.52"
 
+       mkdir $DIR1/$tdir
        for i in {1..100}; do
 #define OBD_FAIL_ONCE|OBD_FAIL_MDS_CREATE_RACE         0x167
                do_nodes $(comma_list $(mdts_nodes)) \
                        "lctl set_param -n fail_loc=0x80000167 2>/dev/null ||
                                true"
                OK=0
-               mkdir $DIR1/$tdir &
+               mkdir $DIR1/$tdir/sub &
                PID1=$!
-               mkdir $DIR2/$tdir && ((OK++))
+               mkdir $DIR2/$tdir/sub && ((OK++))
                wait $PID1 && ((OK++))
                (( OK == 1 )) || error "exactly one mkdir should succeed"
 
-               rmdir $DIR1/$tdir || error "rmdir failed"
+               rmdir $DIR1/$tdir/sub || error "rmdir failed"
        done
        return 0
 }
@@ -3277,56 +3287,59 @@ test_54() {
 run_test 54 "rename locking"
 
 test_55a() {
-       mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
+       mkdir_on_mdt0 $DIR/$tdir
+       mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
 
 #define OBD_FAIL_MDS_RENAME4              0x156
        do_facet mds1 $LCTL set_param fail_loc=0x80000156
 
-       mv -T $DIR/d1/d2 $DIR/d3/d2 &
+       mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
        PID1=$!
        sleep 1
 
-       rm -r $DIR2/d3
+       rm -r $DIR2/$tdir/d3
        wait $PID1 && error "(2) mv succeeded"
 
-       rm -rf $DIR/d1
+       rm -rf $DIR/$tdir
 }
 run_test 55a "rename vs unlink target dir"
 
 test_55b()
 {
-       mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
+       mkdir_on_mdt0 $DIR/$tdir
+       mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
 
 #define OBD_FAIL_MDS_RENAME4             0x156
        do_facet mds1 $LCTL set_param fail_loc=0x80000156
 
-       mv -T $DIR/d1/d2 $DIR/d3/d2 &
+       mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
        PID1=$!
        sleep 1
 
-       rm -r $DIR2/d1
+       rm -r $DIR2/$tdir/d1
        wait $PID1 && error "(2) mv succeeded"
 
-       rm -rf $DIR/d3
+       rm -rf $DIR/$tdir
 }
 run_test 55b "rename vs unlink source dir"
 
 test_55c()
 {
-       mkdir -p $DIR/d1/d2 $DIR/d3 || error "(1) mkdir failed"
+       mkdir_on_mdt0 $DIR/$tdir
+       mkdir -p $DIR/$tdir/d1/d2 $DIR/$tdir/d3 || error "(1) mkdir failed"
 
 #define OBD_FAIL_MDS_RENAME4              0x156
        do_facet mds1 $LCTL set_param fail_loc=0x156
 
-       mv -T $DIR/d1/d2 $DIR/d3/d2 &
+       mv -T $DIR/$tdir/d1/d2 $DIR/$tdir/d3/d2 &
        PID1=$!
        sleep 1
 
        # while rename is sleeping, open and remove d3
-       $MULTIOP $DIR2/d3 D_c &
+       $MULTIOP $DIR2/$tdir/d3 D_c &
        PID2=$!
        sleep 1
-       rm -rf $DIR2/d3
+       rm -rf $DIR2/$tdir/d3
        sleep 5
 
        # while rename is sleeping 2nd time, close d3
@@ -3335,28 +3348,30 @@ test_55c()
 
        wait $PID1 && error "(2) mv succeeded"
 
-       rm -rf $DIR/d1
+       rm -rf $DIR/$tdir
 }
 run_test 55c "rename vs unlink orphan target dir"
 
 test_55d()
 {
-       touch $DIR/f1
+       mkdir_on_mdt0 $DIR/$tdir
+
+       touch $DIR/$tdir/f1
 
 #define OBD_FAIL_MDS_RENAME3              0x155
        do_facet mds1 $LCTL set_param fail_loc=0x155
-       mv $DIR/f1 $DIR/$tdir &
+       mv $DIR/$tdir/f1 $DIR/$tdir/$tdir &
        PID1=$!
        sleep 2
 
        # while rename is sleeping, create $tdir, but as a directory
-       mkdir -p $DIR2/$tdir || error "(1) mkdir failed"
+       mkdir -p $DIR2/$tdir/$tdir || error "(1) mkdir failed"
 
        # link in reverse locking order
-       ln $DIR2/f1 $DIR2/$tdir/
+       ln $DIR2/$tdir/f1 $DIR2/$tdir/$tdir/
 
        wait $PID1 && error "(2) mv succeeded"
-       rm -rf $DIR/f1
+       rm -rf $DIR/$tdir
 }
 run_test 55d "rename file vs link"
 
index f06aa14..32d1cb2 100755 (executable)
@@ -8699,7 +8699,7 @@ check_mount_and_prep()
        is_mounted $MOUNT || setupall
 
        rm -rf $DIR/[df][0-9]* || error "Fail to cleanup the env!"
-       mkdir $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
+       mkdir_on_mdt0 $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
        for idx in $(seq $MDSCOUNT); do
                local name="MDT$(printf '%04x' $((idx - 1)))"
                rm -rf $MOUNT/.lustre/lost+found/$name/*
@@ -10398,3 +10398,10 @@ function restore_opencache()
        [[ -z "${saved_OPENCACHE_value}" ]] ||
                $LCTL set_param -n "llite.*.opencache_threshold_count"=${saved_OPENCACHE_value}
 }
+
+# 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.
+mkdir_on_mdt0() {
+       $LFS mkdir -i 0 -c 1 $*
+}