Btrfs: don't panic if we're trying to drop too many refs
authorJosef Bacik <jbacik@fusionio.com>
Wed, 24 Apr 2013 20:38:50 +0000 (16:38 -0400)
committerJosef Bacik <jbacik@fusionio.com>
Mon, 6 May 2013 19:55:09 +0000 (15:55 -0400)
This is just obnoxious.  Just print a message, abort the transaction, and return
an error.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/extent-tree.c

index 6526f1faf6c2a9e6fc402b186f4528d1be440054..f8a5652b0c4372b52dda46ed3906721bf1220c9b 100644 (file)
@@ -5596,7 +5596,13 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
        }
 
        refs = btrfs_extent_refs(leaf, ei);
-       BUG_ON(refs < refs_to_drop);
+       if (refs < refs_to_drop) {
+               btrfs_err(info, "trying to drop %d refs but we only have %Lu "
+                         "for bytenr %Lu\n", refs_to_drop, refs, bytenr);
+               ret = -EINVAL;
+               btrfs_abort_transaction(trans, extent_root, ret);
+               goto out;
+       }
        refs -= refs_to_drop;
 
        if (refs > 0) {