Skip to content

Commit ab32c44

Browse files
committed
btrfs-progs: qgroup show: fix formatting of limit values in json output
There are reports that json output of 'qgroup show' crashes due to internal error when printing the limit values: INTERNAL ERROR: unknown unit base, mode 2304 btrfs(internal_error+0x10a)[0x5605c37ce48a] btrfs(pretty_size_snprintf+0x5c)[0x5605c37d105c] btrfs(fmt_print+0x44e)[0x5605c37d178e] btrfs(+0x7ed1d)[0x5605c3800d1d] btrfs(main+0x8f)[0x5605c379beff] /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0] /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79] btrfs(_start+0x25)[0x5605c379d405] common/units.c:82: pretty_size_snprintf: Assertion `0` failed, value 0 btrfs(+0x1d4b1)[0x5605c379f4b1] btrfs(pretty_size_snprintf+0x7b)[0x5605c37d107b] btrfs(fmt_print+0x44e)[0x5605c37d178e] btrfs(+0x7ed1d)[0x5605c3800d1d] btrfs(main+0x8f)[0x5605c379beff] /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0] /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79] btrfs(_start+0x25)[0x5605c379d405] This is caused by "size" format that requires the unit mode, but it was not specified and some stack value used. As json prints the raw values, use the plain %llu format. Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1206960 Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1209136#c15 Signed-off-by: David Sterba <[email protected]>
1 parent 4d5711f commit ab32c44

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cmds/qgroup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,10 +1439,10 @@ static const struct rowspec qgroup_show_rowspec[] = {
14391439
{ .key = "qgroupid", .fmt = "qgroupid", .out_json = "qgroupid" },
14401440
{ .key = "referenced", .fmt = "%llu", .out_json = "referenced" },
14411441
{ .key = "exclusive", .fmt = "%llu", .out_json = "exclusive" },
1442-
{ .key = "max_referenced", .fmt = "size", .out_json = "max_referenced" },
1442+
{ .key = "max_referenced", .fmt = "%llu", .out_json = "max_referenced" },
14431443
/* Special value if limits not set. */
14441444
{ .key = "max_referenced-none", .fmt = "%s", .out_json = "max_referenced" },
1445-
{ .key = "max_exclusive", .fmt = "size", .out_json = "max_exclusive" },
1445+
{ .key = "max_exclusive", .fmt = "%llu", .out_json = "max_exclusive" },
14461446
/* Special value if limits not set. */
14471447
{ .key = "max_exclusive-none", .fmt = "%s", .out_json = "max_exclusive" },
14481448
{ .key = "path", .fmt = "str", .out_json = "path" },

tests/cli-tests/005-qgroup-show/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ run_mayfail "$TOP/btrfs" --format json qgroup show "$TEST_MNT"
1717
run_mayfail $SUDO_HELPER "$TOP/btrfs" qgroup show "$TEST_MNT"
1818
run_mayfail $SUDO_HELPER "$TOP/btrfs" --format json qgroup show "$TEST_MNT"
1919
run_check $SUDO_HELPER "$TOP/btrfs" quota enable "$TEST_MNT"
20+
run_check $SUDO_HELPER "$TOP/btrfs" qgroup limit 128m "$TEST_MNT"
2021
run_mayfail "$TOP/btrfs" qgroup show "$TEST_MNT"
2122
run_mayfail "$TOP/btrfs" --format json qgroup show "$TEST_MNT"
2223
run_check $SUDO_HELPER "$TOP/btrfs" qgroup show "$TEST_MNT"

0 commit comments

Comments
 (0)