Re: [PATCH v4] btrfs: zoned: don't force read-only on transient -EAGAIN from reloc merge
Johannes Thumshirn <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs |
|---|---|
| Message-ID | <[email protected]> |
On 6/22/26 1:29 PM, Filipe Manana wrote: > On Mon, Jun 22, 2026 at 9:27 AM Johannes Thumshirn > <[email protected]> wrote: >> On a zoned FS, btrfs_delayed_refs_rsv_refill() returns -EAGAIN whenever >> the over-committed metadata plus the zone_unusable bytes exceeds the >> usable size in a metadata block-group to avoid heavy over-commit of >> metadata and early ENOSPC in one transaction. >> >> If this happens while doing reclaim, the transaction is getting >> aborted. >> >> Treat -EAGAIN as a soft, retryable condition in case of block-group >> reclaim. >> >> Reported-by: Damien Le Moal <[email protected]> >> Fixes: 7bcb04de982f ("btrfs: zoned: cap delayed refs metadata reservation to avoid overcommit") >> Signed-off-by: Johannes Thumshirn <[email protected]> >> --- >> Changes to v3: >> - Don't ASSERT() for zoned in case of EAGAIN in >> btrfs_reclaim_block_group but check for zoned >> >> fs/btrfs/block-group.c | 10 +++++++- >> fs/btrfs/relocation.c | 52 ++++++++++++++++++++++++++++++++++++++---- >> 2 files changed, 57 insertions(+), 5 deletions(-) >> >> diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c >> index ab76a5173272..1327fd526b06 100644 >> --- a/fs/btrfs/block-group.c >> +++ b/fs/btrfs/block-group.c >> @@ -2047,6 +2047,12 @@ static int btrfs_reclaim_block_group(struct btrfs_block_group *bg, int *reclaime >> >> trace_btrfs_reclaim_block_group(bg); >> ret = btrfs_relocate_chunk(fs_info, bg->start, false); >> + if (btrfs_is_zoned(fs_info) && ret == -EAGAIN) { >> + btrfs_dec_block_group_ro(bg); >> + btrfs_debug(fs_info, "deferring reclaim of chunk %llu", >> + bg->start); >> + return ret; >> + } >> if (ret) { >> btrfs_dec_block_group_ro(bg); >> btrfs_err(fs_info, "error relocating chunk %llu", >> @@ -2113,7 +2119,9 @@ void btrfs_reclaim_block_groups(struct btrfs_fs_info *fs_info, unsigned int limi >> spin_unlock(&fs_info->unused_bgs_lock); >> ret = btrfs_reclaim_block_group(bg, &reclaimed); >> >> - if (ret && !READ_ONCE(space_info->periodic_reclaim)) >> + if (ret == -EAGAIN) >> + btrfs_link_bg_list(bg, &retry_list); >> + else if (ret && !READ_ONCE(space_info->periodic_reclaim)) >> btrfs_link_bg_list(bg, &retry_list); >> btrfs_put_block_group(bg); >> >> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c >> index 1819d49d19c3..73d9948b5382 100644 >> --- a/fs/btrfs/relocation.c >> +++ b/fs/btrfs/relocation.c >> @@ -1530,6 +1530,36 @@ static void clear_reloc_root(struct btrfs_root *root) >> clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state); >> } >> >> +/* Drop the reloc trees of a relocation that is being deferred and retried */ > Same comment as in v3: always add punctuation to sentences, this is > our preferred style. Yes I apparently sent out the wrong version, also for the if above.