Whamcloud - gitweb
LU-12838 ptlrpc: fix watchdog ratelimit logic
[fs/lustre-release.git] / lustre / tests / sanity.sh
index fe7c46d..3f784ff 100644 (file)
@@ -4266,7 +4266,7 @@ test_39j() {
                        error "mtime is lost on close: $mtime2, " \
                              "should be $mtime1"
 
-               cancel_lru_locks $OSC
+               cancel_lru_locks
                if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
        done
        lctl set_param fail_loc=0
@@ -4295,7 +4295,7 @@ test_39k() {
                [ "$mtime2" = $TEST_39_MTIME ] || \
                        error "mtime is lost on close: $mtime2, should be $TEST_39_MTIME"
 
-               cancel_lru_locks osc
+               cancel_lru_locks
                if [ $i = 0 ] ; then echo "repeat after cancel_lru_locks"; fi
        done
 }
@@ -7841,6 +7841,29 @@ test_65n() {
        local dir5_layout=$(get_layout_param $dir5)
        [[ "$dir4_layout" = "$dir5_layout" ]] ||
                error "$dir5 should inherit the default layout from $dir4"
+
+       # though subdir under ROOT doesn't inherit default layout, but
+       # its sub dir/file should be created with default layout.
+       [[ $MDSCOUNT -ge 2 ]] || skip_env "needs >= 2 MDTs"
+       [[ $MDS1_VERSION -ge $(version_code 2.12.59) ]] ||
+               skip "Need MDS version at least 2.12.59"
+
+       local default_lmv_count=$($LFS getdirstripe -D -c $MOUNT)
+       local default_lmv_index=$($LFS getdirstripe -D -i $MOUNT)
+       local default_lmv_hash=$($LFS getdirstripe -D -H $MOUNT)
+
+       if [ $default_lmv_hash == "none" ]; then
+               stack_trap "$LFS setdirstripe -D -d $MOUNT" EXIT
+       else
+               stack_trap "$LFS setdirstripe -D -i $default_lmv_index \
+                       -c $default_lmv_count -H $default_lmv_hash $MOUNT" EXIT
+       fi
+
+       $LFS setdirstripe -D -c 2 $MOUNT ||
+               error "setdirstripe -D -c 2 failed"
+       mkdir $MOUNT/$tdir-6 || error "mkdir $tdir-6 failed"
+       local lmv_count=$($LFS getdirstripe -c $MOUNT/$tdir-6)
+       [ $lmv_count -eq 2 ] || error "$tdir-6 stripe count $lmv_count"
 }
 run_test 65n "don't inherit default layout from root for new subdirectories"
 
@@ -8644,7 +8667,6 @@ cleanup_101a() {
 
 test_101a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run"
-       [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
 
        local s
        local discard
@@ -8669,9 +8691,12 @@ test_101a() {
        done
        cleanup_101a
 
-       if [[ $(($discard * 10)) -gt $nreads ]]; then
-               $LCTL get_param osc.*-osc*.rpc_stats
-               $LCTL get_param llite.*.read_ahead_stats
+       $LCTL get_param osc.*-osc*.rpc_stats
+       $LCTL get_param llite.*.read_ahead_stats
+
+       # Discard is generally zero, but sometimes a few random reads line up
+       # and trigger larger readahead, which is wasted & leads to discards.
+       if [[ $(($discard)) -gt $nreads ]]; then
                error "too many ($discard) discarded pages"
        fi
        rm -f $DIR/$tfile || true
@@ -20792,57 +20817,56 @@ test_413b() {
        sleep_maxage
 
        local ffree
+       local bavail
        local max
        local min
        local max_index
        local min_index
+       local tmp
 
-       ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree | uniq))
-       echo "MDT filesfree available: ${ffree[@]}"
-       max=${ffree[0]}
-       min=${ffree[0]}
+       ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.filesfree))
+       bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-[^M]*.kbytesavail))
+       bsize=$(lctl get_param -n mdc.*MDT0000*.blocksize)
+
+       max=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
+       min=$(((${ffree[0]} >> 8) * (${bavail[0]} * bsize >> 16)))
        max_index=0
        min_index=0
