From 963188943f8f19ff766b8153ffc54d9a20dd1570 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Tue, 7 Jun 2022 20:01:17 +0800 Subject: [PATCH] btrfs-progs: make btrfs_super_block::log_root_transid deprecated This is the same on-disk format update synchronized from the kernel code. Unlike kernel, there are two callers reading this member: - btrfs inspect dump-super It's just printing the value, add a notice about deprecation. - btrfs-find-root In that case, since we always got 0, the root search for log root should never find a perfect match. Use btrfs_super_geneartion() + 1 to provide a better result. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- btrfs-find-root.c | 2 +- kernel-shared/ctree.h | 9 +++++---- kernel-shared/print-tree.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/btrfs-find-root.c b/btrfs-find-root.c index e3283340..5ae808cc 100644 --- a/btrfs-find-root.c +++ b/btrfs-find-root.c @@ -249,7 +249,7 @@ static void get_root_gen_and_level(u64 objectid, struct btrfs_fs_info *fs_info, break; case BTRFS_TREE_LOG_OBJECTID: level = btrfs_super_log_root_level(super); - gen = btrfs_super_log_root_transid(super); + gen = btrfs_super_generation(super) + 1; break; case BTRFS_UUID_TREE_OBJECTID: gen = btrfs_super_uuid_tree_generation(super); diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index fc8b61ed..fa46a1da 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -426,8 +426,11 @@ struct btrfs_super_block { __le64 chunk_root; __le64 log_root; - /* this will help find the new super based on the log root */ - __le64 log_root_transid; + /* + * This has never been used and is 0 in all versions. We always use + * generation + 1 to read log tree root. + */ + __le64 __unused_log_root_transid; __le64 total_bytes; __le64 bytes_used; __le64 root_dir_objectid; @@ -2334,8 +2337,6 @@ BTRFS_SETGET_STACK_FUNCS(super_chunk_root_level, struct btrfs_super_block, chunk_root_level, 8); BTRFS_SETGET_STACK_FUNCS(super_log_root, struct btrfs_super_block, log_root, 64); -BTRFS_SETGET_STACK_FUNCS(super_log_root_transid, struct btrfs_super_block, - log_root_transid, 64); BTRFS_SETGET_STACK_FUNCS(super_log_root_level, struct btrfs_super_block, log_root_level, 8); BTRFS_SETGET_STACK_FUNCS(super_total_bytes, struct btrfs_super_block, diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c index a5886ff6..24163258 100644 --- a/kernel-shared/print-tree.c +++ b/kernel-shared/print-tree.c @@ -2014,8 +2014,8 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full) (unsigned long long)btrfs_super_chunk_root_level(sb)); printf("log_root\t\t%llu\n", (unsigned long long)btrfs_super_log_root(sb)); - printf("log_root_transid\t%llu\n", - (unsigned long long)btrfs_super_log_root_transid(sb)); + printf("log_root_transid (deprecated)\t%llu\n", + le64_to_cpu(sb->__unused_log_root_transid)); printf("log_root_level\t\t%llu\n", (unsigned long long)btrfs_super_log_root_level(sb)); printf("total_bytes\t\t%llu\n",