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

[BUG]
For simple quota mode btrfs, dump tree does not show the extra flags
correctly:

 # mkfs.btrfs -f -O squota $dev
 # btrfs inspect 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>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2024-05-09 10:49:03 +09:30 committed by David Sterba
parent d0cc40d23a
commit cae94956d9
1 changed files with 10 additions and 1 deletions

View File

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