Commit 3c7251f2 authored by David Sterba's avatar David Sterba

btrfs: tests: add helper for error messages and update them

The test failures are not clearly visible in the system log as they're
printed at INFO level. Add a new helper that is level ERROR. As this
touches almost all strings, I took the opportunity to unify them:

- decapitalize the first letter as there's a prefix and the text
  continues after ":"
- glue strings split to more lines and un-indent so they fit to 80
  columns
- use %llu instead of %Lu
- drop \n from the modified messages (test_msg is left untouched)
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ad1e3d56
......@@ -10,6 +10,7 @@
int btrfs_run_sanity_tests(void);
#define test_msg(fmt, ...) pr_info("BTRFS: selftest: " fmt, ##__VA_ARGS__)
#define test_err(fmt, ...) pr_err("BTRFS: selftest: " fmt "\n", ##__VA_ARGS__)
struct btrfs_root;
struct btrfs_trans_handle;
......
......@@ -26,31 +26,31 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
u32 value_len = strlen(value);
int ret = 0;
test_msg("Running btrfs_split_item tests\n");
test_msg("running btrfs_split_item tests\n");
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
if (!fs_info) {
test_msg("Could not allocate fs_info\n");
test_err("could not allocate fs_info");
return -ENOMEM;
}
root = btrfs_alloc_dummy_root(fs_info);
if (IS_ERR(root)) {
test_msg("Could not allocate root\n");
test_err("could not allocate root");
ret = PTR_ERR(root);
goto out;
}
path = btrfs_alloc_path();
if (!path) {
test_msg("Could not allocate path\n");
test_err("could not allocate path");
ret = -ENOMEM;
goto out;
}
path->nodes[0] = eb = alloc_dummy_extent_buffer(fs_info, nodesize);
if (!eb) {
test_msg("Could not allocate dummy buffer\n");
test_err("could not allocate dummy buffer");
ret = -ENOMEM;
goto out;
}
......@@ -75,7 +75,7 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
*/
ret = btrfs_split_item(NULL, root, path, &key, 17);
if (ret) {
test_msg("Split item failed %d\n", ret);
test_err("split item failed %d", ret);
goto out;
}
......@@ -86,14 +86,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
btrfs_item_key_to_cpu(eb, &key, 0);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 0) {
test_msg("Invalid key at slot 0\n");
test_err("invalid key at slot 0");
ret = -EINVAL;
goto out;
}
item = btrfs_item_nr(0);
if (btrfs_item_size(eb, item) != strlen(split1)) {
test_msg("Invalid len in the first split\n");
test_err("invalid len in the first split");
ret = -EINVAL;
goto out;
}
......@@ -101,8 +101,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
strlen(split1));
if (memcmp(buf, split1, strlen(split1))) {
test_msg("Data in the buffer doesn't match what it should "
"in the first split have='%.*s' want '%s'\n",
test_err(
"data in the buffer doesn't match what it should in the first split have='%.*s' want '%s'",
(int)strlen(split1), buf, split1);
ret = -EINVAL;
goto out;
......@@ -111,14 +111,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
btrfs_item_key_to_cpu(eb, &key, 1);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 3) {
test_msg("Invalid key at slot 1\n");
test_err("invalid key at slot 1");
ret = -EINVAL;
goto out;
}
item = btrfs_item_nr(1);
if (btrfs_item_size(eb, item) != strlen(split2)) {
test_msg("Invalid len in the second split\n");
test_err("invalid len in the second split");
ret = -EINVAL;
goto out;
}
......@@ -126,8 +126,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
strlen(split2));
if (memcmp(buf, split2, strlen(split2))) {
test_msg("Data in the buffer doesn't match what it should "
"in the second split\n");
test_err(
"data in the buffer doesn't match what it should in the second split");
ret = -EINVAL;
goto out;
}
......@@ -136,21 +136,21 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
/* Do it again so we test memmoving the other items in the leaf */
ret = btrfs_split_item(NULL, root, path, &key, 4);
if (ret) {
test_msg("Second split item failed %d\n", ret);
test_err("second split item failed %d", ret);
goto out;
}
btrfs_item_key_to_cpu(eb, &key, 0);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 0) {
test_msg("Invalid key at slot 0\n");
test_err("invalid key at slot 0");
ret = -EINVAL;
goto out;
}
item = btrfs_item_nr(0);
if (btrfs_item_size(eb, item) != strlen(split3)) {
test_msg("Invalid len in the first split\n");
test_err("invalid len in the first split");
ret = -EINVAL;
goto out;
}
......@@ -158,8 +158,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
strlen(split3));
if (memcmp(buf, split3, strlen(split3))) {
test_msg("Data in the buffer doesn't match what it should "
"in the third split");
test_err(
"data in the buffer doesn't match what it should in the third split");
ret = -EINVAL;
goto out;
}
......@@ -167,14 +167,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
btrfs_item_key_to_cpu(eb, &key, 1);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 1) {
test_msg("Invalid key at slot 1\n");
test_err("invalid key at slot 1");
ret = -EINVAL;
goto out;
}
item = btrfs_item_nr(1);
if (btrfs_item_size(eb, item) != strlen(split4)) {
test_msg("Invalid len in the second split\n");
test_err("invalid len in the second split");
ret = -EINVAL;
goto out;
}
......@@ -182,8 +182,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
strlen(split4));
if (memcmp(buf, split4, strlen(split4))) {
test_msg("Data in the buffer doesn't match what it should "
"in the fourth split\n");
test_err(
"data in the buffer doesn't match what it should in the fourth split");
ret = -EINVAL;
goto out;
}
......@@ -191,14 +191,14 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
btrfs_item_key_to_cpu(eb, &key, 2);
if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 3) {
test_msg("Invalid key at slot 2\n");
test_err("invalid key at slot 2");
ret = -EINVAL;
goto out;
}
item = btrfs_item_nr(2);
if (btrfs_item_size(eb, item) != strlen(split2)) {
test_msg("Invalid len in the second split\n");
test_err("invalid len in the second split");
ret = -EINVAL;
goto out;
}
......@@ -206,8 +206,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 2),
strlen(split2));
if (memcmp(buf, split2, strlen(split2))) {
test_msg("Data in the buffer doesn't match what it should "
"in the last chunk\n");
test_err(
"data in the buffer doesn't match what it should in the last chunk");
ret = -EINVAL;
goto out;
}
......@@ -220,6 +220,6 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize)
{
test_msg("Running extent buffer operation tests\n");
test_msg("running extent buffer operation tests\n");
return test_btrfs_split_item(sectorsize, nodesize);
}
......@@ -46,7 +46,9 @@ static noinline int process_page_range(struct inode *inode, u64 start, u64 end,
cond_resched();
loops++;
if (loops > 100000) {
printk(KERN_ERR "stuck in a loop, start %Lu, end %Lu, nr_pages %lu, ret %d\n", start, end, nr_pages, ret);
printk(KERN_ERR
"stuck in a loop, start %llu, end %llu, nr_pages %lu, ret %d\n",
start, end, nr_pages, ret);
break;
}
}
......@@ -66,11 +68,11 @@ static int test_find_delalloc(u32 sectorsize)
u64 found;
int ret = -EINVAL;
test_msg("Running find delalloc tests\n");
test_msg("running find delalloc tests\n");
inode = btrfs_new_test_inode();
if (!inode) {
test_msg("Failed to allocate test inode\n");
test_err("failed to allocate test inode");
return -ENOMEM;
}
......@@ -84,7 +86,7 @@ static int test_find_delalloc(u32 sectorsize)
for (index = 0; index < (total_dirty >> PAGE_SHIFT); index++) {
page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL);
if (!page) {
test_msg("Failed to allocate test page\n");
test_err("failed to allocate test page");
ret = -ENOMEM;
goto out;
}
......@@ -107,11 +109,11 @@ static int test_find_delalloc(u32 sectorsize)
found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end, max_bytes);
if (!found) {
test_msg("Should have found at least one delalloc\n");
test_err("should have found at least one delalloc");
goto out_bits;
}
if (start != 0 || end != (sectorsize - 1)) {
test_msg("Expected start 0 end %u, got start %llu end %llu\n",
test_err("expected start 0 end %u, got start %llu end %llu",
sectorsize - 1, start, end);
goto out_bits;
}
......@@ -129,7 +131,7 @@ static int test_find_delalloc(u32 sectorsize)
locked_page = find_lock_page(inode->i_mapping,
test_start >> PAGE_SHIFT);
if (!locked_page) {
test_msg("Couldn't find the locked page\n");
test_err("couldn't find the locked page");
goto out_bits;
}
set_extent_delalloc(&tmp, sectorsize, max_bytes - 1, 0, NULL);
......@@ -138,17 +140,17 @@ static int test_find_delalloc(u32 sectorsize)
found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end, max_bytes);
if (!found) {
test_msg("Couldn't find delalloc in our range\n");
test_err("couldn't find delalloc in our range");
goto out_bits;
}
if (start != test_start || end != max_bytes - 1) {
test_msg("Expected start %Lu end %Lu, got start %Lu, end "
"%Lu\n", test_start, max_bytes - 1, start, end);
test_err("expected start %llu end %llu, got start %llu, end %llu",
test_start, max_bytes - 1, start, end);
goto out_bits;
}
if (process_page_range(inode, start, end,
PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
test_msg("There were unlocked pages in the range\n");
test_err("there were unlocked pages in the range");
goto out_bits;
}
unlock_extent(&tmp, start, end);
......@@ -164,7 +166,7 @@ static int test_find_delalloc(u32 sectorsize)
locked_page = find_lock_page(inode->i_mapping, test_start >>
PAGE_SHIFT);
if (!locked_page) {
test_msg("Couldn't find the locked page\n");
test_err("couldn't find the locked page");
goto out_bits;
}
start = test_start;
......@@ -172,11 +174,11 @@ static int test_find_delalloc(u32 sectorsize)
found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end, max_bytes);
if (found) {
test_msg("Found range when we shouldn't have\n");
test_err("found range when we shouldn't have");
goto out_bits;
}
if (end != (u64)-1) {
test_msg("Did not return the proper end offset\n");
test_err("did not return the proper end offset");
goto out_bits;
}
......@@ -193,17 +195,17 @@ static int test_find_delalloc(u32 sectorsize)
found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end, max_bytes);
if (!found) {
test_msg("Didn't find our range\n");
test_err("didn't find our range");
goto out_bits;
}
if (start != test_start || end != total_dirty - 1) {
test_msg("Expected start %Lu end %Lu, got start %Lu end %Lu\n",
test_err("expected start %llu end %llu, got start %llu end %llu",
test_start, total_dirty - 1, start, end);
goto out_bits;
}
if (process_page_range(inode, start, end,
PROCESS_TEST_LOCKED | PROCESS_UNLOCK)) {
test_msg("Pages in range were not all locked\n");
test_err("pages in range were not all locked");
goto out_bits;
}
unlock_extent(&tmp, start, end);
......@@ -215,7 +217,7 @@ static int test_find_delalloc(u32 sectorsize)
page = find_get_page(inode->i_mapping,
(max_bytes + SZ_1M) >> PAGE_SHIFT);
if (!page) {
test_msg("Couldn't find our page\n");
test_err("couldn't find our page");
goto out_bits;
}
ClearPageDirty(page);
......@@ -234,18 +236,17 @@ static int test_find_delalloc(u32 sectorsize)
found = find_lock_delalloc_range(inode, &tmp, locked_page, &start,
&end, max_bytes);
if (!found) {
test_msg("Didn't find our range\n");
test_err("didn't find our range");
goto out_bits;
}
if (start != test_start && end != test_start + PAGE_SIZE - 1) {
test_msg("Expected start %Lu end %Lu, got start %Lu end %Lu\n",
test_start, test_start + PAGE_SIZE - 1, start,
end);
test_err("expected start %llu end %llu, got start %llu end %llu",
test_start, test_start + PAGE_SIZE - 1, start, end);
goto out_bits;
}
if (process_page_range(inode, start, end, PROCESS_TEST_LOCKED |
PROCESS_UNLOCK)) {
test_msg("Pages in range were not all locked\n");
test_err("pages in range were not all locked");
goto out_bits;
}
ret = 0;
......@@ -271,14 +272,14 @@ static int check_eb_bitmap(unsigned long *bitmap, struct extent_buffer *eb,
bit = !!test_bit(i, bitmap);
bit1 = !!extent_buffer_test_bit(eb, 0, i);
if (bit1 != bit) {
test_msg("Bits do not match\n");
test_err("bits do not match");
return -EINVAL;
}
bit1 = !!extent_buffer_test_bit(eb, i / BITS_PER_BYTE,
i % BITS_PER_BYTE);
if (bit1 != bit) {
test_msg("Offset bits do not match\n");
test_err("offset bits do not match");
return -EINVAL;
}
}
......@@ -295,7 +296,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
memset(bitmap, 0, len);
memzero_extent_buffer(eb, 0, len);
if (memcmp_extent_buffer(eb, bitmap, 0, len) != 0) {
test_msg("Bitmap was not zeroed\n");
test_err("bitmap was not zeroed");
return -EINVAL;
}
......@@ -303,7 +304,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
extent_buffer_bitmap_set(eb, 0, 0, len * BITS_PER_BYTE);
ret = check_eb_bitmap(bitmap, eb, len);
if (ret) {
test_msg("Setting all bits failed\n");
test_err("setting all bits failed");
return ret;
}
......@@ -311,7 +312,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
extent_buffer_bitmap_clear(eb, 0, 0, len * BITS_PER_BYTE);
ret = check_eb_bitmap(bitmap, eb, len);
if (ret) {
test_msg("Clearing all bits failed\n");
test_err("clearing all bits failed");
return ret;
}
......@@ -324,7 +325,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
sizeof(long) * BITS_PER_BYTE);
ret = check_eb_bitmap(bitmap, eb, len);
if (ret) {
test_msg("Setting straddling pages failed\n");
test_err("setting straddling pages failed");
return ret;
}
......@@ -337,7 +338,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
sizeof(long) * BITS_PER_BYTE);
ret = check_eb_bitmap(bitmap, eb, len);
if (ret) {
test_msg("Clearing straddling pages failed\n");
test_err("clearing straddling pages failed");
return ret;
}
}
......@@ -361,7 +362,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
ret = check_eb_bitmap(bitmap, eb, len);
if (ret) {
test_msg("Random bit pattern failed\n");
test_err("random bit pattern failed");
return ret;
}
......@@ -376,7 +377,7 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
struct extent_buffer *eb;
int ret;
test_msg("Running extent buffer bitmap tests\n");
test_msg("running extent buffer bitmap tests\n");
/*
* In ppc64, sectorsize can be 64K, thus 4 * 64K will be larger than
......@@ -389,13 +390,13 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
bitmap = kmalloc(len, GFP_KERNEL);
if (!bitmap) {
test_msg("Couldn't allocate test bitmap\n");
test_err("couldn't allocate test bitmap");
return -ENOMEM;
}
eb = __alloc_dummy_extent_buffer(fs_info, 0, len);
if (!eb) {
test_msg("Couldn't allocate test extent buffer\n");
test_err("couldn't allocate test extent buffer");
kfree(bitmap);
return -ENOMEM;
}
......@@ -408,7 +409,7 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
free_extent_buffer(eb);
eb = __alloc_dummy_extent_buffer(NULL, nodesize / 2, len);
if (!eb) {
test_msg("Couldn't allocate test extent buffer\n");
test_err("couldn't allocate test extent buffer");
kfree(bitmap);
return -ENOMEM;
}
......@@ -424,7 +425,7 @@ int btrfs_test_extent_io(u32 sectorsize, u32 nodesize)
{
int ret;
test_msg("Running extent I/O tests\n");
test_msg("running extent I/O tests\n");
ret = test_find_delalloc(sectorsize);
if (ret)
......@@ -432,6 +433,6 @@ int btrfs_test_extent_io(u32 sectorsize, u32 nodesize)
ret = test_eb_bitmaps(sectorsize, nodesize);
out:
test_msg("Extent I/O tests finished\n");
test_msg("extent I/O tests finished\n");
return ret;
}
......@@ -19,8 +19,8 @@ static void free_extent_map_tree(struct extent_map_tree *em_tree)
#ifdef CONFIG_BTRFS_DEBUG
if (refcount_read(&em->refs) != 1) {
test_msg(
"em leak: em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx) refs %d\n",
test_err(
"em leak: em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx) refs %d",
em->start, em->len, em->block_start,
em->block_len, refcount_read(&em->refs));
......@@ -93,12 +93,12 @@ static void test_case_1(struct btrfs_fs_info *fs_info,
em->block_len = len;
ret = btrfs_add_extent_mapping(fs_info, em_tree, &em, em->start, em->len);
if (ret)
test_msg("case1 [%llu %llu]: ret %d\n", start, start + len, ret);
test_err("case1 [%llu %llu]: ret %d", start, start + len, ret);
if (em &&
(em->start != 0 || extent_map_end(em) != SZ_16K ||
em->block_start != 0 || em->block_len != SZ_16K))
test_msg(
"case1 [%llu %llu]: ret %d return a wrong em (start %llu len %llu block_start %llu block_len %llu\n",
test_err(
"case1 [%llu %llu]: ret %d return a wrong em (start %llu len %llu block_start %llu block_len %llu",
start, start + len, ret, em->start, em->len,
em->block_start, em->block_len);
free_extent_map(em);
......@@ -157,12 +157,12 @@ static void test_case_2(struct btrfs_fs_info *fs_info,
em->block_len = (u64)-1;
ret = btrfs_add_extent_mapping(fs_info, em_tree, &em, em->start, em->len);
if (ret)
test_msg("case2 [0 1K]: ret %d\n", ret);
test_err("case2 [0 1K]: ret %d", ret);
if (em &&
(em->start != 0 || extent_map_end(em) != SZ_1K ||
em->block_start != EXTENT_MAP_INLINE || em->block_len != (u64)-1))
test_msg(
"case2 [0 1K]: ret %d return a wrong em (start %llu len %llu block_start %llu block_len %llu\n",
test_err(
"case2 [0 1K]: ret %d return a wrong em (start %llu len %llu block_start %llu block_len %llu",
ret, em->start, em->len, em->block_start,
em->block_len);
free_extent_map(em);
......@@ -203,7 +203,7 @@ static void __test_case_3(struct btrfs_fs_info *fs_info,
em->block_len = SZ_16K;
ret = btrfs_add_extent_mapping(fs_info, em_tree, &em, start, len);
if (ret)
test_msg("case3 [0x%llx 0x%llx): ret %d\n",
test_err("case3 [0x%llx 0x%llx): ret %d",
start, start + len, ret);
/*
* Since bytes within em are contiguous, em->block_start is identical to
......@@ -212,8 +212,8 @@ static void __test_case_3(struct btrfs_fs_info *fs_info,
if (em &&
(start < em->start || start + len > extent_map_end(em) ||
em->start != em->block_start || em->len != em->block_len))
test_msg(
"case3 [0x%llx 0x%llx): ret %d em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx)\n",
test_err(
"case3 [0x%llx 0x%llx): ret %d em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx)",
start, start + len, ret, em->start, em->len,
em->block_start, em->block_len);
free_extent_map(em);
......@@ -290,12 +290,12 @@ static void __test_case_4(struct btrfs_fs_info *fs_info,
em->block_len = SZ_32K;
ret = btrfs_add_extent_mapping(fs_info, em_tree, &em, start, len);
if (ret)
test_msg("case4 [0x%llx 0x%llx): ret %d\n",
test_err("case4 [0x%llx 0x%llx): ret %d",
start, len, ret);
if (em &&
(start < em->start || start + len > extent_map_end(em)))
test_msg(
"case4 [0x%llx 0x%llx): ret %d, added wrong em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx)\n",
test_err(
"case4 [0x%llx 0x%llx): ret %d, added wrong em (start 0x%llx len 0x%llx block_start 0x%llx block_len 0x%llx)",
start, len, ret, em->start, em->len, em->block_start,
em->block_len);
free_extent_map(em);
......@@ -341,7 +341,7 @@ 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");
test_msg("running extent_map tests\n");
/*
* Note: the fs_info is not set up completely, we only need
......
This diff is collapsed.
......@@ -32,7 +32,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans,
info = search_free_space_info(trans, fs_info, cache, path, 0);
if (IS_ERR(info)) {
test_msg("Could not find free space info\n");
test_err("could not find free space info");
ret = PTR_ERR(info);
goto out;
}
......@@ -40,7 +40,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans,
extent_count = btrfs_free_space_extent_count(path->nodes[0], info);
if (extent_count != num_extents) {
test_msg("Extent count is wrong\n");
test_err("extent count is wrong");
ret = -EINVAL;
goto out;
}
......@@ -99,7 +99,7 @@ static int __check_free_space_extents(struct btrfs_trans_handle *trans,
btrfs_release_path(path);
return ret;
invalid:
test_msg("Free space tree is invalid\n");
test_err("free space tree is invalid");
ret = -EINVAL;
goto out;
}
......@@ -117,7 +117,7 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
info = search_free_space_info(trans, fs_info, cache, path, 0);
if (IS_ERR(info)) {
test_msg("Could not find free space info\n");
test_err("could not find free space info");
btrfs_release_path(path);
return PTR_ERR(info);
}
......@@ -133,13 +133,13 @@ static int check_free_space_extents(struct btrfs_trans_handle *trans,
if (flags & BTRFS_FREE_SPACE_USING_BITMAPS) {
ret = convert_free_space_to_extents(trans, cache, path);
if (ret) {
test_msg("Could not convert to extents\n");
test_err("could not convert to extents");
return ret;
}
} else {
ret = convert_free_space_to_bitmaps(trans, cache, path);
if (ret) {
test_msg("Could not convert to bitmaps\n");
test_err("could not convert to bitmaps");
return ret;
}
}
......@@ -174,7 +174,7 @@ static int test_remove_all(struct btrfs_trans_handle *trans,
cache->key.objectid,
cache->key.offset);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
......@@ -197,7 +197,7 @@ static int test_remove_beginning(struct btrfs_trans_handle *trans,
ret = __remove_from_free_space_tree(trans, cache, path,
cache->key.objectid, alignment);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
......@@ -222,7 +222,7 @@ static int test_remove_end(struct btrfs_trans_handle *trans,
cache->key.offset - alignment,
alignment);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
......@@ -247,7 +247,7 @@ static int test_remove_middle(struct btrfs_trans_handle *trans,
cache->key.objectid + alignment,
alignment);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
......@@ -270,14 +270,14 @@ static int test_merge_left(struct btrfs_trans_handle *trans,
cache->key.objectid,
cache->key.offset);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -285,7 +285,7 @@ static int test_merge_left(struct btrfs_trans_handle *trans,
cache->key.objectid + alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -308,7 +308,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
cache->key.objectid,
cache->key.offset);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
......@@ -316,7 +316,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -324,7 +324,7 @@ static int test_merge_right(struct btrfs_trans_handle *trans,
cache->key.objectid + alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -347,14 +347,14 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
cache->key.objectid,
cache->key.offset);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -362,7 +362,7 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -370,7 +370,7 @@ static int test_merge_both(struct btrfs_trans_handle *trans,
cache->key.objectid + alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -395,14 +395,14 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
cache->key.objectid,
cache->key.offset);
if (ret) {
test_msg("Could not remove free space\n");
test_err("could not remove free space");
return ret;
}
ret = __add_to_free_space_tree(trans, cache, path, cache->key.objectid,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -410,7 +410,7 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
cache->key.objectid + 4 * alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -418,7 +418,7 @@ static int test_merge_none(struct btrfs_trans_handle *trans,
cache->key.objectid + 2 * alignment,
alignment);
if (ret) {
test_msg("Could not add free space\n");
test_err("could not add free space");
return ret;
}
......@@ -444,14 +444,14 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
if (!fs_info) {
test_msg("Couldn't allocate dummy fs info\n");
test_err("couldn't allocate dummy fs info");
ret = -ENOMEM;
goto out;
}
root = btrfs_alloc_dummy_root(fs_info);
if (IS_ERR(root)) {
test_msg("Couldn't allocate dummy root\n");
test_err("couldn't allocate dummy root");
ret = PTR_ERR(root);
goto out;
}
......@@ -463,7 +463,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
root->node = alloc_test_extent_buffer(root->fs_info, nodesize);
if (!root->node) {
test_msg("Couldn't allocate dummy buffer\n");
test_err("couldn't allocate dummy buffer");
ret = -ENOMEM;
goto out;
}
......@@ -473,7 +473,7 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
cache = btrfs_alloc_dummy_block_group(fs_info, 8 * alignment);
if (!cache) {
test_msg("Couldn't allocate dummy block group cache\n");
test_err("couldn't allocate dummy block group cache");
ret = -ENOMEM;
goto out;
}
......@@ -486,21 +486,21 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
path = btrfs_alloc_path();
if (!path) {
test_msg("Couldn't allocate path\n");
test_err("couldn't allocate path");
ret = -ENOMEM;
goto out;
}
ret = add_block_group_free_space(&trans, cache);
if (ret) {
test_msg("Could not add block group free space\n");
test_err("could not add block group free space");
goto out;
}
if (bitmaps) {
ret = convert_free_space_to_bitmaps(&trans, cache, path);
if (ret) {
test_msg("Could not convert block group to bitmaps\n");
test_err("could not convert block group to bitmaps");
goto out;
}
}
......@@ -511,12 +511,12 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
ret = remove_block_group_free_space(&trans, cache);
if (ret) {
test_msg("Could not remove block group free space\n");
test_err("could not remove block group free space");
goto out;
}
if (btrfs_header_nritems(root->node) != 0) {
test_msg("Free space tree has leftover items\n");
test_err("free space tree has leftover items");
ret = -EINVAL;
goto out;
}
......@@ -538,14 +538,16 @@ static int run_test_both_formats(test_func_t test_func, u32 sectorsize,
ret = run_test(test_func, 0, sectorsize, nodesize, alignment);
if (ret) {
test_msg("%pf failed with extents, sectorsize=%u, nodesize=%u, alignment=%u\n",
test_err(
"%pf failed with extents, sectorsize=%u, nodesize=%u, alignment=%u",
test_func, sectorsize, nodesize, alignment);
test_ret = ret;
}
ret = run_test(test_func, 1, sectorsize, nodesize, alignment);
if (ret) {
test_msg("%pf failed with bitmaps, sectorsize=%u, nodesize=%u, alignment=%u\n",
test_err(
"%pf failed with bitmaps, sectorsize=%u, nodesize=%u, alignment=%u",
test_func, sectorsize, nodesize, alignment);
test_ret = ret;
}
......@@ -576,7 +578,7 @@ int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize)
*/
bitmap_alignment = BTRFS_FREE_SPACE_BITMAP_BITS * PAGE_SIZE;
test_msg("Running free space tree tests\n");
test_msg("running free space tree tests\n");
for (i = 0; i < ARRAY_SIZE(tests); i++) {
int ret;
......
This diff is collapsed.
This diff is collapsed.
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