public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
@ 2026-04-14 14:33 Johannes Thumshirn
  2026-04-15  5:22 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-04-14 14:33 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Naohiro Aota, fstests, linux-btrfs, Christoph Hellwig,
	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>
---
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"
- This time really did it...

Link to v1:
https://lore.kernel.org/all/20260210111103.265664-1-johannes.thumshirn@wdc.com/
 tests/generic/999     | 46 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  2 ++
 2 files changed, 48 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..ef2b63abefd7
--- /dev/null
+++ b/tests/generic/999
@@ -0,0 +1,46 @@
+#! /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"
+_require_command "$BLKZONE_PROG" blkzone
+
+# This test requires specific data space usage, skip if we have compression
+# enabled.
+_require_no_compress
+
+_fixed_by_fs_commit btrfs 7bcb04de982f \
+	"btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit"
+_fixed_by_fs_commit btrfs 258e46a6385c \
+	"btrfs: zoned: move partially zone_unusable block groups to reclaim list"
+_fixed_by_fs_commit btrfs e2a7fd22378f \
+	"btrfs: zoned: add zone reclaim flush state for DATA space_info"
+
+_scratch_mkfs_sized $((16 * 1024 * 1024 * 1024)) &>>$seqres.full
+_scratch_mount
+
+# Overwrite the data "number of seq zones" times, this is arbitrarily chosen
+# but triggers the original bug reliably
+loops=$($BLKZONE_PROG report $SCRATCH_DEV | grep -c "SEQ_WRITE_REQUIRED")
+
+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


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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-14 14:33 [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
@ 2026-04-15  5:22 ` Christoph Hellwig
  2026-04-15  5:53   ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2026-04-15  5:22 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Zorro Lang, Naohiro Aota, fstests, linux-btrfs, Christoph Hellwig

On Tue, Apr 14, 2026 at 04:33:41PM +0200, 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.

s/bugifx/bugfix/

I tried this on XFS, and it doesn't work as XFS uses SCRATCH_RTDEV for
zoned data.  Manually hacking in SCRATCH_RTDEV makes it work, but that
will break btrfs.  Maybe you can add a little:

if [ -b "$SCRATCH_RTDEV" ];
	zoned_dev=$SCRATCH_RTDEV
else
	zoned_dev=$SCRATCH_DEV
endif

end then use $zoned_dev to make it portable?

I also tried it on f2fs, but mkfs.f2fs fails now with a 'different sector
sizes' warning when using a 4k-sector conventional and 4k-sector zoned
ZNS namespace, so I guess I'll give up on that.

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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  5:22 ` Christoph Hellwig
@ 2026-04-15  5:53   ` Johannes Thumshirn
  2026-04-15  5:56     ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-04-15  5:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On 4/15/26 7:22 AM, Christoph Hellwig wrote:
> On Tue, Apr 14, 2026 at 04:33:41PM +0200, 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.
> s/bugifx/bugfix/
Fixed
> I tried this on XFS, and it doesn't work as XFS uses SCRATCH_RTDEV for
> zoned data.  Manually hacking in SCRATCH_RTDEV makes it work, but that
> will break btrfs.  Maybe you can add a little:
>
> if [ -b "$SCRATCH_RTDEV" ];
> 	zoned_dev=$SCRATCH_RTDEV
> else
> 	zoned_dev=$SCRATCH_DEV
> endif
>
> end then use $zoned_dev to make it portable?
Sure, can I still use _scratch_mkfs_sized for XFS?

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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  5:53   ` Johannes Thumshirn
@ 2026-04-15  5:56     ` Christoph Hellwig
  2026-04-15  6:10       ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2026-04-15  5:56 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On Wed, Apr 15, 2026 at 07:53:52AM +0200, Johannes Thumshirn wrote:
> On 4/15/26 7:22 AM, Christoph Hellwig wrote:
>> On Tue, Apr 14, 2026 at 04:33:41PM +0200, 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.
>> s/bugifx/bugfix/
> Fixed
>> I tried this on XFS, and it doesn't work as XFS uses SCRATCH_RTDEV for
>> zoned data.  Manually hacking in SCRATCH_RTDEV makes it work, but that
>> will break btrfs.  Maybe you can add a little:
>>
>> if [ -b "$SCRATCH_RTDEV" ];
>> 	zoned_dev=$SCRATCH_RTDEV
>> else
>> 	zoned_dev=$SCRATCH_DEV
>> endif
>>
>> end then use $zoned_dev to make it portable?
> Sure, can I still use _scratch_mkfs_sized for XFS?

Yes. It sizes both the main and RT device.

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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  5:56     ` Christoph Hellwig
@ 2026-04-15  6:10       ` Johannes Thumshirn
  2026-04-15  6:27         ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-04-15  6:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On 4/15/26 7:56 AM, Christoph Hellwig wrote:
> On Wed, Apr 15, 2026 at 07:53:52AM +0200, Johannes Thumshirn wrote:
>> On 4/15/26 7:22 AM, Christoph Hellwig wrote:
>>> On Tue, Apr 14, 2026 at 04:33:41PM +0200, 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.
>>> s/bugifx/bugfix/
>> Fixed
>>> I tried this on XFS, and it doesn't work as XFS uses SCRATCH_RTDEV for
>>> zoned data.  Manually hacking in SCRATCH_RTDEV makes it work, but that
>>> will break btrfs.  Maybe you can add a little:
>>>
>>> if [ -b "$SCRATCH_RTDEV" ];
>>> 	zoned_dev=$SCRATCH_RTDEV
>>> else
>>> 	zoned_dev=$SCRATCH_DEV
>>> endif
>>>
>>> end then use $zoned_dev to make it portable?
>> Sure, can I still use _scratch_mkfs_sized for XFS?
> Yes. It sizes both the main and RT device.

The test still doesn't run for me on XFS:

[  160.045250] XFS (vda): EXPERIMENTAL zoned RT device feature enabled.  
Use at your own risk!
[  160.045707] XFS (vda): Mounting V5 Filesystem 
47eb9ed8-526f-4dc3-a488-5862f403ee5c
[  160.062623] XFS (vda): Ending clean mount
[  160.062734] XFS (vda): limiting open zones to 15 due to total zone 
count (60)
[  160.062797] XFS (vda): 60 zones of 65536 blocks (15 max open zones)
FSTYP         -- xfs (non-debug)
PLATFORM      -- Linux/x86_64 virtme-ng 7.0.0-rc5+ #407 SMP 
PREEMPT_DYNAMIC Mon Mar 30 14:36:40 CEST 2026
MKFS_OPTIONS  -- -f /dev/vdb
MOUNT_OPTIONS -- /dev/vdb /tmp/scratch

[  160.375268] XFS (vdb): EXPERIMENTAL zoned RT device feature enabled.  
Use at your own risk!
[  160.375819] XFS (vdb): Mounting V5 Filesystem 
24c36996-2bdd-43cc-a1d0-6fb05f87cf51
[  160.390418] XFS (vdb): Ending clean mount
[  160.390532] XFS (vdb): limiting open zones to 15 due to total zone 
count (60)
[  160.390597] XFS (vdb): 60 zones of 65536 blocks (15 max open zones)
[  160.435057] XFS (vdb): Unmounting Filesystem 
24c36996-2bdd-43cc-a1d0-6fb05f87cf51
[  161.600694] XFS (vda): Unmounting Filesystem 
47eb9ed8-526f-4dc3-a488-5862f403ee5c
[  161.877731] XFS (vda): EXPERIMENTAL zoned RT device feature enabled.  
Use at your own risk!
[  161.878359] XFS (vda): Mounting V5 Filesystem 
47eb9ed8-526f-4dc3-a488-5862f403ee5c
[  161.896765] XFS (vda): Ending clean mount
[  161.896909] XFS (vda): limiting open zones to 15 due to total zone 
count (60)
[  161.897017] XFS (vda): 60 zones of 65536 blocks (15 max open zones)
generic/999        [  161.929562] run fstests generic/999 at 2026-04-15 
08:09:50
[not run] _scratch_mkfs_sized failed with (17179869184)
Ran: generic/999
Not run: generic/999
Passed all 1 tests

[  162.477746] XFS (vda): Unmounting Filesystem 
47eb9ed8-526f-4dc3-a488-5862f403ee5c


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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  6:10       ` Johannes Thumshirn
@ 2026-04-15  6:27         ` Christoph Hellwig
  2026-04-15  6:53           ` Johannes Thumshirn
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2026-04-15  6:27 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On Wed, Apr 15, 2026 at 08:10:29AM +0200, Johannes Thumshirn wrote:
> The test still doesn't run for me on XFS:

Worked for me.  What does the full output say mkfs complained about?


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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  6:27         ` Christoph Hellwig
@ 2026-04-15  6:53           ` Johannes Thumshirn
  2026-04-15  7:04             ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Thumshirn @ 2026-04-15  6:53 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On 4/15/26 8:27 AM, Christoph Hellwig wrote:
> On Wed, Apr 15, 2026 at 08:10:29AM +0200, Johannes Thumshirn wrote:
>> The test still doesn't run for me on XFS:
> Worked for me.  What does the full output say mkfs complained about?
>
Here we go:

bash-5.3# cat ../fstests/results/generic/999.full
** mkfs failed with extra mkfs options added to "" by test 999 **
** attempting to mkfs using only test 999 options: -d size=17179869184 
-r size=17179869184 -b size=4096 **
size 17179869184 specified for data subvolume is too large, maximum is 
262144 blocks
Usage: mkfs.xfs
/* blocksize */        [-b size=num]
/* config file */    [-c options=xxx]
/* metadata */        [-m 
crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,
                 inobtcount=0|1,bigtime=0|1,autofsck=xxx,
                 metadir=0|1]
/* quota */        [-m uquota|uqnoenforce,gquota|gqnoenforce,
                 pquota|pqnoenforce]
/* data subvol */    [-d agcount=n,agsize=n,file,name=xxx,size=num,
                 (sunit=value,swidth=value|su=num,sw=num|noalign),
                 sectsize=num,concurrency=num]
/* force overwrite */    [-f]
/* inode size */    [-i perblock=n|size=num,maxpct=n,attr=0|1|2,
                 projid32bit=0|1,sparse=0|1,nrext64=0|1,
                 exchange=0|1]
/* no discard */    [-K]
/* log subvol */    [-l agnum=n,internal,size=num,logdev=xxx,version=n
                 sunit=value|su=num,sectsize=num,lazy-count=0|1,
                 concurrency=num]
/* label */        [-L label (maximum 12 characters)]
/* naming */        [-n size=num,version=2|ci,ftype=0|1,parent=0|1]]
/* no-op info only */    [-N]
/* prototype file */    [-p fname]
/* quiet */        [-q]
/* realtime subvol */    [-r 
extsize=num,size=num,rtdev=xxx,rgcount=n,rgsize=n,
                 concurrency=num,zoned=0|1,start=n,reserved=n]
