btrfs: pull node/sector/stripe sizes out of root and into fs_info
We track the node sizes per-root, but they never vary from the values in the superblock. This patch messes with the 80-column style a bit, but subsequent patches to factor out root->fs_info into a convenience variable fix it up again. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:

committed by
David Sterba

parent
f15376df0d
commit
da17066c40
@@ -79,7 +79,7 @@ static void btrfs_destroy_test_fs(void)
|
||||
unregister_filesystem(&test_type);
|
||||
}
|
||||
|
||||
struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void)
|
||||
struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info),
|
||||
GFP_KERNEL);
|
||||
@@ -100,6 +100,9 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fs_info->nodesize = nodesize;
|
||||
fs_info->sectorsize = sectorsize;
|
||||
|
||||
if (init_srcu_struct(&fs_info->subvol_srcu)) {
|
||||
kfree(fs_info->fs_devices);
|
||||
kfree(fs_info->super_copy);
|
||||
@@ -189,7 +192,8 @@ void btrfs_free_dummy_root(struct btrfs_root *root)
|
||||
}
|
||||
|
||||
struct btrfs_block_group_cache *
|
||||
btrfs_alloc_dummy_block_group(unsigned long length, u32 sectorsize)
|
||||
btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info,
|
||||
unsigned long length)
|
||||
{
|
||||
struct btrfs_block_group_cache *cache;
|
||||
|
||||
@@ -206,8 +210,9 @@ btrfs_alloc_dummy_block_group(unsigned long length, u32 sectorsize)
|
||||
cache->key.objectid = 0;
|
||||
cache->key.offset = length;
|
||||
cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
|
||||
cache->sectorsize = sectorsize;
|
||||
cache->full_stripe_len = sectorsize;
|
||||
cache->sectorsize = fs_info->sectorsize;
|
||||
cache->full_stripe_len = fs_info->sectorsize;
|
||||
cache->fs_info = fs_info;
|
||||
|
||||
INIT_LIST_HEAD(&cache->list);
|
||||
INIT_LIST_HEAD(&cache->cluster_list);
|
||||
|
@@ -34,11 +34,11 @@ int btrfs_test_inodes(u32 sectorsize, u32 nodesize);
|
||||
int btrfs_test_qgroups(u32 sectorsize, u32 nodesize);
|
||||
int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize);
|
||||
struct inode *btrfs_new_test_inode(void);
|
||||
struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(void);
|
||||
struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize);
|
||||
void btrfs_free_dummy_fs_info(struct btrfs_fs_info *fs_info);
|
||||
void btrfs_free_dummy_root(struct btrfs_root *root);
|
||||
struct btrfs_block_group_cache *
|
||||
btrfs_alloc_dummy_block_group(unsigned long length, u32 sectorsize);
|
||||
btrfs_alloc_dummy_block_group(struct btrfs_fs_info *fs_info, unsigned long length);
|
||||
void btrfs_free_dummy_block_group(struct btrfs_block_group_cache *cache);
|
||||
void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans);
|
||||
#else
|
||||
|
@@ -41,13 +41,13 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
|
||||
|
||||
test_msg("Running btrfs_split_item tests\n");
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Could not allocate fs_info\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Could not allocate root\n");
|
||||
ret = PTR_ERR(root);
|
||||
@@ -61,8 +61,7 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
|
||||
goto out;
|
||||
}
|
||||
|
||||
path->nodes[0] = eb = alloc_dummy_extent_buffer(NULL, nodesize,
|
||||
nodesize);
|
||||
path->nodes[0] = eb = alloc_dummy_extent_buffer(fs_info, nodesize);
|
||||
if (!eb) {
|
||||
test_msg("Could not allocate dummy buffer\n");
|
||||
ret = -ENOMEM;
|
||||
|
@@ -383,6 +383,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
|
||||
|
||||
static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info;
|
||||
unsigned long len;
|
||||
unsigned long *bitmap;
|
||||
struct extent_buffer *eb;
|
||||
@@ -397,13 +398,15 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
|
||||
len = (sectorsize < BTRFS_MAX_METADATA_BLOCKSIZE)
|
||||
? sectorsize * 4 : sectorsize;
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info(len, len);
|
||||
|
||||
bitmap = kmalloc(len, GFP_KERNEL);
|
||||
if (!bitmap) {
|
||||
test_msg("Couldn't allocate test bitmap\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
eb = __alloc_dummy_extent_buffer(NULL, 0, len);
|
||||
eb = __alloc_dummy_extent_buffer(fs_info, 0, len);
|
||||
if (!eb) {
|
||||
test_msg("Couldn't allocate test extent buffer\n");
|
||||
kfree(bitmap);
|
||||
|
@@ -843,33 +843,31 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
|
||||
int ret = -ENOMEM;
|
||||
|
||||
test_msg("Running btrfs free space cache tests\n");
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
/*
|
||||
* For ppc64 (with 64k page size), bytes per bitmap might be
|
||||
* larger than 1G. To make bitmap test available in ppc64,
|
||||
* alloc dummy block group whose size cross bitmaps.
|
||||
*/
|
||||
cache = btrfs_alloc_dummy_block_group(BITS_PER_BITMAP * sectorsize
|
||||
+ PAGE_SIZE, sectorsize);
|
||||
cache = btrfs_alloc_dummy_block_group(fs_info,
|
||||
BITS_PER_BITMAP * sectorsize + PAGE_SIZE);
|
||||
if (!cache) {
|
||||
test_msg("Couldn't run the tests\n");
|
||||
btrfs_free_dummy_fs_info(fs_info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
if (!fs_info) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
ret = PTR_ERR(root);
|
||||
goto out;
|
||||
}
|
||||
|
||||
root->fs_info->extent_root = root;
|
||||
cache->fs_info = root->fs_info;
|
||||
|
||||
ret = test_extents(cache);
|
||||
if (ret)
|
||||
|
@@ -455,14 +455,14 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
|
||||
struct btrfs_path *path = NULL;
|
||||
int ret;
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Couldn't allocate dummy fs info\n");
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Couldn't allocate dummy root\n");
|
||||
ret = PTR_ERR(root);
|
||||
@@ -474,8 +474,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
|
||||
root->fs_info->free_space_root = root;
|
||||
root->fs_info->tree_root = root;
|
||||
|
||||
root->node = alloc_test_extent_buffer(root->fs_info,
|
||||
nodesize, nodesize);
|
||||
root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
|
||||
if (!root->node) {
|
||||
test_msg("Couldn't allocate dummy buffer\n");
|
||||
ret = -ENOMEM;
|
||||
@@ -485,7 +484,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
|
||||
btrfs_set_header_nritems(root->node, 0);
|
||||
root->alloc_bytenr += 2 * nodesize;
|
||||
|
||||
cache = btrfs_alloc_dummy_block_group(8 * alignment, sectorsize);
|
||||
cache = btrfs_alloc_dummy_block_group(fs_info, 8 * alignment);
|
||||
if (!cache) {
|
||||
test_msg("Couldn't allocate dummy block group cache\n");
|
||||
ret = -ENOMEM;
|
||||
|
@@ -249,19 +249,19 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
|
||||
BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
||||
BTRFS_I(inode)->location.offset = 0;
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Couldn't allocate dummy fs info\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Couldn't allocate root\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
root->node = alloc_dummy_extent_buffer(NULL, nodesize, nodesize);
|
||||
root->node = alloc_dummy_extent_buffer(fs_info, nodesize);
|
||||
if (!root->node) {
|
||||
test_msg("Couldn't allocate dummy buffer\n");
|
||||
goto out;
|
||||
@@ -854,19 +854,19 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
|
||||
BTRFS_I(inode)->location.objectid = BTRFS_FIRST_FREE_OBJECTID;
|
||||
BTRFS_I(inode)->location.offset = 0;
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Couldn't allocate dummy fs info\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Couldn't allocate root\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
root->node = alloc_dummy_extent_buffer(NULL, nodesize, nodesize);
|
||||
root->node = alloc_dummy_extent_buffer(fs_info, nodesize);
|
||||
if (!root->node) {
|
||||
test_msg("Couldn't allocate dummy buffer\n");
|
||||
goto out;
|
||||
@@ -950,13 +950,13 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
|
||||
return ret;
|
||||
}
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Couldn't allocate dummy fs info\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Couldn't allocate root\n");
|
||||
goto out;
|
||||
|
@@ -458,13 +458,13 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
|
||||
struct btrfs_root *tmp_root;
|
||||
int ret = 0;
|
||||
|
||||
fs_info = btrfs_alloc_dummy_fs_info();
|
||||
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
|
||||
if (!fs_info) {
|
||||
test_msg("Couldn't allocate dummy fs info\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(root)) {
|
||||
test_msg("Couldn't allocate root\n");
|
||||
ret = PTR_ERR(root);
|
||||
@@ -486,8 +486,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
|
||||
* Can't use bytenr 0, some things freak out
|
||||
* *cough*backref walking code*cough*
|
||||
*/
|
||||
root->node = alloc_test_extent_buffer(root->fs_info, nodesize,
|
||||
nodesize);
|
||||
root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
|
||||
if (!root->node) {
|
||||
test_msg("Couldn't allocate dummy buffer\n");
|
||||
ret = -ENOMEM;
|
||||
@@ -497,7 +496,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
|
||||
btrfs_set_header_nritems(root->node, 0);
|
||||
root->alloc_bytenr += 2 * nodesize;
|
||||
|
||||
tmp_root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
tmp_root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(tmp_root)) {
|
||||
test_msg("Couldn't allocate a fs root\n");
|
||||
ret = PTR_ERR(tmp_root);
|
||||
@@ -512,7 +511,7 @@ int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
|
||||
goto out;
|
||||
}
|
||||
|
||||
tmp_root = btrfs_alloc_dummy_root(fs_info, sectorsize, nodesize);
|
||||
tmp_root = btrfs_alloc_dummy_root(fs_info);
|
||||
if (IS_ERR(tmp_root)) {
|
||||
test_msg("Couldn't allocate a fs root\n");
|
||||
ret = PTR_ERR(tmp_root);
|
||||
|
Reference in New Issue
Block a user