btrfs: do not BUG_ON() on tree mod log failure at balance_level()
authorFilipe Manana <fdmanana@suse.com>
Thu, 8 Jun 2023 10:27:41 +0000 (11:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jul 2023 14:22:08 +0000 (16:22 +0200)
commitb990e3760395d346592d4e7370cefc85aa7fc597
tree3b71dc180b8bc551f568e29c2437ef8ed8fe6119
parent2445a35d05cdf24d27713b32d920a953de0f2405
btrfs: do not BUG_ON() on tree mod log failure at balance_level()

[ Upstream commit 39020d8abc7ec62c4de9b260e3d10d4a1c2478ce ]

At balance_level(), instead of doing a BUG_ON() in case we fail to record
tree mod log operations, do a transaction abort and return the error to
the callers. There's really no need for the BUG_ON() as we can release
all resources in this context, and we have to abort because other future
tree searches that use the tree mod log (btrfs_search_old_slot()) may get
inconsistent results if other operations modify the tree after that
failure and before the tree mod log based search.

CC: stable@vger.kernel.org # 5.4+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/btrfs/ctree.c