public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fstests: test premature ENOSPC in zoned garbage collection
@ 2026-02-10 11:11 Johannes Thumshirn
  2026-02-10 15:51 ` Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2026-02-10 11:11 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Christoph Hellwig, linux-btrfs, fstests, Hans Holmberg,
	Naohiro Aota, Johannes Thumshirn

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 <johannes.thumshirn@wdc.com>
---
 tests/generic/783     | 48 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/783.out |  2 ++
 2 files changed, 50 insertions(+)
 create mode 100755 tests/generic/783
 create mode 100644 tests/generic/783.out

diff --git a/tests/generic/783 b/tests/generic/783
new file mode 100755
index 000000000000..f996d78803a1
--- /dev/null
+++ b/tests/generic/783
@@ -0,0 +1,48 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
+#
+# FS QA Test 783
+#
+# 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
+
+if [ "$FSTYP" = btrfs ]; then
+	_fixed_by_kernel_commit XXXXXXXXXXXX \
+		"btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
+	_fixed_by_kernel_commit XXXXXXXXXXXX \
+		"btrfs: zoned: move partially zone_unusable block groups to reclaim list"
+	_fixed_by_kernel_commit XXXXXXXXXXXX \
+		"btrfs: zoned: add zone reclaim flush state for DATA space_info"
+fi
+
+_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)
+
+for (( i = 0; i < $loops; i++)); do
+	dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=1024 status=none 2>&1
+	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/783.out b/tests/generic/783.out
new file mode 100644
index 000000000000..2522395956d4
--- /dev/null
+++ b/tests/generic/783.out
@@ -0,0 +1,2 @@
+QA output created by 783
+Silence is golden
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-02-10 11:11 [PATCH] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
@ 2026-02-10 15:51 ` Christoph Hellwig
  2026-02-10 15:58   ` Johannes Thumshirn
  2026-03-05  8:50 ` Johannes Thumshirn
  2026-03-09 15:31 ` Zorro Lang
  2 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2026-02-10 15:51 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Zorro Lang, Christoph Hellwig, linux-btrfs, fstests,
	Hans Holmberg, Naohiro Aota

On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn wrote:
> diff --git a/tests/generic/783 b/tests/generic/783
> new file mode 100755
> index 000000000000..f996d78803a1
> --- /dev/null
> +++ b/tests/generic/783

What tree is this against?  generic/783 has already been added to
xfstests in Nov 2025.

> +if [ "$FSTYP" = btrfs ]; then
> +	_fixed_by_kernel_commit XXXXXXXXXXXX \

Can we please finally clean up all this mess with a
_fixed_by_fs_commit <fstype> <commitid> helper?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-02-10 15:51 ` Christoph Hellwig
@ 2026-02-10 15:58   ` Johannes Thumshirn
  2026-02-11 15:29     ` Zorro Lang
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-02-10 15:58 UTC (permalink / raw)
  To: hch
  Cc: Zorro Lang, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Hans Holmberg, Naohiro Aota

On 2/10/26 4:52 PM, Christoph Hellwig wrote:
> On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn wrote:
>> diff --git a/tests/generic/783 b/tests/generic/783
>> new file mode 100755
>> index 000000000000..f996d78803a1
>> --- /dev/null
>> +++ b/tests/generic/783
> What tree is this against?  generic/783 has already been added to
> xfstests in Nov 2025.

Apparently I haven't re-based in a while, should be generic/788 with 
today's master.


>> +if [ "$FSTYP" = btrfs ]; then
>> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> Can we please finally clean up all this mess with a
> _fixed_by_fs_commit <fstype> <commitid> helper?
>
>
Maybe but that's a different topic.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-02-10 15:58   ` Johannes Thumshirn
@ 2026-02-11 15:29     ` Zorro Lang
  0 siblings, 0 replies; 8+ messages in thread
From: Zorro Lang @ 2026-02-11 15:29 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: hch, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Hans Holmberg, Naohiro Aota

On Tue, Feb 10, 2026 at 03:58:06PM +0000, Johannes Thumshirn wrote:
> On 2/10/26 4:52 PM, Christoph Hellwig wrote:
> > On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn wrote:
> >> diff --git a/tests/generic/783 b/tests/generic/783
> >> new file mode 100755
> >> index 000000000000..f996d78803a1
> >> --- /dev/null
> >> +++ b/tests/generic/783
> > What tree is this against?  generic/783 has already been added to
> > xfstests in Nov 2025.
> 
> Apparently I haven't re-based in a while, should be generic/788 with 
> today's master.

Please always rebase on for-next branch, or you can use a large number temporarily
(e.g. generic/999) to avoid conflict, I'll give it a proper number when I merge it.

Thanks,
Zorro

> 
> 
> >> +if [ "$FSTYP" = btrfs ]; then
> >> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> > Can we please finally clean up all this mess with a
> > _fixed_by_fs_commit <fstype> <commitid> helper?
> >
> >
> Maybe but that's a different topic.
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-02-10 11:11 [PATCH] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
  2026-02-10 15:51 ` Christoph Hellwig
