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