fstests: run xfs_io with -i option if supported
authorAmir Goldstein <amir73il@gmail.com>
Mon, 17 Oct 2016 07:31:41 +0000 (10:31 +0300)
committerEryu Guan <eguan@redhat.com>
Fri, 21 Oct 2016 15:18:02 +0000 (23:18 +0800)
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).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/rc

index fe34bb7c63670d8a9b1be7b56e67336debd0ad92..041736dafd4e2a8ed5a70e24a5fb668ebb355580 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -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"