Skip to contentSkip to conversation

Btrfs: don't BUG_ON() in btrfs_orphan_add

PATCH In review Josef Bacik 2 participants 2 messages May 27, 2016 – May 31, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: don't BUG_ON() in btrfs_orphan_add

This is just a screwup for developers, so change it to an ASSERT() so developers notice when things go wrong and deal with the error appropriately if ASSERT() isn't enabled. Thanks,

---
 fs/btrfs/inode.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +10 -1
index e6dd4cc..3c367a8 100644
@@ -3256,7 +3256,16 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
 	/* grab metadata reservation from transaction handle */
 	if (reserve) {
 		ret = btrfs_orphan_reserve_metadata(trans, inode);
-		BUG_ON(ret); /* -ENOSPC in reservation; Logic error? JDM */
+		ASSERT(!ret);
+		if (ret) {
+			atomic_dec(&root->orphan_inodes);
+			clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
+				  &BTRFS_I(inode)->runtime_flags);
+			if (insert)
+				clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
+					  &BTRFS_I(inode)->runtime_flags);
+			return ret;
+		}
 	}
 
 	/* insert an orphan item to track this unlinked/truncated file */
Signature · 1 line
1.8.3.1