Skip to content

Commit

Permalink
Btrfs: check return value of alloc_extent_map()
Browse files Browse the repository at this point in the history
I add the check on the return value of alloc_extent_map() to several places.
In addition, alloc_extent_map() returns only the address or NULL.
Therefore, check by IS_ERR() is unnecessary. So, I remove IS_ERR() checking.

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Tsutomu Itoh authored and Chris Mason committed Feb 14, 2011
1 parent 67100f2 commit c26a920
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -6584,7 +6584,7 @@ static noinline int relocate_data_extent(struct inode *reloc_inode,
u64 end = start + extent_key->offset - 1;

em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em || IS_ERR(em));
BUG_ON(!em);

em->start = start;
em->len = extent_key->offset;
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/extent_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct extent_map *alloc_extent_map(gfp_t mask)
{
struct extent_map *em;
em = kmem_cache_alloc(extent_map_cache, mask);
if (!em || IS_ERR(em))
return em;
if (!em)
return NULL;
em->in_tree = 0;
em->flags = 0;
em->compress_type = BTRFS_COMPRESS_NONE;
Expand Down
1 change: 1 addition & 0 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ int btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
split = alloc_extent_map(GFP_NOFS);
if (!split2)
split2 = alloc_extent_map(GFP_NOFS);
BUG_ON(!split || !split2);

write_lock(&em_tree->lock);
em = lookup_extent_mapping(em_tree, start, len);
Expand Down
3 changes: 3 additions & 0 deletions fs/btrfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ static noinline int submit_compressed_extents(struct inode *inode,
async_extent->ram_size - 1, 0);

em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = async_extent->start;
em->len = async_extent->ram_size;
em->orig_start = em->start;
Expand Down Expand Up @@ -820,6 +821,7 @@ static noinline int cow_file_range(struct inode *inode,
BUG_ON(ret);

em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = start;
em->orig_start = em->start;
ram_size = ins.offset;
Expand Down Expand Up @@ -1169,6 +1171,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
struct extent_map_tree *em_tree;
em_tree = &BTRFS_I(inode)->extent_tree;
em = alloc_extent_map(GFP_NOFS);
BUG_ON(!em);
em->start = cur_offset;
em->orig_start = em->start;
em->len = num_bytes;
Expand Down

0 comments on commit c26a920

Please sign in to comment.