aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2014-06-14 19:07:32 -0400
committerDavid Sterba <dsterba@suse.cz>2014-10-02 11:14:50 -0400
commitce86cd59179279a6fe673d2a105d24fb7e70aef3 (patch)
treed5a57e9f23ef1041497d9ad7bd7e5c6aeb23fdcd /fs/btrfs
parent453848a05ff984cb3665bad5c7e0024e8cfe87a5 (diff)
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>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/backref.c6
-rw-r--r--fs/btrfs/ctree.c10
-rw-r--r--fs/btrfs/disk-io.c17
-rw-r--r--fs/btrfs/disk-io.h2
-rw-r--r--fs/btrfs/extent-tree.c8
-rw-r--r--fs/btrfs/print-tree.c1
-rw-r--r--fs/btrfs/relocation.c11
7 files changed, 18 insertions, 37 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 6829dc5aa657..2d3e32ebfd15 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -490,7 +490,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
490 continue; 490 continue;
491 BUG_ON(!ref->wanted_disk_byte); 491 BUG_ON(!ref->wanted_disk_byte);
492 eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte, 492 eb = read_tree_block(fs_info->tree_root, ref->wanted_disk_byte,
493 fs_info->tree_root->nodesize, 0); 493 0);
494 if (!eb || !extent_buffer_uptodate(eb)) { 494 if (!eb || !extent_buffer_uptodate(eb)) {
495 free_extent_buffer(eb); 495 free_extent_buffer(eb);
496 return -EIO; 496 return -EIO;
@@ -1028,12 +1028,10 @@ again:
1028 if (ref->count && ref->parent) { 1028 if (ref->count && ref->parent) {
1029 if (extent_item_pos && !ref->inode_list && 1029 if (extent_item_pos && !ref->inode_list &&
1030 ref->level == 0) { 1030 ref->level == 0) {
1031 u32 bsz;
1032 struct extent_buffer *eb; 1031 struct extent_buffer *eb;
1033 1032
1034 bsz = fs_info->extent_root->nodesize;
1035 eb = read_tree_block(fs_info->extent_root, 1033 eb = read_tree_block(fs_info->extent_root,
1036 ref->parent, bsz, 0); 1034 ref->parent, 0);
1037 if (!eb || !extent_buffer_uptodate(eb)) { 1035 if (!eb || !extent_buffer_uptodate(eb)) {
1038 free_extent_buffer(eb); 1036 free_extent_buffer(eb);
1039 ret = -EIO; 1037 ret = -EIO;
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 1b7e3545a596..302c3f955706 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1425,7 +1425,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
1425 struct tree_mod_root *old_root = NULL; 1425 struct tree_mod_root *old_root = NULL;
1426 u64 old_generation = 0; 1426 u64 old_generation = 0;
1427 u64 logical; 1427 u64 logical;
1428 u32 blocksize;
1429 1428
1430 eb_root = btrfs_read_lock_root_node(root); 1429 eb_root = btrfs_read_lock_root_node(root);
1431 tm = __tree_mod_log_oldest_root(root->fs_info, eb_root, time_seq); 1430 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)
1444 if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { 1443 if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
1445 btrfs_tree_read_unlock(eb_root); 1444 btrfs_tree_read_unlock(eb_root);
1446 free_extent_buffer(eb_root); 1445 free_extent_buffer(eb_root);
1447 blocksize = root->nodesize; 1446 old = read_tree_block(root, logical, 0);
1448 old = read_tree_block(root, logical, blocksize, 0);
1449 if (WARN_ON(!old || !extent_buffer_uptodate(old))) { 1447 if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
1450 free_extent_buffer(old); 1448 free_extent_buffer(old);
1451 btrfs_warn(root->fs_info, 1449 btrfs_warn(root->fs_info,
@@ -1692,8 +1690,7 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
1692 uptodate = 0; 1690 uptodate = 0;
1693 if (!cur || !uptodate) { 1691 if (!cur || !uptodate) {
1694 if (!cur) { 1692 if (!cur) {
1695 cur = read_tree_block(root, blocknr, 1693 cur = read_tree_block(root, blocknr, gen);
1696 blocksize, gen);
1697 if (!cur || !extent_buffer_uptodate(cur)) { 1694 if (!cur || !extent_buffer_uptodate(cur)) {
1698 free_extent_buffer(cur); 1695 free_extent_buffer(cur);
1699 return -EIO; 1696 return -EIO;
@@ -1872,7 +1869,6 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root,
1872 BUG_ON(level == 0); 1869 BUG_ON(level == 0);
1873 1870
1874 eb = read_tree_block(root, btrfs_node_blockptr(parent, slot), 1871 eb = read_tree_block(root, btrfs_node_blockptr(parent, slot),
1875 root->nodesize,
1876 btrfs_node_ptr_generation(parent, slot)); 1872 btrfs_node_ptr_generation(parent, slot));
1877 if (eb && !extent_buffer_uptodate(eb)) { 1873 if (eb && !extent_buffer_uptodate(eb)) {
1878 free_extent_buffer(eb); 1874 free_extent_buffer(eb);
@@ -2507,7 +2503,7 @@ read_block_for_search(struct btrfs_trans_handle *trans,
2507 btrfs_release_path(p); 2503 btrfs_release_path(p);
2508 2504
2509 ret = -EAGAIN; 2505 ret = -EAGAIN;
2510 tmp = read_tree_block(root, blocknr, blocksize, 0); 2506 tmp = read_tree_block(root, blocknr, 0);
2511 if (tmp) { 2507 if (tmp) {
2512 /* 2508 /*
2513 * If the read above didn't mark this buffer up to date, 2509 * If the read above didn't mark this buffer up to date,
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 332f63518156..03c0973568ef 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1138,12 +1138,12 @@ int btrfs_wait_tree_block_writeback(struct extent_buffer *buf)
1138} 1138}
1139 1139
1140struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, 1140struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
1141 u32 blocksize, u64 parent_transid) 1141 u64 parent_transid)
1142{ 1142{
1143 struct extent_buffer *buf = NULL; 1143 struct extent_buffer *buf = NULL;
1144 int ret; 1144 int ret;
1145 1145
1146 buf = btrfs_find_create_tree_block(root, bytenr, blocksize); 1146 buf = btrfs_find_create_tree_block(root, bytenr, root->nodesize);
1147 if (!buf) 1147 if (!buf)
1148 return NULL; 1148 return NULL;
1149 1149
@@ -1484,7 +1484,6 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
1484 struct btrfs_fs_info *fs_info = tree_root->fs_info; 1484 struct btrfs_fs_info *fs_info = tree_root->fs_info;
1485 struct btrfs_path *path; 1485 struct btrfs_path *path;
1486 u64 generation; 1486 u64 generation;
1487 u32 blocksize;
1488 int ret; 1487 int ret;
1489 1488
1490 path = btrfs_alloc_path(); 1489 path = btrfs_alloc_path();
@@ -1509,9 +1508,8 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root,
1509 } 1508 }
1510 1509
1511 generation = btrfs_root_generation(&root->root_item); 1510 generation = btrfs_root_generation(&root->root_item);
1512 blocksize = root->nodesize;
1513 root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), 1511 root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item),
1514 blocksize, generation); 1512 generation);
1515 if (!root->node) { 1513 if (!root->node) {
1516 ret = -ENOMEM; 1514 ret = -ENOMEM;
1517 goto find_fail; 1515 goto find_fail;
@@ -2139,7 +2137,6 @@ int open_ctree(struct super_block *sb,
2139{ 2137{
2140 u32 sectorsize; 2138 u32 sectorsize;
2141 u32 nodesize; 2139 u32 nodesize;
2142 u32 blocksize;
2143 u32 stripesize; 2140 u32 stripesize;
2144 u64 generation; 2141 u64 generation;
2145 u64 features; 2142 u64 features;
@@ -2643,7 +2640,6 @@ int open_ctree(struct super_block *sb,
2643 goto fail_sb_buffer; 2640 goto fail_sb_buffer;
2644 } 2641 }
2645 2642
2646 blocksize = tree_root->nodesize;
2647 generation = btrfs_super_chunk_root_generation(disk_super); 2643 generation = btrfs_super_chunk_root_generation(disk_super);
2648 2644
2649 __setup_root(nodesize, sectorsize, stripesize, chunk_root, 2645 __setup_root(nodesize, sectorsize, stripesize, chunk_root,
@@ -2651,7 +2647,7 @@ int open_ctree(struct super_block *sb,
2651 2647
2652 chunk_root->node = read_tree_block(chunk_root, 2648 chunk_root->node = read_tree_block(chunk_root,
2653 btrfs_super_chunk_root(disk_super), 2649 btrfs_super_chunk_root(disk_super),
2654 blocksize, generation); 2650 generation);
2655 if (!chunk_root->node || 2651 if (!chunk_root->node ||
2656 !test_bit(EXTENT_BUFFER_UPTODATE, &chunk_root->node->bflags)) { 2652 !test_bit(EXTENT_BUFFER_UPTODATE, &chunk_root->node->bflags)) {
2657 printk(KERN_WARNING "BTRFS: failed to read chunk root on %s\n", 2653 printk(KERN_WARNING "BTRFS: failed to read chunk root on %s\n",
@@ -2684,12 +2680,11 @@ int open_ctree(struct super_block *sb,
2684 } 2680 }
2685 2681
2686retry_root_backup: 2682retry_root_backup:
2687 blocksize = tree_root->nodesize;
2688 generation = btrfs_super_generation(disk_super); 2683 generation = btrfs_super_generation(disk_super);
2689 2684
2690 tree_root->node = read_tree_block(tree_root, 2685 tree_root->node = read_tree_block(tree_root,
2691 btrfs_super_root(disk_super), 2686 btrfs_super_root(disk_super),
2692 blocksize, generation); 2687 generation);
2693 if (!tree_root->node || 2688 if (!tree_root->node ||
2694 !test_bit(EXTENT_BUFFER_UPTODATE, &tree_root->node->bflags)) { 2689 !test_bit(EXTENT_BUFFER_UPTODATE, &tree_root->node->bflags)) {
2695 printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n", 2690 printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n",
@@ -2858,7 +2853,6 @@ retry_root_backup:
2858 err = -EIO; 2853 err = -EIO;
2859 goto fail_qgroup; 2854 goto fail_qgroup;
2860 } 2855 }
2861 blocksize = tree_root->nodesize;
2862 2856
2863 log_tree_root = btrfs_alloc_root(fs_info); 2857 log_tree_root = btrfs_alloc_root(fs_info);
2864 if (!log_tree_root) { 2858 if (!log_tree_root) {
@@ -2870,7 +2864,6 @@ retry_root_backup:
2870 log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID); 2864 log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID);
2871 2865
2872 log_tree_root->node = read_tree_block(tree_root, bytenr, 2866 log_tree_root->node = read_tree_block(tree_root, bytenr,
2873 blocksize,
2874 generation + 1); 2867 generation + 1);
2875 if (!log_tree_root->node || 2868 if (!log_tree_root->node ||
2876 !extent_buffer_uptodate(log_tree_root->node)) { 2869 !extent_buffer_uptodate(log_tree_root->node)) {
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index 0d9793f6b594..03f396144fe1 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -45,7 +45,7 @@ struct btrfs_device;
45struct btrfs_fs_devices; 45struct btrfs_fs_devices;
46 46
47struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, 47struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
48 u32 blocksize, u64 parent_transid); 48 u64 parent_transid);
49void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize); 49void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize);
50int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, 50int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
51 int mirror_num, struct extent_buffer **eb); 51 int mirror_num, struct extent_buffer **eb);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index e0468a9789a5..178f6dbf2d7c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7645,7 +7645,6 @@ walk_down:
7645 level = root_level; 7645 level = root_level;
7646 while (level >= 0) { 7646 while (level >= 0) {
7647 if (path->nodes[level] == NULL) { 7647 if (path->nodes[level] == NULL) {
7648 int child_bsize = root->nodesize;
7649 int parent_slot; 7648 int parent_slot;
7650 u64 child_gen; 7649 u64 child_gen;
7651 u64 child_bytenr; 7650 u64 child_bytenr;
@@ -7657,8 +7656,7 @@ walk_down:
7657 child_bytenr = btrfs_node_blockptr(eb, parent_slot); 7656 child_bytenr = btrfs_node_blockptr(eb, parent_slot);
7658 child_gen = btrfs_node_ptr_generation(eb, parent_slot); 7657 child_gen = btrfs_node_ptr_generation(eb, parent_slot);
7659 7658
7660 eb = read_tree_block(root, child_bytenr, child_bsize, 7659 eb = read_tree_block(root, child_bytenr, child_gen);
7661 child_gen);
7662 if (!eb || !extent_buffer_uptodate(eb)) { 7660 if (!eb || !extent_buffer_uptodate(eb)) {
7663 ret = -EIO; 7661 ret = -EIO;
7664 goto out; 7662 goto out;
@@ -7674,7 +7672,7 @@ walk_down:
7674 ret = btrfs_qgroup_record_ref(trans, root->fs_info, 7672 ret = btrfs_qgroup_record_ref(trans, root->fs_info,
7675 root->objectid, 7673 root->objectid,
7676 child_bytenr, 7674 child_bytenr,
7677 child_bsize, 7675 root->nodesize,
7678 BTRFS_QGROUP_OPER_SUB_SUBTREE, 7676 BTRFS_QGROUP_OPER_SUB_SUBTREE,
7679 0); 7677 0);
7680 if (ret) 7678 if (ret)
@@ -7889,7 +7887,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
7889 if (!next) { 7887 if (!next) {
7890 if (reada && level == 1) 7888 if (reada && level == 1)
7891 reada_walk_down(trans, root, wc, path); 7889 reada_walk_down(trans, root, wc, path);
7892 next = read_tree_block(root, bytenr, blocksize, generation); 7890 next = read_tree_block(root, bytenr, generation);
7893 if (!next || !extent_buffer_uptodate(next)) { 7891 if (!next || !extent_buffer_uptodate(next)) {
7894 free_extent_buffer(next); 7892 free_extent_buffer(next);
7895 return -EIO; 7893 return -EIO;
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index eb309855d5c8..647ab12fdf5d 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -336,7 +336,6 @@ void btrfs_print_tree(struct btrfs_root *root, struct extent_buffer *c)
336 for (i = 0; i < nr; i++) { 336 for (i = 0; i < nr; i++) {
337 struct extent_buffer *next = read_tree_block(root, 337 struct extent_buffer *next = read_tree_block(root,
338 btrfs_node_blockptr(c, i), 338 btrfs_node_blockptr(c, i),
339 root->nodesize,
340 btrfs_node_ptr_generation(c, i)); 339 btrfs_node_ptr_generation(c, i));
341 if (btrfs_is_leaf(next) && 340 if (btrfs_is_leaf(next) &&
342 level != 1) 341 level != 1)
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index d7506325b024..95bc40ae358d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1813,8 +1813,7 @@ again:
1813 break; 1813 break;
1814 } 1814 }
1815 1815
1816 eb = read_tree_block(dest, old_bytenr, blocksize, 1816 eb = read_tree_block(dest, old_bytenr, old_ptr_gen);
1817 old_ptr_gen);
1818 if (!eb || !extent_buffer_uptodate(eb)) { 1817 if (!eb || !extent_buffer_uptodate(eb)) {
1819 ret = (!eb) ? -ENOMEM : -EIO; 1818 ret = (!eb) ? -ENOMEM : -EIO;
1820 free_extent_buffer(eb); 1819 free_extent_buffer(eb);
@@ -1944,7 +1943,6 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
1944 u64 bytenr; 1943 u64 bytenr;
1945 u64 ptr_gen = 0; 1944 u64 ptr_gen = 0;
1946 u64 last_snapshot; 1945 u64 last_snapshot;
1947 u32 blocksize;
1948 u32 nritems; 1946 u32 nritems;
1949 1947
1950 last_snapshot = btrfs_root_last_snapshot(&root->root_item); 1948 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,
1970 } 1968 }
1971 1969
1972 bytenr = btrfs_node_blockptr(eb, path->slots[i]); 1970 bytenr = btrfs_node_blockptr(eb, path->slots[i]);
1973 blocksize = root->nodesize; 1971 eb = read_tree_block(root, bytenr, ptr_gen);
1974 eb = read_tree_block(root, bytenr, blocksize, ptr_gen);
1975 if (!eb || !extent_buffer_uptodate(eb)) { 1972 if (!eb || !extent_buffer_uptodate(eb)) {
1976 free_extent_buffer(eb); 1973 free_extent_buffer(eb);
1977 return -EIO; 1974 return -EIO;
@@ -2680,7 +2677,7 @@ static int do_relocation(struct btrfs_trans_handle *trans,
2680 2677
2681 blocksize = root->nodesize; 2678 blocksize = root->nodesize;
2682 generation = btrfs_node_ptr_generation(upper->eb, slot); 2679 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);
2684 if (!eb || !extent_buffer_uptodate(eb)) { 2681 if (!eb || !extent_buffer_uptodate(eb)) {
2685 free_extent_buffer(eb); 2682 free_extent_buffer(eb);
2686 err = -EIO; 2683 err = -EIO;
@@ -2842,7 +2839,7 @@ static int get_tree_block_key(struct reloc_control *rc,
2842 2839
2843 BUG_ON(block->key_ready); 2840 BUG_ON(block->key_ready);
2844 eb = read_tree_block(rc->extent_root, block->bytenr, 2841 eb = read_tree_block(rc->extent_root, block->bytenr,
2845 block->key.objectid, block->key.offset); 2842 block->key.offset);
2846 if (!eb || !extent_buffer_uptodate(eb)) { 2843 if (!eb || !extent_buffer_uptodate(eb)) {
2847 free_extent_buffer(eb); 2844 free_extent_buffer(eb);
2848 return -EIO; 2845 return -EIO;