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 <w...@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