generic: clean up tests using fio
authorTheodore Ts'o <tytso@mit.edu>
Mon, 8 Mar 2021 01:54:34 +0000 (20:54 -0500)
committerEryu Guan <guaneryu@gmail.com>
Sun, 14 Mar 2021 11:12:42 +0000 (19:12 +0800)
During the code review for a test to exercises AIO/DIO into unwritten
space, a number of changes were requested that were also applicable to
generic/299 and generic/300 (from which the aforementioned test was
patterned).  For example, the use of run_check, which is deprecated,
was dropped.  In addition, we now rely on the test runner to unmount
the scratch file system.

Also fix a nit I found in generic/095, which resulted in debugging
information in the $seqres.full to get lost when "fio ...
--output=$seqres.full" is run.

[Eryu: add _require_aio to generic/095, fix more indention issues]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/generic/095
tests/generic/299
tests/generic/300

index 30fe77a55babd50e36138a5f71144cee2ad5b7c6..b702a397b047159a376c6749db3aec636bd45dac 100755 (executable)
@@ -29,11 +29,13 @@ _cleanup()
 _supported_fs generic
 _require_scratch
 _require_odirect
+_require_aio
 
 iodepth=$((16 * LOAD_FACTOR))
 iodepth_batch=$((8 * LOAD_FACTOR))
 numjobs=$((5 * LOAD_FACTOR))
 fio_config=$tmp.fio
+fio_out=$tmp.fio.out
 cat >$fio_config <<EOF
 [global]
 bs=8k
@@ -101,7 +103,8 @@ _scratch_mount
 # There's a known EIO failure to report collisions between directio and buffered
 # writes to userspace, refer to upstream linux 5a9d929d6e13. So ignore EIO error
 # at here.
-$FIO_PROG $fio_config --ignore_error=,EIO --output=$seqres.full
+$FIO_PROG $fio_config --ignore_error=,EIO --output=$fio_out
+cat $fio_out >> $seqres.full
 echo "Silence is golden"
 
 # xfs generates WARNINGs on purpose when applications mix buffered/mmap IO with
index aff6dac3ec061ca19c7728d4b2d58b79d91d9a03..6380e350c444e744f0d53fcf091bea820d2499c0 100755 (executable)
@@ -15,8 +15,15 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 fio_config=$tmp.fio
+fio_out=$tmp.fio.out
 status=1       # failure is the default!
-trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
 
 # get standard environment, filters and checks
 . ./common/rc
@@ -27,6 +34,7 @@ _supported_fs generic
 _require_test
 _require_scratch
 _require_odirect
+_require_aio
 _require_block_device $SCRATCH_DEV
 
 NUM_JOBS=$((4*LOAD_FACTOR))
@@ -104,47 +112,32 @@ rm -f $seqres.full
 _require_fio $fio_config
 _require_xfs_io_command "falloc"
 
-_workout()
-{
-       echo ""
-       echo "Run fio with random aio-dio pattern"
-       echo ""
-       cat $fio_config >>  $seqres.full
-       run_check $FIO_PROG $fio_config &
-       pid=$!
-       echo "Start fallocate/truncate loop"
-
-       for ((i=0; ; i++))
-       do
-           for ((k=1; k <= NUM_JOBS; k++))
-           do
+_scratch_mkfs >> $seqres.full 2>&1
+_scratch_mount
+
+echo ""
+echo "Run fio with random aio-dio pattern"
+echo ""
+cat $fio_config >>  $seqres.full
+$FIO_PROG $fio_config --output=$fio_out &
+pid=$!
+echo "Start fallocate/truncate loop"
+
+for ((i=0; ; i++)); do
+       for ((k=1; k <= NUM_JOBS; k++)); do
                $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
                        $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
-           done
-           for ((k=1; k <= NUM_JOBS; k++))
-           do
+       done
+       for ((k=1; k <= NUM_JOBS; k++)); do
                $XFS_IO_PROG -c "truncate  0" \
                        $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
-           done
-           # Following like will check that pid is still run.
-           # Once fio exit we can stop fallocate/truncate loop
-           pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
        done
-       wait $pid
-}
-
-_scratch_mkfs >> $seqres.full 2>&1
-_scratch_mount
-
-if ! _workout; then
-       _scratch_unmount 2>/dev/null
-       exit
-fi
+       # Following like will check that pid is still run.
+       # Once fio exit we can stop fallocate/truncate loop
+       pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
+done
+wait $pid
+cat $fio_out >> $seqres.full
 
-if ! _scratch_unmount; then
-       echo "failed to umount"
-       status=1
-       exit
-fi
 status=0
 exit
index f7a99d4aca02ae91395708012d5843473853534d..fed6862baf4b57afd71471fa2f7ba4efea95025a 100755 (executable)
@@ -15,8 +15,15 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 fio_config=$tmp.fio
+fio_out=$tmp.fio.out
 status=1       # failure is the default!
-trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
 
 # get standard environment, filters and checks
 . ./common/rc
@@ -26,6 +33,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 _supported_fs generic
 _require_scratch
 _require_odirect
+_require_aio
 _require_block_device $SCRATCH_DEV
 
 # xfs_io is not required for this test, but it's the best way to verify
@@ -37,9 +45,8 @@ rm -f $seqres.full
 
 NUM_JOBS=$((4*LOAD_FACTOR))
 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
-if [ $((BLK_DEV_SIZE)) -gt 1048576 ]
-then
-    BLK_DEV_SIZE=1048576
+if [ $((BLK_DEV_SIZE)) -gt 1048576 ]; then
+       BLK_DEV_SIZE=1048576
 fi
 FS_SIZE=$((BLK_DEV_SIZE * 512))
 
@@ -115,29 +122,17 @@ rw=randwrite
 filename=aio-dio-verifier
 EOF
 
-_workout()
-{
-       echo ""
-       echo "Run fio with random aio-dio pattern"
-       echo ""
-       cat $fio_config >>  $seqres.full
-       run_check $FIO_PROG $fio_config
-}
-
 _require_fio $fio_config
 
 _scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
 _scratch_mount
 
-if ! _workout; then
-       _scratch_unmount 2>/dev/null
-       exit
-fi
+echo ""
+echo "Run fio with random aio-dio pattern"
+echo ""
+cat $fio_config >>  $seqres.full
+$FIO_PROG $fio_config --output=$fio_out
+cat $fio_out >> $seqres.full
 
-if ! _scratch_unmount; then
-       echo "failed to umount"
-       status=1
-       exit
-fi
 status=0
 exit