OSDN Git Service

btrfs: zoned: unset dedicated block group on allocation failure
authorNaohiro Aota <naohiro.aota@wdc.com>
Tue, 7 Dec 2021 15:35:47 +0000 (00:35 +0900)
committerDavid Sterba <dsterba@suse.com>
Fri, 7 Jan 2022 13:18:26 +0000 (14:18 +0100)
commit1ada69f61c88abb75a1038ee457633325658a183
tree9a07f20fc40f8a7293664c088ba35373699e4fa1
parent736727100067267708d221632ffff4083fc0b278
btrfs: zoned: unset dedicated block group on allocation failure

Allocating an extent from a block group can fail for various reasons.
When an allocation from a dedicated block group (for tree-log or
relocation data) fails, we need to unregister it as a dedicated one so
that we can allocate a new block group for the dedicated one.

However, we are returning early when the block group in case it is
read-only, fully used, or not be able to activate the zone. As a result,
we keep the non-usable block group as a dedicated one, leading to
further allocation failure. With many block groups, the allocator will
iterate hopeless loop to find a free extent, results in a hung task.

Fix the issue by delaying the return and doing the proper cleanups.

CC: stable@vger.kernel.org # 5.16
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c