btrfs: avoid unnecessarily setting the fs to RO and error state at balance_level()
authorFilipe Manana <fdmanana@suse.com>
Thu, 8 Jun 2023 10:27:43 +0000 (11:27 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Jun 2023 11:59:38 +0000 (13:59 +0200)
At balance_level(), when trying to promote a child node to a root node, if
we fail to read the child we call btrfs_handle_fs_error(), which turns the
fs to RO mode and sets it to error state as well, causing any ongoing
transaction to abort. This however is not necessary because at that point
we have not made any change yet at balance_level(), so any error reading
the child node does not leaves us in any inconsistent state. Therefore we
can just return the error to the caller.

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>
fs/btrfs/ctree.c

index e98f9e205e25af11d2cf3fd1c5caa49cbb21ef42..4dcdcf25c3fe05669a90780f462c3a7804f465f9 100644 (file)
@@ -1040,7 +1040,6 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
                child = btrfs_read_node_slot(mid, 0);
                if (IS_ERR(child)) {
                        ret = PTR_ERR(child);
-                       btrfs_handle_fs_error(fs_info, ret, NULL);
                        goto out;
                }