Message ID | 20200608063851.8874-2-anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs-progs: add quiet option | expand |
On Mon, Jun 08, 2020 at 02:38:44PM +0800, Anand Jain wrote: > Enable the quiet option to the btrfs(8) quota rescan command. > Does the job quietly. For example: > btrfs --quiet quota rescan > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > cmds/quota.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/cmds/quota.c b/cmds/quota.c > index 075fc79816ad..4a68f9db081b 100644 > --- a/cmds/quota.c > +++ b/cmds/quota.c > @@ -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(-1, "quota rescan started\n"); That the raw value -1 is used here is not nice, I assume it means print unless there was another setting of the verbosity (nothing if -q, otherwise yes). > fflush(stdout); > } else if (ret < 0 && (!wait_for_completion || e != EINPROGRESS)) { > error("quota rescan failed: %m"); > -- > 2.25.1
On 10/6/20 4:30 pm, David Sterba wrote: > On Mon, Jun 08, 2020 at 02:38:44PM +0800, Anand Jain wrote: >> Enable the quiet option to the btrfs(8) quota rescan command. >> Does the job quietly. For example: >> btrfs --quiet quota rescan >> >> Signed-off-by: Anand Jain <anand.jain@oracle.com> >> --- >> cmds/quota.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/cmds/quota.c b/cmds/quota.c >> index 075fc79816ad..4a68f9db081b 100644 >> --- a/cmds/quota.c >> +++ b/cmds/quota.c >> @@ -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(-1, "quota rescan started\n"); > > That the raw value -1 is used here is not nice, I assume it means print > unless there was another setting of the verbosity (nothing if -q, > otherwise yes). Yes that's right. In v3 I have defined -1 as #define MUST_LOG -1 I ran out of ideas to name it more sensibly, open to suggestions. > >> fflush(stdout); >> } else if (ret < 0 && (!wait_for_completion || e != EINPROGRESS)) { >> error("quota rescan failed: %m"); >> -- >> 2.25.1
On Thu, Jun 11, 2020 at 09:16:37PM +0800, Anand Jain wrote: > On 10/6/20 4:30 pm, David Sterba wrote: > > On Mon, Jun 08, 2020 at 02:38:44PM +0800, Anand Jain wrote: > >> Enable the quiet option to the btrfs(8) quota rescan command. > >> Does the job quietly. For example: > >> btrfs --quiet quota rescan > >> > >> Signed-off-by: Anand Jain <anand.jain@oracle.com> > >> --- > >> cmds/quota.c | 4 +++- > >> 1 file changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/cmds/quota.c b/cmds/quota.c > >> index 075fc79816ad..4a68f9db081b 100644 > >> --- a/cmds/quota.c > >> +++ b/cmds/quota.c > >> @@ -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(-1, "quota rescan started\n"); > > > > That the raw value -1 is used here is not nice, I assume it means print > > unless there was another setting of the verbosity (nothing if -q, > > otherwise yes). > > Yes that's right. In v3 I have defined -1 as > > #define MUST_LOG -1 > > I ran out of ideas to name it more sensibly, open to suggestions. Ok, sounds reasonable to me. It can be documented and used only for the messages that must be printed due to backward compatibility. I have merged the first part to devel, so please send this patchset once you have it ready.
diff --git a/cmds/quota.c b/cmds/quota.c index 075fc79816ad..4a68f9db081b 100644 --- a/cmds/quota.c +++ b/cmds/quota.c @@ -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(-1, "quota rescan started\n"); fflush(stdout); } else if (ret < 0 && (!wait_for_completion || e != EINPROGRESS)) { error("quota rescan failed: %m");
Enable the quiet option to the btrfs(8) quota rescan command. Does the job quietly. For example: btrfs --quiet quota rescan Signed-off-by: Anand Jain <anand.jain@oracle.com> --- cmds/quota.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)