From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags
Date: Thu, 9 May 2024 10:49:03 +0930 [thread overview]
Message-ID: <4c86accc806fc1a53bdb198168458ca90c288ce4.1715217526.git.wqu@suse.com> (raw)
[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
next reply other threads:[~2024-05-09 1:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-09 1:19 Qu Wenruo [this message]
2024-05-10 13:21 ` [PATCH v2] btrfs-progs: dump-tree: support simple quota mode status flags David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c86accc806fc1a53bdb198168458ca90c288ce4.1715217526.git.wqu@suse.com \
--to=wqu@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).