Skip to contentSkip to conversation

Btrfs: don't panic if we're trying to drop too many refs

PATCH New Josef Bacik 1 participant 1 message Apr 24, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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,

---
 fs/btrfs/extent-tree.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
fs/btrfs/extent-tree.c +7 -1
index 52b7e15..796c4ef 100644
@@ -5613,7 +5613,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) {
Signature · 1 line
1.7.7.6