Re: [PATCH v6 12/28] btrfs: ensure metadata space available on/after degraded mount in HMZONED

Josef Bacik
2019-12-17T19:32:33Z

On 12/12/19 11:08 PM, Naohiro Aota wrote:
> On/After degraded mount, we might have no writable metadata block group due
> to broken write pointers. If you e.g. balance the FS before writing any
> data, alloc_tree_block_no_bg_flush() (called from insert_balance_item())
> fails to allocate a tree block for it, due to global reservation failure.
> We can reproduce this situation with xfstests btrfs/124.
>
> While we can workaround the failure if we write some data and, as a result
> of writing, let a new metadata block group allocated, it's a bad practice
> to apply.
>
> This commit avoids such failures by ensuring that read-write mounted volume
> has non-zero metadata space. If metadata space is empty, it forces new
> metadata block group allocation.
>

Ick, I hate this, especially since it doesn't take into account if we're mounted
read only. No instead add something btrfs_start_transaction() or something
similar that does this check to allocate a chunk. And
alloc_tree_block_no_bg_flush() only means we won't create the pending bg's in
that path, we're still able to allocate chunks. So I'm not super sure what you
are actually hitting here, but this is the wrong way to go about fixing it. Thanks,

Josef