瀏覽代碼

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 <josef@redhat.com>
Josef Bacik 13 年之前
父節點
當前提交
ee4d89f0c4
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      fs/btrfs/inode.c

+ 1 - 1
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 */
 	/* insert an orphan item to track this unlinked/truncated file */
 	if (insert >= 1) {
 	if (insert >= 1) {
 		ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
 		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 */
 	/* insert an orphan item to track subvolume contains orphan files */