/* sectorsize */    [-s size=num]
/* version */        [-V]
             devicename
<devicename> is required unless -d name=xxx is given.
<num> is xxx (bytes), xxxs (sectors), xxxb (fs blocks), xxxk (xxx KiB),
       xxxm (xxx MiB), xxxg (xxx GiB), xxxt (xxx TiB) or xxxp (xxx PiB).
<value> is xxx (512 byte blocks).
999 not run: _scratch_mkfs_sized failed with (17179869184)
umount: /dev/vdb: not mounted.
bash-5.3#



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

* Re: [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection
  2026-04-15  6:53           ` Johannes Thumshirn
@ 2026-04-15  7:04             ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2026-04-15  7:04 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Christoph Hellwig, Zorro Lang, Naohiro Aota, fstests, linux-btrfs

On Wed, Apr 15, 2026 at 08:53:52AM +0200, Johannes Thumshirn wrote:
>> Worked for me.  What does the full output say mkfs complained about?
>>
> Here we go:
>
> bash-5.3# cat ../fstests/results/generic/999.full

Oh, this is because your conventional area is too small for the
specified size. My test was with large separate conventional and
zoned devices.

This has hit in a few places before, I'll look into fixing it, but let's
not block this test for it.


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

end of thread, other threads:[~2026-04-15  7:04 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-14 14:33 [PATCH v3] fstests: test premature ENOSPC in zoned garbage collection Johannes Thumshirn
2026-04-15  5:22 ` Christoph Hellwig
2026-04-15  5:53   ` Johannes Thumshirn
2026-04-15  5:56     ` Christoph Hellwig
2026-04-15  6:10       ` Johannes Thumshirn
2026-04-15  6:27         ` Christoph Hellwig
2026-04-15  6:53           ` Johannes Thumshirn
2026-04-15  7:04             ` Christoph Hellwig

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