linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/2] btrfs: Populate btrfs_super_block::log_root_transid
Date: Thu,  4 Oct 2018 13:49:49 +0800	[thread overview]
Message-ID: <20181004054950.11651-2-wqu@suse.com> (raw)
In-Reply-To: <20181004054950.11651-1-wqu@suse.com>

We have btrfs_super_block::log_root_transid to record the transid of log
tree root.

However it's never populated and it's always 0, just as the following
dump-super:
 log_root                30572544
 log_root_transid        0
 log_root_level          0

This patch will populate it with log tree root correctly, so the result
will be:
 log_root                30572544
 log_root_transid        6
 log_root_level          0

This won't affect current kernel behavior or btrfs check result as we
already expect log tree root generation always to be super block
genration + 1.

But it could be later used to detect log tree corruption early.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/transaction.c | 1 +
 fs/btrfs/tree-log.c    | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 3b84f5015029..9d4947079aa3 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -2211,6 +2211,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
 
 	btrfs_set_super_log_root(fs_info->super_copy, 0);
 	btrfs_set_super_log_root_level(fs_info->super_copy, 0);
+	btrfs_set_super_log_root_transid(fs_info->super_copy, 0);
 	memcpy(fs_info->super_for_commit, fs_info->super_copy,
 	       sizeof(*fs_info->super_copy));
 
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1650dc44a5e3..3e16e7b54922 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3131,6 +3131,8 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
 				 log_root_tree->node->start);
 	btrfs_set_super_log_root_level(fs_info->super_for_commit,
 				       btrfs_header_level(log_root_tree->node));
+	btrfs_set_super_log_root_transid(fs_info->super_for_commit,
+				btrfs_header_generation(log_root_tree->node));
 
 	log_root_tree->log_transid++;
 	mutex_unlock(&log_root_tree->log_mutex);
-- 
2.19.0


  reply	other threads:[~2018-10-04  5:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04  5:49 [PATCH 0/2] btrfs: btrfs_super_block::log_root_transid related enhancement Qu Wenruo
2018-10-04  5:49 ` Qu Wenruo [this message]
2018-10-04  8:07   ` [PATCH 1/2] btrfs: Populate btrfs_super_block::log_root_transid Anand Jain
2018-10-04  8:28     ` Qu Wenruo
2018-10-11 12:31   ` David Sterba
2018-10-11 12:45     ` Qu Wenruo
2018-10-11 13:11       ` Nikolay Borisov
2018-10-11 13:13         ` Qu Wenruo
2018-10-04  5:49 ` [PATCH 2/2] btrfs: Validate btrfs_super_block::log_root_transid Qu Wenruo
2018-10-04  6:57   ` Nikolay Borisov
2018-10-04  7:30     ` Qu Wenruo
2018-10-11 12:19     ` 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=20181004054950.11651-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).