Skip to content

Commit ce86cd5

Browse files
committed
btrfs: remove parameter blocksize from read_tree_block
We know the tree block size, no need to pass it around. Signed-off-by: David Sterba <dsterba@suse.cz>
1 parent 453848a commit ce86cd5

7 files changed

Lines changed: 18 additions & 37 deletions

File tree

‎fs/btrfs/backref.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
490490
continue;
491491
BUG_ON(!ref->wanted_disk_byte);
492492
eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
493-
fs_info->tree_root->nodesize, 0);
493+
0);
494494
if (!eb || !extent_buffer_uptodate(eb)) {
495495
free_extent_buffer(eb);
496496
return -EIO;
@@ -1028,12 +1028,10 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
10281028
if (ref->count && ref->parent) {
10291029
if (extent_item_pos && !ref->inode_list &&
10301030
ref->level == 0) {
1031-
u32 bsz;
10321031
struct extent_buffer *eb;
10331032

1034-
bsz = fs_info->extent_root->nodesize;
10351033
eb = read_tree_block(fs_info->extent_root,
1036-
ref->parent, bsz, 0);
1034+
ref->parent, 0);
10371035
if (!eb || !extent_buffer_uptodate(eb)) {
10381036
free_extent_buffer(eb);
10391037
ret = -EIO;

‎fs/btrfs/ctree.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
14251425
struct tree_mod_root *old_root = NULL;
14261426
u64 old_generation = 0;
14271427
u64 logical;
1428-
u32 blocksize;
14291428

14301429
eb_root = btrfs_read_lock_root_node(root);
14311430
tm = __tree_mod_log_oldest_root(root->fs_info, eb_root, time_seq);
@@ -1444,8 +1443,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
14441443
if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
14451444
btrfs_tree_read_unlock(eb_root);
14461445
free_extent_buffer(eb_root);
1447-
blocksize = root->nodesize;
1448-
old = read_tree_block(root, logical, blocksize, 0);
1446+
old = read_tree_block(root, logical, 0);
14491447
if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
14501448
free_extent_buffer(old);
14511449
btrfs_warn(root->fs_info,
@@ -1692,8 +1690,7 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
16921690
uptodate = 0;
16931691
if (!cur || !uptodate) {
16941692
if (!cur) {
1695-
cur = read_tree_block(root, blocknr,
1696-
blocksize, gen);
1693+
cur = read_tree_block(root, blocknr, gen);
16971694
if (!cur || !extent_buffer_uptodate(cur)) {
16981695
free_extent_buffer(cur);
16991696
return -EIO;
@@ -1872,7 +1869,6 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,
18721869
BUG_ON(level == 0);
18731870

18741871
eb = read_tree_block(root, btrfs_node_blockptr(parent, slot),
1875-
root->nodesize,
18761872
btrfs_node_ptr_generation(parent, slot));
18771873
if (eb && !extent_buffer_uptodate(eb)) {
18781874
free_extent_buffer(eb);
@@ -2507,7 +2503,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
25072503
btrfs_release_path(p);
25082504

25092505
ret = -EAGAIN;
2510-
tmp = read_tree_block(root, blocknr, blocksize, 0);
2506+
tmp = read_tree_block(root, blocknr, 0);
25112507
if (tmp) {
25122508
/*
25132509
* If the read above didn't mark this buffer up to date,

‎fs/btrfs/disk-io.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,12 +1138,12 @@ int btrfs_wait_tree_block_writeback(struct extent_buffer *buf)
11381138
}
11391139

11401140
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
1141-
u32 blocksize, u64 parent_transid)
1141+
u64 parent_transid)
11421142
{
11431143
struct extent_buffer *buf = NULL;
11441144
int ret;
11451145

1146-
buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
1146+
buf = btrfs_find_create_tree_block(root, bytenr, root->nodesize);
11471147
if (!buf)
11481148
return NULL;
11491149

@@ -1484,7 +1484,6 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
14841484
struct btrfs_fs_info *fs_info = tree_root->fs_info;
14851485
struct btrfs_path *path;
14861486
u64 generation;
1487-
u32 blocksize;
14881487
int ret;
14891488

14901489
path = btrfs_alloc_path();
@@ -1509,9 +1508,8 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
15091508
}
15101509

15111510
generation = btrfs_root_generation(&root->root_item);
1512-
blocksize = root->nodesize;
15131511
root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
1514-
blocksize, generation);
1512+
generation);
15151513
if (!root->node) {
15161514
ret = -ENOMEM;
15171515
goto find_fail;
@@ -2139,7 +2137,6 @@ int open_ctree(struct super_block *sb,
21392137
{
21402138
u32 sectorsize;
21412139
u32 nodesize;
2142-
u32 blocksize;
21432140
u32 stripesize;
21442141
u64 generation;
21452142
u64 features;
@@ -2643,15 +2640,14 @@ int open_ctree(struct super_block *sb,
26432640
goto fail_sb_buffer;
26442641
}
26452642

2646-
blocksize = tree_root->nodesize;
26472643
generation = btrfs_super_chunk_root_generation(disk_super);
26482644

26492645
__setup_root(nodesize, sectorsize, stripesize, chunk_root,
26502646
fs_info, BTRFS_CHUNK_TREE_OBJECTID);
26512647

26522648
chunk_root->node = read_tree_block(chunk_root,
26532649
btrfs_super_chunk_root(disk_super),
2654-
blocksize, generation);
2650+
generation);
26552651
if (!chunk_root->node ||
26562652
!test_bit(EXTENT_BUFFER_UPTODATE, &chunk_root->node->bflags)) {
26572653
printk(KERN_WARNING "BTRFS: failed to read chunk root on %s\n",
@@ -2684,12 +2680,11 @@ int open_ctree(struct super_block *sb,
26842680
}
26852681

26862682
retry_root_backup:
2687-
blocksize = tree_root->nodesize;
26882683
generation = btrfs_super_generation(disk_super);
26892684

26902685
tree_root->node = read_tree_block(tree_root,
26912686
btrfs_super_root(disk_super),
2692-
blocksize, generation);
2687+
generation);
26932688
if (!tree_root->node ||
26942689
!test_bit(EXTENT_BUFFER_UPTODATE, &tree_root->node->bflags)) {
26952690
printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n",
@@ -2858,7 +2853,6 @@ int open_ctree(struct super_block *sb,
28582853
err = -EIO;
28592854
goto fail_qgroup;
28602855
}
2861-
blocksize = tree_root->nodesize;
28622856

28632857
log_tree_root = btrfs_alloc_root(fs_info);
28642858
if (!log_tree_root) {
@@ -2870,7 +2864,6 @@ int open_ctree(struct super_block *sb,
28702864
log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);
28712865

28722866
log_tree_root->node = read_tree_block(tree_root, bytenr,
2873-
blocksize,
28742867
generation + 1);
28752868
if (!log_tree_root->node ||
28762869
!extent_buffer_uptodate(log_tree_root->node)) {

‎fs/btrfs/disk-io.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct btrfs_device;
4545
struct btrfs_fs_devices;
4646

4747
struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
48-
u32 blocksize, u64 parent_transid);
48+
u64 parent_transid);
4949
void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize);
5050
int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
5151
int mirror_num, struct extent_buffer **eb);

‎fs/btrfs/extent-tree.c‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7645,7 +7645,6 @@ static int account_shared_subtree(struct btrfs_trans_handle *trans,
76457645
level = root_level;
76467646
while (level >= 0) {
76477647
if (path->nodes[level] == NULL) {
7648-
int child_bsize = root->nodesize;
76497648
int parent_slot;
76507649
u64 child_gen;
76517650
u64 child_bytenr;
@@ -7657,8 +7656,7 @@ static int account_shared_subtree(struct btrfs_trans_handle *trans,
76577656
child_bytenr = btrfs_node_blockptr(eb, parent_slot);
76587657
child_gen = btrfs_node_ptr_generation(eb, parent_slot);
76597658

7660-
eb = read_tree_block(root, child_bytenr, child_bsize,
7661-
child_gen);
7659+
eb = read_tree_block(root, child_bytenr, child_gen);
76627660
if (!eb || !extent_buffer_uptodate(eb)) {
76637661
ret = -EIO;
76647662
goto out;
@@ -7674,7 +7672,7 @@ static int account_shared_subtree(struct btrfs_trans_handle *trans,
76747672
ret = btrfs_qgroup_record_ref(trans, root->fs_info,
76757673
root->objectid,
76767674
child_bytenr,
7677-
child_bsize,
7675+
root->nodesize,
76787676
BTRFS_QGROUP_OPER_SUB_SUBTREE,
76797677
0);
76807678
if (ret)
@@ -7889,7 +7887,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
78897887
if (!next) {
78907888
if (reada && level == 1)
78917889
reada_walk_down(trans, root, wc, path);
7892-
next = read_tree_block(root, bytenr, blocksize, generation);
7890+
next = read_tree_block(root, bytenr, generation);
78937891
if (!next || !extent_buffer_uptodate(next)) {
78947892
free_extent_buffer(next);
78957893
return -EIO;

‎fs/btrfs/print-tree.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
336336
for (i = 0; i < nr; i++) {
337337
struct extent_buffer *next = read_tree_block(root,
338338
btrfs_node_blockptr(c, i),
339-
root->nodesize,
340339
btrfs_node_ptr_generation(c, i));
341340
if (btrfs_is_leaf(next) &&
342341
level != 1)

‎fs/btrfs/relocation.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,8 +1813,7 @@ int replace_path(struct btrfs_trans_handle *trans,
18131813
break;
18141814
}
18151815

1816-
eb = read_tree_block(dest, old_bytenr, blocksize,
1817-
old_ptr_gen);
1816+
eb = read_tree_block(dest, old_bytenr, old_ptr_gen);
18181817
if (!eb || !extent_buffer_uptodate(eb)) {
18191818
ret = (!eb) ? -ENOMEM : -EIO;
18201819
free_extent_buffer(eb);
@@ -1944,7 +1943,6 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
19441943
u64 bytenr;
19451944
u64 ptr_gen = 0;
19461945
u64 last_snapshot;
1947-
u32 blocksize;
19481946
u32 nritems;
19491947

19501948
last_snapshot = btrfs_root_last_snapshot(&root->root_item);
@@ -1970,8 +1968,7 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
19701968
}
19711969

19721970
bytenr = btrfs_node_blockptr(eb, path->slots[i]);
1973-
blocksize = root->nodesize;
1974-
eb = read_tree_block(root, bytenr, blocksize, ptr_gen);
1971+
eb = read_tree_block(root, bytenr, ptr_gen);
19751972
if (!eb || !extent_buffer_uptodate(eb)) {
19761973
free_extent_buffer(eb);
19771974
return -EIO;
@@ -2680,7 +2677,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
26802677

26812678
blocksize = root->nodesize;
26822679
generation = btrfs_node_ptr_generation(upper->eb, slot);
2683-
eb = read_tree_block(root, bytenr, blocksize, generation);
2680+
eb = read_tree_block(root, bytenr, generation);
26842681
if (!eb || !extent_buffer_uptodate(eb)) {
26852682
free_extent_buffer(eb);
26862683
err = -EIO;
@@ -2842,7 +2839,7 @@ static int get_tree_block_key(struct reloc_control *rc,
28422839

28432840
BUG_ON(block->key_ready);
28442841
eb = read_tree_block(rc->extent_root, block->bytenr,
2845-
block->key.objectid, block->key.offset);
2842+
block->key.offset);
28462843
if (!eb || !extent_buffer_uptodate(eb)) {
28472844
free_extent_buffer(eb);
28482845
return -EIO;

0 commit comments

Comments
 (0)