From ccdd0a067f36b689a0928074d53e5020f3ff5f5d Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 28 Jan 2015 10:12:55 +0800 Subject: 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 Signed-off-by: David Sterba --- disk-io.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'disk-io.c') diff --git a/disk-io.c b/disk-io.c index d7b906a0..0d33258b 100644 --- a/disk-io.c +++ b/disk-io.c @@ -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; } -- cgit v1.2.3