@ 2026-03-05  8:50 ` Johannes Thumshirn
  2026-03-09 15:31 ` Zorro Lang
  2 siblings, 0 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2026-03-05  8:50 UTC (permalink / raw)
  To: Zorro Lang
  Cc: hch, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Hans Holmberg, Naohiro Aota

On 2/10/26 12:11 PM, Johannes Thumshirn 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.
Zorro ping? Should I rebase this?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-02-10 11:11 [PATCH] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
  2026-02-10 15:51 ` Christoph Hellwig
  2026-03-05  8:50 ` Johannes Thumshirn
@ 2026-03-09 15:31 ` Zorro Lang
  2026-03-09 15:35   ` Johannes Thumshirn
  2 siblings, 1 reply; 8+ messages in thread
From: Zorro Lang @ 2026-03-09 15:31 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, linux-btrfs, fstests, Hans Holmberg,
	Naohiro Aota

On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn 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 <johannes.thumshirn@wdc.com>
> ---
>  tests/generic/783     | 48 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/783.out |  2 ++
>  2 files changed, 50 insertions(+)
>  create mode 100755 tests/generic/783
>  create mode 100644 tests/generic/783.out
> 
> diff --git a/tests/generic/783 b/tests/generic/783
> new file mode 100755
> index 000000000000..f996d78803a1
> --- /dev/null
> +++ b/tests/generic/783
> @@ -0,0 +1,48 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
> +#
> +# FS QA Test 783
> +#
> +# 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
> +
> +if [ "$FSTYP" = btrfs ]; then
> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> +		"btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> +		"btrfs: zoned: move partially zone_unusable block groups to reclaim list"
> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> +		"btrfs: zoned: add zone reclaim flush state for DATA space_info"

Please rebase to latest for-next branch, then change above "_fixed_by_kernel_commit"
to "_fixed_by_fs_commit btrfs ...."

> +fi
> +
> +_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}')"

Wouldn’t it make more sense to get the available size here? And there's a helper
_get_available_space in common/rc.

> +
> +loops=$(echo "$blocks * 4 - 2" | bc)
Is $blocks a huge number? How about using $((blocks * 4 - 2)) simply?

Can you add a comment to explain what's this "blocks * 4 - 2" for?

> +
> +for (( i = 0; i < $loops; i++)); do
> +	dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=1024 status=none 2>&1

Not sure what's the "2>&1" for.

This isn't an append write, right? So we keep writting from 0 to 1G? Can you use a
comment to explain why we require 16G sized SCRATCH_DEV ?

Thanks,
Zorro

> +	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/783.out b/tests/generic/783.out
> new file mode 100644
> index 000000000000..2522395956d4
> --- /dev/null
> +++ b/tests/generic/783.out
> @@ -0,0 +1,2 @@
> +QA output created by 783
> +Silence is golden
> -- 
> 2.53.0
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-03-09 15:31 ` Zorro Lang
@ 2026-03-09 15:35   ` Johannes Thumshirn
  2026-03-09 16:51     ` Zorro Lang
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-03-09 15:35 UTC (permalink / raw)
  To: Zorro Lang
  Cc: hch, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Hans Holmberg, Naohiro Aota

On 3/9/26 4:31 PM, Zorro Lang wrote:
> On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn 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 <johannes.thumshirn@wdc.com>
>> ---
>>   tests/generic/783     | 48 +++++++++++++++++++++++++++++++++++++++++++
>>   tests/generic/783.out |  2 ++
>>   2 files changed, 50 insertions(+)
>>   create mode 100755 tests/generic/783
>>   create mode 100644 tests/generic/783.out
>>
>> diff --git a/tests/generic/783 b/tests/generic/783
>> new file mode 100755
>> index 000000000000..f996d78803a1
>> --- /dev/null
>> +++ b/tests/generic/783
>> @@ -0,0 +1,48 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
>> +#
>> +# FS QA Test 783
>> +#
>> +# 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
>> +
>> +if [ "$FSTYP" = btrfs ]; then
>> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
>> +		"btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
>> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
>> +		"btrfs: zoned: move partially zone_unusable block groups to reclaim list"
>> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
>> +		"btrfs: zoned: add zone reclaim flush state for DATA space_info"
> Please rebase to latest for-next branch, then change above "_fixed_by_kernel_commit"
> to "_fixed_by_fs_commit btrfs ...."

Sure.


>> +fi
>> +
>> +_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}')"
> Wouldn’t it make more sense to get the available size here? And there's a helper
> _get_available_space in common/rc.

I'll have a look at it and see if it fits.


>> +
>> +loops=$(echo "$blocks * 4 - 2" | bc)
> Is $blocks a huge number? How about using $((blocks * 4 - 2)) simply?
>
> Can you add a comment to explain what's this "blocks * 4 - 2" for?
Will do.
>> +
>> +for (( i = 0; i < $loops; i++)); do
>> +	dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=1024 status=none 2>&1
> Not sure what's the "2>&1" for.
It was there before I had status=none, I'll fix it in the next revision.
>
> This isn't an append write, right? So we keep writting from 0 to 1G? Can you use a
> comment to explain why we require 16G sized SCRATCH_DEV ?
Because of the zoned write constraints? We can't overwrite until the 
zone is reset.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] fstests: test premature ENOSPC in zoned garbage collection
  2026-03-09 15:35   ` Johannes Thumshirn
