diff options
author | Liu Bo <bo.li.liu@oracle.com> | 2015-05-25 17:30:15 +0800 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-06-03 04:03:08 -0700 |
commit | 64c043de466d5746e7ca306dab9d418cd871cefc (patch) | |
tree | fcce36cbfdc022f24b5b847152d6b17c967a1b64 /fs/btrfs/extent-tree.c | |
parent | 8635eda91ee11690bd8f73b2504ee19431fd6380 (diff) |
Btrfs: fix up read_tree_block to return proper error
The return value of read_tree_block() can confuse callers as it always
returns NULL for either -ENOMEM or -EIO, so it's likely that callers
parse it to a wrong error, for instance, in btrfs_read_tree_root().
This fixes the above issue.
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 076fd7484a82..f1d1216f7feb 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -7979,9 +7979,12 @@ walk_down: child_gen = btrfs_node_ptr_generation(eb, parent_slot); eb = read_tree_block(root, child_bytenr, child_gen); - if (!eb || !extent_buffer_uptodate(eb)) { - ret = -EIO; + if (IS_ERR(eb)) { + ret = PTR_ERR(eb); + goto out; + } else if (!extent_buffer_uptodate(eb)) { free_extent_buffer(eb); + ret = -EIO; goto out; } @@ -8211,7 +8214,9 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, if (reada && level == 1) reada_walk_down(trans, root, wc, path); next = read_tree_block(root, bytenr, generation); - if (!next || !extent_buffer_uptodate(next)) { + if (IS_ERR(next)) { + return PTR_ERR(next); + } else if (!extent_buffer_uptodate(next)) { free_extent_buffer(next); return -EIO; } |