Skip to contentSkip to conversation

btrfs-progs: parse-utils: allow single number qgroup id

PATCH In review Qu Wenruo 4 participants 6 messages Oct 11, 2021 – Oct 13, 2021 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs-progs: parse-utils: allow single number qgroup id

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

...

  # /usr/bin/btrfs quota enable /mnt/scratch
  # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
  ERROR: invalid qgroupid or subvolume path: 5
  failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

That commit is not a plain refactor without functional change, but removed a simple feature.

[FIX]
Add back the handling for single number qgroupid.

Fixes cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing")
---
 common/parse-utils.c | 6 ++++++
 1 file changed, 6 insertions(+)
common/parse-utils.c +6 -0
index ad57b74a7b64..863ca9f25fd8 100644
@@ -290,6 +290,12 @@ int parse_qgroupid(const char *str, u64 *qgroupid)
 	level = strtoull(str, &end, 10);
 	if (str == end)
 		return -EINVAL;
+	/* We accept single qgroupid like "5", to indicate "0/5"*/
+	if (end[0] == '\0') {
+		*qgroupid = level;
+		return 0;
+	}
+	/* Otherwise qgroupid must go like "1/256" */
 	if (end[0] != '/')
 		return -EINVAL;
 	str = end + 1;
Signature · 1 line
2.33.0
Tested-by on v1 1/1
#1 lore raw
Quoted 15 lines · Qu Wenruo

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

...

  # /usr/bin/btrfs quota enable /mnt/scratch
  # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
  ERROR: invalid qgroupid or subvolume path: 5
  failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

Quoted 8 lines

That commit is not a plain refactor without functional change, but removed a simple feature.

[FIX]
Add back the handling for single number qgroupid.

Fixes cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing")
Quoted 22 lines
---
 common/parse-utils.c | 6 ++++++
 1 file changed, 6 insertions(+)
common/parse-utils.c +6 -0
index ad57b74a7b64..863ca9f25fd8 100644
@@ -290,6 +290,12 @@ int parse_qgroupid(const char *str, u64 *qgroupid)
 	level = strtoull(str, &end, 10);
 	if (str == end)
 		return -EINVAL;
+	/* We accept single qgroupid like "5", to indicate "0/5"*/
+	if (end[0] == '\0') {
+		*qgroupid = level;
+		return 0;
+	}
+	/* Otherwise qgroupid must go like "1/256" */
 	if (end[0] != '/')
 		return -EINVAL;
 	str = end + 1;
#2 lore raw
In reply to Qu Wenruo
Quoted 15 lines · Qu Wenruo

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

...

  # /usr/bin/btrfs quota enable /mnt/scratch
  # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
  ERROR: invalid qgroupid or subvolume path: 5
  failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

Quoted 5 lines

That commit is not a plain refactor without functional change, but removed a simple feature.

[FIX]
Add back the handling for single number qgroupid.

This unfortunately breaks something else, as it's changing the whole parse_qgroupid helper to accept single value id, which is also used for 'qgroup create'.

There's another combined helper for parsing qgroup id and path, so we may need to add another one that also accepts the subvolid, in commands where this makes sense. The helper parse_qgroupid should really remain as it is and parse the 'number/number' format.

#3 lore raw
Quoted 19 lines · David Sterba
Quoted 18 lines · Qu Wenruo

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

   ...
   # /usr/bin/btrfs quota enable /mnt/scratch
   # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
   ERROR: invalid qgroupid or subvolume path: 5
   failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

That commit is not a plain refactor without functional change, but removed a simple feature.

Quoted 6 lines
Quoted 2 lines

[FIX]
Add back the handling for single number qgroupid.

This unfortunately breaks something else, as it's changing the whole parse_qgroupid helper to accept single value id, which is also used for 'qgroup create'.

For 'qgroup create' I think it's OK to accept single value id.

It's a handy shortcut for '0/<subvolid>'.

And for higher level qgroup, we need the level anyway.

Quoted 6 lines

There's another combined helper for parsing qgroup id and path, so we may need to add another one that also accepts the subvolid, in commands where this makes sense. The helper parse_qgroupid should really remain as it is and parse the 'number/number' format.

Then I'm completely fine to update the test case to go "0/5".

But I'm not sure if this change would affect the existing user scripts.

(Considering there is no report yet I guess it's not that widely used anyway?)

Thanks,
Qu

#4 lore raw
Quoted 25 lines · Qu Wenruo
Quoted 22 lines · David Sterba
Quoted 20 lines · Qu Wenruo

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

   ...
   # /usr/bin/btrfs quota enable /mnt/scratch
   # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
   ERROR: invalid qgroupid or subvolume path: 5
   failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

That commit is not a plain refactor without functional change, but removed a simple feature.

[FIX]
Add back the handling for single number qgroupid.

Quoted 7 lines
Quoted 3 lines

This unfortunately breaks something else, as it's changing the whole parse_qgroupid helper to accept single value id, which is also used for 'qgroup create'.

For 'qgroup create' I think it's OK to accept single value id.

It's a handy shortcut for '0/<subvolid>'.

The 0/subvolid qgroup cannot be created manually IIRC.

author
#5 lore raw
Quoted 30 lines · David Sterba
Quoted 29 lines · Qu Wenruo
Quoted 25 lines · David Sterba
Quoted 15 lines · Qu Wenruo

[BUG]
Since btrfs-progs v5.14, fstests/btrfs/099 always fail with the following output in 099.full:

    ...
    # /usr/bin/btrfs quota enable /mnt/scratch
    # /usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch
    ERROR: invalid qgroupid or subvolume path: 5
    failed: '/usr/bin/btrfs qgroup limit 134217728 5 /mnt/scratch'

[CAUSE]
Since commit cb5a542871f9 ("btrfs-progs: factor out plain qgroupid parsing"), btrfs qgroup parser no longer accepts single number qgroup id like "5" used in that test case.

Quoted 5 lines

That commit is not a plain refactor without functional change, but removed a simple feature.

[FIX]
Add back the handling for single number qgroupid.

This unfortunately breaks something else, as it's changing the whole parse_qgroupid helper to accept single value id, which is also used for 'qgroup create'.

Quoted 6 lines
Quoted 3 lines

For 'qgroup create' I think it's OK to accept single value id.

It's a handy shortcut for '0/<subvolid>'.

The 0/subvolid qgroup cannot be created manually IIRC.

They can, even with current kernel/progs.

Thanks,
Qu