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 <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2022-06-07 20:01:17 +08:00 committed by David Sterba
parent 5110ad88cb
commit 963188943f
3 changed files with 8 additions and 7 deletions

View File

@ -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);

View File

@ -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,

View File

@ -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",