From: Josef Bacik Date: Fri, 27 May 2016 17:03:04 +0000 (-0400) Subject: Btrfs: don't BUG_ON() in btrfs_orphan_add X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=62329d766a25509f8373d288c0833081c991b572;p=linux 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, Signed-off-by: Josef Bacik Reviewed-by: Mark Fasheh Signed-off-by: David Sterba (cherry picked from commit 3b6571c180da85e43550c608e954ab7b2a31d954) --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 55a4cb192ade5..c5273e282d363 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -3255,7 +3255,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 */