]> git.hungrycats.org Git - linux/commitdiff
Btrfs: kill BUG_ON in run_delayed_tree_ref
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 15 Sep 2016 02:19:05 +0000 (19:19 -0700)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 24 Sep 2016 04:03:32 +0000 (00:03 -0400)
In a corrupted btrfs image, we can come across this BUG_ON and
get an unreponsive system, but if we return errors instead,
its caller can handle everything gracefully by aborting the current
transaction.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
(cherry picked from commit 0c4aa1adb137011af66259ed5fa20e95ad500baf)

fs/btrfs/extent-tree.c

index 4ac19b1c4ea4ced3f7c86290acf718663a7544d5..03f487ea837c11b79838106e5dffac933784cc3d 100644 (file)
@@ -2358,7 +2358,13 @@ static int run_delayed_tree_ref(struct btrfs_trans_handle *trans,
                ins.type = BTRFS_EXTENT_ITEM_KEY;
        }
 
-       BUG_ON(node->ref_mod != 1);
+       if (node->ref_mod != 1) {
+               btrfs_err(root->fs_info,
+       "btree block(%llu) has %d references rather than 1: action %d ref_root %llu parent %llu",
+                         node->bytenr, node->ref_mod, node->action, ref_root,
+                         parent);
+               return -EIO;
+       }
        if (node->action == BTRFS_ADD_DELAYED_REF && insert_reserved) {
                BUG_ON(!extent_op || !extent_op->update_flags);
                ret = alloc_reserved_tree_block(trans, root,