btrfs-progs: parse-utils: allow single number qgroup id
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.
--- common/parse-utils.c | 6 ++++++ 1 file changed, 6 insertions(+)
common/parse-utils.c +6 -0
@@ -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
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 commitcb5a542871f9("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")Signed-off-by Qu Wenruo <[email protected]>
Quoted 22 lines
--- common/parse-utils.c | 6 ++++++ 1 file changed, 6 insertions(+)common/parse-utils.c +6
-0@@ -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 ;
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 commitcb5a542871f9("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.
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 commitcb5a542871f9("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_qgroupidhelper 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_qgroupidshould 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
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 commitcb5a542871f9("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_qgroupidhelper 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.
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 commitcb5a542871f9("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_qgroupidhelper 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