common/rc: teach _scratch_mkfs_sized to set a size on an xfs realtime volume
authorDarrick J. Wong <>
Fri, 18 Sep 2020 02:08:33 +0000 (19:08 -0700)
committerEryu Guan <>
Sun, 20 Sep 2020 17:09:06 +0000 (01:09 +0800)
Generally speaking, tests that call _scratch_mkfs_sized are trying to
constrain a test's run time by formatting a filesystem that's smaller
than the device.  The current helper does this for the scratch device,
but it doesn't do this for the xfs realtime volume.

If fstests has been configured to create files on the realtime device by
default ("-d rtinherit=1) then those tests that want to run with a small
volume size will instead be running with a huge realtime device.  This
makes certain tests take forever to run, so apply the same sizing to the
rt volume if one exists.

Signed-off-by: Darrick J. Wong <>
Reviewed-by: Zorro Lang <>
Reviewed-by: Christoph Hellwig <>
Signed-off-by: Eryu Guan <>

index 4bee0c8..c1e8180 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -976,14 +976,20 @@ _scratch_mkfs_sized()
        [ "$fssize" -gt "$devsize" ] && _notrun "Scratch device too small"
+    if [ "$FSTYP" = "xfs" ] && [ -b "$SCRATCH_RTDEV" ]; then
+       local rtdevsize=`blockdev --getsize64 $SCRATCH_RTDEV`
+       [ "$fssize" -gt "$rtdevsize" ] && _notrun "Scratch rt device too small"
+       rt_ops="-r size=$fssize"
+    fi
     case $FSTYP in
        # don't override MKFS_OPTIONS that set a block size.
        echo $MKFS_OPTIONS |egrep -q "b?size="
        if [ $? -eq 0 ]; then
-               _scratch_mkfs_xfs -d size=$fssize
+               _scratch_mkfs_xfs -d size=$fssize $rt_ops
-               _scratch_mkfs_xfs -d size=$fssize -b size=$blocksize
+               _scratch_mkfs_xfs -d size=$fssize $rt_ops -b size=$blocksize