diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2015-01-28 10:12:55 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-02-02 19:21:24 +0100 |
commit | ccdd0a067f36b689a0928074d53e5020f3ff5f5d (patch) | |
tree | f06f2dcf7788ab6a3b1e698c1c1b13e15d0b75b3 /disk-io.c | |
parent | 3e7524911214c4399f25ed2dabc0ad2956f7e90e (diff) |
btrfs-progs: read_tree_block() and read_node_slot() cleanup.
Allow read_tree_block() and read_node_slot() to return error pointer.
This should help caller to get more specified error number.
For existing callers, change (!eb) judgmentt to
(!extent_buffer_uptodate(eb)) to keep the compatibility, and for caller
missing the check, use PTR_ERR(eb) if possible.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'disk-io.c')
-rw-r--r-- | disk-io.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -258,7 +258,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, eb = btrfs_find_create_tree_block(root, bytenr, blocksize); if (!eb) - return NULL; + return ERR_PTR(-ENOMEM); if (btrfs_buffer_uptodate(eb, parent_transid)) return eb; @@ -283,6 +283,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, printk("read block failed check_tree_block\n"); else printk("Csum didn't match\n"); + ret = -EIO; break; } num_copies = btrfs_num_copies(&root->fs_info->mapping_tree, @@ -303,7 +304,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, } } free_extent_buffer(eb); - return NULL; + return ERR_PTR(ret); } int write_and_map_eb(struct btrfs_trans_handle *trans, @@ -639,7 +640,7 @@ out: blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item)); root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), blocksize, generation); - if (!root->node) { + if (!extent_buffer_uptodate(root->node)) { free(root); return ERR_PTR(-EIO); } @@ -1068,8 +1069,7 @@ int btrfs_setup_chunk_tree_and_device_map(struct btrfs_fs_info *fs_info) fs_info->chunk_root->node = read_tree_block(fs_info->chunk_root, btrfs_super_chunk_root(sb), blocksize, generation); - if (!fs_info->chunk_root->node || - !extent_buffer_uptodate(fs_info->chunk_root->node)) { + if (!extent_buffer_uptodate(fs_info->chunk_root->node)) { fprintf(stderr, "Couldn't read chunk root\n"); return -EIO; } |