From: Josef Bacik Date: Tue, 13 Dec 2011 17:55:58 +0000 (-0500) Subject: Btrfs: don't panic if orphan item already exists X-Git-Tag: v2.6.39-400.9.0~824^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2d524473836cb777e8b67b6925577c38b2940624;p=users%2Fjedix%2Flinux-maple.git Btrfs: don't panic if orphan item already exists I've been hitting this BUG_ON() in btrfs_orphan_add when running xfstest 269 in a loop. This is because we will add an orphan item, do the truncate, the truncate will fail for whatever reason (*cough*ENOSPC*cough*) and then we're left with an orphan item still in the fs. Then we come back later to do another truncate and it blows up because we already have an orphan item. This is ok so just fix the BUG_ON() to only BUG() if ret is not EEXIST. Thanks, Signed-off-by: Josef Bacik (cherry picked from commit ee4d89f0c4967c624c92516fcc37b41069bfdc23) --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 2211542494cb..c9f365b6649e 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2032,7 +2032,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) /* insert an orphan item to track this unlinked/truncated file */ if (insert >= 1) { ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); - BUG_ON(ret); + BUG_ON(ret && ret != -EEXIST); } /* insert an orphan item to track subvolume contains orphan files */