aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2011-09-01 14:27:57 -0400
committerDavid Sterba <dsterba@suse.cz>2012-03-21 20:45:38 -0400
commit305a26af5b2561a66859ef05ed7eb73d3c9f0913 (patch)
tree9afdcd2ccbe2a72b7dadaf25f92a4a1ec109ecfe /fs/btrfs
parentb68dc2a93e794c8507338c91577a277efa4555d5 (diff)
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: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ctree.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 36e16bd50798..651a26a6c651 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -944,7 +944,12 @@ static noinline int balance_level(struct btrfs_trans_handle *trans,
944 944
945 /* promote the child to a root */ 945 /* promote the child to a root */
946 child = read_node_slot(root, mid, 0); 946 child = read_node_slot(root, mid, 0);
947 BUG_ON(!child); 947 if (!child) {
948 ret = -EROFS;
949 btrfs_std_error(root->fs_info, ret);
950 goto enospc;
951 }
952
948 btrfs_tree_lock(child); 953 btrfs_tree_lock(child);
949 btrfs_set_lock_blocking(child); 954 btrfs_set_lock_blocking(child);
950 ret = btrfs_cow_block(trans, root, child, mid, 0, &child); 955 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 * otherwise we would have pulled some pointers from the 1047 * otherwise we would have pulled some pointers from the
1043 * right 1048 * right
1044 */ 1049 */
1045 BUG_ON(!left); 1050 if (!left) {
1051 ret = -EROFS;
1052 btrfs_std_error(root->fs_info, ret);
1053 goto enospc;
1054 }
1046 wret = balance_node_right(trans, root, mid, left); 1055 wret = balance_node_right(trans, root, mid, left);
1047 if (wret < 0) { 1056 if (wret < 0) {
1048 ret = wret; 1057 ret = wret;