fstests: fix call sites that used xfs_io directly
PATCH v3 1/3 fstests: fix call sites that used xfs_io directly
Convert those few remaining call sites to use the XFS_IO_PROG env var.
--- common/quota | 4 ++-- common/rc | 4 ++-- tests/generic/043 | 2 +- tests/generic/044 | 4 ++-- tests/generic/045 | 4 ++-- tests/generic/046 | 4 ++-- tests/generic/047 | 2 +- tests/generic/048 | 2 +- tests/generic/049 | 2 +- tests/generic/224 | 4 ++-- tests/xfs/109 | 4 ++-- tests/xfs/114 | 4 ++-- tests/xfs/190 | 4 ++-- tests/xfs/201 | 2 +- tests/xfs/229 | 2 +- tests/xfs/250 | 2 +- tests/xfs/291 | 2 +- 17 files changed, 26 insertions(+), 26 deletions(-)
common/quota +2 -2
@@ -139,7 +139,7 @@ _file_as_id() parent=`dirname $1` if [ $3 = p ]; then - echo PARENT: xfs_io -r -c "chproj $2" -c "chattr +P" $parent >>$seqres.full + echo PARENT: $XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$seqres.full $XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$seqres.full 2>&1 magik='$>' # (irrelevent, above set projid-inherit-on-parent) elif [ $3 = u ]; then
@@ -165,7 +165,7 @@ EOF # exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$seqres.full 2>&1"; if [ $3 = p ]; then - echo PARENT: xfs_io -r -c "chproj 0" -c "chattr -P" $parent >>$seqres.full + echo PARENT: $XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$seqres.full $XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$seqres.full 2>&1 fi }
common/rc +2 -2
@@ -3796,8 +3796,8 @@ init_rc() exit 1 fi # Figure out if we need to add -F ("foreign", deprecated) option to xfs_io - xfs_io -c stat $TEST_DIR 2>&1 | grep -q "is not on an XFS filesystem" && \ - export XFS_IO_PROG="$XFS_IO_PROG -F" + $XFS_IO_PROG -c stat $TEST_DIR 2>&1 | grep -q "is not on an XFS filesystem" && \ + export XFS_IO_PROG="$XFS_IO_PROG -F" # xfs_copy doesn't work on v5 xfs yet without -d option if [ "$FSTYP" == "xfs" ] && [[ $MKFS_OPTIONS =~ crc=1 ]]; then
tests/generic/043 +1 -1
@@ -50,7 +50,7 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file
tests/generic/044 +2 -2
@@ -50,13 +50,13 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file exit fi - xfs_io -c "truncate 64k" $file > /dev/null + $XFS_IO_PROG -c "truncate 64k" $file > /dev/null if [ $? -ne 0 ] then echo error truncating file $file
tests/generic/045 +2 -2
@@ -50,13 +50,13 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file exit fi - xfs_io -c "truncate 32k" $file > /dev/null + $XFS_IO_PROG -c "truncate 32k" $file > /dev/null if [ $? -ne 0 ] then echo error truncating file $file
tests/generic/046 +2 -2
@@ -50,13 +50,13 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file exit fi - xfs_io -c "truncate 64k" $file > /dev/null + $XFS_IO_PROG -c "truncate 64k" $file > /dev/null if [ $? -ne 0 ] then echo error truncating file $file
tests/generic/047 +1 -1
@@ -81,7 +81,7 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 32k -S 0xff 0 32k" -c "fsync" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 32k -S 0xff 0 32k" -c "fsync" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file
tests/generic/048 +1 -1
@@ -84,7 +84,7 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 64k -S 0xff 0 10m" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file
tests/generic/049 +1 -1
@@ -81,7 +81,7 @@ i=1; while [ $i -lt 1000 ] do file=$SCRATCH_MNT/$i - xfs_io -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null + $XFS_IO_PROG -f -c "pwrite -b 32k -S 0xff 0 32k" $file > /dev/null if [ $? -ne 0 ] then echo error creating/writing file $file
tests/generic/224 +2 -2
@@ -59,7 +59,7 @@ _scratch_mount >> $seqres.full 2>&1 # set the reserved block pool to almost empty for XFS if [ "$FSTYP" = "xfs" ]; then - xfs_io -x -c "resblks 4" $SCRATCH_MNT >> $seqres.full 2>&1 + $XFS_IO_PROG -x -c "resblks 4" $SCRATCH_MNT >> $seqres.full 2>&1 fi FILES=1000
@@ -71,7 +71,7 @@ for i in `seq 0 1 $FILES`; do # tripped over. ( sleep 5 - xfs_io -f -c "truncate 10485760" $SCRATCH_MNT/testfile.$i + $XFS_IO_PROG -f -c "truncate 10485760" $SCRATCH_MNT/testfile.$i dd if=/dev/zero of=$SCRATCH_MNT/testfile.$i bs=4k conv=notrunc ) > /dev/null 2>&1 & done
tests/xfs/109 +2 -2
@@ -50,7 +50,7 @@ populate() i=0 while [ $i -le $files -a "X$faststart" = "X" ]; do file=$SCRATCH_MNT/f$i - xfs_io -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null + $XFS_IO_PROG -f -d -c 'pwrite -b 64k 0 64k' $file >/dev/null let i=$i+1 done
@@ -77,7 +77,7 @@ allocate() { j=0 while [ $j -lt 100 ]; do - xfs_io -f -c 'pwrite -b 64k 0 16m' $file \ + $XFS_IO_PROG -f -c 'pwrite -b 64k 0 16m' $file \ >/dev/null 2>&1 rm $file let j=$j+1
tests/xfs/114 +2 -2
@@ -44,7 +44,7 @@ _check_paths() sync; sleep 1 echo "" echo "Check parent" - if ! xfs_io -x -c 'parent -c' $SCRATCH_MNT | _filter_num; then + if ! $XFS_IO_PROG -x -c 'parent -c' $SCRATCH_MNT | _filter_num; then exit 1 fi }
@@ -55,7 +55,7 @@ _print_names() echo "Print out hardlink names for given path, $1" echo "" - xfs_io -x -c parent $1 | awk '/p_ino.*=/ {$3 = "inodeXXX"; print; next} {print}' + $XFS_IO_PROG -x -c parent $1 | awk '/p_ino.*=/ {$3 = "inodeXXX"; print; next} {print}' } _test_create()
tests/xfs/190 +2 -2
@@ -62,8 +62,8 @@ dd if=/dev/zero of=$SCRATCH_MNT/$filename bs=1024k count=10 >> $seqres.full 2>&1 echo Punching holes in file echo Punching holes in file >> $seqres.full for i in $holes ; do - echo xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full - xfs_io -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ; + echo $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename >> $seqres.full + $XFS_IO_PROG -c "unresvsp `echo $i |$SED_PROG 's/:/ /g'`" $SCRATCH_MNT/$filename ; done echo Verifying holes are in the correct spots:
tests/xfs/201 +1 -1
@@ -56,7 +56,7 @@ do_pwrite() end=`expr $2 \* $min_align` length=`expr $end - $offset` - xfs_io -d -f $file -c "pwrite $offset $length" >/dev/null + $XFS_IO_PROG -d -f $file -c "pwrite $offset $length" >/dev/null } _require_scratch
tests/xfs/229 +1 -1
@@ -60,7 +60,7 @@ EXTSIZE="256k" mkdir ${TDIR} # Set the test directory extsize -xfs_io -c "extsize ${EXTSIZE}" ${TDIR} +$XFS_IO_PROG -c "extsize ${EXTSIZE}" ${TDIR} # Create a set of holey files echo "generating ${NFILES} files"
tests/xfs/250 +1 -1
@@ -81,7 +81,7 @@ _test_loop() mount -t xfs -o loop $LOOP_DEV $LOOP_MNT echo "*** preallocate large file" - xfs_io -f -c "resvsp 0 $fsize" $LOOP_MNT/foo | _filter_io + $XFS_IO_PROG -f -c "resvsp 0 $fsize" $LOOP_MNT/foo | _filter_io echo "*** unmount loop filesystem" umount $LOOP_MNT > /dev/null 2>&1
tests/xfs/291 +1 -1
@@ -69,7 +69,7 @@ done sync # Soak up any remaining freespace -xfs_io -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1 +$XFS_IO_PROG -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1 # Take a look at freespace for any post-mortem on the test _scratch_unmount
Signature · 1 line
2.7.4
PATCH v3 2/3 fstests: strip quotes from "$XFS_IO_PROG" call sites
The value of "$XFS_IO_PROG" may contain extra flags after the binary path (e.g. -F), so it is wrong to use the variable inside quotes in xfs_io execution call sites.
This bug surfaced while testing the new xfs_io -M flag.
--- common/rc | 6 +++--- common/reflink | 26 +++++++++++++------------- tests/generic/176 | 2 +- tests/xfs/328 | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-)
common/rc +3 -3
@@ -90,7 +90,7 @@ _pwrite_byte() { file="$4" xfs_io_args="$5" - "$XFS_IO_PROG" $xfs_io_args -f -c "pwrite -S $pattern $offset $len" "$file" + $XFS_IO_PROG $xfs_io_args -f -c "pwrite -S $pattern $offset $len" "$file" } # mmap-write a byte into a range of a file
@@ -101,7 +101,7 @@ _mwrite_byte() { mmap_len="$4" file="$5" - "$XFS_IO_PROG" -f -c "mmap -rw 0 $mmap_len" -c "mwrite -S $pattern $offset $len" "$file" + $XFS_IO_PROG -f -c "mmap -rw 0 $mmap_len" -c "mwrite -S $pattern $offset $len" "$file" } # ls -l w/ selinux sometimes puts a dot at the end:
@@ -3437,7 +3437,7 @@ _xfs_bmapx_find() { file="$1" shift - "$XFS_IO_PROG" -c "bmap -${param}lpv" "$file" | grep -c "$@" + $XFS_IO_PROG -c "bmap -${param}lpv" "$file" | grep -c "$@" } _require_chattr()
common/reflink +13 -13
@@ -52,8 +52,8 @@ _require_test_reflink() _require_xfs_io_command "reflink" rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2" - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null - "$XFS_IO_PROG" -f -c "reflink $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null + $XFS_IO_PROG -f -c "reflink $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" > /dev/null if [ ! -s "$TEST_DIR/file2" ]; then rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2" _notrun "Reflink not supported by test filesystem type: $FSTYP"
@@ -69,8 +69,8 @@ _require_scratch_reflink() _scratch_mkfs > /dev/null _scratch_mount - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null - "$XFS_IO_PROG" -f -c "reflink $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null + $XFS_IO_PROG -f -c "reflink $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" > /dev/null if [ ! -s "$SCRATCH_MNT/file2" ]; then _scratch_unmount _notrun "Reflink not supported by scratch filesystem type: $FSTYP"
@@ -85,9 +85,9 @@ _require_test_dedupe() _require_xfs_io_command "dedupe" rm -rf "$TEST_DIR/file1" "$TEST_DIR/file2" - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file2" > /dev/null - testio="$("$XFS_IO_PROG" -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)" + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file1" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$TEST_DIR/file2" > /dev/null + testio="$($XFS_IO_PROG -f -c "dedupe $TEST_DIR/file1 0 0 65536" "$TEST_DIR/file2" 2>&1)" echo $testio | grep -q "Operation not supported" && \ _notrun "Dedupe not supported by test filesystem type: $FSTYP" echo $testio | grep -q "Inappropriate ioctl for device" && \
@@ -105,9 +105,9 @@ _require_scratch_dedupe() _scratch_mkfs > /dev/null _scratch_mount - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null - "$XFS_IO_PROG" -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null - testio="$("$XFS_IO_PROG" -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)" + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file1" > /dev/null + $XFS_IO_PROG -f -c "pwrite -S 0x61 0 65536" "$SCRATCH_MNT/file2" > /dev/null + testio="$($XFS_IO_PROG -f -c "dedupe $SCRATCH_MNT/file1 0 0 65536" "$SCRATCH_MNT/file2" 2>&1)" echo $testio | grep -q "Operation not supported" && \ _notrun "Dedupe not supported by test filesystem type: $FSTYP" echo $testio | grep -q "Inappropriate ioctl for device" && \
@@ -161,7 +161,7 @@ _reflink() { file1="$1" file2="$2" - "$XFS_IO_PROG" -f -c "reflink $file1" "$file2" + $XFS_IO_PROG -f -c "reflink $file1" "$file2" } # Reflink some part of file1 into another part of file2
@@ -173,7 +173,7 @@ _reflink_range() { len="$5" xfs_io_args="$6" - "$XFS_IO_PROG" $xfs_io_args -f -c "reflink $file1 $offset1 $offset2 $len" "$file2" + $XFS_IO_PROG $xfs_io_args -f -c "reflink $file1 $offset1 $offset2 $len" "$file2" } # Dedupe some part of file1 into another part of file2
@@ -185,7 +185,7 @@ _dedupe_range() { len="$5" xfs_io_args="$6" - "$XFS_IO_PROG" $xfs_io_args -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2" + $XFS_IO_PROG $xfs_io_args -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2" } # Create a file of interleaved unwritten and reflinked blocks
tests/generic/176 +1 -1
@@ -75,7 +75,7 @@ test $fnr -lt 17 && _notrun "Insufficient space for stress test; would only crea echo "Create a many-block file" echo "creating $blocks_needed blocks..." >> "$seqres.full" -"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b 4194304 0 $((2 ** (fnr + 1) * blksz))" "$testdir/file1" >> "$seqres.full" +$XFS_IO_PROG -f -c "pwrite -S 0x61 -b 4194304 0 $((2 ** (fnr + 1) * blksz))" "$testdir/file1" >> "$seqres.full" echo "punching..." >> "$seqres.full" "$here/src/punch-alternating" "$testdir/file1" >> "$seqres.full" echo "...done" >> "$seqres.full"
tests/xfs/328 +1 -1
@@ -80,7 +80,7 @@ bytes=$((blocks_needed * blksz)) echo "Create a many-block file" echo "creating $blocks_needed blocks..." >> "$seqres.full" _pwrite_byte 0x62 0 $blksz $testdir/file0 >> $seqres.full -"$XFS_IO_PROG" -f -c "pwrite -S 0x61 -b 4194304 0 $bytes" "$testdir/file1" >> "$seqres.full" +$XFS_IO_PROG -f -c "pwrite -S 0x61 -b 4194304 0 $bytes" "$testdir/file1" >> "$seqres.full" echo "punching..." >> "$seqres.full" "$here/src/punch-alternating" "$testdir/file1" >> "$seqres.full" seq 0 2 $((2 ** (fnr + 1) )) | while read lblk; do
Signature · 1 line
2.7.4
PATCH v3 3/3 fstests: run xfs_io with -i option is supported
In reply to Amir GoldsteinTry to run xfs_io with command line option -i, which starts an idle thread before performing any io.
The purpose of this idle thread is to test io from a multi threaded process. With single threaded process, the file table is not shared and file structs are not reference counted.
In order to improve the chance of detecting file struct reference leaks, we should run xfs_io commands with this option as much as possible.
Analysis of the effect of xfs_io -i on tests runtime showed that it may lead to slightly longer run times in extreme cases (e.g +3s for generic/132), but has a negligable effect on runtime of tests among the 'quick' group (worst case +0.3s for generic/130).
--- common/rc | 9 +++++++++ 1 file changed, 9 insertions(+)
common/rc +9 -0
@@ -3799,6 +3799,15 @@ init_rc() $XFS_IO_PROG -c stat $TEST_DIR 2>&1 | grep -q "is not on an XFS filesystem" && \ export XFS_IO_PROG="$XFS_IO_PROG -F" + # xfs_io -i option starts an idle thread for xfs_io. + # With single threaded process, the file table is not shared + # and file structs are not reference counted. + # Spawning an idle thread can help detecting file struct + # reference leaks, so we want to enable the option whenever + # it is supported. + $XFS_IO_PROG -i -c quit 2>/dev/null && \ + export XFS_IO_PROG="$XFS_IO_PROG -i" + # xfs_copy doesn't work on v5 xfs yet without -d option if [ "$FSTYP" == "xfs" ] && [[ $MKFS_OPTIONS =~ crc=1 ]]; then export XFS_COPY_PROG="$XFS_COPY_PROG -d"
Signature · 1 line
2.7.4
PATCH v3 3/3 fstests: run xfs_io with -i option if supported
Try to run xfs_io with command line option -i, which starts an idle thread before performing any io.
The purpose of this idle thread is to test io from a multi threaded process. With single threaded process, the file table is not shared and file structs are not reference counted.
In order to improve the chance of detecting file struct reference leaks, we should run xfs_io commands with this option as much as possible.
Analysis of the effect of xfs_io -i on tests runtime showed that it may lead to slightly longer run times in extreme cases (e.g +3s for generic/132), but has a negligible effect on runtime of tests among the 'quick' group (worst case +0.3s for generic/130).
--- common/rc | 9 +++++++++ 1 file changed, 9 insertions(+)
common/rc +9 -0
@@ -3799,6 +3799,15 @@ init_rc() $XFS_IO_PROG -c stat $TEST_DIR 2>&1 | grep -q "is not on an XFS filesystem" && \ export XFS_IO_PROG="$XFS_IO_PROG -F" + # xfs_io -i option starts an idle thread for xfs_io. + # With single threaded process, the file table is not shared + # and file structs are not reference counted. + # Spawning an idle thread can help detecting file struct + # reference leaks, so we want to enable the option whenever + # it is supported. + $XFS_IO_PROG -i -c quit 2>/dev/null && \ + export XFS_IO_PROG="$XFS_IO_PROG -i" + # xfs_copy doesn't work on v5 xfs yet without -d option if [ "$FSTYP" == "xfs" ] && [[ $MKFS_OPTIONS =~ crc=1 ]]; then export XFS_COPY_PROG="$XFS_COPY_PROG -d"
Signature · 1 line
2.7.4
Re: [PATCH v3 2/3] fstests: strip quotes from "$XFS_IO_PROG" call sites
In reply to Amir GoldsteinQuoted 5 lines · Amir Goldstein
The value of "$XFS_IO_PROG" may contain extra flags after the binary path (e.g. -F), so it is wrong to use the variable inside quotes in
xfs_ioexecution call sites.This bug surfaced while testing the new
xfs_io-M flag.
^^^ should be -i now? :)
I can fix it at commit time.
Thanks,
Eryu
Re: [PATCH v3 2/3] fstests: strip quotes from "$XFS_IO_PROG" call sites
Quoted 7 lines · Eryu Guan
Quoted 5 lines · Amir Goldstein
The value of "$XFS_IO_PROG" may contain extra flags after the binary path (e.g. -F), so it is wrong to use the variable inside quotes in
xfs_ioexecution call sites.This bug surfaced while testing the new
xfs_io-M flag.^^^ should be -i now? :)
indeed
Thanks.
Quoted 5 lines
I can fix it at commit time.
Thanks,
Eryu