diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/backref.c | 6 | ||||
-rw-r--r-- | fs/btrfs/ctree.c | 54 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 6 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 37 | ||||
-rw-r--r-- | fs/btrfs/disk-io.h | 7 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 20 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 3 | ||||
-rw-r--r-- | fs/btrfs/print-tree.c | 1 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 28 |
9 files changed, 57 insertions, 105 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 b289d2a9bbf5..19bc6162fb8e 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -258,9 +258,8 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, | |||
258 | else | 258 | else |
259 | btrfs_node_key(buf, &disk_key, 0); | 259 | btrfs_node_key(buf, &disk_key, 0); |
260 | 260 | ||
261 | cow = btrfs_alloc_free_block(trans, root, buf->len, 0, | 261 | cow = btrfs_alloc_tree_block(trans, root, 0, new_root_objectid, |
262 | new_root_objectid, &disk_key, level, | 262 | &disk_key, level, buf->start, 0); |
263 | buf->start, 0); | ||
264 | if (IS_ERR(cow)) | 263 | if (IS_ERR(cow)) |
265 | return PTR_ERR(cow); | 264 | return PTR_ERR(cow); |
266 | 265 | ||
@@ -1133,9 +1132,9 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans, | |||
1133 | } else | 1132 | } else |
1134 | parent_start = 0; | 1133 | parent_start = 0; |
1135 | 1134 | ||
1136 | cow = btrfs_alloc_free_block(trans, root, buf->len, parent_start, | 1135 | cow = btrfs_alloc_tree_block(trans, root, parent_start, |
1137 | root->root_key.objectid, &disk_key, | 1136 | root->root_key.objectid, &disk_key, level, |
1138 | level, search_start, empty_size); | 1137 | search_start, empty_size); |
1139 | if (IS_ERR(cow)) | 1138 | if (IS_ERR(cow)) |
1140 | return PTR_ERR(cow); | 1139 | return PTR_ERR(cow); |
1141 | 1140 | ||
@@ -1425,7 +1424,6 @@ get_old_root(struct btrfs_root *root, u64 time_seq) | |||
1425 | struct tree_mod_root *old_root = NULL; | 1424 | struct tree_mod_root *old_root = NULL; |
1426 | u64 old_generation = 0; | 1425 | u64 old_generation = 0; |
1427 | u64 logical; | 1426 | u64 logical; |
1428 | u32 blocksize; | ||
1429 | 1427 | ||
1430 | eb_root = btrfs_read_lock_root_node(root); | 1428 | eb_root = btrfs_read_lock_root_node(root); |
1431 | tm = __tree_mod_log_oldest_root(root->fs_info, eb_root, time_seq); | 1429 | tm = __tree_mod_log_oldest_root(root->fs_info, eb_root, time_seq); |
@@ -1444,8 +1442,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) | |||
1444 | if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { | 1442 | if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) { |
1445 | btrfs_tree_read_unlock(eb_root); | 1443 | btrfs_tree_read_unlock(eb_root); |
1446 | free_extent_buffer(eb_root); | 1444 | free_extent_buffer(eb_root); |
1447 | blocksize = root->nodesize; | 1445 | 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))) { | 1446 | if (WARN_ON(!old || !extent_buffer_uptodate(old))) { |
1450 | free_extent_buffer(old); | 1447 | free_extent_buffer(old); |
1451 | btrfs_warn(root->fs_info, | 1448 | btrfs_warn(root->fs_info, |
@@ -1684,15 +1681,14 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
1684 | continue; | 1681 | continue; |
1685 | } | 1682 | } |
1686 | 1683 | ||
1687 | cur = btrfs_find_tree_block(root, blocknr, blocksize); | 1684 | cur = btrfs_find_tree_block(root, blocknr); |
1688 | if (cur) | 1685 | if (cur) |
1689 | uptodate = btrfs_buffer_uptodate(cur, gen, 0); | 1686 | uptodate = btrfs_buffer_uptodate(cur, gen, 0); |
1690 | else | 1687 | else |
1691 | uptodate = 0; | 1688 | uptodate = 0; |
1692 | if (!cur || !uptodate) { | 1689 | if (!cur || !uptodate) { |
1693 | if (!cur) { | 1690 | if (!cur) { |
1694 | cur = read_tree_block(root, blocknr, | 1691 | cur = read_tree_block(root, blocknr, gen); |
1695 | blocksize, gen); | ||
1696 | if (!cur || !extent_buffer_uptodate(cur)) { | 1692 | if (!cur || !extent_buffer_uptodate(cur)) { |
1697 | free_extent_buffer(cur); | 1693 | free_extent_buffer(cur); |
1698 | return -EIO; | 1694 | return -EIO; |
@@ -1871,7 +1867,6 @@ static noinline struct extent_buffer *read_node_slot(struct btrfs_root *root, | |||
1871 | BUG_ON(level == 0); | 1867 | BUG_ON(level == 0); |
1872 | 1868 | ||
1873 | eb = read_tree_block(root, btrfs_node_blockptr(parent, slot), | 1869 | eb = read_tree_block(root, btrfs_node_blockptr(parent, slot), |
1874 | root->nodesize, | ||
1875 | btrfs_node_ptr_generation(parent, slot)); | 1870 | btrfs_node_ptr_generation(parent, slot)); |
1876 | if (eb && !extent_buffer_uptodate(eb)) { | 1871 | if (eb && !extent_buffer_uptodate(eb)) { |
1877 | free_extent_buffer(eb); | 1872 | free_extent_buffer(eb); |
@@ -2267,7 +2262,7 @@ static void reada_for_search(struct btrfs_root *root, | |||
2267 | 2262 | ||
2268 | search = btrfs_node_blockptr(node, slot); | 2263 | search = btrfs_node_blockptr(node, slot); |
2269 | blocksize = root->nodesize; | 2264 | blocksize = root->nodesize; |
2270 | eb = btrfs_find_tree_block(root, search, blocksize); | 2265 | eb = btrfs_find_tree_block(root, search); |
2271 | if (eb) { | 2266 | if (eb) { |
2272 | free_extent_buffer(eb); | 2267 | free_extent_buffer(eb); |
2273 | return; | 2268 | return; |
@@ -2297,7 +2292,7 @@ static void reada_for_search(struct btrfs_root *root, | |||
2297 | if ((search <= target && target - search <= 65536) || | 2292 | if ((search <= target && target - search <= 65536) || |
2298 | (search > target && search - target <= 65536)) { | 2293 | (search > target && search - target <= 65536)) { |
2299 | gen = btrfs_node_ptr_generation(node, nr); | 2294 | gen = btrfs_node_ptr_generation(node, nr); |
2300 | readahead_tree_block(root, search, blocksize, gen); | 2295 | readahead_tree_block(root, search, blocksize); |
2301 | nread += blocksize; | 2296 | nread += blocksize; |
2302 | } | 2297 | } |
2303 | nscan++; | 2298 | nscan++; |
@@ -2329,7 +2324,7 @@ static noinline void reada_for_balance(struct btrfs_root *root, | |||
2329 | if (slot > 0) { | 2324 | if (slot > 0) { |
2330 | block1 = btrfs_node_blockptr(parent, slot - 1); | 2325 | block1 = btrfs_node_blockptr(parent, slot - 1); |
2331 | gen = btrfs_node_ptr_generation(parent, slot - 1); | 2326 | gen = btrfs_node_ptr_generation(parent, slot - 1); |
2332 | eb = btrfs_find_tree_block(root, block1, blocksize); | 2327 | eb = btrfs_find_tree_block(root, block1); |
2333 | /* | 2328 | /* |
2334 | * if we get -eagain from btrfs_buffer_uptodate, we | 2329 | * if we get -eagain from btrfs_buffer_uptodate, we |
2335 | * don't want to return eagain here. That will loop | 2330 | * don't want to return eagain here. That will loop |
@@ -2342,16 +2337,16 @@ static noinline void reada_for_balance(struct btrfs_root *root, | |||
2342 | if (slot + 1 < nritems) { | 2337 | if (slot + 1 < nritems) { |
2343 | block2 = btrfs_node_blockptr(parent, slot + 1); | 2338 | block2 = btrfs_node_blockptr(parent, slot + 1); |
2344 | gen = btrfs_node_ptr_generation(parent, slot + 1); | 2339 | gen = btrfs_node_ptr_generation(parent, slot + 1); |
2345 | eb = btrfs_find_tree_block(root, block2, blocksize); | 2340 | eb = btrfs_find_tree_block(root, block2); |
2346 | if (eb && btrfs_buffer_uptodate(eb, gen, 1) != 0) | 2341 | if (eb && btrfs_buffer_uptodate(eb, gen, 1) != 0) |
2347 | block2 = 0; | 2342 | block2 = 0; |
2348 | free_extent_buffer(eb); | 2343 | free_extent_buffer(eb); |
2349 | } | 2344 | } |
2350 | 2345 | ||
2351 | if (block1) | 2346 | if (block1) |
2352 | readahead_tree_block(root, block1, blocksize, 0); | 2347 | readahead_tree_block(root, block1, blocksize); |
2353 | if (block2) | 2348 | if (block2) |
2354 | readahead_tree_block(root, block2, blocksize, 0); | 2349 | readahead_tree_block(root, block2, blocksize); |
2355 | } | 2350 | } |
2356 | 2351 | ||
2357 | 2352 | ||
@@ -2453,16 +2448,14 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
2453 | { | 2448 | { |
2454 | u64 blocknr; | 2449 | u64 blocknr; |
2455 | u64 gen; | 2450 | u64 gen; |
2456 | u32 blocksize; | ||
2457 | struct extent_buffer *b = *eb_ret; | 2451 | struct extent_buffer *b = *eb_ret; |
2458 | struct extent_buffer *tmp; | 2452 | struct extent_buffer *tmp; |
2459 | int ret; | 2453 | int ret; |
2460 | 2454 | ||
2461 | blocknr = btrfs_node_blockptr(b, slot); | 2455 | blocknr = btrfs_node_blockptr(b, slot); |
2462 | gen = btrfs_node_ptr_generation(b, slot); | 2456 | gen = btrfs_node_ptr_generation(b, slot); |
2463 | blocksize = root->nodesize; | ||
2464 | 2457 | ||
2465 | tmp = btrfs_find_tree_block(root, blocknr, blocksize); | 2458 | tmp = btrfs_find_tree_block(root, blocknr); |
2466 | if (tmp) { | 2459 | if (tmp) { |
2467 | /* first we do an atomic uptodate check */ | 2460 | /* first we do an atomic uptodate check */ |
2468 | if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { | 2461 | if (btrfs_buffer_uptodate(tmp, gen, 1) > 0) { |
@@ -2506,7 +2499,7 @@ read_block_for_search(struct btrfs_trans_handle *trans, | |||
2506 | btrfs_release_path(p); | 2499 | btrfs_release_path(p); |
2507 | 2500 | ||
2508 | ret = -EAGAIN; | 2501 | ret = -EAGAIN; |
2509 | tmp = read_tree_block(root, blocknr, blocksize, 0); | 2502 | tmp = read_tree_block(root, blocknr, 0); |
2510 | if (tmp) { | 2503 | if (tmp) { |
2511 | /* | 2504 | /* |
2512 | * If the read above didn't mark this buffer up to date, | 2505 | * If the read above didn't mark this buffer up to date, |
@@ -3360,9 +3353,8 @@ static noinline int insert_new_root(struct btrfs_trans_handle *trans, | |||
3360 | else | 3353 | else |
3361 | btrfs_node_key(lower, &lower_key, 0); | 3354 | btrfs_node_key(lower, &lower_key, 0); |
3362 | 3355 | ||
3363 | c = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 3356 | c = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
3364 | root->root_key.objectid, &lower_key, | 3357 | &lower_key, level, root->node->start, 0); |
3365 | level, root->node->start, 0); | ||
3366 | if (IS_ERR(c)) | 3358 | if (IS_ERR(c)) |
3367 | return PTR_ERR(c); | 3359 | return PTR_ERR(c); |
3368 | 3360 | ||
@@ -3500,9 +3492,8 @@ static noinline int split_node(struct btrfs_trans_handle *trans, | |||
3500 | mid = (c_nritems + 1) / 2; | 3492 | mid = (c_nritems + 1) / 2; |
3501 | btrfs_node_key(c, &disk_key, mid); | 3493 | btrfs_node_key(c, &disk_key, mid); |
3502 | 3494 | ||
3503 | split = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 3495 | split = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
3504 | root->root_key.objectid, | 3496 | &disk_key, level, c->start, 0); |
3505 | &disk_key, level, c->start, 0); | ||
3506 | if (IS_ERR(split)) | 3497 | if (IS_ERR(split)) |
3507 | return PTR_ERR(split); | 3498 | return PTR_ERR(split); |
3508 | 3499 | ||
@@ -4280,9 +4271,8 @@ again: | |||
4280 | else | 4271 | else |
4281 | btrfs_item_key(l, &disk_key, mid); | 4272 | btrfs_item_key(l, &disk_key, mid); |
4282 | 4273 | ||
4283 | right = btrfs_alloc_free_block(trans, root, root->nodesize, 0, | 4274 | right = btrfs_alloc_tree_block(trans, root, 0, root->root_key.objectid, |
4284 | root->root_key.objectid, | 4275 | &disk_key, 0, l->start, 0); |
4285 | &disk_key, 0, l->start, 0); | ||
4286 | if (IS_ERR(right)) | 4276 | if (IS_ERR(right)) |
4287 | return PTR_ERR(right); | 4277 | return PTR_ERR(right); |
4288 | 4278 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index baa4031602c1..f7555e2767de 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -3291,9 +3291,9 @@ struct btrfs_block_group_cache *btrfs_lookup_block_group( | |||
3291 | u64 bytenr); | 3291 | u64 bytenr); |
3292 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); | 3292 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); |
3293 | int get_block_group_index(struct btrfs_block_group_cache *cache); | 3293 | int get_block_group_index(struct btrfs_block_group_cache *cache); |
3294 | struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | 3294 | struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, |
3295 | struct btrfs_root *root, u32 blocksize, | 3295 | struct btrfs_root *root, u64 parent, |
3296 | u64 parent, u64 root_objectid, | 3296 | u64 root_objectid, |
3297 | struct btrfs_disk_key *key, int level, | 3297 | struct btrfs_disk_key *key, int level, |
3298 | u64 hint, u64 empty_size); | 3298 | u64 hint, u64 empty_size); |
3299 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, | 3299 | void btrfs_free_tree_block(struct btrfs_trans_handle *trans, |
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; |
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 9ac233923ca3..414651821fb3 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
@@ -45,9 +45,8 @@ struct btrfs_device; | |||
45 | struct btrfs_fs_devices; | 45 | struct btrfs_fs_devices; |
46 | 46 | ||
47 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | 47 | struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, |
48 | u32 blocksize, u64 parent_transid); | 48 | u64 parent_transid); |
49 | int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, | 49 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize); |
50 | u64 parent_transid); | ||
51 | int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, | 50 | int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, |
52 | int mirror_num, struct extent_buffer **eb); | 51 | int mirror_num, struct extent_buffer **eb); |
53 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | 52 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, |
@@ -63,7 +62,7 @@ int write_ctree_super(struct btrfs_trans_handle *trans, | |||
63 | struct buffer_head *btrfs_read_dev_super(struct block_device *bdev); | 62 | struct buffer_head *btrfs_read_dev_super(struct block_device *bdev); |
64 | int btrfs_commit_super(struct btrfs_root *root); | 63 | int btrfs_commit_super(struct btrfs_root *root); |
65 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | 64 | struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, |
66 | u64 bytenr, u32 blocksize); | 65 | u64 bytenr); |
67 | struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root, | 66 | struct btrfs_root *btrfs_read_fs_root(struct btrfs_root *tree_root, |
68 | struct btrfs_key *location); | 67 | struct btrfs_key *location); |
69 | int btrfs_init_fs_root(struct btrfs_root *root); | 68 | int btrfs_init_fs_root(struct btrfs_root *root); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 23940cc207e8..9a5effa32a66 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -7323,8 +7323,8 @@ static void unuse_block_rsv(struct btrfs_fs_info *fs_info, | |||
7323 | * | 7323 | * |
7324 | * returns the tree buffer or NULL. | 7324 | * returns the tree buffer or NULL. |
7325 | */ | 7325 | */ |
7326 | struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | 7326 | struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, |
7327 | struct btrfs_root *root, u32 blocksize, | 7327 | struct btrfs_root *root, |
7328 | u64 parent, u64 root_objectid, | 7328 | u64 parent, u64 root_objectid, |
7329 | struct btrfs_disk_key *key, int level, | 7329 | struct btrfs_disk_key *key, int level, |
7330 | u64 hint, u64 empty_size) | 7330 | u64 hint, u64 empty_size) |
@@ -7334,6 +7334,7 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, | |||
7334 | struct extent_buffer *buf; | 7334 | struct extent_buffer *buf; |
7335 | u64 flags = 0; | 7335 | u64 flags = 0; |
7336 | int ret; | 7336 | int ret; |
7337 | u32 blocksize = root->nodesize; | ||
7337 | bool skinny_metadata = btrfs_fs_incompat(root->fs_info, | 7338 | bool skinny_metadata = btrfs_fs_incompat(root->fs_info, |
7338 | SKINNY_METADATA); | 7339 | SKINNY_METADATA); |
7339 | 7340 | ||
@@ -7486,10 +7487,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans, | |||
7486 | continue; | 7487 | continue; |
7487 | } | 7488 | } |
7488 | reada: | 7489 | reada: |
7489 | ret = readahead_tree_block(root, bytenr, blocksize, | 7490 | readahead_tree_block(root, bytenr, blocksize); |
7490 | generation); | ||
7491 | if (ret) | ||
7492 | break; | ||
7493 | nread++; | 7491 | nread++; |
7494 | } | 7492 | } |
7495 | wc->reada_slot = slot; | 7493 | wc->reada_slot = slot; |
@@ -7648,7 +7646,6 @@ walk_down: | |||
7648 | level = root_level; | 7646 | level = root_level; |
7649 | while (level >= 0) { | 7647 | while (level >= 0) { |
7650 | if (path->nodes[level] == NULL) { | 7648 | if (path->nodes[level] == NULL) { |
7651 | int child_bsize = root->nodesize; | ||
7652 | int parent_slot; | 7649 | int parent_slot; |
7653 | u64 child_gen; | 7650 | u64 child_gen; |
7654 | u64 child_bytenr; | 7651 | u64 child_bytenr; |
@@ -7660,8 +7657,7 @@ walk_down: | |||
7660 | child_bytenr = btrfs_node_blockptr(eb, parent_slot); | 7657 | child_bytenr = btrfs_node_blockptr(eb, parent_slot); |
7661 | child_gen = btrfs_node_ptr_generation(eb, parent_slot); | 7658 | child_gen = btrfs_node_ptr_generation(eb, parent_slot); |
7662 | 7659 | ||
7663 | eb = read_tree_block(root, child_bytenr, child_bsize, | 7660 | eb = read_tree_block(root, child_bytenr, child_gen); |
7664 | child_gen); | ||
7665 | if (!eb || !extent_buffer_uptodate(eb)) { | 7661 | if (!eb || !extent_buffer_uptodate(eb)) { |
7666 | ret = -EIO; | 7662 | ret = -EIO; |
7667 | goto out; | 7663 | goto out; |
@@ -7677,7 +7673,7 @@ walk_down: | |||
7677 | ret = btrfs_qgroup_record_ref(trans, root->fs_info, | 7673 | ret = btrfs_qgroup_record_ref(trans, root->fs_info, |
7678 | root->objectid, | 7674 | root->objectid, |
7679 | child_bytenr, | 7675 | child_bytenr, |
7680 | child_bsize, | 7676 | root->nodesize, |
7681 | BTRFS_QGROUP_OPER_SUB_SUBTREE, | 7677 | BTRFS_QGROUP_OPER_SUB_SUBTREE, |
7682 | 0); | 7678 | 0); |
7683 | if (ret) | 7679 | if (ret) |
@@ -7830,7 +7826,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, | |||
7830 | bytenr = btrfs_node_blockptr(path->nodes[level], path->slots[level]); | 7826 | bytenr = btrfs_node_blockptr(path->nodes[level], path->slots[level]); |
7831 | blocksize = root->nodesize; | 7827 | blocksize = root->nodesize; |
7832 | 7828 | ||
7833 | next = btrfs_find_tree_block(root, bytenr, blocksize); | 7829 | next = btrfs_find_tree_block(root, bytenr); |
7834 | if (!next) { | 7830 | if (!next) { |
7835 | next = btrfs_find_create_tree_block(root, bytenr, blocksize); | 7831 | next = btrfs_find_create_tree_block(root, bytenr, blocksize); |
7836 | if (!next) | 7832 | if (!next) |
@@ -7892,7 +7888,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, | |||
7892 | if (!next) { | 7888 | if (!next) { |
7893 | if (reada && level == 1) | 7889 | if (reada && level == 1) |
7894 | reada_walk_down(trans, root, wc, path); | 7890 | reada_walk_down(trans, root, wc, path); |
7895 | next = read_tree_block(root, bytenr, blocksize, generation); | 7891 | next = read_tree_block(root, bytenr, generation); |
7896 | if (!next || !extent_buffer_uptodate(next)) { | 7892 | if (!next || !extent_buffer_uptodate(next)) { |
7897 | free_extent_buffer(next); | 7893 | free_extent_buffer(next); |
7898 | return -EIO; | 7894 | return -EIO; |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 87a7267a6bb2..fd9d19057e7e 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -480,8 +480,7 @@ static noinline int create_subvol(struct inode *dir, | |||
480 | if (ret) | 480 | if (ret) |
481 | goto fail; | 481 | goto fail; |
482 | 482 | ||
483 | leaf = btrfs_alloc_free_block(trans, root, root->nodesize, | 483 | leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0); |
484 | 0, objectid, NULL, 0, 0, 0); | ||
485 | if (IS_ERR(leaf)) { | 484 | if (IS_ERR(leaf)) { |
486 | ret = PTR_ERR(leaf); | 485 | ret = PTR_ERR(leaf); |
487 | goto fail; | 486 | goto fail; |
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 8f9967f03b64..74257d6436ad 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -1846,8 +1846,7 @@ again: | |||
1846 | break; | 1846 | break; |
1847 | } | 1847 | } |
1848 | 1848 | ||
1849 | eb = read_tree_block(dest, old_bytenr, blocksize, | 1849 | eb = read_tree_block(dest, old_bytenr, old_ptr_gen); |
1850 | old_ptr_gen); | ||
1851 | if (!eb || !extent_buffer_uptodate(eb)) { | 1850 | if (!eb || !extent_buffer_uptodate(eb)) { |
1852 | ret = (!eb) ? -ENOMEM : -EIO; | 1851 | ret = (!eb) ? -ENOMEM : -EIO; |
1853 | free_extent_buffer(eb); | 1852 | free_extent_buffer(eb); |
@@ -1977,7 +1976,6 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path, | |||
1977 | u64 bytenr; | 1976 | u64 bytenr; |
1978 | u64 ptr_gen = 0; | 1977 | u64 ptr_gen = 0; |
1979 | u64 last_snapshot; | 1978 | u64 last_snapshot; |
1980 | u32 blocksize; | ||
1981 | u32 nritems; | 1979 | u32 nritems; |
1982 | 1980 | ||
1983 | last_snapshot = btrfs_root_last_snapshot(&root->root_item); | 1981 | last_snapshot = btrfs_root_last_snapshot(&root->root_item); |
@@ -2003,8 +2001,7 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path, | |||
2003 | } | 2001 | } |
2004 | 2002 | ||
2005 | bytenr = btrfs_node_blockptr(eb, path->slots[i]); | 2003 | bytenr = btrfs_node_blockptr(eb, path->slots[i]); |
2006 | blocksize = root->nodesize; | 2004 | eb = read_tree_block(root, bytenr, ptr_gen); |
2007 | eb = read_tree_block(root, bytenr, blocksize, ptr_gen); | ||
2008 | if (!eb || !extent_buffer_uptodate(eb)) { | 2005 | if (!eb || !extent_buffer_uptodate(eb)) { |
2009 | free_extent_buffer(eb); | 2006 | free_extent_buffer(eb); |
2010 | return -EIO; | 2007 | return -EIO; |
@@ -2712,7 +2709,7 @@ static int do_relocation(struct btrfs_trans_handle *trans, | |||
2712 | 2709 | ||
2713 | blocksize = root->nodesize; | 2710 | blocksize = root->nodesize; |
2714 | generation = btrfs_node_ptr_generation(upper->eb, slot); | 2711 | generation = btrfs_node_ptr_generation(upper->eb, slot); |
2715 | eb = read_tree_block(root, bytenr, blocksize, generation); | 2712 | eb = read_tree_block(root, bytenr, generation); |
2716 | if (!eb || !extent_buffer_uptodate(eb)) { | 2713 | if (!eb || !extent_buffer_uptodate(eb)) { |
2717 | free_extent_buffer(eb); | 2714 | free_extent_buffer(eb); |
2718 | err = -EIO; | 2715 | err = -EIO; |
@@ -2874,7 +2871,7 @@ static int get_tree_block_key(struct reloc_control *rc, | |||
2874 | 2871 | ||
2875 | BUG_ON(block->key_ready); | 2872 | BUG_ON(block->key_ready); |
2876 | eb = read_tree_block(rc->extent_root, block->bytenr, | 2873 | eb = read_tree_block(rc->extent_root, block->bytenr, |
2877 | block->key.objectid, block->key.offset); | 2874 | block->key.offset); |
2878 | if (!eb || !extent_buffer_uptodate(eb)) { | 2875 | if (!eb || !extent_buffer_uptodate(eb)) { |
2879 | free_extent_buffer(eb); | 2876 | free_extent_buffer(eb); |
2880 | return -EIO; | 2877 | return -EIO; |
@@ -2889,20 +2886,6 @@ static int get_tree_block_key(struct reloc_control *rc, | |||
2889 | return 0; | 2886 | return 0; |
2890 | } | 2887 | } |
2891 | 2888 | ||
2892 | static int reada_tree_block(struct reloc_control *rc, | ||
2893 | struct tree_block *block) | ||
2894 | { | ||
2895 | BUG_ON(block->key_ready); | ||
2896 | if (block->key.type == BTRFS_METADATA_ITEM_KEY) | ||
2897 | readahead_tree_block(rc->extent_root, block->bytenr, | ||
2898 | block->key.objectid, | ||
2899 | rc->extent_root->nodesize); | ||
2900 | else | ||
2901 | readahead_tree_block(rc->extent_root, block->bytenr, | ||
2902 | block->key.objectid, block->key.offset); | ||
2903 | return 0; | ||
2904 | } | ||
2905 | |||
2906 | /* | 2889 | /* |
2907 | * helper function to relocate a tree block | 2890 | * helper function to relocate a tree block |
2908 | */ | 2891 | */ |
@@ -2982,7 +2965,8 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans, | |||
2982 | while (rb_node) { | 2965 | while (rb_node) { |
2983 | block = rb_entry(rb_node, struct tree_block, rb_node); | 2966 | block = rb_entry(rb_node, struct tree_block, rb_node); |
2984 | if (!block->key_ready) | 2967 | if (!block->key_ready) |
2985 | reada_tree_block(rc, block); | 2968 | readahead_tree_block(rc->extent_root, block->bytenr, |
2969 | block->key.objectid); | ||
2986 | rb_node = rb_next(rb_node); | 2970 | rb_node = rb_next(rb_node); |
2987 | } | 2971 | } |
2988 | 2972 | ||