btrfs-progs: replace blocksize with parent argument for btrfs_alloc_tree_block

In the kernel we pass in the parent to btrfs_alloc_tree_block instead of
the blocksize and simply derive the blocksize from the fs_info.  Update
the function to match the kernel's convention and update all of the
callers so we can sync ctree.c easily.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2023-08-23 10:32:47 -04:00 committed by David Sterba
parent 5fa9f437e2
commit 2d8058ae09
6 changed files with 22 additions and 29 deletions

View File

@ -9084,8 +9084,7 @@ static struct extent_buffer *btrfs_fsck_clear_root(
if (!path)
return ERR_PTR(-ENOMEM);
c = btrfs_alloc_tree_block(trans, gfs_info->tree_root,
gfs_info->nodesize, key->objectid,
c = btrfs_alloc_tree_block(trans, gfs_info->tree_root, 0, key->objectid,
&disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
if (IS_ERR(c)) {
btrfs_free_path(path);

View File

@ -1143,8 +1143,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans,
btrfs_set_disk_key_type(&disk_key, BTRFS_DEV_ITEM_KEY);
btrfs_set_disk_key_offset(&disk_key, min_devid);
cow = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
BTRFS_CHUNK_TREE_OBJECTID,
cow = btrfs_alloc_tree_block(trans, root, 0, BTRFS_CHUNK_TREE_OBJECTID,
&disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
btrfs_set_header_bytenr(cow, cow->start);
btrfs_set_header_generation(cow, trans->transid);

View File

@ -307,9 +307,8 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
else
btrfs_node_key(buf, &disk_key, 0);
cow = btrfs_alloc_tree_block(trans, new_root, buf->len,
new_root_objectid, &disk_key,
level, buf->start, 0,
cow = btrfs_alloc_tree_block(trans, new_root, 0, new_root_objectid,
&disk_key, level, buf->start, 0,
BTRFS_NESTING_NORMAL);
if (IS_ERR(cow)) {
kfree(new_root);
@ -606,9 +605,8 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
else
btrfs_node_key(buf, &disk_key, 0);
cow = btrfs_alloc_tree_block(trans, root, buf->len,
root->root_key.objectid, &disk_key,
level, search_start, empty_size,
cow = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid,
&disk_key, level, search_start, empty_size,
BTRFS_NESTING_NORMAL);
if (IS_ERR(cow))
return PTR_ERR(cow);
@ -1683,9 +1681,8 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
else
btrfs_node_key(lower, &lower_key, 0);
c = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid, &lower_key,
level, root->node->start, 0,
c = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid,
&lower_key, level, root->node->start, 0,
BTRFS_NESTING_NORMAL);
if (IS_ERR(c))
@ -1805,10 +1802,9 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
mid = (c_nritems + 1) / 2;
btrfs_node_key(c, &disk_key, mid);
split = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
&disk_key, level, c->start, 0,
BTRFS_NESTING_NORMAL);
split = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid,
&disk_key, level, c->start, 0,
BTRFS_NESTING_NORMAL);
if (IS_ERR(split))
return PTR_ERR(split);
@ -2368,10 +2364,9 @@ again:
else
btrfs_item_key(l, &disk_key, mid);
right = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
root->root_key.objectid,
&disk_key, 0, l->start, 0,
BTRFS_NESTING_NORMAL);
right = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid,
&disk_key, 0, l->start, 0,
BTRFS_NESTING_NORMAL);
if (IS_ERR(right)) {
BUG_ON(1);
return PTR_ERR(right);

View File

@ -892,7 +892,7 @@ struct btrfs_block_group *btrfs_lookup_first_block_group(struct
u64 bytenr);
struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
u64 parent, u64 root_objectid,
struct btrfs_disk_key *key, int level,
u64 hint, u64 empty_size,
enum btrfs_lock_nesting nest);

View File

@ -2346,9 +2346,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
btrfs_setup_root(root, fs_info, key->objectid);
memcpy(&root->root_key, key, sizeof(struct btrfs_key));
leaf = btrfs_alloc_tree_block(trans, root, fs_info->nodesize,
root->root_key.objectid, NULL, 0, 0, 0,
BTRFS_NESTING_NORMAL);
leaf = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid,
NULL, 0, 0, 0, BTRFS_NESTING_NORMAL);
if (IS_ERR(leaf)) {
ret = PTR_ERR(leaf);
leaf = NULL;

View File

@ -2479,7 +2479,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
}
static int alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 num_bytes,
struct btrfs_root *root, u64 parent,
u64 root_objectid, u64 generation,
u64 flags, struct btrfs_disk_key *key,
int level, u64 empty_size, u64 hint_byte,
@ -2490,6 +2490,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_delayed_extent_op *extent_op;
struct btrfs_space_info *sinfo;
struct btrfs_fs_info *fs_info = root->fs_info;
u64 num_bytes = fs_info->nodesize;
bool skinny_metadata = btrfs_fs_incompat(root->fs_info,
SKINNY_METADATA);
@ -2536,7 +2537,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
sinfo->bytes_reserved += extent_size;
ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, ins->objectid,
extent_size, 0, root_objectid,
extent_size, parent, root_objectid,
level, BTRFS_ADD_DELAYED_EXTENT,
extent_op, NULL, NULL);
return ret;
@ -2548,7 +2549,7 @@ static int alloc_tree_block(struct btrfs_trans_handle *trans,
*/
struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
u32 blocksize, u64 root_objectid,
u64 parent, u64 root_objectid,
struct btrfs_disk_key *key, int level,
u64 hint, u64 empty_size,
enum btrfs_lock_nesting nest)
@ -2557,7 +2558,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
int ret;
struct extent_buffer *buf;
ret = alloc_tree_block(trans, root, blocksize, root_objectid,
ret = alloc_tree_block(trans, root, parent, root_objectid,
trans->transid, 0, key, level,
empty_size, hint, (u64)-1, &ins);
if (ret) {