From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2] btrfs: Introduce new tree block flag, BTRFS_HEADER_FLAG_LOG
Date: Tue, 19 Mar 2019 14:04:18 +0800 [thread overview]
Message-ID: <20190319060418.29575-2-wqu@suse.com> (raw)
In-Reply-To: <20190319060418.29575-1-wqu@suse.com>
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@suse.com>
---
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
next prev parent reply other threads:[~2019-03-19 6:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 6:04 [PATCH 1/2] btrfs: Make btrfs_(set|clear)_header_flag return void Qu Wenruo
2019-03-19 6:04 ` Qu Wenruo [this message]
2019-03-19 7:04 ` [PATCH 2/2] btrfs: Introduce new tree block flag, BTRFS_HEADER_FLAG_LOG Nikolay Borisov
2019-03-19 7:10 ` Qu Wenruo
2019-03-19 13:52 ` Qu Wenruo
2019-03-19 18:23 ` David Sterba
2019-03-20 0:54 ` Qu Wenruo
2019-03-19 6:51 ` [PATCH 1/2] btrfs: Make btrfs_(set|clear)_header_flag return void Nikolay Borisov
2019-03-19 18:05 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190319060418.29575-2-wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.