Commit 305a26af authored by Mark Fasheh's avatar Mark Fasheh Committed by David Sterba

btrfs: Go readonly on tree errors in balance_level

balace_level() seems to deal with missing tree nodes by BUG_ON(). Instead,
we can easily just set the file system readonly and bubble -EROFS back up
the stack.
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent b68dc2a9
...@@ -944,7 +944,12 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, ...@@ -944,7 +944,12 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
/* promote the child to a root */ /* promote the child to a root */
child = read_node_slot(root, mid, 0); child = read_node_slot(root, mid, 0);
BUG_ON(!child); if (!child) {
ret = -EROFS;
btrfs_std_error(root->fs_info, ret);
goto enospc;
}
btrfs_tree_lock(child); btrfs_tree_lock(child);
btrfs_set_lock_blocking(child); btrfs_set_lock_blocking(child);
ret = btrfs_cow_block(trans, root, child, mid, 0, &child); ret = btrfs_cow_block(trans, root, child, mid, 0, &child);
...@@ -1042,7 +1047,11 @@ static noinline int balance_level(struct btrfs_trans_handle *trans, ...@@ -1042,7 +1047,11 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
* otherwise we would have pulled some pointers from the * otherwise we would have pulled some pointers from the
* right * right
*/ */
BUG_ON(!left); if (!left) {
ret = -EROFS;
btrfs_std_error(root->fs_info, ret);
goto enospc;
}
wret = balance_node_right(trans, root, mid, left); wret = balance_node_right(trans, root, mid, left);
if (wret < 0) { if (wret < 0) {
ret = wret; ret = wret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment