Whamcloud - gitweb
LU-8367 osp: enable replay for precreation request
[fs/lustre-release.git] / lustre / tests / sanity.sh
index b906786..ad95b63 100755 (executable)
@@ -46,7 +46,6 @@ always_except LU-8411  407
 
 if $SHARED_KEY; then
        always_except LU-14181 64e 64f
-       always_except LU-15910 413g
 fi
 
 # skip the grant tests for ARM until they are fixed
@@ -3379,31 +3378,6 @@ test_27R() {
 }
 run_test 27R "test max_stripecount limitation when stripe count is set to -1"
 
-test_27S() {
-       (( $MDS1_VERSION >= $(version_code 2.14.54) )) ||
-               skip "Need MDS version at least 2.14.54"
-       [[ "$(facet_host mds1)" != "$(facet_host ost1)" ]] ||
-               skip "needs different host for mdt1 ost1"
-
-       local count=$(precreated_ost_obj_count 0 0)
-
-       echo "precreate count $count"
-       mkdir_on_mdt0 $DIR/$tdir || error "mkdir $tdir failed"
-       $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "setstripe $tdir failed"
-       #define OBD_FAIL_OSP_GET_LAST_FID       0x2109
-       do_facet mds1 $LCTL set_param fail_loc=0x2109
-       #define OBD_FAIL_OST_GET_LAST_FID       0x252
-       do_facet ost1 $LCTL set_param fail_loc=0x252
-       createmany -o $DIR/$tdir/f $count &
-       pid=$!
-       echo "precreate count $(precreated_ost_obj_count 0 0)"
-       do_facet mds1 $LCTL set_param fail_loc=0
-       do_facet ost1 $LCTL set_param fail_loc=0
-       wait $pid || error "createmany failed"
-       echo "precreate count $(precreated_ost_obj_count 0 0)"
-}
-run_test 27S "don't deactivate OSP on network issue"
-
 test_27T() {
        [ $(facet_host client) == $(facet_host ost1) ] &&
                skip "need ost1 and client on different nodes"
@@ -5892,7 +5866,7 @@ test_51d_sub() {
 
        local nlast
        local min=4
-       local max=5 # allow variance of (1 - $min/$max) = 20% by default
+       local max=6 # allow variance of (1 - $min/$max) = 33% by default
 
        # For some combinations of stripecount and OSTCOUNT current code
        # is not ideal, and allocates 50% fewer *first* objects to some OSTs
@@ -18807,18 +18781,32 @@ test_205b() {
        (( $MDS1_VERSION >= $(version_code 2.13.54.91) )) ||
                skip "Need MDS version at least 2.13.54.91"
 
-       job_stats="mdt.*.job_stats"
-       $LCTL set_param $job_stats=clear
+       local job_stats="mdt.*.job_stats"
+       local old_jobid=$(do_facet mds1 $LCTL get_param jobid_var)
+
+       do_facet mds1 $LCTL set_param $job_stats=clear
+
        # Setting jobid_var to USER might not be supported
+       [[ -n "$old_jobid" ]] && stack_trap "$LCTL set_param $old_jobid"
        $LCTL set_param jobid_var=USER || true
-       $LCTL set_param jobid_name="%e.%u"
+       stack_trap "$LCTL set_param $($LCTL get_param jobid_name)"
+       $LCTL set_param jobid_name="%j.%e.%u"
+
        env -i USERTESTJOBSTATS=foolish touch $DIR/$tfile.1
-       do_facet $SINGLEMDS $LCTL get_param $job_stats |
-               grep "job_id:.*foolish" &&
-                       error "Unexpected jobid found"
-       do_facet $SINGLEMDS $LCTL get_param $job_stats |
-               grep "open:.*min.*max.*sum" ||
-                       error "wrong job_stats format found"
+       do_facet mds1 $LCTL get_param $job_stats | grep "job_id:.*foolish" &&
+               { do_facet mds1 $LCTL get_param $job_stats;
+                 error "Unexpected jobid found"; }
+       do_facet mds1 $LCTL get_param $job_stats | grep "open:.*min.*max.*sum"||
+               { do_facet mds1 $LCTL get_param $job_stats;
+                 error "wrong job_stats format found"; }
+
+       (( $MDS1_VERSION <= $(version_code 2.15.0) )) &&
+               echo "MDS does not yet escape jobid" && return 0
+       $LCTL set_param jobid_var=TEST205b
+       env -i TEST205b="has sp" touch $DIR/$tfile.2
+       do_facet mds1 $LCTL get_param $job_stats | grep "has.*x20sp" ||
+               { do_facet mds1 $LCTL get_param $job_stats;
+                 error "jobid not escaped"; }
 }
 run_test 205b "Verify job stats jobid and output format"
 
@@ -25585,6 +25573,7 @@ test_412() {
 }
 run_test 412 "mkdir on specific MDTs"
 
+TEST413_COUNT=${TEST413_COUNT:-200}
 generate_uneven_mdts() {
        local threshold=$1
        local lmv_qos_maxage
@@ -25642,23 +25631,24 @@ generate_uneven_mdts() {
        local testdir=$DIR/$tdir-fillmdt
        local start
 
-       mkdir -p $testdir
-
        i=0
        while (( diff < threshold )); do
+               mkdir -p $testdir
                # generate uneven MDTs, create till $threshold% diff
                echo -n "weight diff=$diff% must be > $threshold% ..."
-               echo "Fill MDT$min_index with 1000 files: loop $i"
+               echo "Fill MDT$min_index with $TEST413_COUNT files: loop $i"
                testdir=$DIR/$tdir-fillmdt/$i
-               [ -d $testdir ] || $LFS mkdir -i $min_index $testdir ||
+               [ -d $testdir ] && continue
+               $LFS mkdir -i $min_index $testdir ||
                        error "mkdir $testdir failed"
                $LFS setstripe -E 1M -L mdt $testdir ||
                        error "setstripe $testdir failed"
                start=$SECONDS
-               for F in f.{0..999}; do
-                       dd if=/dev/zero of=$testdir/$F bs=64K count=1 > \
+               for ((F=0; F < TEST413_COUNT; F++)); do
+                       dd if=/dev/zero of=$testdir/f.$F bs=128K count=1 > \
                                /dev/null 2>&1 || error "dd $F failed"
                done
+               sync; sleep 1; sync
 
                # wait for QOS to update
                (( SECONDS < start + 1 )) && sleep $((start + 1 - SECONDS))
@@ -26123,13 +26113,56 @@ test_413g() {
 }
 run_test 413g "enforce ROOT default LMV on subdir mount"
 
+test_413h() {
+       (( MDSCOUNT >= 2 )) ||
+               skip "We need at least 2 MDTs for this test"
+
+       (( MDS1_VERSION >= $(version_code 2.15.50.6) )) ||
+               skip "Need server version at least 2.15.50.6"
+
+       local lmv_qos_maxage=$($LCTL get_param -n lmv.*.qos_maxage)
+
+       stack_trap "$LCTL set_param \
+               lmv.*.qos_maxage=$lmv_qos_maxage > /dev/null"
+       $LCTL set_param lmv.*.qos_maxage=1
+
+       local depth=5
+       local rr_depth=4
+       local dir=$DIR/$tdir/l1/l2/l3/l4/l5
+       local count=$((MDSCOUNT * 20))
+
+       generate_uneven_mdts 50
+
+       mkdir -p $dir || error "mkdir $dir failed"
+       stack_trap "rm -rf $dir"
+       $LFS setdirstripe -D -c 1 -i -1 --max-inherit=$depth \
+               --max-inherit-rr=$rr_depth $dir
+
+       for ((d=0; d < depth + 2; d++)); do
+               log "dir=$dir:"
+               for ((sub=0; sub < count; sub++)); do
+                       mkdir $dir/d$sub
+               done
+               $LFS getdirstripe -i $dir/d* | sort | uniq -c | sort -nr
+               local num=($($LFS getdirstripe -i $dir/d* | sort | uniq -c))
+               # subdirs within $rr_depth should be created round-robin
+               if (( d < rr_depth )); then
+                       (( ${num[0]} != count )) ||
+                               error "all objects created on MDT ${num[1]}"
+               fi
+
+               dir=$dir/d0
+       done
+}
+run_test 413h "don't stick to parent for round-robin dirs"
+
 test_413z() {
        local pids=""
        local subdir
        local pid
 
        for subdir in $(\ls -1 -d $DIR/d413*-fillmdt/*); do
-               unlinkmany $subdir/f. 1000 &
+               unlinkmany $subdir/f. $TEST413_COUNT &
                pids="$pids $!"
        done
 
@@ -28310,34 +28343,6 @@ test_820() {
 }
 run_test 820 "update max EA from open intent"
 
-test_822() {
-       local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
-
-       save_lustre_params mds1 \
-               "osp.$FSNAME-OST*-osc-MDT0000.max_create_count" > $p
-       do_facet $SINGLEMDS "$LCTL set_param -n \
-                       osp.$FSNAME-OST*MDT0000.max_create_count=0"
-       do_facet $SINGLEMDS "$LCTL set_param -n \
-                       osp.$FSNAME-OST0000*MDT0000.max_create_count=20000"
-
-       # wait for statfs update to clear OS_STATFS_NOPRECREATE
-       local maxage=$(do_facet mds1 $LCTL get_param -n \
-                      osp.$FSNAME-OST0000*MDT0000.maxage)
-       sleep $((maxage + 1))
-
-       #define OBD_FAIL_NET_ERROR_RPC          0x532
-       do_facet mds1 "$LCTL set_param fail_loc=0x80000532 fail_val=5"
-
-       stack_trap "restore_lustre_params < $p; rm $p"
-
-       local count=$(do_facet $SINGLEMDS "lctl get_param -n \
-                     osp.$FSNAME-OST0000*MDT0000.create_count")
-       for i in $(seq 1 $count); do
-               touch $DIR/$tfile.${i} || error "touch failed"
-       done
-}
-run_test 822 "test precreate failure"
-
 test_823() {
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
        local OST_MAX_PRECREATE=20000
@@ -28578,6 +28583,27 @@ test_904() {
 }
 run_test 904 "virtual project ID xattr"
 
+# LU-8582
+test_905() {
+       (( $OST1_VERSION >= $(version_code 2.8.54) )) ||
+               skip "lustre < 2.8.54 does not support ladvise"
+
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       $LFS setstripe -c -1 -i 0 $DIR/$tfile || error "setstripe failed"
+
+       $LFS ladvise -a willread $DIR/$tfile || error "ladvise does not work"
+
+       #define OBD_FAIL_OST_OPCODE 0x253
+       # OST_LADVISE = 21
+       do_facet ost1 "$LCTL set_param fail_val=21 fail_loc=0x0253"
+       $LFS ladvise -a willread $DIR/$tfile &&
+               error "unexpected success of ladvise with fault injection"
+       $LFS ladvise -a willread $DIR/$tfile |&
+               grep -q "Operation not supported"
+       (( $? == 0 )) || error "unexpected stderr of ladvise with fault injection"
+}
+run_test 905 "bad or new opcode should not stuck client"
+
 complete $SECONDS
 [ -f $EXT2_DEV ] && rm $EXT2_DEV || true
 check_and_cleanup_lustre