diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 07d9e83f8954..2409718e3f20 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1073,20 +1073,17 @@ static const struct address_space_operations btree_aops = { | |||
1073 | .set_page_dirty = btree_set_page_dirty, | 1073 | .set_page_dirty = btree_set_page_dirty, |
1074 | }; | 1074 | }; |
1075 | 1075 | ||
1076 | int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, | 1076 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) |
1077 | u64 parent_transid) | ||
1078 | { | 1077 | { |
1079 | struct extent_buffer *buf = NULL; | 1078 | struct extent_buffer *buf = NULL; |
1080 | struct inode *btree_inode = root->fs_info->btree_inode; | 1079 | struct inode *btree_inode = root->fs_info->btree_inode; |
1081 | int ret = 0; | ||
1082 | 1080 | ||
1083 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 1081 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); |
1084 | if (!buf) | 1082 | if (!buf) |
1085 | return 0; | 1083 | return; |
1086 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, | 1084 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, |
1087 | buf, 0, WAIT_NONE, btree_get_extent, 0); | 1085 | buf, 0, WAIT_NONE, btree_get_extent, 0); |
1088 | free_extent_buffer(buf); | 1086 | free_extent_buffer(buf); |
1089 | return ret; | ||
1090 | } | 1087 | } |
1091 | 1088 | ||
1092 | int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, | 1089 | int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, |
@@ -1122,7 +1119,7 @@ int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, | |||
1122 | } | 1119 | } |
1123 | 1120 | ||
1124 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | 1121 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, |
1125 | u64 bytenr, u32 blocksize) | 1122 | u64 bytenr) |
1126 | { | 1123 | { |
1127 | return find_extent_buffer(root->fs_info, bytenr); | 1124 | return find_extent_buffer(root->fs_info, bytenr); |
1128 | } | 1125 | } |
@@ -1150,12 +1147,12 @@ int btrfs_wait_tree_block_writeback(struct extent_buffer *buf) | |||
1150 | } | 1147 | } |
1151 | 1148 | ||
1152 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | 1149 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, |
1153 | u32 blocksize, u64 parent_transid) | 1150 | u64 parent_transid) |
1154 | { | 1151 | { |
1155 | struct extent_buffer *buf = NULL; | 1152 | struct extent_buffer *buf = NULL; |
1156 | int ret; | 1153 | int ret; |
1157 | 1154 | ||
1158 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 1155 | buf = btrfs_find_create_tree_block(root, bytenr, root->nodesize); |
1159 | if (!buf) | 1156 | if (!buf) |
1160 | return NULL; | 1157 | return NULL; |
1161 | 1158 | ||
@@ -1336,8 +1333,7 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, | |||
1336 | root->root_key.type = BTRFS_ROOT_ITEM_KEY; | 1333 | root->root_key.type = BTRFS_ROOT_ITEM_KEY; |
1337 | root->root_key.offset = 0; | 1334 | root->root_key.offset = 0; |
1338 | 1335 | ||
1339 | leaf = btrfs_alloc_free_block(trans, root, root->nodesize, | 1336 | leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0); |
1340 | 0, objectid, NULL, 0, 0, 0); | ||
1341 | if (IS_ERR(leaf)) { | 1337 | if (IS_ERR(leaf)) { |
1342 | ret = PTR_ERR(leaf); | 1338 | ret = PTR_ERR(leaf); |
1343 | leaf = NULL; | 1339 | leaf = NULL; |
@@ -1424,9 +1420,8 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans, | |||
1424 | * updated (along with back refs to the log tree). | 1420 | * updated (along with back refs to the log tree). |
1425 | */ | 1421 | */ |
1426 | 1422 | ||
1427 | leaf = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 1423 | leaf = btrfs_alloc_tree_block(trans, root, 0, BTRFS_TREE_LOG_OBJECTID, |
1428 | BTRFS_TREE_LOG_OBJECTID, NULL, | 1424 | NULL, 0, 0, 0); |
1429 | 0, 0, 0); | ||
1430 | if (IS_ERR(leaf)) { | 1425 | if (IS_ERR(leaf)) { |
1431 | kfree(root); | 1426 | kfree(root); |
1432 | return ERR_CAST(leaf); | 1427 | return ERR_CAST(leaf); |
@@ -1496,7 +1491,6 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root, | |||
1496 | struct btrfs_fs_info *fs_info = tree_root->fs_info; | 1491 | struct btrfs_fs_info *fs_info = tree_root->fs_info; |
1497 | struct btrfs_path *path; | 1492 | struct btrfs_path *path; |
1498 | u64 generation; | 1493 | u64 generation; |
1499 | u32 blocksize; | ||
1500 | int ret; | 1494 | int ret; |
1501 | 1495 | ||
1502 | path = btrfs_alloc_path(); | 1496 | path = btrfs_alloc_path(); |
@@ -1521,9 +1515,8 @@ static struct btrfs_root *btrfs_read_tree_root(struct btrfs_root *tree_root, | |||
1521 | } | 1515 | } |
1522 | 1516 | ||
1523 | generation = btrfs_root_generation(&root->root_item); | 1517 | generation = btrfs_root_generation(&root->root_item); |
1524 | blocksize = root->nodesize; | ||
1525 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), | 1518 | root->node = read_tree_block(root, btrfs_root_bytenr(&root->root_item), |
1526 | blocksize, generation); | 1519 | generation); |
1527 | if (!root->node) { | 1520 | if (!root->node) { |
1528 | ret = -ENOMEM; | 1521 | ret = -ENOMEM; |
1529 | goto find_fail; | 1522 | goto find_fail; |
@@ -2151,7 +2144,6 @@ int open_ctree(struct super_block *sb, | |||
2151 | { | 2144 | { |
2152 | u32 sectorsize; | 2145 | u32 sectorsize; |
2153 | u32 nodesize; | 2146 | u32 nodesize; |
2154 | u32 blocksize; | ||
2155 | u32 stripesize; | 2147 | u32 stripesize; |
2156 | u64 generation; | 2148 | u64 generation; |
2157 | u64 features; | 2149 | u64 features; |
@@ -2655,7 +2647,6 @@ int open_ctree(struct super_block *sb, | |||
2655 | goto fail_sb_buffer; | 2647 | goto fail_sb_buffer; |
2656 | } | 2648 | } |
2657 | 2649 | ||
2658 | blocksize = tree_root->nodesize; | ||
2659 | generation = btrfs_super_chunk_root_generation(disk_super); | 2650 | generation = btrfs_super_chunk_root_generation(disk_super); |
2660 | 2651 | ||
2661 | __setup_root(nodesize, sectorsize, stripesize, chunk_root, | 2652 | __setup_root(nodesize, sectorsize, stripesize, chunk_root, |
@@ -2663,7 +2654,7 @@ int open_ctree(struct super_block *sb, | |||
2663 | 2654 | ||
2664 | chunk_root->node = read_tree_block(chunk_root, | 2655 | chunk_root->node = read_tree_block(chunk_root, |
2665 | btrfs_super_chunk_root(disk_super), | 2656 | btrfs_super_chunk_root(disk_super), |
2666 | blocksize, generation); | 2657 | generation); |
2667 | if (!chunk_root->node || | 2658 | if (!chunk_root->node || |
2668 | !test_bit(EXTENT_BUFFER_UPTODATE, &chunk_root->node->bflags)) { | 2659 | !test_bit(EXTENT_BUFFER_UPTODATE, &chunk_root->node->bflags)) { |
2669 | printk(KERN_WARNING "BTRFS: failed to read chunk root on %s\n", | 2660 | printk(KERN_WARNING "BTRFS: failed to read chunk root on %s\n", |
@@ -2696,12 +2687,11 @@ int open_ctree(struct super_block *sb, | |||
2696 | } | 2687 | } |
2697 | 2688 | ||
2698 | retry_root_backup: | 2689 | retry_root_backup: |
2699 | blocksize = tree_root->nodesize; | ||
2700 | generation = btrfs_super_generation(disk_super); | 2690 | generation = btrfs_super_generation(disk_super); |
2701 | 2691 | ||
2702 | tree_root->node = read_tree_block(tree_root, | 2692 | tree_root->node = read_tree_block(tree_root, |
2703 | btrfs_super_root(disk_super), | 2693 | btrfs_super_root(disk_super), |
2704 | blocksize, generation); | 2694 | generation); |
2705 | if (!tree_root->node || | 2695 | if (!tree_root->node || |
2706 | !test_bit(EXTENT_BUFFER_UPTODATE, &tree_root->node->bflags)) { | 2696 | !test_bit(EXTENT_BUFFER_UPTODATE, &tree_root->node->bflags)) { |
2707 | printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n", | 2697 | printk(KERN_WARNING "BTRFS: failed to read tree root on %s\n", |
@@ -2870,7 +2860,6 @@ retry_root_backup: | |||
2870 | err = -EIO; | 2860 | err = -EIO; |
2871 | goto fail_qgroup; | 2861 | goto fail_qgroup; |
2872 | } | 2862 | } |
2873 | blocksize = tree_root->nodesize; | ||
2874 | 2863 | ||
2875 | log_tree_root = btrfs_alloc_root(fs_info); | 2864 | log_tree_root = btrfs_alloc_root(fs_info); |
2876 | if (!log_tree_root) { | 2865 | if (!log_tree_root) { |
@@ -2882,7 +2871,6 @@ retry_root_backup: | |||
2882 | log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID); | 2871 | log_tree_root, fs_info, BTRFS_TREE_LOG_OBJECTID); |
2883 | 2872 | ||
2884 | log_tree_root->node = read_tree_block(tree_root, bytenr, | 2873 | log_tree_root->node = read_tree_block(tree_root, bytenr, |
2885 | blocksize, | ||
2886 | generation + 1); | 2874 | generation + 1); |
2887 | if (!log_tree_root->node || | 2875 | if (!log_tree_root->node || |
2888 | !extent_buffer_uptodate(log_tree_root->node)) { | 2876 | !extent_buffer_uptodate(log_tree_root->node)) { |
@@ -4084,8 +4072,7 @@ static int btrfs_destroy_marked_extents(struct btrfs_root *root, | |||
4084 | 4072 | ||
4085 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); | 4073 | clear_extent_bits(dirty_pages, start, end, mark, GFP_NOFS); |
4086 | while (start <= end) { | 4074 | while (start <= end) { |
4087 | eb = btrfs_find_tree_block(root, start, | 4075 | eb = btrfs_find_tree_block(root, start); |
4088 | root->nodesize); | ||
4089 | start += root->nodesize; | 4076 | start += root->nodesize; |
4090 | if (!eb) | 4077 | if (!eb) |
4091 | continue; | 4078 | continue; |