Commit 0e08eb9b authored by David Sterba's avatar David Sterba

btrfs: tests: pass fs_info to extent_map tests

Preparatory work to pass fs_info to btrfs_add_extent_mapping so we can
get a better tracepoint message. Extent maps do not need fs_info for
anything so we only add a dummy one without any other initialization.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2e63e62d
......@@ -47,7 +47,8 @@ static void free_extent_map_tree(struct extent_map_tree *em_tree)
* ->add_extent_mapping(0, 16K)
* -> #handle -EEXIST
*/
static void test_case_1(struct extent_map_tree *em_tree)
static void test_case_1(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
struct extent_map *em;
u64 start = 0;
......@@ -112,7 +113,8 @@ static void test_case_1(struct extent_map_tree *em_tree)
* Reading the inline ending up with EEXIST, ie. read an inline
* extent and discard page cache and read it again.
*/
static void test_case_2(struct extent_map_tree *em_tree)
static void test_case_2(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
struct extent_map *em;
int ret;
......@@ -169,7 +171,8 @@ static void test_case_2(struct extent_map_tree *em_tree)
free_extent_map_tree(em_tree);
}
static void __test_case_3(struct extent_map_tree *em_tree, u64 start)
static void __test_case_3(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree, u64 start)
{
struct extent_map *em;
u64 len = SZ_4K;
......@@ -235,14 +238,16 @@ static void __test_case_3(struct extent_map_tree *em_tree, u64 start)
* -> add_extent_mapping()
* -> add_extent_mapping()
*/
static void test_case_3(struct extent_map_tree *em_tree)
static void test_case_3(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
__test_case_3(em_tree, 0);
__test_case_3(em_tree, SZ_8K);
__test_case_3(em_tree, (12 * 1024ULL));
__test_case_3(fs_info, em_tree, 0);
__test_case_3(fs_info, em_tree, SZ_8K);
__test_case_3(fs_info, em_tree, (12 * 1024ULL));
}
static void __test_case_4(struct extent_map_tree *em_tree, u64 start)
static void __test_case_4(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree, u64 start)
{
struct extent_map *em;
u64 len = SZ_4K;
......@@ -324,30 +329,45 @@ static void __test_case_4(struct extent_map_tree *em_tree, u64 start)
* # handle -EEXIST when adding
* # [0, 32K)
*/
static void test_case_4(struct extent_map_tree *em_tree)
static void test_case_4(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
__test_case_4(em_tree, 0);
__test_case_4(em_tree, SZ_4K);
__test_case_4(fs_info, em_tree, 0);
__test_case_4(fs_info, em_tree, SZ_4K);
}
int btrfs_test_extent_map(void)
{
struct btrfs_fs_info *fs_info = NULL;
struct extent_map_tree *em_tree;
test_msg("Running extent_map tests\n");
/*
* Note: the fs_info is not set up completely, we only need
* fs_info::fsid for the tracepoint.
*/
fs_info = btrfs_alloc_dummy_fs_info(PAGE_SIZE, PAGE_SIZE);
if (!fs_info) {
test_msg("Couldn't allocate dummy fs info\n");
return -ENOMEM;
}
em_tree = kzalloc(sizeof(*em_tree), GFP_KERNEL);
if (!em_tree)
/* Skip the test on error. */
return 0;
goto out;
extent_map_tree_init(em_tree);
test_case_1(em_tree);
test_case_2(em_tree);
test_case_3(em_tree);
test_case_4(em_tree);
test_case_1(fs_info, em_tree);
test_case_2(fs_info, em_tree);
test_case_3(fs_info, em_tree);
test_case_4(fs_info, em_tree);
kfree(em_tree);
out:
btrfs_free_dummy_fs_info(fs_info);
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment