public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: zoned fix two long standing ENOSPC bugs
@ 2026-02-09 14:36 Johannes Thumshirn
  2026-02-09 14:36 ` [PATCH 1/3] btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit Johannes Thumshirn
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Johannes Thumshirn @ 2026-02-09 14:36 UTC (permalink / raw)
  To: linux-btrfs
  Cc: Filipe Manana, Damien Le Moal, Naohiro Aota, Christoph Hellwig,
	Hans Holmberg, Boris Burkov, David Sterba, Johannes Thumshirn

This series fixes two long standing bugs with zoned BTRFS leading to
premature ENOSPC.

Patch 1 caps the amount of metadata reservations to not let
`bytes_may_use + bytes_zone_available` climb beyond a space_info's
capacity.

Patch 2 moves a block-group to the reclaim list, if it cannot be deleted
in btrfs_delete_unused_bgs() because there's still user data left.

Patch 3 adds a new zoned only state to the flush machinery performing
reclaim of block-groups that can be reclaimed.


For all these patches a single reproducer was used (and it can be turned
into a fstest):

```
#!/bin/sh

SCRATCH_DEV="/dev/vdb"
SCRATCH_MNT="/tmp/scratch"
MOUNT_OPTIONS="-o enospc_debug"

mkdir -p $SCRATCH_MNT
mkfs.btrfs -f $SCRATCH_DEV
mount $MOUNT_OPTIONS $SCRATCH_DEV $SCRATCH_MNT

blocks="$(df -TB 1G $SCRATCH_DEV | awk '/btrfs/ { 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 > /dev/null
	if [ $? -ne 0 ]; then
		break
	fi
done

umount $SCRATCH_DEV
btrfs check $SCRATCH_DEV
```

Johannes Thumshirn (3):
  btrfs: zoned: cap delayed refs metadata reservation to avoid
    overcommit
  btrfs: zoned: move partially zone_unusable block groups to reclaim
    list
  btrfs: zoned: add zone reclaim flush state for DATA space_info

 fs/btrfs/block-group.c | 16 ++++++++++++++++
 fs/btrfs/delayed-ref.c | 26 ++++++++++++++++++++++++++
 fs/btrfs/space-info.c  | 12 ++++++++++++
 fs/btrfs/space-info.h  |  1 +
 fs/btrfs/transaction.c |  7 +++++++
 5 files changed, 62 insertions(+)

-- 
2.53.0


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

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09 14:36 [PATCH 0/3] btrfs: zoned fix two long standing ENOSPC bugs Johannes Thumshirn
2026-02-09 14:36 ` [PATCH 1/3] btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit Johannes Thumshirn
2026-02-09 16:47   ` Filipe Manana
2026-02-09 14:36 ` [PATCH 2/3] btrfs: zoned: move partially zone_unusable block groups to reclaim list Johannes Thumshirn
2026-02-09 16:56   ` Filipe Manana
2026-02-09 14:36 ` [PATCH 3/3] btrfs: zoned: add zone reclaim flush state for DATA space_info Johannes Thumshirn
2026-02-09 16:59   ` Filipe Manana
2026-02-09 14:51 ` [PATCH 0/3] btrfs: zoned fix two long standing ENOSPC bugs Christoph Hellwig

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