Re: [PATCH 2/9] fstests: add _mkfs_scratch_clone() helper

Anand Jain
2026-03-11T02:32:22Z

> What about if ${#devs[@]} > 2 ?

On purpose- so tests using _scratch_mkfs_sized_clone() don't
pick a random higher number. If a test needs more than two
devices, opens an opportunity to critically review this function.
>> + fi
>> +
>> + case "$FSTYP" in
>> + "btrfs")
>> + _scratch_mkfs_sized $size
>> + _scratch_mount
>> + $BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/sv1
>> + _scratch_unmount
>> + ;;
>> + "xfs"|"ext4")
>> + _scratch_mkfs_sized $size
>> + ;;
>> + *)
>> + _notrun "fstests clone op unsupported for FS $FSTYP"
>> + ;;
>> + esac
>> +
>> + # clone SCRATCH_DEV devs[0] to devs[1].
>> + dd if=$SCRATCH_DEV of=${devs[1]} bs=$size status=none count=1 || \
>> + _fail "Clone failed"
>
> I'm wondering if we absolutely need to use SCRATCH_DEV_POOL for this test. Could we clone SCRATCH_DEV
> to an image file instead? Or would it be feasible to simply run the test using two image files?

Using a config file and testing directly on block devices lets
us cover a wider range of devices.

When I wrote this test case, I was also considering whether a
serial-number–based mount without extra mount option, would be
better in the kernel.

The downside is that xfs/ext4 testers now need to use
SCRATCH_DEV_POOL. Let me know what you prefer.