Re: [PATCH] generic/347: Fix sporadic test failures

Zorro Lang <[email protected]> Mon, 3 Aug 2026 16:27:15 +0800
Newsgroups org.kernel.vger.fstests
Message-ID <anBNLS4JmtT8GHGu@zlang-mailbox>
On Thu, Jul 30, 2026 at 05:18:17PM +0200, Jan Kara wrote:
> generic/347 was occasionally failing on ext4 in our QA due to ext4
> aborting its journal when the filesystem on thinp device was overfilled.
> I have tracked the problem down to journal checkpointing failing to
> write a metadata block to its final location due to ENOSPC failure from
> the thinp device. Modify the test to first preallocate blocks for the
> files and remount the filesystem which practically makes sure all
> involved metadata blocks were written and so their further modifications
> will not fail.
> 
> Signed-off-by: Jan Kara <[email protected]>
> ---
>  tests/generic/347 | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/generic/347 b/tests/generic/347
> index 06df0cf9eddc..56538c160392 100755
> --- a/tests/generic/347
> +++ b/tests/generic/347
> @@ -38,7 +38,17 @@ _setup_thin()
>  
>  _workout()
>  {
> -	# Overfill it by a bit
> +	# Preallocate space to avoid failure for metadata writeback
> +	for I in `seq 1 500`; do
> +		$XFS_IO_PROG -f -c "falloc 0 1M" $SCRATCH_MNT/file$I &>/dev/null

Hi Jan,

Thanks for this fix! Adding fallocate introduces an extra dependency via
_require_xfs_io_command "falloc", which will limit some filesystems can
run this test.

Additionally, since the underlying storage is a thinp device, I doubt
`falloc 0 1M` actually triggers physical block allocation on the thin
pool (correct me if I'm wrong). If so, I suspect this 1M * 500 preallocation
might exhaust the 500M BACKING_SIZE prematurely (along with file system
metadata overhead), similar to the pwrite loop below.

Do you think changing it to something smaller, like fallocate 0 64k, would
be better to populate the metadata structures without prematurely running
out of thin pool space?

Thanks,
Zorro

> +	done
> +
> +	# Unmount and check the device to make sure all metadata is written
> +	_dmthin_check_fs
> +	_dmthin_mount
> +
> +	# Write the data blocks to force thinp space allocation.
> +	# Overfill it by a bit.
>  	for I in `seq 1 500`; do
>  		$XFS_IO_PROG -f -c "pwrite -W 0 1M" $SCRATCH_MNT/file$I &>/dev/null
>  	done
> -- 
> 2.51.0
>