* ->add_extent_mapping(0, 16K)
* -> #handle -EEXIST
*/
-static void test_case_1(struct btrfs_fs_info *fs_info,
+static int test_case_1(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
struct extent_map *em;
em = alloc_extent_map();
if (!em)
- /* Skip the test on error. */
- return;
+ return -ENOMEM;
/* Add [0, 16K) */
em->start = 0;
/* Add [16K, 20K) following [0, 16K) */
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
em->start = SZ_16K;
em->len = SZ_4K;
free_extent_map(em);
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
/* Add [0, 8K), should return [0, 16K) instead. */
em->start = start;
start, start + len, ret, em->start, em->len,
em->block_start, em->block_len);
free_extent_map(em);
+ ret = 0;
out:
/* free memory */
free_extent_map_tree(em_tree);
+
+ return ret;
}
/*
* 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 btrfs_fs_info *fs_info,
+static int test_case_2(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree)
{
struct extent_map *em;
em = alloc_extent_map();
if (!em)
- /* Skip the test on error. */
- return;
+ return -ENOMEM;
/* Add [0, 1K) */
em->start = 0;
/* Add [4K, 4K) following [0, 1K) */
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
em->start = SZ_4K;
em->len = SZ_4K;
free_extent_map(em);
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
/* Add [0, 1K) */
em->start = 0;
ret, em->start, em->len, em->block_start,
em->block_len);
free_extent_map(em);
+ ret = 0;
out:
/* free memory */
free_extent_map_tree(em_tree);
+
+ return ret;
}
-static void __test_case_3(struct btrfs_fs_info *fs_info,
+static int __test_case_3(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree, u64 start)
{
struct extent_map *em;
em = alloc_extent_map();
if (!em)
- /* Skip this test on error. */
- return;
+ return -ENOMEM;
/* Add [4K, 8K) */
em->start = SZ_4K;
free_extent_map(em);
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
/* Add [0, 16K) */
em->start = 0;
start, start + len, ret, em->start, em->len,
em->block_start, em->block_len);
free_extent_map(em);
+ ret = 0;
out:
/* free memory */
free_extent_map_tree(em_tree);
+
+ return ret;
}
/*
__test_case_3(fs_info, em_tree, (12 * 1024ULL));
}
-static void __test_case_4(struct btrfs_fs_info *fs_info,
+static int __test_case_4(struct btrfs_fs_info *fs_info,
struct extent_map_tree *em_tree, u64 start)
{
struct extent_map *em;
em = alloc_extent_map();
if (!em)
- /* Skip this test on error. */
- return;
+ return -ENOMEM;
/* Add [0K, 8K) */
em->start = 0;
free_extent_map(em);
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
/* Add [8K, 24K) */
em->start = SZ_8K;
free_extent_map(em);
em = alloc_extent_map();
- if (!em)
+ if (!em) {
+ ret = -ENOMEM;
goto out;
+ }
/* Add [0K, 32K) */
em->start = 0;
em->len = SZ_32K;
start, len, ret, em->start, em->len, em->block_start,
em->block_len);
free_extent_map(em);
+ ret = 0;
out:
/* free memory */
free_extent_map_tree(em_tree);
+
+ return ret;
}
/*
{
struct btrfs_fs_info *fs_info = NULL;
struct extent_map_tree *em_tree;
+ int ret = 0;
test_msg("running extent_map tests");
}
em_tree = kzalloc(sizeof(*em_tree), GFP_KERNEL);
- if (!em_tree)
- /* Skip the test on error. */
+ if (!em_tree) {
+ ret = -ENOMEM;
goto out;
+ }
extent_map_tree_init(em_tree);
out:
btrfs_free_dummy_fs_info(fs_info);
- return 0;
+ return ret;
}