Re: [PATCH v2] fstests: test premature ENOSPC in zoned garbage collection

Filipe Manana <[email protected]>
Newsgroups org.kernel.vger.fstests,org.kernel.vger.linux-btrfs
Message-ID <CAL3q7H42ddA_HtL9yuO4rWuLhtFht_UjUy3jDr+FgjOQQTcJ8A@mail.gmail.com>
On Tue, Apr 14, 2026 at 2:50 PM Johannes Thumshirn
<[email protected]> wrote:
>
> This test stresses garbage collection in zoned file systems by
> constantly overwriting the same file. It is inspired by a reproducer for
> a btrfs bugifx.
>
> Signed-off-by: Johannes Thumshirn <[email protected]>
> ---
> Changes to v1:
> - Rebased onto patches-in-queue
> - Use "generic/999" to avoid any conflicts
> - Change the number of loops to number of seq zones
> - Remove bogus "2>&1"
>
> Link to v1:
> https://lore.kernel.org/all/[email protected]/
>
>
>  tests/generic/999     | 48 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  2 ++
>  2 files changed, 50 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
>
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 000000000000..4ac6c0ff935c
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,48 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
> +#
> +# FS QA Test 999
> +#
> +# This test stresses garbage collection in zoned file systems by constantly
> +# overwriting the same file. It is inspired by a reproducer for a btrfs bugifx.
> +
> +. ./common/preamble
> +_begin_fstest auto quick zone
> +
> +. ./common/filter
> +
> +_require_scratch_size $((16 * 1024 * 1024))
> +_require_zoned_device "$SCRATCH_DEV"
> +
> +# This test requires specific data space usage, skip if we have compression
> +# enabled.
> +_require_no_compress
> +
> +
> +_fixed_by_fs_commit XXXXXXXXXXXX \
> +       "btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
> +_fixed_by_fs_commit XXXXXXXXXXXX \
> +       "btrfs: zoned: move partially zone_unusable block groups to reclaim list"

Already in Linus' tree, commit hash 258e46a6385c.

> +_fixed_by_fs_commit XXXXXXXXXXXX \
> +       "btrfs: zoned: add zone reclaim flush state for DATA space_info"

Also in Linus' tree, commit hash e2a7fd22378f.

> +
> +
> +_scratch_mkfs_sized $((16 * 1024 * 1024 * 1024)) &>>$seqres.full
> +_scratch_mount
> +
> +blocks="$(df -TB 1G $SCRATCH_DEV |\
> +       $AWK_PROG -v fstyp="$FSTYP" 'match($2, fstyp) {print $3}')"
> +
> +loops=$(echo "$blocks * 4 - 2" | bc)

nit: why pipe to bc? Wouldn't a simple bash expression like the following work?

loops=$(( blocks * 4 - 2 ))

Otherwise it looks fine to me, thanks.

> +
> +for (( i = 0; i < $loops; i++)); do
> +       dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=1024 status=none
> +       if [ $? -ne 0 ]; then
> +               _fail "Failed writing on iteration $i"
> +       fi
> +done
> +
> +echo "Silence is golden"
> +# success, all done
> +_exit 0
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 000000000000..3b276ca804fc
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,2 @@
> +QA output created by 999
> +Silence is golden
> --
> 2.53.0
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.