@ 2026-03-09 16:51     ` Zorro Lang
  0 siblings, 0 replies; 8+ messages in thread
From: Zorro Lang @ 2026-03-09 16:51 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: hch, linux-btrfs@vger.kernel.org, fstests@vger.kernel.org,
	Hans Holmberg, Naohiro Aota

On Mon, Mar 09, 2026 at 03:35:56PM +0000, Johannes Thumshirn wrote:
> On 3/9/26 4:31 PM, Zorro Lang wrote:
> > On Tue, Feb 10, 2026 at 12:11:03PM +0100, Johannes Thumshirn 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 <johannes.thumshirn@wdc.com>
> >> ---
> >>   tests/generic/783     | 48 +++++++++++++++++++++++++++++++++++++++++++
> >>   tests/generic/783.out |  2 ++
> >>   2 files changed, 50 insertions(+)
> >>   create mode 100755 tests/generic/783
> >>   create mode 100644 tests/generic/783.out
> >>
> >> diff --git a/tests/generic/783 b/tests/generic/783
> >> new file mode 100755
> >> index 000000000000..f996d78803a1
> >> --- /dev/null
> >> +++ b/tests/generic/783
> >> @@ -0,0 +1,48 @@
> >> +#! /bin/bash
> >> +# SPDX-License-Identifier: GPL-2.0
> >> +# Copyright (c) 2026 Western Digital Corporation.  All Rights Reserved.
> >> +#
> >> +# FS QA Test 783
> >> +#
> >> +# 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
> >> +
> >> +if [ "$FSTYP" = btrfs ]; then
> >> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> >> +		"btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
> >> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> >> +		"btrfs: zoned: move partially zone_unusable block groups to reclaim list"
> >> +	_fixed_by_kernel_commit XXXXXXXXXXXX \
> >> +		"btrfs: zoned: add zone reclaim flush state for DATA space_info"
> > Please rebase to latest for-next branch, then change above "_fixed_by_kernel_commit"
> > to "_fixed_by_fs_commit btrfs ...."
> 
> Sure.
> 
> 
> >> +fi
> >> +
> >> +_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}')"
> > Wouldn’t it make more sense to get the available size here? And there's a helper
> > _get_available_space in common/rc.
> 
> I'll have a look at it and see if it fits.
> 
> 
> >> +
> >> +loops=$(echo "$blocks * 4 - 2" | bc)
> > Is $blocks a huge number? How about using $((blocks * 4 - 2)) simply?
> >
> > Can you add a comment to explain what's this "blocks * 4 - 2" for?
> Will do.
> >> +
> >> +for (( i = 0; i < $loops; i++)); do
> >> +	dd if=/dev/zero of=$SCRATCH_MNT/test bs=1M count=1024 status=none 2>&1
> > Not sure what's the "2>&1" for.
> It was there before I had status=none, I'll fix it in the next revision.
> >
> > This isn't an append write, right? So we keep writting from 0 to 1G? Can you use a
> > comment to explain why we require 16G sized SCRATCH_DEV ?
> Because of the zoned write constraints? We can't overwrite until the 
> zone is reset.

Oh, this's a zoned storage test, sure, thanks! I think we could add a comment here to
remind readers that this is actually a sequential/append write :)

Thanks,
Zorro


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-09 16:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-10 11:11 [PATCH] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
2026-02-10 15:51 ` Christoph Hellwig
2026-02-10 15:58   ` Johannes Thumshirn
2026-02-11 15:29     ` Zorro Lang
2026-03-05  8:50 ` Johannes Thumshirn
2026-03-09 15:31 ` Zorro Lang
2026-03-09 15:35   ` Johannes Thumshirn
2026-03-09 16:51     ` Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox