* [PATCH 09/11] btrfs: selftests: add a test for delete_one_dir_name
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (7 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 08/11] btrfs: add a debug range check for header_v2 Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:37 ` [PATCH 10/11] btrfs: don't do the global_id thing if we are a DUMMY_FS_INFO Josef Bacik
2022-03-07 22:37 ` [PATCH 11/11] btrfs: selftests: run with EXTENT_TREE_V2 set as well Josef Bacik
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Because I can't do simple math I was convinced btrfs_delete_one_dir_name
was doing the wrong thing, so I wrote a self test to validate my theory.
I turned out to be wrong, but it's a valuable test to have for the
future.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/tests/extent-buffer-tests.c | 170 ++++++++++++++++++++++++++-
1 file changed, 169 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/tests/extent-buffer-tests.c b/fs/btrfs/tests/extent-buffer-tests.c
index 51a8b075c259..131495ffad12 100644
--- a/fs/btrfs/tests/extent-buffer-tests.c
+++ b/fs/btrfs/tests/extent-buffer-tests.c
@@ -8,6 +8,7 @@
#include "../ctree.h"
#include "../extent_io.h"
#include "../disk-io.h"
+#include "../transaction.h"
static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
{
@@ -210,8 +211,175 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
return ret;
}
+static int test_delete_one_dir_name(u32 sectorsize, u32 nodesize)
+{
+ struct btrfs_fs_info *fs_info;
+ struct btrfs_path *path = NULL;
+ struct btrfs_root *root = NULL;
+ struct extent_buffer *eb;
+ struct btrfs_dir_item *dir_item;
+ char *ptr;
+ struct btrfs_trans_handle trans;
+ char name_buf[6];
+ struct btrfs_key key;
+ u32 len = 0;
+ int ret = 0;
+ int i;
+
+ test_msg("running btrfs_delete_one_dir_name tests");
+
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ if (!fs_info) {
+ test_std_err(TEST_ALLOC_FS_INFO);
+ return -ENOMEM;
+ }
+
+ root = btrfs_alloc_dummy_root(fs_info);
+ if (IS_ERR(root)) {
+ test_std_err(TEST_ALLOC_ROOT);
+ ret = PTR_ERR(root);
+ goto out;
+ }
+
+ path = btrfs_alloc_path();
+ if (!path) {
+ test_std_err(TEST_ALLOC_PATH);
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ path->nodes[0] = eb = alloc_dummy_extent_buffer(fs_info, nodesize);
+ if (!eb) {
+ test_std_err(TEST_ALLOC_EXTENT_BUFFER);
+ ret = -ENOMEM;
+ goto out;
+ }
+ path->slots[0] = 0;
+
+ key.objectid = 0;
+ key.type = BTRFS_DIR_ITEM_KEY;
+ key.offset = 0;
+
+ btrfs_init_dummy_trans(&trans, fs_info);
+
+ /*
+ * We are going to have 5 names, a, bb, ccc, dddd, eeeee, so the sizes
+ * are the dir_item + i + 1.
+ */
+ for (i = 0; i < 5; i++)
+ len += sizeof(struct btrfs_dir_item) + i + 1;
+
+ btrfs_setup_item_for_insert(root, path, &key, len);
+
+ ptr = btrfs_item_ptr(eb, path->slots[0], char);
+ for (i = 0; i < 5; i++) {
+ unsigned long name_ptr;
+
+ memset(name_buf, 'a' + i, i + 1);
+ dir_item = (struct btrfs_dir_item *)ptr;
+ btrfs_set_dir_type(eb, dir_item, i);
+ btrfs_set_dir_data_len(eb, dir_item, 0);
+ btrfs_set_dir_name_len(eb, dir_item, i + 1);
+ name_ptr = (unsigned long)(dir_item + 1);
+ write_extent_buffer(eb, name_buf, name_ptr, i + 1);
+ ptr += sizeof(struct btrfs_dir_item) + i + 1;
+ }
+
+ if (btrfs_item_size(eb, 0) != len) {
+ test_err("invalid len after initial start up");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ /* Delete the ccc dir_name */
+ ptr = btrfs_item_ptr(eb, path->slots[0], char);
+ for (i = 0; i < 2; i++)
+ ptr += sizeof(struct btrfs_dir_item) + i + 1;
+ dir_item = (struct btrfs_dir_item *)ptr;
+ if (btrfs_dir_type(eb, dir_item) != 2) {
+ test_err("got the wrong dir type???\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ret = btrfs_delete_one_dir_name(&trans, root, path, dir_item);
+ if (ret) {
+ test_err("got %d from btrfs_delete_one_dir_name", ret);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ len -= sizeof(struct btrfs_dir_item) + 3;
+ if (btrfs_item_size(eb, 0) != len) {
+ test_err("invalid len after delete");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ ptr = btrfs_item_ptr(eb, path->slots[0], char);
+ for (i = 0; i < 4; i++) {
+ int real_index = i;
+ int c;
+
+ /*
+ * We deleted ccc, which was index 2, so increase real_index by
+ * 1 so we get the right value.
+ */
+ if (i >= 2)
+ real_index++;
+
+ dir_item = (struct btrfs_dir_item *)ptr;
+ if (btrfs_dir_type(eb, dir_item) != real_index) {
+ test_err("dir item %d is mangled, dir_type is %d expected %d",
+ i, btrfs_dir_type(eb, dir_item), real_index);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (btrfs_dir_data_len(eb, dir_item) != 0) {
+ test_err("dir item %d is mangled, data_len is %d expected 0",
+ i, btrfs_dir_data_len(eb, dir_item));
+ ret = -EINVAL;
+ goto out;
+ }
+
+ if (btrfs_dir_name_len(eb, dir_item) != real_index + 1) {
+ test_err("dir item %d is mangled, name_len is %d expected %d",
+ i, btrfs_dir_name_len(eb, dir_item),
+ real_index + 1);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ read_extent_buffer(eb, name_buf, (unsigned long)(dir_item + 1),
+ btrfs_dir_name_len(eb, dir_item));
+ for (c = 0; c < real_index + 1; c++) {
+ if (name_buf[c] != 'a' + real_index) {
+ test_err(
+ "dir item name %d is mangled, index is %d val is %c wanted %c",
+ i, c, name_buf[c], 'a' + real_index);
+ ret = -EINVAL;
+ goto out;
+ }
+ }
+
+ ptr += sizeof(struct btrfs_dir_item) + real_index + 1;
+ }
+out:
+ btrfs_free_path(path);
+ btrfs_free_dummy_root(root);
+ btrfs_free_dummy_fs_info(fs_info);
+ return ret;
+}
+
int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize)
{
+ int ret;
+
test_msg("running extent buffer operation tests");
- return test_btrfs_split_item(sectorsize, nodesize);
+ ret = test_btrfs_split_item(sectorsize, nodesize);
+ if (ret)
+ return ret;
+ test_msg("running delete dir name etests");
+ return test_delete_one_dir_name(sectorsize, nodesize);
}
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 11/11] btrfs: selftests: run with EXTENT_TREE_V2 set as well
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (9 preceding siblings ...)
2022-03-07 22:37 ` [PATCH 10/11] btrfs: don't do the global_id thing if we are a DUMMY_FS_INFO Josef Bacik
@ 2022-03-07 22:37 ` Josef Bacik
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:37 UTC (permalink / raw)
To: linux-btrfs, kernel-team
With the btrfs header change I wanted to validate that the math worked
out properly. To do this I modified the tests to also test with
EXTENT_TREE_V2 set and without. This requires passing the incompat
flags throughout the stack which is why this looks so churny. Finally
with the flag set on the fs_info we can allocate dummy extent buffers
with the HEADER_FLAG_V2 set on them to get the correct math.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
with '#' will be ignored, and an empty message aborts the commit.
---
fs/btrfs/extent_io.c | 2 +
fs/btrfs/tests/btrfs-tests.c | 77 ++++++++++++++++----------
fs/btrfs/tests/btrfs-tests.h | 18 +++---
fs/btrfs/tests/extent-buffer-tests.c | 19 ++++---
fs/btrfs/tests/extent-io-tests.c | 9 +--
fs/btrfs/tests/extent-map-tests.c | 2 +-
fs/btrfs/tests/free-space-tests.c | 6 +-
fs/btrfs/tests/free-space-tree-tests.c | 21 ++++---
fs/btrfs/tests/inode-tests.c | 25 +++++----
fs/btrfs/tests/qgroup-tests.c | 5 +-
10 files changed, 115 insertions(+), 69 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 88dc53595192..c7088c4ad305 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5961,6 +5961,8 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
btrfs_set_header_nritems(eb, 0);
set_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
memzero_extent_buffer(eb, 0, sizeof(struct btrfs_header));
+ if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
+ btrfs_set_header_flag(eb, BTRFS_HEADER_FLAG_V2);
return eb;
err:
diff --git a/fs/btrfs/tests/btrfs-tests.c b/fs/btrfs/tests/btrfs-tests.c
index d8e56edd6991..ad19739d677d 100644
--- a/fs/btrfs/tests/btrfs-tests.c
+++ b/fs/btrfs/tests/btrfs-tests.c
@@ -113,7 +113,8 @@ static void btrfs_free_dummy_device(struct btrfs_device *dev)
kfree(dev);
}
-struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
+struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info = kzalloc(sizeof(struct btrfs_fs_info),
GFP_KERNEL);
@@ -142,6 +143,7 @@ struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize)
fs_info->sectorsize = sectorsize;
fs_info->sectorsize_bits = ilog2(sectorsize);
set_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state);
+ btrfs_set_super_incompat_flags(fs_info->super_copy, incompat_flags);
test_mnt->mnt_sb->s_fs_info = fs_info;
@@ -256,42 +258,61 @@ void btrfs_init_dummy_trans(struct btrfs_trans_handle *trans,
trans->fs_info = fs_info;
}
+static int run_sectorsize_tests(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
+{
+ int ret;
+
+ pr_info("BTRFS: selftest: sectorsize: %u nodesize: %u incompat_flags: %llu\n",
+ sectorsize, nodesize, incompat_flags);
+ ret = btrfs_test_free_space_cache(sectorsize, nodesize, incompat_flags);
+ if (ret)
+ return ret;
+ ret = btrfs_test_extent_buffer_operations(sectorsize, nodesize,
+ incompat_flags);
+ if (ret)
+ return ret;
+ ret = btrfs_test_extent_io(sectorsize, nodesize, incompat_flags);
+ if (ret)
+ return ret;
+ ret = btrfs_test_inodes(sectorsize, nodesize, incompat_flags);
+ if (ret)
+ return ret;
+ ret = btrfs_test_qgroups(sectorsize, nodesize, incompat_flags);
+ if (ret)
+ return ret;
+ return btrfs_test_free_space_tree(sectorsize, nodesize, incompat_flags);
+}
+
int btrfs_run_sanity_tests(void)
{
- int ret, i;
+ int ret, i, c;
u32 sectorsize, nodesize;
u32 test_sectorsize[] = {
PAGE_SIZE,
};
+ u64 test_incompat_flags[] = {
+ 0,
+ BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2,
+ };
+ u64 flags;
+
ret = btrfs_init_test_fs();
if (ret)
return ret;
- for (i = 0; i < ARRAY_SIZE(test_sectorsize); i++) {
- sectorsize = test_sectorsize[i];
- for (nodesize = sectorsize;
- nodesize <= BTRFS_MAX_METADATA_BLOCKSIZE;
- nodesize <<= 1) {
- pr_info("BTRFS: selftest: sectorsize: %u nodesize: %u\n",
- sectorsize, nodesize);
- ret = btrfs_test_free_space_cache(sectorsize, nodesize);
- if (ret)
- goto out;
- ret = btrfs_test_extent_buffer_operations(sectorsize,
- nodesize);
- if (ret)
- goto out;
- ret = btrfs_test_extent_io(sectorsize, nodesize);
- if (ret)
- goto out;
- ret = btrfs_test_inodes(sectorsize, nodesize);
- if (ret)
- goto out;
- ret = btrfs_test_qgroups(sectorsize, nodesize);
- if (ret)
- goto out;
- ret = btrfs_test_free_space_tree(sectorsize, nodesize);
- if (ret)
- goto out;
+
+ for (c = 0; c < ARRAY_SIZE(test_incompat_flags); c++) {
+ flags = test_incompat_flags[c];
+ for (i = 0; i < ARRAY_SIZE(test_sectorsize); i++) {
+ sectorsize = test_sectorsize[i];
+ for (nodesize = sectorsize;
+ nodesize <= BTRFS_MAX_METADATA_BLOCKSIZE;
+ nodesize <<= 1) {
+ ret = run_sectorsize_tests(sectorsize, nodesize,
+ flags);
+ if (ret)
+ goto out;
+ }
}
}
ret = btrfs_test_extent_map();
diff --git a/fs/btrfs/tests/btrfs-tests.h b/fs/btrfs/tests/btrfs-tests.h
index 7a2d7ffbe30e..5d02bf83f7f3 100644
--- a/fs/btrfs/tests/btrfs-tests.h
+++ b/fs/btrfs/tests/btrfs-tests.h
@@ -30,15 +30,19 @@ extern const char *test_error[];
struct btrfs_root;
struct btrfs_trans_handle;
-int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize);
-int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize);
-int btrfs_test_extent_io(u32 sectorsize, u32 nodesize);
-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);
+int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags);
+int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags);
+int btrfs_test_extent_io(u32 sectorsize, u32 nodesize, u64 incompat_flags);
+int btrfs_test_inodes(u32 sectorsize, u32 nodesize, u64 incompat_flags);
+int btrfs_test_qgroups(u32 sectorsize, u32 nodesize, u64 incompat_flags);
+int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags);
int btrfs_test_extent_map(void);
struct inode *btrfs_new_test_inode(void);
-struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize);
+struct btrfs_fs_info *btrfs_alloc_dummy_fs_info(u32 nodesize, u32 sectorsize,
+ u64 incompat_flags);
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 *
diff --git a/fs/btrfs/tests/extent-buffer-tests.c b/fs/btrfs/tests/extent-buffer-tests.c
index 131495ffad12..9765638120a7 100644
--- a/fs/btrfs/tests/extent-buffer-tests.c
+++ b/fs/btrfs/tests/extent-buffer-tests.c
@@ -10,7 +10,8 @@
#include "../disk-io.h"
#include "../transaction.h"
-static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
+static int test_btrfs_split_item(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info;
struct btrfs_path *path = NULL;
@@ -28,7 +29,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
test_msg("running btrfs_split_item tests");
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
@@ -211,7 +213,8 @@ static int test_btrfs_split_item(u32 sectorsize, u32 nodesize)
return ret;
}
-static int test_delete_one_dir_name(u32 sectorsize, u32 nodesize)
+static int test_delete_one_dir_name(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info;
struct btrfs_path *path = NULL;
@@ -228,7 +231,8 @@ static int test_delete_one_dir_name(u32 sectorsize, u32 nodesize)
test_msg("running btrfs_delete_one_dir_name tests");
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
@@ -372,14 +376,15 @@ static int test_delete_one_dir_name(u32 sectorsize, u32 nodesize)
return ret;
}
-int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize)
+int btrfs_test_extent_buffer_operations(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
int ret;
test_msg("running extent buffer operation tests");
- ret = test_btrfs_split_item(sectorsize, nodesize);
+ ret = test_btrfs_split_item(sectorsize, nodesize, incompat_flags);
if (ret)
return ret;
test_msg("running delete dir name etests");
- return test_delete_one_dir_name(sectorsize, nodesize);
+ return test_delete_one_dir_name(sectorsize, nodesize, incompat_flags);
}
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index a232b15b8021..3c181d26b431 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -426,7 +426,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb,
return 0;
}
-static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
+static int test_eb_bitmaps(u32 sectorsize, u32 nodesize, u64 incompat_flags)
{
struct btrfs_fs_info *fs_info;
unsigned long *bitmap = NULL;
@@ -435,7 +435,8 @@ static int test_eb_bitmaps(u32 sectorsize, u32 nodesize)
test_msg("running extent buffer bitmap tests");
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
@@ -591,7 +592,7 @@ static int test_find_first_clear_extent_bit(void)
return ret;
}
-int btrfs_test_extent_io(u32 sectorsize, u32 nodesize)
+int btrfs_test_extent_io(u32 sectorsize, u32 nodesize, u64 incompat_flags)
{
int ret;
@@ -605,7 +606,7 @@ int btrfs_test_extent_io(u32 sectorsize, u32 nodesize)
if (ret)
goto out;
- ret = test_eb_bitmaps(sectorsize, nodesize);
+ ret = test_eb_bitmaps(sectorsize, nodesize, incompat_flags);
out:
return ret;
}
diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c
index c5b3a631bf4f..74aef02664fc 100644
--- a/fs/btrfs/tests/extent-map-tests.c
+++ b/fs/btrfs/tests/extent-map-tests.c
@@ -596,7 +596,7 @@ int btrfs_test_extent_map(void)
* 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);
+ fs_info = btrfs_alloc_dummy_fs_info(PAGE_SIZE, PAGE_SIZE, 0);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c
index 5930cdcae5cb..f703c9085543 100644
--- a/fs/btrfs/tests/free-space-tests.c
+++ b/fs/btrfs/tests/free-space-tests.c
@@ -1002,7 +1002,8 @@ static int test_bytes_index(struct btrfs_block_group *cache, u32 sectorsize)
return 0;
}
-int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
+int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info;
struct btrfs_block_group *cache;
@@ -1010,7 +1011,8 @@ int btrfs_test_free_space_cache(u32 sectorsize, u32 nodesize)
int ret = -ENOMEM;
test_msg("running btrfs free space cache tests");
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
diff --git a/fs/btrfs/tests/free-space-tree-tests.c b/fs/btrfs/tests/free-space-tree-tests.c
index 13734ed43bfc..a57261136653 100644
--- a/fs/btrfs/tests/free-space-tree-tests.c
+++ b/fs/btrfs/tests/free-space-tree-tests.c
@@ -421,7 +421,7 @@ typedef int (*test_func_t)(struct btrfs_trans_handle *,
u32 alignment);
static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
- u32 nodesize, u32 alignment)
+ u32 nodesize, u32 alignment, u64 incompat_flags)
{
struct btrfs_fs_info *fs_info;
struct btrfs_root *root = NULL;
@@ -430,7 +430,8 @@ 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(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
ret = -ENOMEM;
@@ -522,12 +523,14 @@ static int run_test(test_func_t test_func, int bitmaps, u32 sectorsize,
}
static int run_test_both_formats(test_func_t test_func, u32 sectorsize,
- u32 nodesize, u32 alignment)
+ u32 nodesize, u32 alignment,
+ u64 incompat_flags)
{
int test_ret = 0;
int ret;
- ret = run_test(test_func, 0, sectorsize, nodesize, alignment);
+ ret = run_test(test_func, 0, sectorsize, nodesize, alignment,
+ incompat_flags);
if (ret) {
test_err(
"%ps failed with extents, sectorsize=%u, nodesize=%u, alignment=%u",
@@ -535,7 +538,8 @@ static int run_test_both_formats(test_func_t test_func, u32 sectorsize,
test_ret = ret;
}
- ret = run_test(test_func, 1, sectorsize, nodesize, alignment);
+ ret = run_test(test_func, 1, sectorsize, nodesize, alignment,
+ incompat_flags);
if (ret) {
test_err(
"%ps failed with bitmaps, sectorsize=%u, nodesize=%u, alignment=%u",
@@ -546,7 +550,8 @@ static int run_test_both_formats(test_func_t test_func, u32 sectorsize,
return test_ret;
}
-int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize)
+int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
test_func_t tests[] = {
test_empty_block_group,
@@ -574,12 +579,12 @@ int btrfs_test_free_space_tree(u32 sectorsize, u32 nodesize)
int ret;
ret = run_test_both_formats(tests[i], sectorsize, nodesize,
- sectorsize);
+ sectorsize, incompat_flags);
if (ret)
test_ret = ret;
ret = run_test_both_formats(tests[i], sectorsize, nodesize,
- bitmap_alignment);
+ bitmap_alignment, incompat_flags);
if (ret)
test_ret = ret;
}
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
index cac89c388131..df960a0f96ae 100644
--- a/fs/btrfs/tests/inode-tests.c
+++ b/fs/btrfs/tests/inode-tests.c
@@ -213,7 +213,8 @@ static unsigned long prealloc_only = 0;
static unsigned long compressed_only = 0;
static unsigned long vacancy_only = 0;
-static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
+static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info = NULL;
struct inode *inode = NULL;
@@ -232,7 +233,8 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
return ret;
}
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
goto out;
@@ -814,7 +816,7 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
return ret;
}
-static int test_hole_first(u32 sectorsize, u32 nodesize)
+static int test_hole_first(u32 sectorsize, u32 nodesize, u64 incompat_flags)
{
struct btrfs_fs_info *fs_info = NULL;
struct inode *inode = NULL;
@@ -830,7 +832,8 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
return ret;
}
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
goto out;
@@ -912,7 +915,8 @@ static int test_hole_first(u32 sectorsize, u32 nodesize)
return ret;
}
-static int test_extent_accounting(u32 sectorsize, u32 nodesize)
+static int test_extent_accounting(u32 sectorsize, u32 nodesize,
+ u64 incompat_flags)
{
struct btrfs_fs_info *fs_info = NULL;
struct inode *inode = NULL;
@@ -927,7 +931,8 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
return ret;
}
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
goto out;
@@ -1099,7 +1104,7 @@ static int test_extent_accounting(u32 sectorsize, u32 nodesize)
return ret;
}
-int btrfs_test_inodes(u32 sectorsize, u32 nodesize)
+int btrfs_test_inodes(u32 sectorsize, u32 nodesize, u64 incompat_flags)
{
int ret;
@@ -1108,11 +1113,11 @@ int btrfs_test_inodes(u32 sectorsize, u32 nodesize)
set_bit(EXTENT_FLAG_COMPRESSED, &compressed_only);
set_bit(EXTENT_FLAG_PREALLOC, &prealloc_only);
- ret = test_btrfs_get_extent(sectorsize, nodesize);
+ ret = test_btrfs_get_extent(sectorsize, nodesize, incompat_flags);
if (ret)
return ret;
- ret = test_hole_first(sectorsize, nodesize);
+ ret = test_hole_first(sectorsize, nodesize, incompat_flags);
if (ret)
return ret;
- return test_extent_accounting(sectorsize, nodesize);
+ return test_extent_accounting(sectorsize, nodesize, incompat_flags);
}
diff --git a/fs/btrfs/tests/qgroup-tests.c b/fs/btrfs/tests/qgroup-tests.c
index eee1e4459541..ef42662b2769 100644
--- a/fs/btrfs/tests/qgroup-tests.c
+++ b/fs/btrfs/tests/qgroup-tests.c
@@ -434,14 +434,15 @@ static int test_multiple_refs(struct btrfs_root *root,
return 0;
}
-int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
+int btrfs_test_qgroups(u32 sectorsize, u32 nodesize, u64 incompat_flags)
{
struct btrfs_fs_info *fs_info = NULL;
struct btrfs_root *root;
struct btrfs_root *tmp_root;
int ret = 0;
- fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize);
+ fs_info = btrfs_alloc_dummy_fs_info(nodesize, sectorsize,
+ incompat_flags);
if (!fs_info) {
test_std_err(TEST_ALLOC_FS_INFO);
return -ENOMEM;
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread