]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: error when COWing block from a root that is being deleted
authorFilipe Manana <fdmanana@suse.com>
Wed, 27 Sep 2023 11:09:22 +0000 (12:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 10:03:11 +0000 (12:03 +0200)
commitf174c8d2c634929f93c3a1115a1fad18a38718f7
tree0495218cc936b5ea50b532100736380798cdae81
parentc833f1e28d137158be066f80fe0d7f2c17fe9a4b
btrfs: error when COWing block from a root that is being deleted

[ Upstream commit a2caab29884397e583d09be6546259a83ebfbdb1 ]

At btrfs_cow_block() we check if the block being COWed belongs to a root
that is being deleted and if so we log an error message. However this is
an unexpected case and it indicates a bug somewhere, so we should return
an error and abort the transaction. So change this in the following ways:

1) Abort the transaction with -EUCLEAN, so that if the issue ever happens
   it can easily be noticed;

2) Change the logged message level from error to critical, and change the
   message itself to print the block's logical address and the ID of the
   root;

3) Return -EUCLEAN to the caller;

4) As this is an unexpected scenario, that should never happen, mark the
   check as unlikely, allowing the compiler to potentially generate better
   code.

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