btrfs-progs: add quiet option
v2 cover btrfs-progs: add quiet option
v2: pr_verbose()'s first argument %level can accept -1, and if the
quiet option is not set, pr_verbose() shall print the message overriding the verbose level set during the command option. We need this -1 level to make sure we continue to print the messages which have been printed with the default log level, so that backward compatibility is maintained.
Now in v2 value: -1 is defined as MUST_LOG. The relevant patch
is sent as a reroll patch v3
[PATCH v3 02/16] btrfs-progs: add global verbose and quiet options and helper functions
in the part-1 set. So replace -1 with the new define wherever necessary.
The whole series (both part-1 and part-2) has been pushed to the git repo branch as below [2].
----- main cover-letter -------
The part-1 patchset [1] 'btrfs-progs: global verbose and quiet option'
[1]
https://patchwork.kernel.org/project/linux-btrfs/list/?series=207709
provided a global structure to communicate the verbose and quiet options down to the individual sub-commands where the actual printf happens. So each of the sub-command could enable the verbose or quiet option as needed.
But some of the sub-commands already had the verbose and quiet options locally at the sub-command level. So the aim of part-1 of this series was to merge the local verbose and quiet option with the global verbose and quiet, which it did successfully.
In this series, part-2, adds the global quiet option to the found chatty sub-commands. So each of the sub-commands outputs were individually checked and brought those logs under the global quiet option. As this process is nondeterministic (unless like in part-1 where sub-commands with -v or -q were checked) so there might have few logs left behind and those can be fixed as moved along.
The whole series can be fetched from [2], which is based on latest devel branch, last commit: c1d6d654a3f9 (btrfs-progs: docs: update balance).
[2]
https://github.com/asj/btrfs-progs.git verbose
Anand Jain (8):
btrfs-progs: quota rescan: add quiet option
btrfs-progs: subvolume create: add quiet option
btrfs-progs: subvolume delete: add quiet option
btrfs-progs: balance start: add quiet option
btrfs-progs: balance resume: add quiet option
btrfs-progs: subvolume snapshot: add quiet option
btrfs-progs: scrub start|resume: use global quiet option
btrfs-progs: scrub cancel: add quiet option
cmds/balance.c | 17 +++++++++++------ cmds/quota.c | 4 +++- cmds/scrub.c | 27 +++++++++++++++++---------- cmds/subvolume.c | 24 +++++++++++++++--------- 4 files changed, 46 insertions(+), 26 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/8 btrfs-progs: quota rescan: add quiet option
Enable the quiet option to the btrfs(8) quota rescan command. Does the job quietly. For example:
btrfs --quiet quota rescan
---
v2: Use MUST_LOG
cmds/quota.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
cmds/quota.c +3 -1
@@ -108,6 +108,8 @@ static const char * const cmd_quota_rescan_usage[] = {"" ,"-s show status of a running rescan operation" ,"-w wait for rescan operation to finish (can be already in progress)" , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET , NULL };
@@ -172,7 +174,7 @@ static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv) }if (ret ==0 ) { -printf ("quota rescan started\n" ); +pr_verbose (MUST_LOG ,"quota rescan started\n" );fflush (stdout); }else if (ret <0 && (!wait_for_completion || e !=EINPROGRESS )) {error ("quota rescan failed: %m" );
Signature · 1 line
2.25.1
PATCH v2 2/8 btrfs-progs: subvolume create: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) subvolume create command. Does the job quietly. For example:
btrfs --quiet subvolume create <path>
---
v2: use MUST_LOG
cmds/subvolume.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
cmds/subvolume.c +3 -1
@@ -88,6 +88,8 @@ static const char * const cmd_subvol_create_usage[] = {"" ,"-i <qgroupid> add the newly created subvolume to a qgroup. This" ," option can be given multiple times." , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET , NULL };
@@ -169,7 +171,7 @@ static int cmd_subvol_create(const struct cmd_struct *cmd,if (fddst <0 ) goto out; -printf ("Create subvolume '%s/%s'\n" , dstdir, newname); +pr_verbose (MUST_LOG ,"Create subvolume '%s/%s'\n" , dstdir, newname);if (inherit) {struct btrfs_ioctl_vol_args_v2 args;
Signature · 1 line
2.25.1
PATCH v2 3/8 btrfs-progs: subvolume delete: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) subvolume delete command. Does the job quietly. For example:
btrfs --quiet subvolume delete <path>
Also, fix a line with over 80 char with proper indentation.
---
v2: add missed usage for global quiet
Use MUST_LOG
cmds/subvolume.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
cmds/subvolume.c +5 -4
@@ -241,6 +241,7 @@ static const char * const cmd_subvol_delete_usage[] = {"-v|--verbose verbose output of operations" ,HELPINFO_INSERT_GLOBALS ,HELPINFO_INSERT_VERBOSE , +HELPINFO_INSERT_QUIET , NULL };
@@ -359,14 +360,14 @@ again: goto out; } -printf ("Delete subvolume (%s): " , - commit_mode ==COMMIT_EACH || (commit_mode ==COMMIT_AFTER && cnt +1 == argc) +pr_verbose (MUST_LOG ,"Delete subvolume (%s): " , +commit_mode ==COMMIT_EACH || (commit_mode ==COMMIT_AFTER && cnt +1 == argc) ?"commit" :"no-commit" );if (subvolid ==0 ) -printf ("'%s/%s'\n" , dname, vname); +pr_verbose (MUST_LOG ,"'%s/%s'\n" , dname, vname);else -printf ("'%s'\n" , full_subvolpath); +pr_verbose (MUST_LOG ,"'%s'\n" , full_subvolpath);if (subvolid ==0 ) err =btrfs_util_delete_subvolume_fd (fd, vname,0 );
Signature · 1 line
2.25.1
PATCH v2 4/8 btrfs-progs: balance start: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) balance start command. Does the job quietly. For example:
btrfs -q balance start --full-balance <path>
---
v2: Use MUST_LOG
cmds/balance.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
cmds/balance.c +5 -3
@@ -470,9 +470,10 @@ static int do_balance(const char *path, struct btrfs_ioctl_balance_args *args, }else if (ret >0 ) {error ("balance: %s" ,btrfs_err_str (ret)); }else { -printf ("Done, had to relocate %llu out of %llu chunks\n" , - (unsigned long long )args->stat.completed, - (unsigned long long )args->stat.considered); +pr_verbose (MUST_LOG , +"Done, had to relocate %llu out of %llu chunks\n" , + (unsigned long long )args->stat.completed, + (unsigned long long )args->stat.considered); } out:
@@ -501,6 +502,7 @@ static const char * const cmd_balance_start_usage[] = {" run the balance as a background process" ,HELPINFO_INSERT_GLOBALS ,HELPINFO_INSERT_VERBOSE , +HELPINFO_INSERT_QUIET , NULL };
Signature · 1 line
2.25.1
PATCH v2 5/8 btrfs-progs: balance resume: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) balance resume command. Does the job quietly. For example:
btrfs -q balance resume <path>
---
v2: Use MUST_LOG
cmds/balance.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
cmds/balance.c +6 -3
@@ -769,6 +769,8 @@ static DEFINE_SIMPLE_COMMAND(balance_cancel, "cancel");static const char *const cmd_balance_resume_usage[] = {"btrfs balance resume <path>" ,"Resume interrupted balance" , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET ,NULL };
@@ -817,9 +819,10 @@ static int cmd_balance_resume(const struct cmd_struct *cmd, ret =1 ; } }else { -printf ("Done, had to relocate %llu out of %llu chunks\n" , - (unsigned long long )args.stat.completed, - (unsigned long long )args.stat.considered); +pr_verbose (MUST_LOG , +"Done, had to relocate %llu out of %llu chunks\n" , + (unsigned long long )args.stat.completed, + (unsigned long long )args.stat.considered); }close_file_or_dir (fd, dirstream);
Signature · 1 line
2.25.1
PATCH v2 6/8 btrfs-progs: subvolume snapshot: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) subvolume snapshot command. Does the job quietly. For example:
btrfs -q subvolume snapshot <src> <dest>
---
v2: Use MUST_LOG
cmds/subvolume.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
cmds/subvolume.c +8 -4
@@ -669,6 +669,8 @@ static const char * const cmd_subvol_snapshot_usage[] = {"-r create a readonly snapshot" ,"-i <qgroupid> add the newly created snapshot to a qgroup. This" ," option can be given multiple times." , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET , NULL };
@@ -783,11 +785,13 @@ static int cmd_subvol_snapshot(const struct cmd_struct *cmd,if (readonly) { args.flags |=BTRFS_SUBVOL_RDONLY ; -printf ("Create a readonly snapshot of '%s' in '%s/%s'\n" , - subvol, dstdir, newname); +pr_verbose (MUST_LOG , +"Create a readonly snapshot of '%s' in '%s/%s'\n" , + subvol, dstdir, newname); }else { -printf ("Create a snapshot of '%s' in '%s/%s'\n" , - subvol, dstdir, newname); +pr_verbose (MUST_LOG , +"Create a snapshot of '%s' in '%s/%s'\n" , + subvol, dstdir, newname); } args.fd = fd;
Signature · 1 line
2.25.1
PATCH v2 7/8 btrfs-progs: scrub start|resume: use global quiet option
In reply to Anand JainTranspire global --quiet option down to the btrfs scrub start|resume sub-command.
Now either/both of the following quiet options work.
btrfs -q scrub start <path>
and
btrfs scrub start -q <path>
btrfs -q scrub resume <path>
and
btrfs scrub resume -q <path>
---
v2: Use MUST_LOG
cmds/scrub.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
cmds/scrub.c +14 -9
@@ -1141,7 +1141,7 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,int do_background =1 ;int do_wait =0 ;int do_print =0 ; -int do_quiet =0 ; +int do_quiet = !bconf.verbose;/*Read the global quiet option if set*/ int do_record =1 ;int readonly =0 ;int do_stats_per_dev =0 ;
@@ -1184,7 +1184,8 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv, do_stats_per_dev =1 ;break ;case 'q' : - do_quiet =1 ; +bconf_be_quiet (); + do_quiet = !bconf.verbose;break ;case 'r' : readonly =1 ;
@@ -1330,9 +1331,9 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv, }if (!n_start && !n_resume) { -if (!do_quiet) -printf ("scrub: nothing to resume for %s, fsid %s\n" , - path, fsid); +pr_verbose (MUST_LOG , +"scrub: nothing to resume for %s, fsid %s\n" , + path, fsid); nothing_to_resume =1 ; goto out; }
@@ -1403,10 +1404,10 @@ static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,if (pid) {int stat;scrub_handle_sigint_parent (); -if (!do_quiet) -printf ("scrub %s on %s, fsid %s (pid=%d)\n" , - n_start ?"started" :"resumed" , - path, fsid, pid); +pr_verbose (MUST_LOG , +"scrub %s on %s, fsid %s (pid=%d)\n" , + n_start ?"started" :"resumed" , + path, fsid, pid);if (!do_wait) { err =0 ; goto out;
@@ -1611,6 +1612,8 @@ static const char * const cmd_scrub_start_usage[] = {"-n set ioprio classdata (see ionice(1) manpage)" ,"-f force starting new scrub even if a scrub is already running" ," this is useful when scrub stats record file is damaged" , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET , NULL };
@@ -1678,6 +1681,8 @@ static const char * const cmd_scrub_resume_usage[] = {"-R raw print mode, print full data instead of summary" ,"-c set ioprio class (see ionice(1) manpage)" ,"-n set ioprio classdata (see ionice(1) manpage)" , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET , NULL };
Signature · 1 line
2.25.1
PATCH v2 8/8 btrfs-progs: scrub cancel: add quiet option
In reply to Anand JainEnable the quiet option to the btrfs(8) scrub cancel command. Does the job quietly. For example:
btrfs -q scrub cancel <mnt>
---
v2: MUST_LOG
cmds/scrub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
cmds/scrub.c +3 -1
@@ -1626,6 +1626,8 @@ static DEFINE_SIMPLE_COMMAND(scrub_start, "start");static const char *const cmd_scrub_cancel_usage[] = {"btrfs scrub cancel <path>|<device>" ,"Cancel a running scrub" , +HELPINFO_INSERT_GLOBALS , +HELPINFO_INSERT_QUIET ,NULL };
@@ -1662,7 +1664,7 @@ static int cmd_scrub_cancel(const struct cmd_struct *cmd, int argc, char **argv) } ret =0 ; -printf ("scrub cancelled\n" ); +pr_verbose (MUST_LOG ,"scrub cancelled\n" ); out:close_file_or_dir (fdmnt, dirstream);
Signature · 1 line
2.25.1
David Sterba
AppliedQuoted 43 lines · Anand Jain
v2: pr_verbose()'s first argument %level can accept -1, and if the
quiet option is not set,pr_verbose()shall print the message overriding the verbose level set during the command option. We need this -1 level to make sure we continue to print the messages which have been printed with the default log level, so that backward compatibility is maintained.Now in v2 value: -1 is defined as
MUST_LOG. The relevant patch
is sent as a reroll patch v3
[PATCH v3 02/16] btrfs-progs: add global verbose and quiet options and helper functions
in the part-1 set. So replace -1 with the new define wherever necessary.The whole series (both part-1 and part-2) has been pushed to the git repo branch as below [2].
----- main cover-letter -------
The part-1 patchset [1] 'btrfs-progs: global verbose and quiet option'
[1]
https://patchwork.kernel.org/project/linux-btrfs/list/?series=207709provided a global structure to communicate the verbose and quiet options down to the individual sub-commands where the actual printf happens. So each of the sub-command could enable the verbose or quiet option as needed.
But some of the sub-commands already had the verbose and quiet options locally at the sub-command level. So the aim of part-1 of this series was to merge the local verbose and quiet option with the global verbose and quiet, which it did successfully.In this series, part-2, adds the global quiet option to the found chatty sub-commands. So each of the sub-commands outputs were individually checked and brought those logs under the global quiet option. As this process is nondeterministic (unless like in part-1 where sub-commands with -v or -q were checked) so there might have few logs left behind and those can be fixed as moved along.
The whole series can be fetched from [2], which is based on latest devel branch, last commit:
c1d6d654a3f9(btrfs-progs: docs: update balance).[2]
https://github.com/asj/btrfs-progs.git verbose
Quoted 9 lines
Anand Jain (8):
btrfs-progs: quota rescan: add quiet option
btrfs-progs: subvolume create: add quiet option
btrfs-progs: subvolume delete: add quiet option
btrfs-progs: balance start: add quiet option
btrfs-progs: balance resume: add quiet option
btrfs-progs: subvolume snapshot: add quiet option
btrfs-progs: scrub start|resume: use global quiet option
btrfs-progs: scrub cancel: add quiet option
Merged to devel, some time ago, with some fixups. Thanks.