aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2011-07-19 03:27:20 -0400
committerChris Mason <chris.mason@oracle.com>2011-08-01 14:30:42 -0400
commitb532402e4d147e4f409c4e7f50d4413e8450101d (patch)
tree0c196fd362d03243704a47e69e41c13acd323bd0 /fs/btrfs
parenta0f98dde11a1afe9fbf5c98f57968e086e98b6f5 (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')
-rw-r--r--fs/btrfs/extent-tree.c3
-rw-r--r--fs/btrfs/inode.c10
2 files changed, 9 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 55bddffede7..db2057f262a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7201,7 +7201,8 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
7201 7201
7202 inode = lookup_free_space_inode(root, block_group, path); 7202 inode = lookup_free_space_inode(root, block_group, path);
7203 if (!IS_ERR(inode)) { 7203 if (!IS_ERR(inode)) {
7204 btrfs_orphan_add(trans, inode); 7204 ret = btrfs_orphan_add(trans, inode);
7205 BUG_ON(ret);
7205 clear_nlink(inode); 7206 clear_nlink(inode);
7206 /* One for the block groups ref */ 7207 /* One for the block groups ref */
7207 spin_lock(&block_group->lock); 7208 spin_lock(&block_group->lock);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 4360ccb191b..5da43aea205 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
3015out:
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);