-       for ((i = 0; i < ${#ffree[@]}; i++)); do
-               if [[ ${ffree[i]} -gt $max ]]; then
-                       max=${ffree[i]}
+       for ((i = 1; i < ${#ffree[@]}; i++)); do
+               tmp=$(((${ffree[i]} >> 8) * (${bavail[i]} * bsize >> 16)))
+               if [ $tmp -gt $max ]; then
+                       max=$tmp
                        max_index=$i
                fi
-               if [[ ${ffree[i]} -lt $min ]]; then
-                       min=${ffree[i]}
+               if [ $tmp -lt $min ]; then
+                       min=$tmp
                        min_index=$i
                fi
        done
-       echo "Min free files: MDT$min_index: $min"
-       echo "Max free files: MDT$max_index: $max"
 
-       [ $min -eq 0 ] && skip "no free files in MDT$min_index"
-       [ $min -gt 10000000 ] && skip "too much free files in MDT$min_index"
+       [ ${ffree[min_index]} -eq 0 ] &&
+               skip "no free files in MDT$min_index"
+       [ ${ffree[min_index]} -gt 100000000 ] &&
+               skip "too much free files in MDT$min_index"
 
        # Check if we need to generate uneven MDTs
-       test_mkdir -i $min_index -c 1 -p $DIR/$tdir-MDT$min_index
-       local threshold=10
-       local diff=$((max - min))
-       local diff2=$((diff * 100 / min))
-
-       echo -n "Check for uneven MDTs: "
-       echo -n "diff=$diff files ($diff2%) must be > $threshold% ..."
+       local threshold=50
+       local diff=$(((max - min ) * 100 / min))
+       local value="$(generate_string 1024)"
+       local i
 
-       if [ $diff2 -gt $threshold ]; then
-               echo "ok"
-               echo "Don't need to fill MDT$min_index"
-       else
-               # generate uneven MDTs, create till 25% diff
-               echo "no"
-               diff2=$((threshold - diff2))
-               diff=$((min * diff2 / 100))
+       while [ $diff -lt $threshold ]; do
+               # generate uneven MDTs, create till $threshold% diff
+               echo -n "weight diff=$diff% must be > $threshold% ..."
+               count=$((${ffree[min_index]} / 10))
                # 50 sec per 10000 files in vm
-               [ $diff -gt 40000 ] && [ "$SLOW" = "no" ] &&
-                       skip "$diff files to create"
-               echo "Fill $diff2% diff in MDT$min_index with $diff files"
-               local i
-               local value="$(generate_string 1024)"
-               for i in $(seq $diff); do
+               [ $count -gt 40000 ] && [ "$SLOW" = "no" ] &&
+                       skip "$count files to create"
+               echo "Fill MDT$min_index with $count files"
+               [ -d $DIR/$tdir-MDT$min_index ] ||
+                       $LFS mkdir -i $min_index $DIR/$tdir-MDT$min_index ||
+                       error "mkdir $tdir-MDT$min_index failed"
+               for i in $(seq $count); do
                        $OPENFILE -f O_CREAT:O_LOV_DELAY_CREATE \
                                $DIR/$tdir-MDT$min_index/f$i > /dev/null ||
                                error "create f$i failed"
@@ -20850,31 +20874,43 @@ test_413b() {
                                $DIR/$tdir-MDT$min_index/f$i ||
                                error "setfattr f$i failed"
                done
-       fi
 
-       min=$((100 *MDSCOUNT))
-       max=0
+               ffree=($(lctl get_param -n mdc.*[mM][dD][cC]-*.filesfree))
+               bavail=($(lctl get_param -n mdc.*[mM][dD][cC]-*.kbytesavail))
+               max=$(((${ffree[max_index]} >> 8) * \
+                       (${bavail[max_index]} * bsize >> 16)))
+               min=$(((${ffree[min_index]} >> 8) * \
+                       (${bavail[min_index]} * bsize >> 16)))
+               diff=$(((max - min) * 100 / min))
+       done
+
+       echo "MDT filesfree available: ${ffree[@]}"
+       echo "MDT blocks available: ${bavail[@]}"
+       echo "weight diff=$diff%"
 
        echo "mkdir with balanced space usage"
        $LCTL set_param lmv.*.qos_prio_free=100
        for i in $(seq $((100 * MDSCOUNT))); do
                mkdir $DIR/$tdir/subdir$i || error "mkdir subdir$i failed"
        done
+
        for i in $(seq $MDSCOUNT); do
                count=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$((i - 1))$ |
                        wc -w)
                echo "$count directories created on MDT$((i - 1))"
-               [ $min -gt $count ] && min=$count
-               [ $max -lt $count ] && max=$count
        done
-       [ $((max - min)) -gt $MDSCOUNT ] ||
+
+       max=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$max_index$ | wc -l)
+       min=$($LFS getdirstripe -i $DIR/$tdir/* | grep ^$min_index$ | wc -l)
+
+       [ $((max - min)) -lt 10 ] &&
                error "subdirs shouldn't be evenly distributed"
 
        which getfattr > /dev/null 2>&1 || skip_env "no getfattr command"
 
        $LFS setdirstripe -D -d $DIR/$tdir || error "setdirstripe -d failed"
-       getfattr -n trusted.dmv $DIR/$tdir && error "default dir layout exists"
-       true
+       getfattr -n trusted.dmv $DIR/$tdir &&
+               error "default dir layout exists" || true
 }
 run_test 413b "mkdir with balanced space usage"
 
@@ -21340,6 +21376,50 @@ test_421g() {
 }
 run_test 421g "rmfid to return errors properly"
 
+test_422() {
+       test_mkdir -i 0 -c 1 -p $DIR/$tdir/d1
+       test_mkdir -i 0 -c 1 -p $DIR/$tdir/d2
+       test_mkdir -i 0 -c 1 -p $DIR/$tdir/d3
+       dd if=/dev/zero of=$DIR/$tdir/d1/file1 bs=1k count=1
+       dd if=/dev/zero of=$DIR/$tdir/d2/file1 bs=1k count=1
+
+       local amc=$(at_max_get client)
+       local amo=$(at_max_get mds1)
+       local timeout=`lctl get_param -n timeout`
+
+       at_max_set 0 client
+       at_max_set 0 mds1
+
+#define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
+       do_facet mds1 $LCTL set_param fail_loc=0x8000050a \
+                       fail_val=$(((2*timeout + 10)*1000))
+       touch $DIR/$tdir/d3/file &
+       sleep 2
+#define OBD_FAIL_TGT_REPLY_DATA_RACE    0x722
+       do_facet mds1 $LCTL set_param fail_loc=0x80000722 \
+                       fail_val=$((2*timeout + 5))
+       mv $DIR/$tdir/d1/file1 $DIR/$tdir/d1/file2 &
+       local pid=$!
+       sleep 1
+       kill -9 $pid
+       sleep $((2 * timeout))
+       echo kill $pid
+       kill -9 $pid
+       lctl mark touch
+       touch $DIR/$tdir/d2/file3
+       touch $DIR/$tdir/d2/file4
+       touch $DIR/$tdir/d2/file5
+
+       wait
+       at_max_set $amc client
+       at_max_set $amo mds1
+
+       # LU-12838 - verify the ptlrpc thread watchdog is not always throttled
+       do_facet mds1 "dmesg | grep 'Dumping the stack trace for debugging'" ||
+               error "Watchdog is always throttled"
+}
+run_test 422 "kill a process with RPC in progress"
+
 prep_801() {
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $OST1_VERSION -lt $(version_code 2.9.55) ]] &&