diff mbox series

[v2] btrfs-progs: dump-tree: support simple quota mode status flags

Message ID 4c86accc806fc1a53bdb198168458ca90c288ce4.1715217526.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series [v2] btrfs-progs: dump-tree: support simple quota mode status flags | expand

Commit Message

Qu Wenruo May 9, 2024, 1:19 a.m. UTC
[BUG]
For simple quota mode btrfs, dump tree does not show the extra flags
correctly:

 # mkfs.btrfs -f -O squota $dev
 # btrfs ins dump-tree -t quota $dev | grep QGROUP_STATUS -A1
	item 0 key (0 QGROUP_STATUS 0) itemoff 16243 itemsize 40
		version 1 generation 10 flags ON scan 0 enable_gen 7

Note just ON is shown, but squota has one extra bit set for it.

[CAUSE]
Just no support for the new flag.

[FIX]
Add the new flag support, also to be consistent with other flags string
output, add output for extra unknown flags.

With a hand crafted image, the output with unknown flags looks like
this:
	item 0 key (0 QGROUP_STATUS 0) itemoff 16243 itemsize 40
		version 1 generation 10 flags ON|SIMPLE_MODE|UNKNOWN(0xf00) scan 0 enable_gen 7

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Change the output format for unknown flags to match the example
---
 kernel-shared/print-tree.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--
2.45.0

Comments

David Sterba May 10, 2024, 1:21 p.m. UTC | #1
On Thu, May 09, 2024 at 10:49:03AM +0930, Qu Wenruo wrote:
> [BUG]
> For simple quota mode btrfs, dump tree does not show the extra flags
> correctly:
> 
>  # mkfs.btrfs -f -O squota $dev
>  # btrfs ins dump-tree -t quota $dev | grep QGROUP_STATUS -A1
> 	item 0 key (0 QGROUP_STATUS 0) itemoff 16243 itemsize 40
> 		version 1 generation 10 flags ON scan 0 enable_gen 7
> 
> Note just ON is shown, but squota has one extra bit set for it.
> 
> [CAUSE]
> Just no support for the new flag.
> 
> [FIX]
> Add the new flag support, also to be consistent with other flags string
> output, add output for extra unknown flags.
> 
> With a hand crafted image, the output with unknown flags looks like
> this:
> 	item 0 key (0 QGROUP_STATUS 0) itemoff 16243 itemsize 40
> 		version 1 generation 10 flags ON|SIMPLE_MODE|UNKNOWN(0xf00) scan 0 enable_gen 7
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to devel, thanks.
diff mbox series

Patch

diff --git a/kernel-shared/print-tree.c b/kernel-shared/print-tree.c
index a36737712b9d..b303fcdc7ccd 100644
--- a/kernel-shared/print-tree.c
+++ b/kernel-shared/print-tree.c
@@ -211,19 +211,28 @@  static void bg_flags_to_str(u64 flags, char *ret)
 	}
 }

-/* Caller should ensure sizeof(*ret)>= 26 "OFF|SCANNING|INCONSISTENT" */
+/*
+ * Caller should ensure sizeof(*ret)>= 64
+ * "OFF|SCANNING|INCONSISTENT|UNKNOWN(0xffffffffffffffff)"
+ */
 static void qgroup_flags_to_str(u64 flags, char *ret)
 {
 	ret[0] = 0;
+
 	if (flags & BTRFS_QGROUP_STATUS_FLAG_ON)
 		strcpy(ret, "ON");
 	else
 		strcpy(ret, "OFF");

+	if (flags & BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE)
+		strcat(ret, "|SIMPLE_MODE");
 	if (flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN)
 		strcat(ret, "|SCANNING");
 	if (flags & BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
 		strcat(ret, "|INCONSISTENT");
+	if (flags & ~BTRFS_QGROUP_STATUS_FLAGS_MASK)
+		sprintf(ret + strlen(ret), "|UNKNOWN(0x%llx)",
+			flags & ~BTRFS_QGROUP_STATUS_FLAGS_MASK);
 }

 void print_chunk_item(struct extent_buffer *eb, struct btrfs_chunk *chunk)