* [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags
@ 2024-05-09 1:19 Qu Wenruo
2024-05-10 13:21 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2024-05-09 1:19 UTC (permalink / raw)
To: linux-btrfs
[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(-)
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)
--
2.45.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags
2024-05-09 1:19 [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags Qu Wenruo
@ 2024-05-10 13:21 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2024-05-10 13:21 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-05-10 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-09 1:19 [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags Qu Wenruo
2024-05-10 13:21 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox