提交 b532402e 编写于 作者: T Tsutomu Itoh 提交者: Chris Mason

Btrfs: return error to caller when btrfs_unlink() failes

When btrfs_unlink_inode() and btrfs_orphan_add() in btrfs_unlink()
are error, the error code is returned to the caller instead of
BUG_ON().
Signed-off-by: NTsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: NChris Mason <chris.mason@oracle.com>
上级 a0f98dde
...@@ -7201,7 +7201,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, ...@@ -7201,7 +7201,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
inode = lookup_free_space_inode(root, block_group, path); inode = lookup_free_space_inode(root, block_group, path);
if (!IS_ERR(inode)) { if (!IS_ERR(inode)) {
btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, inode);
BUG_ON(ret);
clear_nlink(inode); clear_nlink(inode);
/* One for the block groups ref */ /* One for the block groups ref */
spin_lock(&block_group->lock); spin_lock(&block_group->lock);
......
...@@ -2217,7 +2217,8 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) ...@@ -2217,7 +2217,8 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
if (!root->orphan_block_rsv) { if (!root->orphan_block_rsv) {
block_rsv = btrfs_alloc_block_rsv(root); block_rsv = btrfs_alloc_block_rsv(root);
BUG_ON(!block_rsv); if (!block_rsv)
return -ENOMEM;
} }
spin_lock(&root->orphan_lock); spin_lock(&root->orphan_lock);
...@@ -3002,13 +3003,16 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -3002,13 +3003,16 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,
dentry->d_name.name, dentry->d_name.len); dentry->d_name.name, dentry->d_name.len);
BUG_ON(ret); if (ret)
goto out;
if (inode->i_nlink == 0) { if (inode->i_nlink == 0) {
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, inode);
BUG_ON(ret); if (ret)
goto out;
} }
out:
nr = trans->blocks_used; nr = trans->blocks_used;
__unlink_end_trans(trans, root); __unlink_end_trans(trans, root);
btrfs_btree_balance_dirty(root, nr); btrfs_btree_balance_dirty(root, nr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册