From: Josef Bacik Date: Mon, 13 Jun 2022 22:31:17 +0000 (-0400) Subject: btrfs: reset block group chunk force if we have to wait X-Git-Tag: baikal/mips/sdk5.9~53 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=99f7e0799327ab85f96f277d03dbfeab03810f3c;p=kernel.git btrfs: reset block group chunk force if we have to wait [ Upstream commit b458761ba924e524f93716713eae84498044e340 ] If you try to force a chunk allocation, but you race with another chunk allocation, you will end up waiting on the chunk allocation that just occurred and then allocate another chunk. If you have many threads all doing this at once you can way over-allocate chunks. Fix this by resetting force to NO_FORCE, that way if we think we need to allocate we can, otherwise we don't force another chunk allocation if one is already happening. Reviewed-by: Filipe Manana CC: stable@vger.kernel.org # 5.4+ Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Sasha Levin --- diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c index c6c5a22ff6e86..4b2282aa274e4 100644 --- a/fs/btrfs/block-group.c +++ b/fs/btrfs/block-group.c @@ -3632,6 +3632,7 @@ int btrfs_chunk_alloc(struct btrfs_trans_handle *trans, u64 flags, * attempt. */ wait_for_alloc = true; + force = CHUNK_ALLOC_NO_FORCE; spin_unlock(&space_info->lock); mutex_lock(&fs_info->chunk_mutex); mutex_unlock(&fs_info->chunk_mutex);