mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-03 04:02:04 +00:00
btrfs-progs: deprecate and stop using btrfs_level_size
Size of a b-tree node is always nodesize, regardless of the level. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
2a796d84af
commit
3be6e3e7c9
@ -805,8 +805,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
|
||||
ref->level == 0) {
|
||||
u32 bsz;
|
||||
struct extent_buffer *eb;
|
||||
bsz = btrfs_level_size(fs_info->extent_root,
|
||||
ref->level);
|
||||
bsz = fs_info->extent_root->nodesize;
|
||||
eb = read_tree_block(fs_info->extent_root,
|
||||
ref->parent, bsz, 0);
|
||||
if (!extent_buffer_uptodate(eb)) {
|
||||
|
16
cmds-check.c
16
cmds-check.c
@ -1753,7 +1753,7 @@ static void reada_walk_down(struct btrfs_root *root,
|
||||
return;
|
||||
|
||||
nritems = btrfs_header_nritems(node);
|
||||
blocksize = btrfs_level_size(root, level - 1);
|
||||
blocksize = root->nodesize;
|
||||
for (i = slot; i < nritems; i++) {
|
||||
bytenr = btrfs_node_blockptr(node, i);
|
||||
ptr_gen = btrfs_node_ptr_generation(node, i);
|
||||
@ -1860,7 +1860,7 @@ static int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path,
|
||||
}
|
||||
bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
|
||||
ptr_gen = btrfs_node_ptr_generation(cur, path->slots[*level]);
|
||||
blocksize = btrfs_level_size(root, *level - 1);
|
||||
blocksize = root->nodesize;
|
||||
ret = btrfs_lookup_extent_info(NULL, root, bytenr, *level - 1,
|
||||
1, &refs, NULL);
|
||||
if (ret < 0)
|
||||
@ -6178,7 +6178,7 @@ static int run_next_block(struct btrfs_root *root,
|
||||
level = btrfs_header_level(buf);
|
||||
for (i = 0; i < nritems; i++) {
|
||||
ptr = btrfs_node_blockptr(buf, i);
|
||||
size = btrfs_level_size(root, level - 1);
|
||||
size = root->nodesize;
|
||||
btrfs_node_key_to_cpu(buf, &key, i);
|
||||
if (ri != NULL) {
|
||||
if ((level == ri->drop_level)
|
||||
@ -8201,14 +8201,14 @@ again:
|
||||
level = btrfs_header_level(root1->node);
|
||||
ret = add_root_item_to_list(&normal_trees, root1->root_key.objectid,
|
||||
root1->node->start, 0, level, 0,
|
||||
btrfs_level_size(root1, level), NULL);
|
||||
root1->nodesize, NULL);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
root1 = root->fs_info->chunk_root;
|
||||
level = btrfs_header_level(root1->node);
|
||||
ret = add_root_item_to_list(&normal_trees, root1->root_key.objectid,
|
||||
root1->node->start, 0, level, 0,
|
||||
btrfs_level_size(root1, level), NULL);
|
||||
root1->nodesize, NULL);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
btrfs_init_path(&path);
|
||||
@ -8239,7 +8239,7 @@ again:
|
||||
last_snapshot = btrfs_root_last_snapshot(&ri);
|
||||
if (btrfs_disk_key_objectid(&ri.drop_progress) == 0) {
|
||||
level = btrfs_root_level(&ri);
|
||||
level_size = btrfs_level_size(root, level);
|
||||
level_size = root->nodesize;
|
||||
ret = add_root_item_to_list(&normal_trees,
|
||||
found_key.objectid,
|
||||
btrfs_root_bytenr(&ri),
|
||||
@ -8249,7 +8249,7 @@ again:
|
||||
goto out;
|
||||
} else {
|
||||
level = btrfs_root_level(&ri);
|
||||
level_size = btrfs_level_size(root, level);
|
||||
level_size = root->nodesize;
|
||||
objectid = found_key.objectid;
|
||||
btrfs_disk_key_to_cpu(&found_key,
|
||||
&ri.drop_progress);
|
||||
@ -8364,7 +8364,7 @@ static int btrfs_fsck_reinit_root(struct btrfs_trans_handle *trans,
|
||||
goto init;
|
||||
}
|
||||
c = btrfs_alloc_free_block(trans, root,
|
||||
btrfs_level_size(root, 0),
|
||||
root->nodesize,
|
||||
root->root_key.objectid,
|
||||
&disk_key, level, 0, 0);
|
||||
if (IS_ERR(c)) {
|
||||
|
@ -47,7 +47,7 @@ static void print_extents(struct btrfs_root *root, struct extent_buffer *eb)
|
||||
return;
|
||||
}
|
||||
|
||||
size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
|
||||
size = root->nodesize;
|
||||
nr = btrfs_header_nritems(eb);
|
||||
for (i = 0; i < nr; i++) {
|
||||
struct extent_buffer *next = read_tree_block(root,
|
||||
@ -400,8 +400,7 @@ again:
|
||||
read_extent_buffer(leaf, &ri, offset, sizeof(ri));
|
||||
buf = read_tree_block(tree_root_scan,
|
||||
btrfs_root_bytenr(&ri),
|
||||
btrfs_level_size(tree_root_scan,
|
||||
btrfs_root_level(&ri)),
|
||||
tree_root_scan->nodesize,
|
||||
0);
|
||||
if (!extent_buffer_uptodate(buf))
|
||||
goto next;
|
||||
|
@ -152,7 +152,7 @@ static int walk_nodes(struct btrfs_root *root, struct btrfs_path *path,
|
||||
path->slots[level] = i;
|
||||
if ((level - 1) > 0 || find_inline) {
|
||||
tmp = read_tree_block(root, cur_blocknr,
|
||||
btrfs_level_size(root, level - 1),
|
||||
root->nodesize,
|
||||
btrfs_node_ptr_generation(b, i));
|
||||
if (!extent_buffer_uptodate(tmp)) {
|
||||
fprintf(stderr, "Failed to read blocknr %llu\n",
|
||||
|
4
ctree.c
4
ctree.c
@ -649,7 +649,7 @@ struct extent_buffer *read_node_slot(struct btrfs_root *root,
|
||||
return NULL;
|
||||
|
||||
return read_tree_block(root, btrfs_node_blockptr(parent, slot),
|
||||
btrfs_level_size(root, level - 1),
|
||||
root->nodesize,
|
||||
btrfs_node_ptr_generation(parent, slot));
|
||||
}
|
||||
|
||||
@ -990,7 +990,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
|
||||
|
||||
node = path->nodes[level];
|
||||
search = btrfs_node_blockptr(node, slot);
|
||||
blocksize = btrfs_level_size(root, level - 1);
|
||||
blocksize = root->nodesize;
|
||||
eb = btrfs_find_tree_block(root, search, blocksize);
|
||||
if (eb) {
|
||||
free_extent_buffer(eb);
|
||||
|
5
ctree.h
5
ctree.h
@ -2223,6 +2223,11 @@ static inline u32 btrfs_file_extent_inline_len(struct extent_buffer *eb,
|
||||
return btrfs_file_extent_ram_bytes(eb, fi);
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: Backward compatibility, do not use.
|
||||
* Replacement: read nodesize directly
|
||||
*/
|
||||
__attribute__((deprecated))
|
||||
static inline u32 btrfs_level_size(struct btrfs_root *root, int level) {
|
||||
if (level == 0)
|
||||
return root->leafsize;
|
||||
|
12
disk-io.c
12
disk-io.c
@ -619,7 +619,7 @@ static int find_and_setup_root(struct btrfs_root *tree_root,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
|
||||
blocksize = root->nodesize;
|
||||
generation = btrfs_root_generation(&root->root_item);
|
||||
root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
|
||||
blocksize, generation);
|
||||
@ -645,8 +645,7 @@ static int find_and_setup_log_root(struct btrfs_root *tree_root,
|
||||
return 0;
|
||||
}
|
||||
|
||||
blocksize = btrfs_level_size(tree_root,
|
||||
btrfs_super_log_root_level(disk_super));
|
||||
blocksize = tree_root->nodesize;
|
||||
|
||||
__setup_root(tree_root->nodesize, tree_root->leafsize,
|
||||
tree_root->sectorsize, tree_root->stripesize,
|
||||
@ -737,7 +736,7 @@ out:
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
generation = btrfs_root_generation(&root->root_item);
|
||||
blocksize = btrfs_level_size(root, btrfs_root_level(&root->root_item));
|
||||
blocksize = root->nodesize;
|
||||
root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
|
||||
blocksize, generation);
|
||||
if (!extent_buffer_uptodate(root->node)) {
|
||||
@ -978,7 +977,7 @@ int btrfs_setup_all_roots(struct btrfs_fs_info *fs_info, u64 root_tree_bytenr,
|
||||
root = fs_info->tree_root;
|
||||
__setup_root(nodesize, leafsize, sectorsize, stripesize,
|
||||
root, fs_info, BTRFS_ROOT_TREE_OBJECTID);
|
||||
blocksize = btrfs_level_size(root, btrfs_super_root_level(sb));
|
||||
blocksize = root->nodesize;
|
||||
generation = btrfs_super_generation(sb);
|
||||
|
||||
if (!root_tree_bytenr && !(flags & OPEN_CTREE_BACKUP_ROOT)) {
|
||||
@ -1170,8 +1169,7 @@ int btrfs_setup_chunk_tree_and_device_map(struct btrfs_fs_info *fs_info,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
blocksize = btrfs_level_size(fs_info->chunk_root,
|
||||
btrfs_super_chunk_root_level(sb));
|
||||
blocksize = fs_info->chunk_root->nodesize;
|
||||
generation = btrfs_super_chunk_root_generation(sb);
|
||||
|
||||
if (chunk_root_bytenr && !IS_ALIGNED(chunk_root_bytenr,
|
||||
|
@ -1686,7 +1686,7 @@ static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
|
||||
}
|
||||
} else {
|
||||
bytenr = btrfs_node_blockptr(buf, i);
|
||||
num_bytes = btrfs_level_size(root, level - 1);
|
||||
num_bytes = root->nodesize;
|
||||
ret = process_func(trans, root, bytenr, num_bytes,
|
||||
parent, ref_root, level - 1, 0);
|
||||
if (ret) {
|
||||
|
@ -1118,7 +1118,7 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *eb, int fol
|
||||
(unsigned long long)btrfs_header_owner(eb));
|
||||
print_uuids(eb);
|
||||
fflush(stdout);
|
||||
size = btrfs_level_size(root, btrfs_header_level(eb) - 1);
|
||||
size = root->nodesize;
|
||||
for (i = 0; i < nr; i++) {
|
||||
u64 blocknr = btrfs_node_blockptr(eb, i);
|
||||
btrfs_node_key(eb, &disk_key, i);
|
||||
|
@ -544,8 +544,7 @@ static int travel_tree(struct btrfs_fs_info *info, struct btrfs_root *root,
|
||||
nr = btrfs_header_nritems(eb);
|
||||
for (i = 0; i < nr; i++) {
|
||||
new_bytenr = btrfs_node_blockptr(eb, i);
|
||||
new_num_bytes = btrfs_level_size(root,
|
||||
btrfs_header_level(eb) - 1);
|
||||
new_num_bytes = root->nodesize;
|
||||
|
||||
ret = travel_tree(info, root, new_bytenr, new_num_bytes,
|
||||
ref_parent);
|
||||
|
Loading…
Reference in New Issue
Block a user