btrfs-progs: quota: Check for args.progress in cmd_quota_rescan
PATCH 1/1 btrfs-progs: quota: Check for args.progress in cmd_quota_rescan
The progress struct member is only set when there is a rescan being executed, so it's more readable read it directly.
--- cmds/quota.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
cmds/quota.c +3 -3
@@ -166,11 +166,11 @@ static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv)error ("could not obtain quota rescan status: %m" );return 1 ; } -if (!args.flags) -printf ("no rescan operation in progress\n" ); -else +if (args.progress)printf ("rescan operation running (current key %lld)\n" , args.progress); +else +printf ("no rescan operation in progress\n" );return 0 ; }
Signature · 1 line
2.26.2
Quoted 2 lines · Marcos Paulo de Souza
The progress struct member is only set when there is a rescan being executed, so it's more readable read it directly.
I'm not sure this is right, kernel sets the flags and progress together, ie. the progress value depends on the flags being set, so reading just the progress does not follow the "ioctl protocol".
If the reason is to make the code readable I'd say it's obscuring the fact that there's some semantics behind the ioctl so it should not be obscured for readability reasons.
Quoted 12 lines
Signed-off-by Marcos Paulo de Souza <[email protected]>--- cmds/quota.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)cmds/quota.c +0
-0@@ -166,11 +166,11 @@ static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv)error ("could not obtain quota rescan status: %m" );
cmds/quota.c static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv) · line 173
Quoted 10 lines
cmds/quota.c +3
-3return 1 ; } -if (!args.flags) -printf ("no rescan operation in progress\n" ); -else +if (args.progress)printf ("rescan operation running (current key %lld)\n" , args.progress); +else +printf ("no rescan operation in progress\n" );
This could be improved that it checks for bit 0 set, and so should do the kernel. Right now we haven't had anything else than the progress so switching qsa->flags = 1 to |= 1 in btrfs_ioctl_quota_rescan_status should be doing the same thing.
Quoted 5 lines
cmds/quota.c +0
-0return 0 ; }Signature · 1 line
2.26.2