diff options
author | Chris Mason <clm@fb.com> | 2015-01-21 20:49:35 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-01-21 20:49:35 -0500 |
commit | 57bbddd7fbf468336940d18a4c68a8678163acb0 (patch) | |
tree | 5d9c5ecf6ba145cdaf369e0c6ddfc4ea88ce8dd9 /fs | |
parent | d3541834884f042aaaab1d6c0610cdc3488028e4 (diff) | |
parent | ce3e69847e3ec79a38421bfd3d6f554d5e481231 (diff) |
Merge branch 'cleanup/blocksize-diet-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 13 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 17 | ||||
-rw-r--r-- | fs/btrfs/disk-io.h | 6 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 13 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 34 | ||||
-rw-r--r-- | fs/btrfs/extent_io.h | 7 | ||||
-rw-r--r-- | fs/btrfs/reada.c | 15 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 12 | ||||
-rw-r--r-- | fs/btrfs/tests/extent-buffer-tests.c | 2 | ||||
-rw-r--r-- | fs/btrfs/tests/inode-tests.c | 4 | ||||
-rw-r--r-- | fs/btrfs/tests/qgroup-tests.c | 23 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 2 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 9 |
13 files changed, 84 insertions, 73 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index f64471e95e33..6b2ec9089229 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1371,8 +1371,7 @@ tree_mod_log_rewind(struct btrfs_fs_info *fs_info, struct btrfs_path *path, | |||
1371 | 1371 | ||
1372 | if (tm->op == MOD_LOG_KEY_REMOVE_WHILE_FREEING) { | 1372 | if (tm->op == MOD_LOG_KEY_REMOVE_WHILE_FREEING) { |
1373 | BUG_ON(tm->slot != 0); | 1373 | BUG_ON(tm->slot != 0); |
1374 | eb_rewin = alloc_dummy_extent_buffer(eb->start, | 1374 | eb_rewin = alloc_dummy_extent_buffer(fs_info, eb->start); |
1375 | fs_info->tree_root->nodesize); | ||
1376 | if (!eb_rewin) { | 1375 | if (!eb_rewin) { |
1377 | btrfs_tree_read_unlock_blocking(eb); | 1376 | btrfs_tree_read_unlock_blocking(eb); |
1378 | free_extent_buffer(eb); | 1377 | free_extent_buffer(eb); |
@@ -1452,7 +1451,7 @@ get_old_root(struct btrfs_root *root, u64 time_seq) | |||
1452 | } else if (old_root) { | 1451 | } else if (old_root) { |
1453 | btrfs_tree_read_unlock(eb_root); | 1452 | btrfs_tree_read_unlock(eb_root); |
1454 | free_extent_buffer(eb_root); | 1453 | free_extent_buffer(eb_root); |
1455 | eb = alloc_dummy_extent_buffer(logical, root->nodesize); | 1454 | eb = alloc_dummy_extent_buffer(root->fs_info, logical); |
1456 | } else { | 1455 | } else { |
1457 | btrfs_set_lock_blocking_rw(eb_root, BTRFS_READ_LOCK); | 1456 | btrfs_set_lock_blocking_rw(eb_root, BTRFS_READ_LOCK); |
1458 | eb = btrfs_clone_extent_buffer(eb_root); | 1457 | eb = btrfs_clone_extent_buffer(eb_root); |
@@ -2290,7 +2289,7 @@ static void reada_for_search(struct btrfs_root *root, | |||
2290 | if ((search <= target && target - search <= 65536) || | 2289 | if ((search <= target && target - search <= 65536) || |
2291 | (search > target && search - target <= 65536)) { | 2290 | (search > target && search - target <= 65536)) { |
2292 | gen = btrfs_node_ptr_generation(node, nr); | 2291 | gen = btrfs_node_ptr_generation(node, nr); |
2293 | readahead_tree_block(root, search, blocksize); | 2292 | readahead_tree_block(root, search); |
2294 | nread += blocksize; | 2293 | nread += blocksize; |
2295 | } | 2294 | } |
2296 | nscan++; | 2295 | nscan++; |
@@ -2309,7 +2308,6 @@ static noinline void reada_for_balance(struct btrfs_root *root, | |||
2309 | u64 gen; | 2308 | u64 gen; |
2310 | u64 block1 = 0; | 2309 | u64 block1 = 0; |
2311 | u64 block2 = 0; | 2310 | u64 block2 = 0; |
2312 | int blocksize; | ||
2313 | 2311 | ||
2314 | parent = path->nodes[level + 1]; | 2312 | parent = path->nodes[level + 1]; |
2315 | if (!parent) | 2313 | if (!parent) |
@@ -2317,7 +2315,6 @@ static noinline void reada_for_balance(struct btrfs_root *root, | |||
2317 | 2315 | ||
2318 | nritems = btrfs_header_nritems(parent); | 2316 | nritems = btrfs_header_nritems(parent); |
2319 | slot = path->slots[level + 1]; | 2317 | slot = path->slots[level + 1]; |
2320 | blocksize = root->nodesize; | ||
2321 | 2318 | ||
2322 | if (slot > 0) { | 2319 | if (slot > 0) { |
2323 | block1 = btrfs_node_blockptr(parent, slot - 1); | 2320 | block1 = btrfs_node_blockptr(parent, slot - 1); |
@@ -2342,9 +2339,9 @@ static noinline void reada_for_balance(struct btrfs_root *root, | |||
2342 | } | 2339 | } |
2343 | 2340 | ||
2344 | if (block1) | 2341 | if (block1) |
2345 | readahead_tree_block(root, block1, blocksize); | 2342 | readahead_tree_block(root, block1); |
2346 | if (block2) | 2343 | if (block2) |
2347 | readahead_tree_block(root, block2, blocksize); | 2344 | readahead_tree_block(root, block2); |
2348 | } | 2345 | } |
2349 | 2346 | ||
2350 | 2347 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8d486603e8a3..65384de10375 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1073,12 +1073,12 @@ 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 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) | 1076 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr) |
1077 | { | 1077 | { |
1078 | struct extent_buffer *buf = NULL; | 1078 | struct extent_buffer *buf = NULL; |
1079 | struct inode *btree_inode = root->fs_info->btree_inode; | 1079 | struct inode *btree_inode = root->fs_info->btree_inode; |
1080 | 1080 | ||
1081 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 1081 | buf = btrfs_find_create_tree_block(root, bytenr); |
1082 | if (!buf) | 1082 | if (!buf) |
1083 | return; | 1083 | return; |
1084 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, | 1084 | read_extent_buffer_pages(&BTRFS_I(btree_inode)->io_tree, |
@@ -1086,7 +1086,7 @@ void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize) | |||
1086 | free_extent_buffer(buf); | 1086 | free_extent_buffer(buf); |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | 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, |
1090 | int mirror_num, struct extent_buffer **eb) | 1090 | int mirror_num, struct extent_buffer **eb) |
1091 | { | 1091 | { |
1092 | struct extent_buffer *buf = NULL; | 1092 | struct extent_buffer *buf = NULL; |
@@ -1094,7 +1094,7 @@ int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize, | |||
1094 | struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree; | 1094 | struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree; |
1095 | int ret; | 1095 | int ret; |
1096 | 1096 | ||
1097 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 1097 | buf = btrfs_find_create_tree_block(root, bytenr); |
1098 | if (!buf) | 1098 | if (!buf) |
1099 | return 0; | 1099 | return 0; |
1100 | 1100 | ||
@@ -1125,12 +1125,11 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, | |||
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | 1127 | struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, |
1128 | u64 bytenr, u32 blocksize) | 1128 | u64 bytenr) |
1129 | { | 1129 | { |
1130 | if (btrfs_test_is_dummy_root(root)) | 1130 | if (btrfs_test_is_dummy_root(root)) |
1131 | return alloc_test_extent_buffer(root->fs_info, bytenr, | 1131 | return alloc_test_extent_buffer(root->fs_info, bytenr); |
1132 | blocksize); | 1132 | return alloc_extent_buffer(root->fs_info, bytenr); |
1133 | return alloc_extent_buffer(root->fs_info, bytenr, blocksize); | ||
1134 | } | 1133 | } |
1135 | 1134 | ||
1136 | 1135 | ||
@@ -1152,7 +1151,7 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr, | |||
1152 | struct extent_buffer *buf = NULL; | 1151 | struct extent_buffer *buf = NULL; |
1153 | int ret; | 1152 | int ret; |
1154 | 1153 | ||
1155 | buf = btrfs_find_create_tree_block(root, bytenr, root->nodesize); | 1154 | buf = btrfs_find_create_tree_block(root, bytenr); |
1156 | if (!buf) | 1155 | if (!buf) |
1157 | return NULL; | 1156 | return NULL; |
1158 | 1157 | ||
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h index 414651821fb3..27d44c0fd236 100644 --- a/fs/btrfs/disk-io.h +++ b/fs/btrfs/disk-io.h | |||
@@ -46,11 +46,11 @@ 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 | u64 parent_transid); | 48 | u64 parent_transid); |
49 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize); | 49 | void readahead_tree_block(struct btrfs_root *root, u64 bytenr); |
50 | 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, |
51 | int mirror_num, struct extent_buffer **eb); | 51 | int mirror_num, struct extent_buffer **eb); |
52 | 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, |
53 | u64 bytenr, u32 blocksize); | 53 | u64 bytenr); |
54 | void clean_tree_block(struct btrfs_trans_handle *trans, | 54 | void clean_tree_block(struct btrfs_trans_handle *trans, |
55 | struct btrfs_root *root, struct extent_buffer *buf); | 55 | struct btrfs_root *root, struct extent_buffer *buf); |
56 | int open_ctree(struct super_block *sb, | 56 | int open_ctree(struct super_block *sb, |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 21c373fe256c..1c591d6eae58 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -7149,11 +7149,11 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, | |||
7149 | 7149 | ||
7150 | static struct extent_buffer * | 7150 | static struct extent_buffer * |
7151 | btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, | 7151 | btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, |
7152 | u64 bytenr, u32 blocksize, int level) | 7152 | u64 bytenr, int level) |
7153 | { | 7153 | { |
7154 | struct extent_buffer *buf; | 7154 | struct extent_buffer *buf; |
7155 | 7155 | ||
7156 | buf = btrfs_find_create_tree_block(root, bytenr, blocksize); | 7156 | buf = btrfs_find_create_tree_block(root, bytenr); |
7157 | if (!buf) | 7157 | if (!buf) |
7158 | return ERR_PTR(-ENOMEM); | 7158 | return ERR_PTR(-ENOMEM); |
7159 | btrfs_set_header_generation(buf, trans->transid); | 7159 | btrfs_set_header_generation(buf, trans->transid); |
@@ -7272,7 +7272,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, | |||
7272 | 7272 | ||
7273 | if (btrfs_test_is_dummy_root(root)) { | 7273 | if (btrfs_test_is_dummy_root(root)) { |
7274 | buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, | 7274 | buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, |
7275 | blocksize, level); | 7275 | level); |
7276 | if (!IS_ERR(buf)) | 7276 | if (!IS_ERR(buf)) |
7277 | root->alloc_bytenr += blocksize; | 7277 | root->alloc_bytenr += blocksize; |
7278 | return buf; | 7278 | return buf; |
@@ -7289,8 +7289,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, | |||
7289 | return ERR_PTR(ret); | 7289 | return ERR_PTR(ret); |
7290 | } | 7290 | } |
7291 | 7291 | ||
7292 | buf = btrfs_init_new_buffer(trans, root, ins.objectid, | 7292 | buf = btrfs_init_new_buffer(trans, root, ins.objectid, level); |
7293 | blocksize, level); | ||
7294 | BUG_ON(IS_ERR(buf)); /* -ENOMEM */ | 7293 | BUG_ON(IS_ERR(buf)); /* -ENOMEM */ |
7295 | 7294 | ||
7296 | if (root_objectid == BTRFS_TREE_RELOC_OBJECTID) { | 7295 | if (root_objectid == BTRFS_TREE_RELOC_OBJECTID) { |
@@ -7419,7 +7418,7 @@ static noinline void reada_walk_down(struct btrfs_trans_handle *trans, | |||
7419 | continue; | 7418 | continue; |
7420 | } | 7419 | } |
7421 | reada: | 7420 | reada: |
7422 | readahead_tree_block(root, bytenr, blocksize); | 7421 | readahead_tree_block(root, bytenr); |
7423 | nread++; | 7422 | nread++; |
7424 | } | 7423 | } |
7425 | wc->reada_slot = slot; | 7424 | wc->reada_slot = slot; |
@@ -7760,7 +7759,7 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans, | |||
7760 | 7759 | ||
7761 | next = btrfs_find_tree_block(root, bytenr); | 7760 | next = btrfs_find_tree_block(root, bytenr); |
7762 | if (!next) { | 7761 | if (!next) { |
7763 | next = btrfs_find_create_tree_block(root, bytenr, blocksize); | 7762 | next = btrfs_find_create_tree_block(root, bytenr); |
7764 | if (!next) | 7763 | if (!next) |
7765 | return -ENOMEM; | 7764 | return -ENOMEM; |
7766 | btrfs_set_buffer_lockdep_class(root->root_key.objectid, next, | 7765 | btrfs_set_buffer_lockdep_class(root->root_key.objectid, next, |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4ebabd237153..c4ca90ab687e 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -4598,11 +4598,11 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb) | |||
4598 | 4598 | ||
4599 | static struct extent_buffer * | 4599 | static struct extent_buffer * |
4600 | __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, | 4600 | __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start, |
4601 | unsigned long len, gfp_t mask) | 4601 | unsigned long len) |
4602 | { | 4602 | { |
4603 | struct extent_buffer *eb = NULL; | 4603 | struct extent_buffer *eb = NULL; |
4604 | 4604 | ||
4605 | eb = kmem_cache_zalloc(extent_buffer_cache, mask); | 4605 | eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS); |
4606 | if (eb == NULL) | 4606 | if (eb == NULL) |
4607 | return NULL; | 4607 | return NULL; |
4608 | eb->start = start; | 4608 | eb->start = start; |
@@ -4643,7 +4643,7 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src) | |||
4643 | struct extent_buffer *new; | 4643 | struct extent_buffer *new; |
4644 | unsigned long num_pages = num_extent_pages(src->start, src->len); | 4644 | unsigned long num_pages = num_extent_pages(src->start, src->len); |
4645 | 4645 | ||
4646 | new = __alloc_extent_buffer(NULL, src->start, src->len, GFP_NOFS); | 4646 | new = __alloc_extent_buffer(src->fs_info, src->start, src->len); |
4647 | if (new == NULL) | 4647 | if (new == NULL) |
4648 | return NULL; | 4648 | return NULL; |
4649 | 4649 | ||
@@ -4666,13 +4666,26 @@ struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src) | |||
4666 | return new; | 4666 | return new; |
4667 | } | 4667 | } |
4668 | 4668 | ||
4669 | struct extent_buffer *alloc_dummy_extent_buffer(u64 start, unsigned long len) | 4669 | struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info, |
4670 | u64 start) | ||
4670 | { | 4671 | { |
4671 | struct extent_buffer *eb; | 4672 | struct extent_buffer *eb; |
4672 | unsigned long num_pages = num_extent_pages(0, len); | 4673 | unsigned long len; |
4674 | unsigned long num_pages; | ||
4673 | unsigned long i; | 4675 | unsigned long i; |
4674 | 4676 | ||
4675 | eb = __alloc_extent_buffer(NULL, start, len, GFP_NOFS); | 4677 | if (!fs_info) { |
4678 | /* | ||
4679 | * Called only from tests that don't always have a fs_info | ||
4680 | * available, but we know that nodesize is 4096 | ||
4681 | */ | ||
4682 | len = 4096; | ||
4683 | } else { | ||
4684 | len = fs_info->tree_root->nodesize; | ||
4685 | } | ||
4686 | num_pages = num_extent_pages(0, len); | ||
4687 | |||
4688 | eb = __alloc_extent_buffer(fs_info, start, len); | ||
4676 | if (!eb) | 4689 | if (!eb) |
4677 | return NULL; | 4690 | return NULL; |
4678 | 4691 | ||
@@ -4762,7 +4775,7 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, | |||
4762 | 4775 | ||
4763 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 4776 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS |
4764 | struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, | 4777 | struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, |
4765 | u64 start, unsigned long len) | 4778 | u64 start) |
4766 | { | 4779 | { |
4767 | struct extent_buffer *eb, *exists = NULL; | 4780 | struct extent_buffer *eb, *exists = NULL; |
4768 | int ret; | 4781 | int ret; |
@@ -4770,7 +4783,7 @@ struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, | |||
4770 | eb = find_extent_buffer(fs_info, start); | 4783 | eb = find_extent_buffer(fs_info, start); |
4771 | if (eb) | 4784 | if (eb) |
4772 | return eb; | 4785 | return eb; |
4773 | eb = alloc_dummy_extent_buffer(start, len); | 4786 | eb = alloc_dummy_extent_buffer(fs_info, start); |
4774 | if (!eb) | 4787 | if (!eb) |
4775 | return NULL; | 4788 | return NULL; |
4776 | eb->fs_info = fs_info; | 4789 | eb->fs_info = fs_info; |
@@ -4808,8 +4821,9 @@ free_eb: | |||
4808 | #endif | 4821 | #endif |
4809 | 4822 | ||
4810 | struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, | 4823 | struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, |
4811 | u64 start, unsigned long len) | 4824 | u64 start) |
4812 | { | 4825 | { |
4826 | unsigned long len = fs_info->tree_root->nodesize; | ||
4813 | unsigned long num_pages = num_extent_pages(start, len); | 4827 | unsigned long num_pages = num_extent_pages(start, len); |
4814 | unsigned long i; | 4828 | unsigned long i; |
4815 | unsigned long index = start >> PAGE_CACHE_SHIFT; | 4829 | unsigned long index = start >> PAGE_CACHE_SHIFT; |
@@ -4824,7 +4838,7 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, | |||
4824 | if (eb) | 4838 | if (eb) |
4825 | return eb; | 4839 | return eb; |
4826 | 4840 | ||
4827 | eb = __alloc_extent_buffer(fs_info, start, len, GFP_NOFS); | 4841 | eb = __alloc_extent_buffer(fs_info, start, len); |
4828 | if (!eb) | 4842 | if (!eb) |
4829 | return NULL; | 4843 | return NULL; |
4830 | 4844 | ||
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h index ece9ce87edff..71268e508b7a 100644 --- a/fs/btrfs/extent_io.h +++ b/fs/btrfs/extent_io.h | |||
@@ -262,8 +262,9 @@ int get_state_private(struct extent_io_tree *tree, u64 start, u64 *private); | |||
262 | void set_page_extent_mapped(struct page *page); | 262 | void set_page_extent_mapped(struct page *page); |
263 | 263 | ||
264 | struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, | 264 | struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, |
265 | u64 start, unsigned long len); | 265 | u64 start); |
266 | struct extent_buffer *alloc_dummy_extent_buffer(u64 start, unsigned long len); | 266 | struct extent_buffer *alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info, |
267 | u64 start); | ||
267 | struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src); | 268 | struct extent_buffer *btrfs_clone_extent_buffer(struct extent_buffer *src); |
268 | struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, | 269 | struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info, |
269 | u64 start); | 270 | u64 start); |
@@ -377,5 +378,5 @@ noinline u64 find_lock_delalloc_range(struct inode *inode, | |||
377 | u64 *end, u64 max_bytes); | 378 | u64 *end, u64 max_bytes); |
378 | #endif | 379 | #endif |
379 | struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, | 380 | struct extent_buffer *alloc_test_extent_buffer(struct btrfs_fs_info *fs_info, |
380 | u64 start, unsigned long len); | 381 | u64 start); |
381 | #endif | 382 | #endif |
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index b63ae20618fb..4d3d4e5287c5 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c | |||
@@ -66,7 +66,6 @@ struct reada_extctl { | |||
66 | struct reada_extent { | 66 | struct reada_extent { |
67 | u64 logical; | 67 | u64 logical; |
68 | struct btrfs_key top; | 68 | struct btrfs_key top; |
69 | u32 blocksize; | ||
70 | int err; | 69 | int err; |
71 | struct list_head extctl; | 70 | struct list_head extctl; |
72 | int refcnt; | 71 | int refcnt; |
@@ -349,7 +348,6 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, | |||
349 | 348 | ||
350 | blocksize = root->nodesize; | 349 | blocksize = root->nodesize; |
351 | re->logical = logical; | 350 | re->logical = logical; |
352 | re->blocksize = blocksize; | ||
353 | re->top = *top; | 351 | re->top = *top; |
354 | INIT_LIST_HEAD(&re->extctl); | 352 | INIT_LIST_HEAD(&re->extctl); |
355 | spin_lock_init(&re->lock); | 353 | spin_lock_init(&re->lock); |
@@ -660,7 +658,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, | |||
660 | int mirror_num = 0; | 658 | int mirror_num = 0; |
661 | struct extent_buffer *eb = NULL; | 659 | struct extent_buffer *eb = NULL; |
662 | u64 logical; | 660 | u64 logical; |
663 | u32 blocksize; | ||
664 | int ret; | 661 | int ret; |
665 | int i; | 662 | int i; |
666 | int need_kick = 0; | 663 | int need_kick = 0; |
@@ -694,7 +691,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, | |||
694 | spin_unlock(&fs_info->reada_lock); | 691 | spin_unlock(&fs_info->reada_lock); |
695 | return 0; | 692 | return 0; |
696 | } | 693 | } |
697 | dev->reada_next = re->logical + re->blocksize; | 694 | dev->reada_next = re->logical + fs_info->tree_root->nodesize; |
698 | re->refcnt++; | 695 | re->refcnt++; |
699 | 696 | ||
700 | spin_unlock(&fs_info->reada_lock); | 697 | spin_unlock(&fs_info->reada_lock); |
@@ -709,7 +706,6 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, | |||
709 | } | 706 | } |
710 | } | 707 | } |
711 | logical = re->logical; | 708 | logical = re->logical; |
712 | blocksize = re->blocksize; | ||
713 | 709 | ||
714 | spin_lock(&re->lock); | 710 | spin_lock(&re->lock); |
715 | if (re->scheduled_for == NULL) { | 711 | if (re->scheduled_for == NULL) { |
@@ -724,8 +720,8 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, | |||
724 | return 0; | 720 | return 0; |
725 | 721 | ||
726 | atomic_inc(&dev->reada_in_flight); | 722 | atomic_inc(&dev->reada_in_flight); |
727 | ret = reada_tree_block_flagged(fs_info->extent_root, logical, blocksize, | 723 | ret = reada_tree_block_flagged(fs_info->extent_root, logical, |
728 | mirror_num, &eb); | 724 | mirror_num, &eb); |
729 | if (ret) | 725 | if (ret) |
730 | __readahead_hook(fs_info->extent_root, NULL, logical, ret); | 726 | __readahead_hook(fs_info->extent_root, NULL, logical, ret); |
731 | else if (eb) | 727 | else if (eb) |
@@ -851,7 +847,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) | |||
851 | break; | 847 | break; |
852 | printk(KERN_DEBUG | 848 | printk(KERN_DEBUG |
853 | " re: logical %llu size %u empty %d for %lld", | 849 | " re: logical %llu size %u empty %d for %lld", |
854 | re->logical, re->blocksize, | 850 | re->logical, fs_info->tree_root->nodesize, |
855 | list_empty(&re->extctl), re->scheduled_for ? | 851 | list_empty(&re->extctl), re->scheduled_for ? |
856 | re->scheduled_for->devid : -1); | 852 | re->scheduled_for->devid : -1); |
857 | 853 | ||
@@ -886,7 +882,8 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) | |||
886 | } | 882 | } |
887 | printk(KERN_DEBUG | 883 | printk(KERN_DEBUG |
888 | "re: logical %llu size %u list empty %d for %lld", | 884 | "re: logical %llu size %u list empty %d for %lld", |
889 | re->logical, re->blocksize, list_empty(&re->extctl), | 885 | re->logical, fs_info->tree_root->nodesize, |
886 | list_empty(&re->extctl), | ||
890 | re->scheduled_for ? re->scheduled_for->devid : -1); | 887 | re->scheduled_for ? re->scheduled_for->devid : -1); |
891 | for (i = 0; i < re->nzones; ++i) { | 888 | for (i = 0; i < re->nzones; ++i) { |
892 | printk(KERN_CONT " zone %llu-%llu devs", | 889 | printk(KERN_CONT " zone %llu-%llu devs", |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 74257d6436ad..d83085381bcc 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -2855,9 +2855,10 @@ static void update_processed_blocks(struct reloc_control *rc, | |||
2855 | } | 2855 | } |
2856 | } | 2856 | } |
2857 | 2857 | ||
2858 | static int tree_block_processed(u64 bytenr, u32 blocksize, | 2858 | static int tree_block_processed(u64 bytenr, struct reloc_control *rc) |
2859 | struct reloc_control *rc) | ||
2860 | { | 2859 | { |
2860 | u32 blocksize = rc->extent_root->nodesize; | ||
2861 | |||
2861 | if (test_range_bit(&rc->processed_blocks, bytenr, | 2862 | if (test_range_bit(&rc->processed_blocks, bytenr, |
2862 | bytenr + blocksize - 1, EXTENT_DIRTY, 1, NULL)) | 2863 | bytenr + blocksize - 1, EXTENT_DIRTY, 1, NULL)) |
2863 | return 1; | 2864 | return 1; |
@@ -2965,8 +2966,7 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans, | |||
2965 | while (rb_node) { | 2966 | while (rb_node) { |
2966 | block = rb_entry(rb_node, struct tree_block, rb_node); | 2967 | block = rb_entry(rb_node, struct tree_block, rb_node); |
2967 | if (!block->key_ready) | 2968 | if (!block->key_ready) |
2968 | readahead_tree_block(rc->extent_root, block->bytenr, | 2969 | readahead_tree_block(rc->extent_root, block->bytenr); |
2969 | block->key.objectid); | ||
2970 | rb_node = rb_next(rb_node); | 2970 | rb_node = rb_next(rb_node); |
2971 | } | 2971 | } |
2972 | 2972 | ||
@@ -3353,7 +3353,7 @@ static int __add_tree_block(struct reloc_control *rc, | |||
3353 | bool skinny = btrfs_fs_incompat(rc->extent_root->fs_info, | 3353 | bool skinny = btrfs_fs_incompat(rc->extent_root->fs_info, |
3354 | SKINNY_METADATA); | 3354 | SKINNY_METADATA); |
3355 | 3355 | ||
3356 | if (tree_block_processed(bytenr, blocksize, rc)) | 3356 | if (tree_block_processed(bytenr, rc)) |
3357 | return 0; | 3357 | return 0; |
3358 | 3358 | ||
3359 | if (tree_search(blocks, bytenr)) | 3359 | if (tree_search(blocks, bytenr)) |
@@ -3611,7 +3611,7 @@ static int find_data_references(struct reloc_control *rc, | |||
3611 | if (added) | 3611 | if (added) |
3612 | goto next; | 3612 | goto next; |
3613 | 3613 | ||
3614 | if (!tree_block_processed(leaf->start, leaf->len, rc)) { | 3614 | if (!tree_block_processed(leaf->start, rc)) { |
3615 | block = kmalloc(sizeof(*block), GFP_NOFS); | 3615 | block = kmalloc(sizeof(*block), GFP_NOFS); |
3616 | if (!block) { | 3616 | if (!block) { |
3617 | err = -ENOMEM; | 3617 | err = -ENOMEM; |
diff --git a/fs/btrfs/tests/extent-buffer-tests.c b/fs/btrfs/tests/extent-buffer-tests.c index cc286ce97d1e..f51963a8f929 100644 --- a/fs/btrfs/tests/extent-buffer-tests.c +++ b/fs/btrfs/tests/extent-buffer-tests.c | |||
@@ -53,7 +53,7 @@ static int test_btrfs_split_item(void) | |||
53 | return -ENOMEM; | 53 | return -ENOMEM; |
54 | } | 54 | } |
55 | 55 | ||
56 | path->nodes[0] = eb = alloc_dummy_extent_buffer(0, 4096); | 56 | path->nodes[0] = eb = alloc_dummy_extent_buffer(NULL, 4096); |
57 | if (!eb) { | 57 | if (!eb) { |
58 | test_msg("Could not allocate dummy buffer\n"); | 58 | test_msg("Could not allocate dummy buffer\n"); |
59 | ret = -ENOMEM; | 59 | ret = -ENOMEM; |
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c index 3ae0f5b8bb80..a116b55ce788 100644 --- a/fs/btrfs/tests/inode-tests.c +++ b/fs/btrfs/tests/inode-tests.c | |||
@@ -255,7 +255,7 @@ static noinline int test_btrfs_get_extent(void) | |||
255 | goto out; | 255 | goto out; |
256 | } | 256 | } |
257 | 257 | ||
258 | root->node = alloc_dummy_extent_buffer(0, 4096); | 258 | root->node = alloc_dummy_extent_buffer(NULL, 4096); |
259 | if (!root->node) { | 259 | if (!root->node) { |
260 | test_msg("Couldn't allocate dummy buffer\n"); | 260 | test_msg("Couldn't allocate dummy buffer\n"); |
261 | goto out; | 261 | goto out; |
@@ -843,7 +843,7 @@ static int test_hole_first(void) | |||
843 | goto out; | 843 | goto out; |
844 | } | 844 | } |
845 | 845 | ||
846 | root->node = alloc_dummy_extent_buffer(0, 4096); | 846 | root->node = alloc_dummy_extent_buffer(NULL, 4096); |
847 | if (!root->node) { | 847 | if (!root->node) { |
848 | test_msg("Couldn't allocate dummy buffer\n"); | 848 | test_msg("Couldn't allocate dummy buffer\n"); |
849 | goto out; | 849 | goto out; |
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c index ec3dcb202357..73f299ebdabb 100644 --- a/fs/btrfs/tests/qgroup-tests.c +++ b/fs/btrfs/tests/qgroup-tests.c | |||
@@ -404,12 +404,22 @@ int btrfs_test_qgroups(void) | |||
404 | ret = -ENOMEM; | 404 | ret = -ENOMEM; |
405 | goto out; | 405 | goto out; |
406 | } | 406 | } |
407 | /* We are using this root as our extent root */ | ||
408 | root->fs_info->extent_root = root; | ||
409 | |||
410 | /* | ||
411 | * Some of the paths we test assume we have a filled out fs_info, so we | ||
412 | * just need to add the root in there so we don't panic. | ||
413 | */ | ||
414 | root->fs_info->tree_root = root; | ||
415 | root->fs_info->quota_root = root; | ||
416 | root->fs_info->quota_enabled = 1; | ||
407 | 417 | ||
408 | /* | 418 | /* |
409 | * Can't use bytenr 0, some things freak out | 419 | * Can't use bytenr 0, some things freak out |
410 | * *cough*backref walking code*cough* | 420 | * *cough*backref walking code*cough* |
411 | */ | 421 | */ |
412 | root->node = alloc_test_extent_buffer(root->fs_info, 4096, 4096); | 422 | root->node = alloc_test_extent_buffer(root->fs_info, 4096); |
413 | if (!root->node) { | 423 | if (!root->node) { |
414 | test_msg("Couldn't allocate dummy buffer\n"); | 424 | test_msg("Couldn't allocate dummy buffer\n"); |
415 | ret = -ENOMEM; | 425 | ret = -ENOMEM; |
@@ -448,17 +458,6 @@ int btrfs_test_qgroups(void) | |||
448 | goto out; | 458 | goto out; |
449 | } | 459 | } |
450 | 460 | ||
451 | /* We are using this root as our extent root */ | ||
452 | root->fs_info->extent_root = root; | ||
453 | |||
454 | /* | ||
455 | * Some of the paths we test assume we have a filled out fs_info, so we | ||
456 | * just need to addt he root in there so we don't panic. | ||
457 | */ | ||
458 | root->fs_info->tree_root = root; | ||
459 | root->fs_info->quota_root = root; | ||
460 | root->fs_info->quota_enabled = 1; | ||
461 | |||
462 | test_msg("Running qgroup tests\n"); | 461 | test_msg("Running qgroup tests\n"); |
463 | ret = test_no_shared_qgroup(root); | 462 | ret = test_no_shared_qgroup(root); |
464 | if (ret) | 463 | if (ret) |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 25a1c363a5f4..67e5bf709dca 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -2165,7 +2165,7 @@ static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
2165 | parent = path->nodes[*level]; | 2165 | parent = path->nodes[*level]; |
2166 | root_owner = btrfs_header_owner(parent); | 2166 | root_owner = btrfs_header_owner(parent); |
2167 | 2167 | ||
2168 | next = btrfs_find_create_tree_block(root, bytenr, blocksize); | 2168 | next = btrfs_find_create_tree_block(root, bytenr); |
2169 | if (!next) | 2169 | if (!next) |
2170 | return -ENOMEM; | 2170 | return -ENOMEM; |
2171 | 2171 | ||
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 50c5a8762aed..0d9bfebdaa4c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -6247,8 +6247,13 @@ int btrfs_read_sys_array(struct btrfs_root *root) | |||
6247 | u32 cur; | 6247 | u32 cur; |
6248 | struct btrfs_key key; | 6248 | struct btrfs_key key; |
6249 | 6249 | ||
6250 | sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET, | 6250 | ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize); |
6251 | BTRFS_SUPER_INFO_SIZE); | 6251 | /* |
6252 | * This will create extent buffer of nodesize, superblock size is | ||
6253 | * fixed to BTRFS_SUPER_INFO_SIZE. If nodesize > sb size, this will | ||
6254 | * overallocate but we can keep it as-is, only the first page is used. | ||
6255 | */ | ||
6256 | sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET); | ||
6252 | if (!sb) | 6257 | if (!sb) |
6253 | return -ENOMEM; | 6258 | return -ENOMEM; |
6254 | btrfs_set_buffer_uptodate(sb); | 6259 | btrfs_set_buffer_uptodate(sb); |