Re: [PATCH 7/7] generic/274: Make the test compatible with all blocksizes.

Qu Wenruo
2025-08-04T04:35:23Z

在 2025/7/29 15:51, Nirjhar Roy (IBM) 写道:
> On btrfs with 64k blocksize on powerpc with 64k pagesize
> it failed with the following error:
>
> ------------------------------
> preallocation test
> ------------------------------
> -done
> +failed to write to test file
> +(see /home/xfstests-dev/results//btrfs_64k/generic/274.full for details)
> ...
> So, this test is written with 4K block size in mind. As we can see,
> it first creates a file of size 4K and then fallocates 4MB beyond the
> EOF.
> Then there are 2 loops - one that fragments at alternate blocks and
> the other punches holes in the remaining alternate blocks. Hence,
> the test fails in 64k block size due to incorrect calculations.
>
> Fix this test by making the test scale with the block size, that is
> the offset, filesize and the assumed blocksize matches/scales with
> the actual blocksize of the underlying filesystem.

Again, just enlarge the block size from 4K to 64K, then all block size
will work.

Thanks,
Qu

>
> Reported-by: Disha Goel <disgoel@linux.ibm.com>
> Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
> ---
> tests/generic/274 | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/tests/generic/274 b/tests/generic/274
> index 916c7173..4ea42f30 100755
> --- a/tests/generic/274
> +++ b/tests/generic/274
> @@ -40,30 +40,31 @@ _scratch_unmount 2>/dev/null
> _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
> _scratch_mount
>
> -# Create a 4k file and Allocate 4M past EOF on that file
> -$XFS_IO_PROG -f -c "pwrite 0 4k" -c "falloc -k 4k 4m" $SCRATCH_MNT/test \
> - >>$seqres.full 2>&1 || _fail "failed to create test file"
> +blksz=`_get_block_size $SCRATCH_MNT`
> +scale=$(( blksz / 1024 ))
> +# Create a blocksize worth file and Allocate a large file past EOF on that file
> +$XFS_IO_PROG -f -c "pwrite -b $blksz 0 $blksz" -c "falloc -k $blksz $(( 1 * 1024 * 1024 * scale ))" \
> + $SCRATCH_MNT/test >>$seqres.full 2>&1 || _fail "failed to create test file"
>
> # Fill the rest of the fs completely
> # Note, this will show ENOSPC errors in $seqres.full, that's ok.
> echo "Fill fs with 1M IOs; ENOSPC expected" >> $seqres.full
> dd if=/dev/zero of=$SCRATCH_MNT/tmp1 bs=1M >>$seqres.full 2>&1
> -echo "Fill fs with 4K IOs; ENOSPC expected" >> $seqres.full
> -dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=4K >>$seqres.full 2>&1
> +echo "Fill fs with $blksz K IOs; ENOSPC expected" >> $seqres.full
> +dd if=/dev/zero of=$SCRATCH_MNT/tmp2 bs=$blksz >>$seqres.full 2>&1
> _scratch_sync
> # Last effort, use O_SYNC
> -echo "Fill fs with 4K DIOs; ENOSPC expected" >> $seqres.full
> -dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=4K oflag=sync >>$seqres.full 2>&1
> +echo "Fill fs with $blksz DIOs; ENOSPC expected" >> $seqres.full
> +dd if=/dev/zero of=$SCRATCH_MNT/tmp3 bs=$blksz oflag=sync >>$seqres.full 2>&1
> # Save space usage info
> echo "Post-fill space:" >> $seqres.full
> df $SCRATCH_MNT >>$seqres.full 2>&1
> -
> # Now attempt a write into all of the preallocated space -
> # in a very nasty way, badly fragmenting it and then filling it in.
> echo "Fill in prealloc space; fragment at offsets:" >> $seqres.full
> for i in `seq 1 2 1023`; do
> echo -n "$i " >> $seqres.full
> - dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
> + dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=$blksz count=1 conv=notrunc \
> >>$seqres.full 2>/dev/null || _fail "failed to write to test file"
> done
> _scratch_sync
> @@ -71,7 +72,7 @@ echo >> $seqres.full
> echo "Fill in prealloc space; fill holes at offsets:" >> $seqres.full
> for i in `seq 2 2 1023`; do
> echo -n "$i " >> $seqres.full
> - dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=4K count=1 conv=notrunc \
> + dd if=/dev/zero of=$SCRATCH_MNT/test seek=$i bs=$blksz count=1 conv=notrunc \
> >>$seqres.full 2>/dev/null || _fail "failed to fill test file"
> done
> _scratch_sync