* [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item
@ 2022-03-07 22:36 Josef Bacik
2022-03-07 22:36 ` [PATCH 01/11] btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers Josef Bacik
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Hello,
This is the next series of changes for extent tree v2. This adds support for
the snapshot_id to the btrfs_header and btrfs_root_item. This will allow us to
track shared blocks more simply without requiring a lot of reference updates.
There are also a few extra patches tacked onto the end to add some more testing.
Since we're changing the size of the btrfs_header I wanted to get as much
coverage as possible on the different ways we modify leaves and nodes so I added
another selftest and added support for running the selftests with extent tree v2
set.
Thanks,
Josef
Josef Bacik (11):
btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers
btrfs: add global_tree_id to btrfs_root_item
btrfs: add snapshot_id to the btrfs_root_item
btrfs: handle the new snapshot_id field properly
btrfs: add a sanity checker for the header flags
btrfs: zero dummy extent buffers
btrfs: zero out temporary superblock buffer header
btrfs: add a debug range check for header_v2
btrfs: selftests: add a test for delete_one_dir_name
btrfs: don't do the global_id thing if we are a DUMMY_FS_INFO
btrfs: selftests: run with EXTENT_TREE_V2 set as well
fs/btrfs/ctree.c | 13 +-
fs/btrfs/ctree.h | 14 +-
fs/btrfs/disk-io.c | 4 +
fs/btrfs/extent-tree.c | 7 +
fs/btrfs/extent_io.c | 22 +++
fs/btrfs/tests/btrfs-tests.c | 77 +++++++----
fs/btrfs/tests/btrfs-tests.h | 18 ++-
fs/btrfs/tests/extent-buffer-tests.c | 181 ++++++++++++++++++++++++-
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 +-
fs/btrfs/tree-checker.c | 27 ++++
fs/btrfs/volumes.c | 2 +
include/uapi/linux/btrfs_tree.h | 12 +-
17 files changed, 376 insertions(+), 69 deletions(-)
--
2.26.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 01/11] btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 02/11] btrfs: add global_tree_id to btrfs_root_item Josef Bacik
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
The size of the header is slightly larger for _V2, so return the
appropriate offset if the header has _V2 set.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index ec77871ad839..b1cc1d34944a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2073,6 +2073,9 @@ BTRFS_SETGET_STACK_FUNCS(stack_key_generation, struct btrfs_key_ptr,
static inline unsigned long btrfs_node_key_ptr_offset(const struct extent_buffer *eb,
int nr)
{
+ if (btrfs_header_flag(eb, BTRFS_HEADER_FLAG_V2))
+ return offsetof(struct btrfs_node_v2, ptrs) +
+ sizeof(struct btrfs_key_ptr) * nr;
return offsetof(struct btrfs_node, ptrs) +
sizeof(struct btrfs_key_ptr) * nr;
}
@@ -2128,6 +2131,9 @@ BTRFS_SETGET_STACK_FUNCS(stack_item_size, struct btrfs_item, size, 32);
static inline unsigned long btrfs_item_nr_offset(const struct extent_buffer *eb,
int nr)
{
+ if (btrfs_header_flag(eb, BTRFS_HEADER_FLAG_V2))
+ return offsetof(struct btrfs_leaf_v2, items) +
+ sizeof(struct btrfs_item) * nr;
return offsetof(struct btrfs_leaf, items) +
sizeof(struct btrfs_item) * nr;
}
@@ -2187,12 +2193,14 @@ static inline void btrfs_set_item_key(struct extent_buffer *eb,
static inline u32 BTRFS_LEAF_DATA_SIZE(const struct btrfs_fs_info *info)
{
+ if (btrfs_fs_incompat(info, EXTENT_TREE_V2))
+ return info->nodesize - sizeof(struct btrfs_header_v2);
return info->nodesize - sizeof(struct btrfs_header);
}
static inline unsigned long BTRFS_LEAF_DATA_OFFSET(const struct extent_buffer *leaf)
{
- return offsetof(struct btrfs_leaf, items);
+ return btrfs_item_nr_offset(leaf, 0);
}
static inline u32 BTRFS_MAX_ITEM_SIZE(const struct btrfs_fs_info *info)
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 02/11] btrfs: add global_tree_id to btrfs_root_item
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
2022-03-07 22:36 ` [PATCH 01/11] btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 03/11] btrfs: add snapshot_id to the btrfs_root_item Josef Bacik
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This is something Dave asked for in case we want to limit a subvolume to
a set of global roots.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 2 ++
include/uapi/linux/btrfs_tree.h | 6 +++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index b1cc1d34944a..222c5dda9079 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2412,6 +2412,8 @@ BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item,
stransid, 64);
BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
rtransid, 64);
+BTRFS_SETGET_STACK_FUNCS(root_global_tree_id, struct btrfs_root_item,
+ global_tree_id, 64);
static inline bool btrfs_root_readonly(const struct btrfs_root *root)
{
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index 92760ea4b448..cd62ca1950cb 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -682,7 +682,11 @@ struct btrfs_root_item {
struct btrfs_timespec otime;
struct btrfs_timespec stime;
struct btrfs_timespec rtime;
- __le64 reserved[8]; /* for future */
+
+ /* If we want to use a specific set of global roots for this root. */
+ __le64 global_tree_id;
+
+ __le64 reserved[7]; /* for future */
} __attribute__ ((__packed__));
/*
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 03/11] btrfs: add snapshot_id to the btrfs_root_item
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
2022-03-07 22:36 ` [PATCH 01/11] btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers Josef Bacik
2022-03-07 22:36 ` [PATCH 02/11] btrfs: add global_tree_id to btrfs_root_item Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 04/11] btrfs: handle the new snapshot_id field properly Josef Bacik
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
This will be incremented on every snapshot in order to keep track of
which blocks belong to which snapshots.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.h | 2 ++
include/uapi/linux/btrfs_tree.h | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 222c5dda9079..6f446cdf05c2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2414,6 +2414,8 @@ BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item,
rtransid, 64);
BTRFS_SETGET_STACK_FUNCS(root_global_tree_id, struct btrfs_root_item,
global_tree_id, 64);
+BTRFS_SETGET_STACK_FUNCS(root_snapshot_id, struct btrfs_root_item,
+ snapshot_id, 64);
static inline bool btrfs_root_readonly(const struct btrfs_root *root)
{
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index cd62ca1950cb..91dd7feae9aa 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -686,7 +686,13 @@ struct btrfs_root_item {
/* If we want to use a specific set of global roots for this root. */
__le64 global_tree_id;
- __le64 reserved[7]; /* for future */
+ /*
+ * The current snapshot id of this root, increases every time we are
+ * snapshotted.
+ */
+ __le64 snapshot_id;
+
+ __le64 reserved[6]; /* for future */
} __attribute__ ((__packed__));
/*
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 04/11] btrfs: handle the new snapshot_id field properly
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (2 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 03/11] btrfs: add snapshot_id to the btrfs_root_item Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 05/11] btrfs: add a sanity checker for the header flags Josef Bacik
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
With new blocks we'll be setting the snapshot_id to the root's current
snapshot_id. The COW rules are extended to make sure that if the
block's snapshot_id is < the root's snapshot_id we know we need to cow
the block.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/ctree.c | 13 ++++++++++++-
fs/btrfs/extent-tree.c | 7 +++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 6e8c02eec548..e634eeab89a7 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -521,6 +521,16 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
return 0;
}
+static inline bool should_cow_block_v2(struct btrfs_root *root,
+ struct extent_buffer *buf)
+{
+ if (btrfs_header_flag(buf, BTRFS_HEADER_FLAG_V2) &&
+ (btrfs_root_snapshot_id(&root->root_item) >
+ btrfs_header_snapshot_id(buf)))
+ return true;
+ return false;
+}
+
static inline int should_cow_block(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct extent_buffer *buf)
@@ -546,7 +556,8 @@ static inline int should_cow_block(struct btrfs_trans_handle *trans,
!btrfs_header_flag(buf, BTRFS_HEADER_FLAG_WRITTEN) &&
!(root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID &&
btrfs_header_flag(buf, BTRFS_HEADER_FLAG_RELOC)) &&
- !test_bit(BTRFS_ROOT_FORCE_COW, &root->state))
+ !test_bit(BTRFS_ROOT_FORCE_COW, &root->state) &&
+ !should_cow_block_v2(root, buf))
return 0;
return 1;
}
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 309d8753bf41..504c6f152780 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4874,6 +4874,13 @@ btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root,
btrfs_set_header_owner(buf, owner);
write_extent_buffer_fsid(buf, fs_info->fs_devices->metadata_uuid);
write_extent_buffer_chunk_tree_uuid(buf, fs_info->chunk_tree_uuid);
+
+ if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
+ btrfs_set_header_snapshot_id(buf,
+ btrfs_root_snapshot_id(&root->root_item));
+ btrfs_set_header_flag(buf, BTRFS_HEADER_FLAG_V2);
+ }
+
if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) {
buf->log_index = root->log_transid % 2;
/*
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 05/11] btrfs: add a sanity checker for the header flags
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (3 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 04/11] btrfs: handle the new snapshot_id field properly Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 06/11] btrfs: zero dummy extent buffers Josef Bacik
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Make sure that we don't have HEADER_FLAG_V2 set on !V2 file systems, but
we do have it set on V2 file systems.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/tree-checker.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index f0aabda9fd94..41b7fbf67e97 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -1578,6 +1578,27 @@ static int check_inode_ref(struct extent_buffer *leaf,
return 0;
}
+static int check_header_flags(struct extent_buffer *buf)
+{
+ struct btrfs_fs_info *fs_info = buf->fs_info;
+
+ if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
+ if (unlikely(!btrfs_header_flag(buf, BTRFS_HEADER_FLAG_V2))) {
+ generic_err(buf, 0,
+ "no HEADER_FLAG_V2 set on a V2 file system");
+ return -EUCLEAN;
+ }
+ } else {
+ if (unlikely(btrfs_header_flag(buf, BTRFS_HEADER_FLAG_V2))) {
+ generic_err(buf, 0,
+ "have HEADER_FLAG_V2 set on a !V2 file system");
+ return -EUCLEAN;
+ }
+ }
+
+ return 0;
+}
+
/*
* Common point to switch the item-specific validation.
*/
@@ -1644,6 +1665,9 @@ static int check_leaf(struct extent_buffer *leaf, bool check_item_data)
u32 nritems = btrfs_header_nritems(leaf);
int slot;
+ if (unlikely(check_header_flags(leaf)))
+ return -EUCLEAN;
+
if (unlikely(btrfs_header_level(leaf) != 0)) {
generic_err(leaf, 0,
"invalid level for leaf, have %d expect 0",
@@ -1807,6 +1831,9 @@ int btrfs_check_node(struct extent_buffer *node)
u64 bytenr;
int ret = 0;
+ if (unlikely(check_header_flags(node)))
+ return -EUCLEAN;
+
if (unlikely(level <= 0 || level >= BTRFS_MAX_LEVEL)) {
generic_err(node, 0,
"invalid level for node, have %d expect [1, %d]",
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 06/11] btrfs: zero dummy extent buffers
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (4 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 05/11] btrfs: add a sanity checker for the header flags Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 07/11] btrfs: zero out temporary superblock buffer header Josef Bacik
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
Our self tests allocate dummy extent buffers to test a variety of
things, however these eb's are very lightly initialized. This causes
problems with the extent tree v2 stuff as we will read the header flags
and could have the V2 flag set and thus do the wrong thing. Fix this by
zero'ing out the header of any dummy extent buffers we allocate.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/extent_io.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 951b2e0e0df1..31309aba3344 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -5960,6 +5960,7 @@ struct extent_buffer *__alloc_dummy_extent_buffer(struct btrfs_fs_info *fs_info,
set_extent_buffer_uptodate(eb);
btrfs_set_header_nritems(eb, 0);
set_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
+ memzero_extent_buffer(eb, 0, sizeof(struct btrfs_header));
return eb;
err:
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 07/11] btrfs: zero out temporary superblock buffer header
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (5 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 06/11] btrfs: zero dummy extent buffers Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 08/11] btrfs: add a debug range check for header_v2 Josef Bacik
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
We use HEADER_FLAG_V2 to determine different offsets into the buffer, so
we need to make sure that we clear the header of the temporary
extent_buffer we allocate to read the super block in, otherwise we could
have this flag set and do the wrong math for the different item helpers.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/volumes.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 1be7cb2f955f..fc2d3db8e539 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7403,6 +7403,8 @@ int btrfs_read_sys_array(struct btrfs_fs_info *fs_info)
if (IS_ERR(sb))
return PTR_ERR(sb);
set_extent_buffer_uptodate(sb);
+ memzero_extent_buffer(sb, 0, sizeof(struct btrfs_header));
+
/*
* The sb extent buffer is artificial and just used to read the system array.
* set_extent_buffer_uptodate() call does not properly mark all it's
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 08/11] btrfs: add a debug range check for header_v2
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (6 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 07/11] btrfs: zero out temporary superblock buffer header Josef Bacik
@ 2022-03-07 22:36 ` Josef Bacik
2022-03-07 22:36 ` [PATCH 09/11] btrfs: selftests: add a test for delete_one_dir_name Josef Bacik
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Josef Bacik @ 2022-03-07 22:36 UTC (permalink / raw)
To: linux-btrfs, kernel-team
There's a few places where we modify the extent buffer data that I
missed in my initial conversion. This check helped me catch the places
I missed. Simply check to see if the eb has FLAG_V2 set and then make
sure we're not overlapping access with the header_v2. This will go away
in the future, but is handy while I'm working on the code.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/extent_io.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 31309aba3344..88dc53595192 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -6736,6 +6736,25 @@ static inline int check_eb_range(const struct extent_buffer *eb,
if (unlikely(check_add_overflow(start, len, &offset) || offset > eb->len))
return report_eb_range(eb, start, len);
+#ifdef CONFIG_BTRFS_DEBUG
+ /*
+ * Catch places where we may have the wrong header math, this can go
+ * away later.
+ */
+ if (btrfs_header_flag(eb, BTRFS_HEADER_FLAG_V2)) {
+ if (start >= sizeof(struct btrfs_header_v2))
+ return false;
+ if (start == 0 && len == eb->len)
+ return false;
+ if (start + len > sizeof(struct btrfs_header_v2)) {
+ btrfs_warn(eb->fs_info,
+ "access overlaps the header_v2 on eb %llu start %lu len %lu",
+ eb->start, start, len);
+ return true;
+ }
+ }
+#endif
+
return false;
}
--
2.26.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [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 10/11] btrfs: don't do the global_id thing if we are a DUMMY_FS_INFO
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
` (8 preceding siblings ...)
2022-03-07 22:36 ` [PATCH 09/11] btrfs: selftests: add a test for delete_one_dir_name Josef Bacik
@ 2022-03-07 22:37 ` 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:37 UTC (permalink / raw)
To: linux-btrfs, kernel-team
I want to use extent tree v2 in our self tests to make sure the extent
buffer related tests all do the correct thing, which requires setting
BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 on the fs_info. However we won't
be having per-block group global roots for the dummy fs_info, so add
another check to btrfs_global_root_id to bail if we have DUMMY set.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
fs/btrfs/disk-io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index c4e9d69ed672..00e97156101b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1308,6 +1308,10 @@ static u64 btrfs_global_root_id(struct btrfs_fs_info *fs_info, u64 bytenr)
struct btrfs_block_group *block_group;
u64 ret;
+#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
+ if (test_bit(BTRFS_FS_STATE_DUMMY_FS_INFO, &fs_info->fs_state))
+ return 0;
+#endif
if (!btrfs_fs_incompat(fs_info, EXTENT_TREE_V2))
return 0;
--
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
end of thread, other threads:[~2022-03-07 22:37 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-07 22:36 [PATCH 00/11] btrfs: add snapshot_id to btrfs_header and root_item Josef Bacik
2022-03-07 22:36 ` [PATCH 01/11] btrfs: take into account BTRFS_HEADER_FLAG_V2 in the item/node helpers Josef Bacik
2022-03-07 22:36 ` [PATCH 02/11] btrfs: add global_tree_id to btrfs_root_item Josef Bacik
2022-03-07 22:36 ` [PATCH 03/11] btrfs: add snapshot_id to the btrfs_root_item Josef Bacik
2022-03-07 22:36 ` [PATCH 04/11] btrfs: handle the new snapshot_id field properly Josef Bacik
2022-03-07 22:36 ` [PATCH 05/11] btrfs: add a sanity checker for the header flags Josef Bacik
2022-03-07 22:36 ` [PATCH 06/11] btrfs: zero dummy extent buffers Josef Bacik
2022-03-07 22:36 ` [PATCH 07/11] btrfs: zero out temporary superblock buffer header Josef Bacik
2022-03-07 22:36 ` [PATCH 08/11] btrfs: add a debug range check for header_v2 Josef Bacik
2022-03-07 22:36 ` [PATCH 09/11] btrfs: selftests: add a test for delete_one_dir_name 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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox