diff mbox series

[01/10,v2] btrfs-progs: dump-super print actual metadata_uuid value

Message ID 53c1111fcc49df5f0563839146260c8f0950b071.1690985783.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series fixes and preparatory related to metadata_uuid | expand

Commit Message

Anand Jain Aug. 2, 2023, 11:29 p.m. UTC
The function btrfs_print_superblock() prints all members of the
superblock as they are, except for the superblock::metadata_uuid.
If the METADATA_UUID flag is unset, it prints the fsid instead of
zero as in the superblock::metadata_uuid.

Perhaps this was done because to match with the kernel
btrfs_fs_devices::metadata_uuid value as it also sets fsid if
METADATA_UUID flag is unset.

However, the actual superblock::metadata_uuid is always zero if the
METADATA_UUID flag is unset. Just to mention the kernel does not alter
the superblock::metadata_uuid value any time.

The dump-super printing fsid instead of zero, is confusing because we
generally expect dump_super to print the superblock value in the raw
formet without modification.

Fix this by printing the actual metadata_uuid value instead of fsid.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 kernel-shared/print-tree.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Anand Jain Aug. 3, 2023, 12:52 p.m. UTC | #1
On 03/08/2023 07:29, Anand Jain wrote:
> The function btrfs_print_superblock() prints all members of the
> superblock as they are, except for the superblock::metadata_uuid.
> If the METADATA_UUID flag is unset, it prints the fsid instead of
> zero as in the superblock::metadata_uuid.
> 
> Perhaps this was done because to match with the kernel
> btrfs_fs_devices::metadata_uuid value as it also sets fsid if
> METADATA_UUID flag is unset.
> 
> However, the actual superblock::metadata_uuid is always zero if the
> METADATA_UUID flag is unset. Just to mention the kernel does not alter
> the superblock::metadata_uuid value any time.
> 
> The dump-super printing fsid instead of zero, is confusing because we
> generally expect dump_super to print the superblock value in the raw
> formet without modification.
> 
> Fix this by printing the actual metadata_uuid value instead of fsid.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
V2: none. pls ignore the v2 in the subject.

>   kernel-shared/print-tree.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
> index f97148c47b5a..1c398c3dacab 100644
> --- a/kernel-shared/print-tree.c
> +++ b/kernel-shared/print-tree.c
> @@ -2006,12 +2006,8 @@ void btrfs_print_superblock(struct btrfs_super_block *sb, int full)
>   
>   	uuid_unparse(sb->fsid, buf);
>   	printf("fsid\t\t\t%s\n", buf);
> -	if (metadata_uuid_present) {
> -		uuid_unparse(sb->metadata_uuid, buf);
> -		printf("metadata_uuid\t\t%s\n", buf);
> -	} else {
> -		printf("metadata_uuid\t\t%s\n", buf);
> -	}
> +	uuid_unparse(sb->metadata_uuid, buf);
> +	printf("metadata_uuid\t\t%s\n", buf);
>   
>   	printf("label\t\t\t");
>   	s = sb->label;
diff mbox series

Patch

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index f97148c47b5a..1c398c3dacab 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -2006,12 +2006,8 @@  void btrfs_print_superblock(struct btrfs_super_block *sb, int full)
 
 	uuid_unparse(sb->fsid, buf);
 	printf("fsid\t\t\t%s\n", buf);
-	if (metadata_uuid_present) {
-		uuid_unparse(sb->metadata_uuid, buf);
-		printf("metadata_uuid\t\t%s\n", buf);
-	} else {
-		printf("metadata_uuid\t\t%s\n", buf);
-	}
+	uuid_unparse(sb->metadata_uuid, buf);
+	printf("metadata_uuid\t\t%s\n", buf);
 
 	printf("label\t\t\t");
 	s = sb->label;