mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-16 23:08:38 +00:00
btrfs-progs: drop blocksize argument from btrfs_find_create_tree_block
Metadata blocks are always nodesize. When reading the superblock::sys_array, the actual size of data is fixed to 4k and smaller than nodesize, but otherwise everything works as before. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
d1b968dcba
commit
2030f49751
@ -1364,7 +1364,7 @@ int main(int argc, char **argv)
|
||||
struct extent_buffer *eb;
|
||||
|
||||
eb = btrfs_find_create_tree_block(root->fs_info,
|
||||
logical, root->fs_info->sectorsize);
|
||||
logical);
|
||||
if (!eb) {
|
||||
error(
|
||||
"not enough memory to allocate extent buffer for bytenr %llu",
|
||||
|
12
disk-io.c
12
disk-io.c
@ -182,9 +182,10 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_fs_info *fs_info,
|
||||
}
|
||||
|
||||
struct extent_buffer* btrfs_find_create_tree_block(
|
||||
struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize)
|
||||
struct btrfs_fs_info *fs_info, u64 bytenr)
|
||||
{
|
||||
return alloc_extent_buffer(&fs_info->extent_cache, bytenr, blocksize);
|
||||
return alloc_extent_buffer(&fs_info->extent_cache, bytenr,
|
||||
fs_info->nodesize);
|
||||
}
|
||||
|
||||
void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
|
||||
@ -306,7 +307,6 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
|
||||
struct extent_buffer *eb;
|
||||
u64 best_transid = 0;
|
||||
u32 sectorsize = fs_info->sectorsize;
|
||||
u32 nodesize = fs_info->nodesize;
|
||||
int mirror_num = 0;
|
||||
int good_mirror = 0;
|
||||
int num_copies;
|
||||
@ -324,7 +324,7 @@ struct extent_buffer* read_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
|
||||
return ERR_PTR(-EIO);
|
||||
}
|
||||
|
||||
eb = btrfs_find_create_tree_block(fs_info, bytenr, nodesize);
|
||||
eb = btrfs_find_create_tree_block(fs_info, bytenr);
|
||||
if (!eb)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@ -937,9 +937,7 @@ static int setup_root_or_create_block(struct btrfs_fs_info *fs_info,
|
||||
struct btrfs_root *info_root,
|
||||
u64 objectid, char *str)
|
||||
{
|
||||
struct btrfs_super_block *sb = fs_info->super_copy;
|
||||
struct btrfs_root *root = fs_info->tree_root;
|
||||
u32 nodesize = btrfs_super_nodesize(sb);
|
||||
int ret;
|
||||
|
||||
ret = find_and_setup_root(root, fs_info, objectid, info_root);
|
||||
@ -952,7 +950,7 @@ static int setup_root_or_create_block(struct btrfs_fs_info *fs_info,
|
||||
* million of places that assume a root has a valid ->node
|
||||
*/
|
||||
info_root->node =
|
||||
btrfs_find_create_tree_block(fs_info, 0, nodesize);
|
||||
btrfs_find_create_tree_block(fs_info, 0);
|
||||
if (!info_root->node)
|
||||
return -ENOMEM;
|
||||
clear_extent_buffer_uptodate(info_root->node);
|
||||
|
@ -123,7 +123,7 @@ int read_extent_data(struct btrfs_fs_info *fs_info, char *data, u64 logical,
|
||||
void readahead_tree_block(struct btrfs_fs_info *fs_info, u64 bytenr,
|
||||
u32 blocksize, u64 parent_transid);
|
||||
struct extent_buffer* btrfs_find_create_tree_block(
|
||||
struct btrfs_fs_info *fs_info, u64 bytenr, u32 blocksize);
|
||||
struct btrfs_fs_info *fs_info, u64 bytenr);
|
||||
|
||||
void btrfs_setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
|
||||
u64 objectid);
|
||||
|
@ -2818,8 +2818,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
buf = btrfs_find_create_tree_block(root->fs_info, ins.objectid,
|
||||
blocksize);
|
||||
buf = btrfs_find_create_tree_block(root->fs_info, ins.objectid);
|
||||
if (!buf) {
|
||||
btrfs_free_extent(trans, root, ins.objectid, ins.offset,
|
||||
0, root->root_key.objectid, level, 0);
|
||||
|
@ -1963,9 +1963,12 @@ int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
|
||||
u32 cur_offset;
|
||||
struct btrfs_key key;
|
||||
|
||||
sb = btrfs_find_create_tree_block(fs_info,
|
||||
BTRFS_SUPER_INFO_OFFSET,
|
||||
BTRFS_SUPER_INFO_SIZE);
|
||||
if (fs_info->nodesize < BTRFS_SUPER_INFO_SIZE) {
|
||||
printf("ERROR: nodesize %u too small to read superblock\n",
|
||||
fs_info->nodesize);
|
||||
return -EINVAL;
|
||||
}
|
||||
sb = btrfs_find_create_tree_block(fs_info, BTRFS_SUPER_INFO_OFFSET);
|
||||
if (!sb)
|
||||
return -ENOMEM;
|
||||
btrfs_set_buffer_uptodate(sb);
|
||||
|
Loading…
Reference in New Issue
Block a user