From: Josef Bacik Date: Wed, 24 Apr 2013 20:38:50 +0000 (-0400) Subject: Btrfs: don't panic if we're trying to drop too many refs X-Git-Tag: firefly_0821_release~3680^2~310^2~33 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=32b0253803bf8e384a37a70f2dfffb2056e7d087;p=firefly-linux-kernel-4.4.55.git Btrfs: don't panic if we're trying to drop too many refs This is just obnoxious. Just print a message, abort the transaction, and return an error. Thanks, Signed-off-by: Josef Bacik --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 6526f1faf6c2..f8a5652b0c43 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -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) {