This new tree block flag is to indicate the tree block belongs to a log
tree.
For btrfs on-disk format, there are several different trees could use
the same owner number:
- ordinary subvolume tree
- log tree for ordinary subvolume
- reloc tree for ordinary subvolume
It's possible to do the backref walk or use the content to determine the
real owner of the tree block.
But backref walk is too expensive, content detection is not reliable.
So adding a new flag to explicitly show the owner of log tree.
Thankfully, tree-checker hasn't checked header flags yet, and there is
no real user for this flag yet.
So we don't need to introduce any compatibility flag for this
modification.
The introduction of this new flag makes tree block owner easier to
distinguish, making life easier for:
- tree checker on log tree
Log tree could contain some items impossible for regular trees
- performance profiler
Now it's much easier to distinguish log tree.
Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
---
fs/btrfs/disk-io.c | 1 +
include/uapi/linux/btrfs_tree.h | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6fe9197f6ee4..8cffdb7789d8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1362,6 +1362,7 @@ static struct btrfs_root *alloc_log_tree(struct btrfs_trans_handle *trans,
return ERR_CAST(leaf);
}
+ btrfs_set_header_flag(leaf, BTRFS_HEADER_FLAG_LOG);
root->node = leaf;
btrfs_mark_buffer_dirty(root->node);
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index e974f4bb5378..d4ef80b702a0 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -447,9 +447,15 @@ struct btrfs_free_space_header {
__le64 num_bitmaps;
} __attribute__ ((__packed__));
+/* Tree/super has written to disk */
#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
+
+/* Tree block which gets relocated */
#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
+/* Tree block which belows to log tree */
+#define BTRFS_HEADER_FLAG_LOG (1ULL << 2)
+
/* Super block flags */
/* Errors detected */
#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
--
2.21.0