aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2011-07-13 13:38:47 -0400
committerMark Fasheh <mfasheh@suse.com>2011-07-14 17:14:44 -0400
commitd8926bb3badd36670fecf2de4a062c78bc37430b (patch)
tree60c8194f9fbba47ff9535b62b9fe439239997e9c /fs/btrfs/extent-tree.c
parent8d86e5f91440aa56a5df516bf58fe3883552ad56 (diff)
btrfs: don't BUG_ON btrfs_alloc_path() errors
This patch fixes many callers of btrfs_alloc_path() which BUG_ON allocation failure. All the sites that are fixed in this patch were checked by me to be fairly trivial to fix because of at least one of two criteria: - Callers of the function catch errors from it already so bubbling the error up will be handled. - Callers of the function might BUG_ON any nonzero return code in which case there is no behavior changed (but we still got to remove a BUG_ON) The following functions were updated: btrfs_lookup_extent, alloc_reserved_tree_block, btrfs_remove_block_group, btrfs_lookup_csums_range, btrfs_csum_file_blocks, btrfs_mark_extent_written, btrfs_inode_by_name, btrfs_new_inode, btrfs_symlink, insert_reserved_file_extent, and run_delalloc_nocow Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 71cd456fdb60..aa91773fe31b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -667,7 +667,9 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
667 struct btrfs_path *path; 667 struct btrfs_path *path;
668 668
669 path = btrfs_alloc_path(); 669 path = btrfs_alloc_path();
670 BUG_ON(!path); 670 if (!path)
671 return -ENOMEM;
672
671 key.objectid = start; 673 key.objectid = start;
672 key.offset = len; 674 key.offset = len;
673 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); 675 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
@@ -5494,7 +5496,8 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
5494 u32 size = sizeof(*extent_item) + sizeof(*block_info) + sizeof(*iref); 5496 u32 size = sizeof(*extent_item) + sizeof(*block_info) + sizeof(*iref);
5495 5497
5496 path = btrfs_alloc_path(); 5498 path = btrfs_alloc_path();
5497 BUG_ON(!path); 5499 if (!path)
5500 return -ENOMEM;
5498 5501
5499 path->leave_spinning = 1; 5502 path->leave_spinning = 1;
5500 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, 5503 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
@@ -7162,7 +7165,10 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
7162 spin_unlock(&cluster->refill_lock); 7165 spin_unlock(&cluster->refill_lock);
7163 7166
7164 path = btrfs_alloc_path(); 7167 path = btrfs_alloc_path();
7165 BUG_ON(!path); 7168 if (!path) {
7169 ret = -ENOMEM;
7170 goto out;
7171 }
7166 7172
7167 inode = lookup_free_space_inode(root, block_group, path); 7173 inode = lookup_free_space_inode(root, block_group, path);
7168 if (!IS_ERR(inode)) { 7174 if (!IS_ERR(inode)) {