[PATCH 2/2] generic/563: limit loop device size

Shin'ichiro Kawasaki <[email protected]> Sat, 25 Jul 2026 16:04:12 +0900
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-xfs
Message-ID <[email protected]>
The test case generic/563 sets up a loop device on top of SCRATCH_DEV.
Currently, the loop device has the same size as SCRATCH_DEV. When
SCRATCH_DEV has huge size, mkfs for the loop device can take very long
time. Especially, when SCRATCH_DEV is a NVMe device that takes long time
for discard operation, mkfs for huge loop device can take hours.

To avoid the long mkfs time, limit the size of the loop device. Choose a
size four times the test's I/O size, then round it up to the
filesystem's minimum supported size by calling _small_fs_size_mb().

Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
---
 tests/generic/563 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tests/generic/563 b/tests/generic/563
index f95eb073..670238ae 100755
--- a/tests/generic/563
+++ b/tests/generic/563
@@ -91,7 +91,9 @@ reset()
 
 # cgroup I/O accounting doesn't work on partitions. Use a loop device to rule
 # that out.
-loop_dev=$(_create_loop_device_like_bdev $SCRATCH_DEV $SCRATCH_DEV)
+loopsize_mb=$(_small_fs_size_mb $(( iosize * 4 / 1024 / 1024 )))
+loop_dev=$(_create_loop_device_like_bdev $SCRATCH_DEV $SCRATCH_DEV \
+					 $((loopsize_mb * 1024 * 1024)))
 smajor=$((0x`stat -L -c %t $loop_dev`))
 sminor=$((0x`stat -L -c %T $loop_dev`))
 
-- 
2.54.0