diff options
author | Tsutomu Itoh <t-itoh@jp.fujitsu.com> | 2011-07-19 03:27:20 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-08-01 14:30:42 -0400 |
commit | b532402e4d147e4f409c4e7f50d4413e8450101d (patch) | |
tree | 0c196fd362d03243704a47e69e41c13acd323bd0 /fs/btrfs/inode.c | |
parent | a0f98dde11a1afe9fbf5c98f57968e086e98b6f5 (diff) |
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: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 4360ccb191b1..5da43aea205f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2217,7 +2217,8 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) | |||
2217 | 2217 | ||
2218 | if (!root->orphan_block_rsv) { | 2218 | if (!root->orphan_block_rsv) { |
2219 | block_rsv = btrfs_alloc_block_rsv(root); | 2219 | block_rsv = btrfs_alloc_block_rsv(root); |
2220 | BUG_ON(!block_rsv); | 2220 | if (!block_rsv) |
2221 | return -ENOMEM; | ||
2221 | } | 2222 | } |
2222 | 2223 | ||
2223 | spin_lock(&root->orphan_lock); | 2224 | spin_lock(&root->orphan_lock); |
@@ -3002,13 +3003,16 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | |||
3002 | 3003 | ||
3003 | ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, | 3004 | ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode, |
3004 | dentry->d_name.name, dentry->d_name.len); | 3005 | dentry->d_name.name, dentry->d_name.len); |
3005 | BUG_ON(ret); | 3006 | if (ret) |
3007 | goto out; | ||
3006 | 3008 | ||
3007 | if (inode->i_nlink == 0) { | 3009 | if (inode->i_nlink == 0) { |
3008 | ret = btrfs_orphan_add(trans, inode); | 3010 | ret = btrfs_orphan_add(trans, inode); |
3009 | BUG_ON(ret); | 3011 | if (ret) |
3012 | goto out; | ||
3010 | } | 3013 | } |
3011 | 3014 | ||
3015 | out: | ||
3012 | nr = trans->blocks_used; | 3016 | nr = trans->blocks_used; |
3013 | __unlink_end_trans(trans, root); | 3017 | __unlink_end_trans(trans, root); |
3014 | btrfs_btree_balance_dirty(root, nr); | 3018 | btrfs_btree_balance_dirty(root, nr); |