linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid
@ 2023-07-20  8:50 Anand Jain
  2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-20  8:50 UTC (permalink / raw)
  To: linux-btrfs

This can be integrated independently; so sending it out separately while
I continue to revise the other patches.

This has passed Btrfs-progs tests, and Fstests tests need no fix.

Patch 1 fixes the dump-super output, and patch 2 fixes the test cases
depending on the dump-super output.

Anand Jain (2):
  btrfs-progs: dump-super print actual metadata_uuid value
  btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID
    flag

 kernel-shared/print-tree.c                 |  8 ++------
 tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.39.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value
  2023-07-20  8:50 [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
@ 2023-07-20  8:50 ` Anand Jain
  2023-07-20  9:03   ` Anand Jain
  2023-07-25  8:24   ` Anand Jain
  2023-07-20  9:03 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-20  8:50 UTC (permalink / raw)
  To: linux-btrfs

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(-)

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 0f7f7b72f96a..d7ffeccd1e89 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -2005,12 +2005,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;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid
  2023-07-20  8:50 [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
  2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
@ 2023-07-20  9:03 ` Anand Jain
  2023-07-20  9:03 ` [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Anand Jain
  2023-07-25  8:24 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
  3 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-20  9:03 UTC (permalink / raw)
  To: linux-btrfs

This can be integrated independently; so sending it out separately while
I continue to revise the other patches.

This has passed Btrfs-progs tests, and Fstests tests need no fix.

Patch 1 fixes the dump-super output, and patch 2 fixes the test cases
depending on the dump-super output.

Anand Jain (2):
  btrfs-progs: dump-super print actual metadata_uuid value
  btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID
    flag

 kernel-shared/print-tree.c                 |  8 ++------
 tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.39.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value
  2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
@ 2023-07-20  9:03   ` Anand Jain
  2023-07-25  8:24   ` Anand Jain
  1 sibling, 0 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-20  9:03 UTC (permalink / raw)
  To: linux-btrfs

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(-)

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 0f7f7b72f96a..d7ffeccd1e89 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -2005,12 +2005,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;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag
  2023-07-20  8:50 [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
  2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
  2023-07-20  9:03 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
@ 2023-07-20  9:03 ` Anand Jain
  2023-07-25  8:24   ` Anand Jain
  2023-07-25  8:24 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
  3 siblings, 1 reply; 8+ messages in thread
From: Anand Jain @ 2023-07-20  9:03 UTC (permalink / raw)
  To: linux-btrfs

Commit
  btrfs-progs: dump-super print actual metadata_uuid value

fixed the value of the super_block::metadata_uuid to be printed as it
is, without tweaking it depending on the METADATA_UUID flag.

Apply similar counter tweak in the common helper functions used to read
the metadata_uuid so that test-cases still be successful.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh
index 77a310d54f0f..dba31db90368 100755
--- a/tests/misc-tests/034-metadata-uuid/test.sh
+++ b/tests/misc-tests/034-metadata-uuid/test.sh
@@ -15,6 +15,19 @@ if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
 	_not_run "METADATA_UUID feature not supported"
 fi
 
+has_metadata_uuid_flag() {
+	local dev="$1"
+
+	run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
+		dump-super "$dev" | egrep -q METADATA_UUID
+
+	if [ $? -eq 0 ]; then
+		echo true
+	else
+		echo false
+	fi
+}
+
 read_fsid() {
 	local dev="$1"
 
@@ -24,9 +37,14 @@ read_fsid() {
 
 read_metadata_uuid() {
 	local dev="$1"
-
-	echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
-		dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
+	local flag=$(has_metadata_uuid_flag $dev)
+
+	if [ "$flag" == "true" ]; then
+		echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
+			dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
+	else
+		read_fsid $dev
+	fi
 }
 
 check_btrfstune() {
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid
  2023-07-20  8:50 [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
                   ` (2 preceding siblings ...)
  2023-07-20  9:03 ` [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Anand Jain
@ 2023-07-25  8:24 ` Anand Jain
  3 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-25  8:24 UTC (permalink / raw)
  To: linux-btrfs

This can be integrated independently; so sending it out separately while
I continue to revise the other patches.

This has passed Btrfs-progs tests, and Fstests tests need no fix.

Patch 1 fixes the dump-super output, and patch 2 fixes the test cases
depending on the dump-super output.

Anand Jain (2):
  btrfs-progs: dump-super print actual metadata_uuid value
  btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID
    flag

 kernel-shared/print-tree.c                 |  8 ++------
 tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++---
 2 files changed, 23 insertions(+), 9 deletions(-)

-- 
2.39.3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value
  2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
  2023-07-20  9:03   ` Anand Jain
@ 2023-07-25  8:24   ` Anand Jain
  1 sibling, 0 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-25  8:24 UTC (permalink / raw)
  To: linux-btrfs

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(-)

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index 0f7f7b72f96a..d7ffeccd1e89 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -2005,12 +2005,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;
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag
  2023-07-20  9:03 ` [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Anand Jain
@ 2023-07-25  8:24   ` Anand Jain
  0 siblings, 0 replies; 8+ messages in thread
From: Anand Jain @ 2023-07-25  8:24 UTC (permalink / raw)
  To: linux-btrfs

Commit
  btrfs-progs: dump-super print actual metadata_uuid value

fixed the value of the super_block::metadata_uuid to be printed as it
is, without tweaking it depending on the METADATA_UUID flag.

Apply similar counter tweak in the common helper functions used to read
the metadata_uuid so that test-cases still be successful.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 tests/misc-tests/034-metadata-uuid/test.sh | 24 +++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh
index 77a310d54f0f..dba31db90368 100755
--- a/tests/misc-tests/034-metadata-uuid/test.sh
+++ b/tests/misc-tests/034-metadata-uuid/test.sh
@@ -15,6 +15,19 @@ if [ ! -f /sys/fs/btrfs/features/metadata_uuid ] ; then
 	_not_run "METADATA_UUID feature not supported"
 fi
 
+has_metadata_uuid_flag() {
+	local dev="$1"
+
+	run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
+		dump-super "$dev" | egrep -q METADATA_UUID
+
+	if [ $? -eq 0 ]; then
+		echo true
+	else
+		echo false
+	fi
+}
+
 read_fsid() {
 	local dev="$1"
 
@@ -24,9 +37,14 @@ read_fsid() {
 
 read_metadata_uuid() {
 	local dev="$1"
-
-	echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
-		dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
+	local flag=$(has_metadata_uuid_flag $dev)
+
+	if [ "$flag" == "true" ]; then
+		echo $(run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal \
+			dump-super "$dev" | awk '/metadata_uuid/ {print $2}')
+	else
+		read_fsid $dev
+	fi
 }
 
 check_btrfstune() {
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-25  8:25 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-20  8:50 [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
2023-07-20  8:50 ` [PATCH 1/2] btrfs-progs: dump-super print actual metadata_uuid value Anand Jain
2023-07-20  9:03   ` Anand Jain
2023-07-25  8:24   ` Anand Jain
2023-07-20  9:03 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain
2023-07-20  9:03 ` [PATCH 2/2] btrfs-progs: tests: return metadata_uuid or fsid as per METADATA_UUID flag Anand Jain
2023-07-25  8:24   ` Anand Jain
2023-07-25  8:24 ` [PATCH 0/2] btrfs-progs: fix dump-super metadata_uuid Anand Jain

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).