Whamcloud - gitweb
LU-18646 tests: use /dev/urandom to consume space 71/57871/12
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 23 Jan 2025 05:07:26 +0000 (22:07 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Feb 2025 01:28:53 +0000 (01:28 +0000)
It appears newer ZFS is using data compression by default, so reading
from /dev/zero results in files not consuming the expected amount of
space.  Instead, read from /dev/urandom for ZFS to write files in
sanity-quota and ost-pools to ensure they fill the OSTs as expected.

Minor script style cleanups for affected tests.

Test-Parameters: trivial testlist=sanity-quota,ost-pools fstype=zfs
Test-Parameters: testlist=sanity-quota,ost-pools fstype=ldiskfs
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ia2340da6e4c6d00123078545fde135a89c2540e5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57871
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Sergey Cheremencev <scherementsev@ddn.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
lustre/tests/ost-pools.sh
lustre/tests/sanity-quota.sh
lustre/tests/test-framework.sh

index 3b2181e..f339500 100755 (executable)
@@ -303,7 +303,7 @@ test_1n() {
        local POOL_ROOT=${POOL_ROOT:-$DIR/$tdir}
        create_dir $POOL_ROOT ${POOL}1234567
        stack_trap "rm -f $POOL_ROOT/file"
-       dd if=/dev/zero of=$POOL_ROOT/file bs=1M count=100
+       $DD of=$POOL_ROOT/file count=100
        RC=$?; [[ $RC -eq 0 ]] ||
                error "failed to write to $POOL_ROOT/file: $RC"
        do_facet mgs lctl pool_remove $FSNAME.${POOL}1234567 OST0000
@@ -924,10 +924,8 @@ test_14() {
        OST0_SIZE=$($LFS df $POOL_ROOT/dir2 | awk '/\[OST:0\]/ { print $4 }')
        FILE_SIZE=$((OST0_SIZE/1024/10))
        echo "Filling OST0 with 9 files of ${FILE_SIZE}MB in $POOL_ROOT/dir2"
-       i=1
-       while [[ $i -lt 10 ]]; do
-               dd if=/dev/zero of=$POOL_ROOT/dir2/f${i} bs=1M count=$FILE_SIZE
-               i=$((i + 1))
+       for ((i = 1; $i < 10; i++)); do
+               $DD of=$POOL_ROOT/dir2/f${i} count=$FILE_SIZE
        done
        sleep 1 # get new statfs info
        $LFS df $POOL_ROOT/dir2
@@ -1302,20 +1300,19 @@ test_23a() {
        # This does two "dd" runs to ensure that the quota failure is returned
        # to userspace when we check.  The first "dd" might otherwise complete
        # without error if it is only writing into cache.
-       stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
-               count=$((BUNIT_SZ*2)) 2>&1)
+       stat=$(LOCALE=C $RUNAS $DD of=$file bs=$BUNIT_SZ count=$((BUNIT_SZ*2)) 2>&1)
        echo $stat | grep "Disk quota exceeded" > /dev/null
        if [ $? -eq 0 ]; then
                $LFS quota -v -u $RUNAS_ID $dir
                cancel_lru_locks osc
                stack_trap "rm -f $file"
-               stat=$(LOCALE=C $RUNAS dd if=/dev/zero of=$file bs=$BUNIT_SZ \
-                       count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
+               stat=$(LOCALE=C $RUNAS $DD of=$file bs=$BUNIT_SZ \
+                      count=$BUNIT_SZ seek=$((BUNIT_SZ*2)) 2>&1)
                RC=$?
                echo $stat
-               [[ $RC -eq 0 ]] && error "second dd did not fail."
+               (( $RC != 0 )) || error "second dd did not fail."
                echo $stat | grep "Disk quota exceeded" > /dev/null
-               [[ $? -eq 1 ]] && error "second dd did not fail with EDQUOT."
+               (( $? != 1 )) || error "second dd did not fail with EDQUOT."
        else
                log "first dd failed with EDQUOT."
        fi
@@ -1333,81 +1330,76 @@ test_23b() {
        }
 
        local i=0
-       local TGT
        local dir=$POOL_ROOT/dir
        local file="$dir/$tfile-quota"
 
        create_pool_nofail $POOL
 
-       local TGT=$(for i in $(seq 0x$TGT_FIRST 3 0x$TGT_MAX); do \
+       local tgt=$(for ((i = 0x$TGT_FIRST; i <= 0x$TGT_MAX; i += 3)); do
                printf "$FSNAME-OST%04x_UUID " $i; done)
-       add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$TGT"
+       add_pool $POOL "$FSNAME-OST[$TGT_FIRST-$TGT_MAX/3]" "$tgt"
        create_dir $dir $POOL
+       stack_trap "rm -rf $POOL_ROOT; wait_delete_completed"
 
+       $LFS df -p $POOL $dir
        local maxfree=$((1024 * 1024 * 30)) # 30G
-       local AVAIL=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
-       [ $AVAIL -gt $maxfree ] &&
-               skip_env "Filesystem space $AVAIL is larger than " \
-                       "$maxfree limit"
+       local avail=$(lfs_df -p $POOL $dir | awk '/summary/ { print $4 }')
+       (( $avail <= $maxfree )) ||
+               skip_env "Filesystem space $avail > $maxfree limit"
 
-       echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, AVAIL=$AVAIL"
-       echo "MAXFREE=$maxfree, SLOW=$SLOW"
+       echo "OSTCOUNT=$OSTCOUNT, OSTSIZE=$OSTSIZE, SLOW=$SLOW, POOL=$POOL"
+       echo "pool_avail=$avail, maxfree=$maxfree"
 
-       # XXX remove the interoperability code once we drop the old server
-       #     ( < 2.3.50) support.
-       if [ "$MDS1_VERSION" -lt $(version_code 2.3.50) ]; then
-               $LFS quotaoff -ug $MOUNT
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
+               do_facet mgs $PERM_CMD \
+                       osd-*.$FSNAME-OST*.quota_slave.enabled=none
        else
-               if [[ $PERM_CMD == *"set_param -P"* ]]; then
-                       do_facet mgs $PERM_CMD \
-                               osd-*.$FSNAME-OST*.quota_slave.enabled=none
-               else
-                       do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
-               fi
-               sleep 5
+               do_facet mgs $PERM_CMD $FSNAME.quota.ost=none
        fi
+       sleep 5
 
        chown $RUNAS_ID.$RUNAS_ID $dir
        i=0
-       local RC=0
-       local TOTAL=0 # KB
-       local stime=$(date +%s)
-       local stat
-       local etime
-       local elapsed
+       local rc=0
+       local total=0 # KB
+       local wr_mb=$((5 * 1024))
+       local stime=$SECONDS
        local maxtime=300 # minimum speed: 5GB / 300sec ~= 17MB/s
-       while [ $RC -eq 0 ]; do
-               i=$((i + 1))
-               stat=$(LOCALE=C $RUNAS2 dd if=/dev/zero of=${file}$i bs=1M \
-                       count=$((5 * 1024)) 2>&1)
-               RC=$?
-               TOTAL=$((TOTAL + 1024 * 1024 * 5))
-               echo "[$i iteration] $stat"
-               echo "total written: $TOTAL"
 
-               etime=$(date +%s)
+       while (( $rc == 0 )); do
+               local stat
+               local etime
+               local elapsed
+
+               i=$((i + 1))
+               # use urandom to avoid data compression
+               stat=$(LOCALE=C $RUNAS2 $DD of=$file.$i count=$wr_mb 2>&1)
+               rc=$?
+               ((total += wr_mb * 1024))
+               echo "iteration $i: $stat"
+               ls -ls $file.*
+               echo "total written: $total"
+
+               etime=$SECONDS
                elapsed=$((etime - stime))
-               echo "stime=$stime, etime=$etime, elapsed=$elapsed"
+               echo "start=$stime, end=$etime, elapsed=$elapsed"
 
-               if [ $RC -eq 1 ]; then
+               if (( $rc == 1 )); then
                        echo $stat | grep -q "Disk quota exceeded"
-                       [[ $? -eq 0 ]] &&
+                       (( $? != 0 )) ||
                                error "dd failed with EDQUOT with quota off"
 
                        echo $stat | grep -q "No space left on device"
-                       [[ $? -ne 0 ]] &&
-                               error "dd did not fail with ENOSPC"
-               elif [ $TOTAL -gt $AVAIL ]; then
-                       error "dd didn't fail with ENOSPC ($TOTAL > $AVAIL)"
-               elif [ $i -eq 1 -a $elapsed -gt $maxtime ]; then
-                       log "The first 5G write used $elapsed (> $maxtime) " \
-                               "seconds, terminated"
-                       RC=1
+                       (( $? == 0 )) || error "dd did not fail with ENOSPC"
+               elif (( $total > $avail )); then
+                       error "dd didn't fail with ENOSPC ($total > $avail)"
+               elif (( $i == 1 && $elapsed > $maxtime )); then
+                       skip "5G write used $elapsed > $maxtime sec, give up"
+                       rc=1
                fi
        done
 
        df -h
-       rm -rf $POOL_ROOT
 }
 run_test 23b "OST pools and OOS"
 
@@ -1605,7 +1597,7 @@ test_28() {
        start_full_debug_logging
        #$LFS setstripe -E 4M -c 1 -p $POOL -E 16M -c 2 $DIR/$tfile
        $LFS setstripe -c 1 -p $POOL $DIR/$tfile
-       dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=16
+       $DD of=$DIR/$tfile count=1 seek=16
        local csum=$(cksum $DIR/$tfile)
        $LFS getstripe $DIR/$tfile
        local pool="$($LFS getstripe -p $DIR/$tfile)"
index 7042f85..18a4df7 100755 (executable)
@@ -17,6 +17,10 @@ ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT "
 ALWAYS_EXCEPT+=""
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
+if [[ "$ost1_FSTYPE" == "zfs" ]]; then
+       always_except LU-18676 49
+fi
+
 # Test duration:                   30 min
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="61"
 
@@ -95,7 +99,6 @@ lustre_fail() {
 
 RUNAS="runas -u $TSTID -g $TSTID"
 RUNAS2="runas -u $TSTID2 -g $TSTID2"
-DD="dd if=/dev/zero bs=1M"
 
 FAIL_ON_ERROR=false
 
@@ -1483,7 +1486,7 @@ test_block_soft() {
        cancel_lru_locks osc
 
        echo "Write to exceed soft limit"
-       $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
+       $RUNAS $DD of=$testfile bs=1K count=10 seek=$OFFSET ||
                quota_error a $TSTUSR "write failure, but expect success"
        OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
        cancel_lru_locks osc
@@ -1501,7 +1504,7 @@ test_block_soft() {
        $SHOW_QUOTA_INFO_PROJID
 
        echo "Write before timer goes off"
-       $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
+       $RUNAS $DD of=$testfile bs=1K count=10 seek=$OFFSET ||
                quota_error a $TSTUSR "write failure, but expect success"
        OFFSET=$((OFFSET + 1024))
        cancel_lru_locks osc
@@ -1519,12 +1522,11 @@ test_block_soft() {
        # maybe cache write, ignore.
        # write up to soft least quint to consume all
        # possible slave granted space.
-       $RUNAS dd if=/dev/zero of=$testfile bs=1K \
-               count=$soft_limit seek=$OFFSET || true
+       $RUNAS $DD of=$testfile bs=1K count=$soft_limit seek=$OFFSET || true
        OFFSET=$((OFFSET + soft_limit))
        cancel_lru_locks osc
        log "Write after cancel lru locks"
-       $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET &&
+       $RUNAS $DD of=$testfile bs=1K count=10 seek=$OFFSET &&
                quota_error a $TSTUSR "write success, but expect EDQUOT"
 
        $SHOW_QUOTA_USER
@@ -4460,8 +4462,8 @@ test_55() {
        usermod -G $TSTUSR,$TSTUSR2 $TSTUSR
 
        #prepare test file
-       $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1024 count=100000 ||
-       error "failed to dd"
+       $RUNAS $DD of=$DIR/$tdir/$tfile bs=1024 count=100000 ||
+               error "failed to dd"
 
        cancel_lru_locks osc
        sync; sync_all_data || true
@@ -5335,11 +5337,11 @@ test_69()
        $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
                error "set user quota failed"
 
-       $RUNAS dd if=/dev/zero of="$dom0/f1" bs=1K count=512 oflag=sync ||
+       $RUNAS $DD of="$dom0/f1" bs=1K count=512 oflag=sync ||
                quota_error u $TSTUSR "write failed"
 
-       $RUNAS dd if=/dev/zero of="$dom0/f1" bs=1K count=512 seek=512 \
-               oflag=sync || quota_error u $TSTUSR "write failed"
+       $RUNAS $DD of="$dom0/f1" bs=1K count=512 seek=512 oflag=sync ||
+               quota_error u $TSTUSR "write failed"
 
        $RUNAS $DD of=$testfile count=$limit || true
 
@@ -5354,11 +5356,11 @@ test_69()
 
        # Now all members of qpool1 should get EDQUOT. Expect success
        # when write to DOM on MDT0, as it belongs to global pool.
-       $RUNAS dd if=/dev/zero of="$dom0/f1" bs=1K count=512 \
-               oflag=sync || quota_error u $TSTUSR "write failed"
+       $RUNAS $DD of="$dom0/f1" bs=1K count=512 oflag=sync ||
+               quota_error u $TSTUSR "write failed"
 
-       $RUNAS dd if=/dev/zero of="$dom0/f1" bs=1K count=512 seek=512 \
-               oflag=sync || quota_error u $TSTUSR "write failed"
+       $RUNAS $DD of="$dom0/f1" bs=1K count=512 seek=512 oflag=sync ||
+               quota_error u $TSTUSR "write failed"
 }
 run_test 69 "EDQUOT at one of pools shouldn't affect DOM"
 
@@ -5867,7 +5869,7 @@ test_75()
        cancel_lru_locks osc
 
        echo "Write to exceed soft limit"
-       dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
+       $DD of=$testfile bs=1K count=10 seek=$OFFSET ||
              quota_error a $TSTUSR "root write failure, but expect success (2)"
        OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
        cancel_lru_locks osc
index cf834c1..764202b 100755 (executable)
@@ -687,6 +687,13 @@ init_test_env() {
        export BLCKSIZE=${BLCKSIZE:-4096}
        export MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
        get_lustre_env
+       # use /dev/urandom when consuming space on ZFS to avoid compression
+       if [[ "$ost1_FSTYPE" == "zfs" ]]; then
+               DD_DEV="/dev/urandom"
+       else
+               DD_DEV="/dev/zero"
+       fi
+       DD="dd if=$DD_DEV bs=1M"
 
        # use localrecov to enable recovery for local clients, LU-12722
        [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] || {
@@ -3636,7 +3643,7 @@ fill_ost() {
        if (( lwm <= $free_kb / 1024 )) ||
           [ ! -f $DIR/${filename}.fill_ost$ost_idx ]; then
                $LFS setstripe -i $ost_idx -c1 $DIR/${filename}.fill_ost$ost_idx
-               dd if=/dev/zero of=$DIR/${filename}.fill_ost$ost_idx bs=1M \
+               $DD of=$DIR/${filename}.fill_ost$ost_idx \
                        count=$size_mb oflag=append conv=notrunc
        fi