2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020-2021 Red Hat, Inc. All Rights Reserved.
7 # XFS online shrinkfs stress test
9 # This test attempts to shrink unused space as much as possible with
10 # background fsstress workload. It will decrease the shrink size if
11 # larger size fails. And totally repeat 2 * TIME_FACTOR times.
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
22 # get standard environment, filters and checks
28 _scratch_mkfs_xfs $@ | tee -a $seqres.full | \
29 _filter_mkfs 2>$tmp.mkfs >/dev/null
33 # fix the reserve block pool to a known size so that the enospc
34 # calculations work out correctly.
35 _scratch_resvblks 1024 > /dev/null 2>&1
40 $XFS_IO_PROG -f -c "falloc 0 $1" $SCRATCH_MNT/resvfile
47 # -w ensures that the only ops are ones which cause write I/O
48 local FSSTRESS_ARGS=`_scale_fsstress_args -d $SCRATCH_MNT -w \
49 -p $procs -n $nops $FSSTRESS_AVOID`
50 $FSSTRESS_PROG $FSSTRESS_ARGS >> $seqres.full 2>&1
53 # real QA test starts here
55 _require_scratch_xfs_shrink
56 _require_xfs_io_command "falloc"
59 _scratch_mkfs_xfs | tee -a $seqres.full | _filter_mkfs 2>$tmp.mkfs >/dev/null
60 . $tmp.mkfs # extract blocksize and data size for scratch device
62 endsize=`expr 125 \* 1048576` # stop after shrinking this big
63 [ `expr $endsize / $dbsize` -lt $dblocks ] || _notrun "Scratch device too small"
66 totalcount=$((2 * TIME_FACTOR))
68 while [ $totalcount -gt 0 ]; do
69 size=`expr 1010 \* 1048576` # 1010 megabytes initially
70 logblks=$(_scratch_find_xfs_min_logblocks -dsize=${size} -dagcount=${nags})
72 create_scratch -lsize=${logblks}b -dsize=${size} -dagcount=${nags}
74 for i in `seq 125 -1 90`; do
75 fillsize=`expr $i \* 1048576`
76 out="$(fill_scratch $fillsize 2>&1)"
77 echo "$out" | grep -q 'No space left on device' && continue
78 test -n "${out}" && echo "$out"
82 # shrink in chunks of this size at most
83 decsize=`expr 41 \* 1048576 + 1 + $RANDOM \* $RANDOM % 1048576`
85 while [ $size -gt $endsize ]; do
89 decb=`expr $decsize / $dbsize` # in data blocks
90 while [ $decb -gt 0 ]; do
91 sizeb=`expr $size / $dbsize - $decb`
93 $XFS_GROWFS_PROG -D ${sizeb} $SCRATCH_MNT \
94 >> $seqres.full 2>&1 && break
96 [ $decb -gt 100 ] && decb=`expr $decb + $RANDOM % 10`
101 [ $decb -eq 0 ] && break
104 $XFS_INFO_PROG $SCRATCH_MNT 2>&1 | _filter_mkfs 2>$tmp.growfs >/dev/null
107 size=`expr $dblocks \* $dbsize`
109 _scratch_xfs_repair -n >> $seqres.full 2>&1 || \
110 _fail "xfs_repair failed with shrinking $sizeb"
115 _scratch_xfs_repair -n >> $seqres.full 2>&1 || \
116 _fail "xfs_repair failed with shrinking $sizeb"
117 totalcount=`expr $totalcount - 1`
120 echo "Silence is golden"