linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 00/18] btrfs-progs: global verbose and quiet option
@ 2019-10-30  8:41 Anand Jain
  2019-10-30  8:41 ` [PATCH v1 01/18] btrfs-progs: receive: fix option quiet Anand Jain
                   ` (17 more replies)
  0 siblings, 18 replies; 23+ messages in thread
From: Anand Jain @ 2019-10-30  8:41 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba

RFC->v1:
. Adds --quiet option to the global btrfs(8) command.
. Used global struct bconf.
. Refactored pr_verbose(), accepts level (int) as argument, so now the
sub-command can specify the verbose level at which the particular
verbose messages has to be printed.
. Added global help defines.

Kindly note the following:-

1.
 There are certain sub-commands which does not have any verbose output
 or quiet output. However if the global options were used with those
 sub-commands then the command shall not report any usage error. Or
 my question is should it error out.? For example:
  (with the patch) btrfs --verbose device ready /dev/sdb
 actually there isn't any verbose output but we won't error out.
 Similarly,
  (without the patch) btrfs send -vvvvv will not show usage error
  as well.
  So I believe this is fine. IMO.

2.
  There is slight difference in output when global options are used
  as compared to the output using the same sequence of options at the
  sub-command level. For example:

   btrfs send -v -q -v  is-equal-to  btrfs send
   But same sequence in the global option
   btrfs -v -q -v send is-not-equal-to btrfs send
   but is-equal-to btrfs -v send or btrfs send -v.
   (similarly applies to receive as well).

  which IMO is fair expectation as -v is ending last.


RFC:
This patch set brings --verbose option to the top level btrfs command,
such as 'btrfs --verbose'. With this we don't have to add or remember
verbose option at the sub-commands level.

As there are already verbose options to 11 sub-commands as listed
below [1][2]. So the top level --verbose option here takes care to transpire
verbose request from the top level to the sub-command level for 9 (not 11)
sub-commands as in [1] as of now.

This patch is RFC still for the following two reasons (comments appreciated).

1.
The sub-commands as in [2] uses multi-level compile time verbose option,
such as %g_verbose = 0 (quite), %g_verbose = 1 (default), %g_verbose > 1
(real-verbose). And verbose at default is also part the .out files in
fstests. So it needs further discussions on how to handle the multi-
level verbose option using the global verbose option, and so sub-
commands in [2] are untouched.

2.
These patch has been unit-tested individually.
These patches does not alter the verbose output.
But it fixes the indentation in the command's help output, which may be
used in fstests and btrfs-progs/tests and their verification is pending
still, which I am planning to do it before v1.

[1]
btrfs subvolume delete --help
        -v|--verbose           verbose output of operations
btrfs filesystem defragment --help
        -v                  be verbose
btrfs balance start --help
        -v|--verbose        be verbose
btrfs balance status --help
        -v|--verbose        be verbose
btrfs rescue chunk-recover --help
        -v      Verbose mode
btrfs rescue super-recover --help
        -v      Verbose mode
btrfs restore --help
        -v|--verbose         verbose
btrfs inspect-internal inode-resolve --help
        -v   verbose mode
btrfs inspect-internal logical-resolve --help
        -v          verbose mode

[2]
btrfs send --help
        -v|--verbose     enable verbose output to stderr, each occurrence of
btrfs receive --help
        -v               increase verbosity about performed action

Anand Jain (18):
  btrfs-progs: receive: fix option quiet
  btrfs-progs: balance status: fix usage show long verbose
  btrfs-progs: balance start: fix usage add long verbose
  btrfs-progs: add global verbose and quiet options and helper functions
  btrfs-progs: send: use global verbose and quiet options
  btrfs-progs: receive: use global verbose and quiet options
  btrfs-progs: subvolume delete: use global verbose option
  btrfs-progs: filesystem defragment: use global verbose option
  btrfs-progs: balance start: use global verbose option
  btrfs-progs: balance status: use global verbose option
  btrfs-progs: rescue chunk-recover: use global verbose option
  btrfs-progs: rescue super-recover: use global verbose option
  btrfs-progs: restore: use global verbose option
  btrfs-progs: inspect-internal inode-resolve: use global verbose
  btrfs-progs: inspect-internal logical-resolve: use global verbose
    option
  btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument
  btrfs-progs: device scan: add verbose option
  btrfs-progs: device scan: add quiet option

 btrfs.c              | 20 +++++++++--
 cmds/balance.c       | 26 ++++++++++-----
 cmds/device.c        |  7 ++--
 cmds/filesystem.c    | 18 +++++-----
 cmds/inspect.c       | 45 +++++++++++++------------
 cmds/receive.c       | 79 ++++++++++++++++++++++++--------------------
 cmds/rescue.c        | 22 ++++++++----
 cmds/restore.c       | 55 +++++++++++++++---------------
 cmds/send.c          | 33 +++++++++++-------
 cmds/subvolume.c     | 32 +++++++++---------
 common/device-scan.c |  4 ++-
 common/device-scan.h |  2 +-
 common/help.h        | 11 ++++++
 common/messages.c    | 18 ++++++++++
 common/messages.h    |  5 +++
 common/utils.c       |  3 +-
 common/utils.h       |  3 ++
 disk-io.c            |  2 +-
 18 files changed, 242 insertions(+), 143 deletions(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 23+ messages in thread
* [PATCH v1.1 00/18] btrfs-progs: global verbose and quiet option
@ 2019-11-04  6:32 Anand Jain
  2019-11-04  6:33 ` [PATCH v1 12/18] btrfs-progs: rescue super-recover: use global verbose option Anand Jain
  0 siblings, 1 reply; 23+ messages in thread
From: Anand Jain @ 2019-11-04  6:32 UTC (permalink / raw)
  To: linux-btrfs

v1->v1.1:
 . Fix typo in HELPINFO_INSERT_QUIET.
 . Remove #include <stdbool.h> where its no more required.
   (was needed when %bconf.verbose was declared as bool).
 . Use pr_verbose(-1,..) instead of all conditions printf()
 . Use pr_verbose(1,..) instead of pr_verbose(true,..)

verbosity sample code as in v1.1

global init
-----------
        bconf.verbose = -1; //-1:default, 0:quiet, >1:verbose

at global options
-----------------
	case 'v':
		bconf.verbose < 0 ? bconf.verbose = 1 : bconf.verbose++;
		break;
	case 'q':
		bconf.verbose = 0;
		break;

sub-command init
----------------
For send/receive only (special cases, default verbosity is 1):

	if (bconf.verbose < 0)
		bconf.verbose = 1;
	else if (bconf.verbose > 0)
		bconf.verbose++;

Non-send/receive:
default verbosity is 0 (ref: cmds/rescue.c)
	if (bconf.verbose < 0)
		bconf.verbose = 0;

at sub-command options
----------------------
	case 'v':
		bconf.verbose++;
		break;
	case 'q':
		bconf.verbose = 0;
		break;


pr_verbose()
------------
/*
 * level -1: prints message unless bconf.verbose == 0;
 * level  0: quiet
 * level >0: prints message only if <= bconf.verbose
 */
void pr_verbose(int level, const char *fmt, ...)
{
        va_list args;

        if (level == 0 || bconf.verbose == 0)
                return;

        if (level > bconf.verbose)
                return;

        va_start(args, fmt);
        vfprintf(stdout, fmt, args);
        va_end(args);
}


RFC->v1:
. Adds --quiet option to the global btrfs(8) command.
. Used global struct bconf.
. Refactored pr_verbose(), accepts level (int) as argument, so now the
sub-command can specify the verbose level at which the particular
verbose messages has to be printed.
. Added global help defines.

Kindly note the following:-

1.
 There are certain sub-commands which does not have any verbose output
 or quiet output. However if the global options were used with those
 sub-commands then the command shall not report any usage error. Or
 my question is should it error out.? For example:
  (with the patch) btrfs --verbose device ready /dev/sdb
 actually there isn't any verbose output but we won't error out.
 Similarly,
  (without the patch) btrfs send -vvvvv will not show usage error
  as well.
  So I believe this is fine. IMO.

2.
  There is slight difference in output when global options are used
  as compared to the output using the same sequence of options at the
  sub-command level. For example:

   btrfs send -v -q -v  is-equal-to  btrfs send
   But same sequence in the global option
   btrfs -v -q -v send is-not-equal-to btrfs send
   but is-equal-to btrfs -v send or btrfs send -v.
   (similarly applies to receive as well).

  which IMO is fair expectation as -v is ending last.


RFC:
This patch set brings --verbose option to the top level btrfs command,
such as 'btrfs --verbose'. With this we don't have to add or remember
verbose option at the sub-commands level.

As there are already verbose options to 11 sub-commands as listed
below [1][2]. So the top level --verbose option here takes care to transpire
verbose request from the top level to the sub-command level for 9 (not 11)
sub-commands as in [1] as of now.

This patch is RFC still for the following two reasons (comments appreciated).

1.
The sub-commands as in [2] uses multi-level compile time verbose option,
such as %g_verbose = 0 (quite), %g_verbose = 1 (default), %g_verbose > 1
(real-verbose). And verbose at default is also part the .out files in
fstests. So it needs further discussions on how to handle the multi-
level verbose option using the global verbose option, and so sub-
commands in [2] are untouched.

2.
These patch has been unit-tested individually.
These patches does not alter the verbose output.
But it fixes the indentation in the command's help output, which may be
used in fstests and btrfs-progs/tests and their verification is pending
still, which I am planning to do it before v1.

[1]
btrfs subvolume delete --help
        -v|--verbose           verbose output of operations
btrfs filesystem defragment --help
        -v                  be verbose
btrfs balance start --help
        -v|--verbose        be verbose
btrfs balance status --help
        -v|--verbose        be verbose
btrfs rescue chunk-recover --help
        -v      Verbose mode
btrfs rescue super-recover --help
        -v      Verbose mode
btrfs restore --help
        -v|--verbose         verbose
btrfs inspect-internal inode-resolve --help
        -v   verbose mode
btrfs inspect-internal logical-resolve --help
        -v          verbose mode

[2]
btrfs send --help
        -v|--verbose     enable verbose output to stderr, each occurrence of
btrfs receive --help
        -v               increase verbosity about performed action

Anand Jain (18):
  btrfs-progs: receive: fix option quiet
  btrfs-progs: balance status: fix usage show long verbose
  btrfs-progs: balance start: fix usage add long verbose
  btrfs-progs: add global verbose and quiet options and helper functions
  btrfs-progs: send: use global verbose and quiet options
  btrfs-progs: receive: use global verbose and quiet options
  btrfs-progs: subvolume delete: use global verbose option
  btrfs-progs: filesystem defragment: use global verbose option
  btrfs-progs: balance start: use global verbose option
  btrfs-progs: balance status: use global verbose option
  btrfs-progs: rescue chunk-recover: use global verbose option
  btrfs-progs: rescue super-recover: use global verbose option
  btrfs-progs: restore: use global verbose option
  btrfs-progs: inspect-internal inode-resolve: use global verbose
  btrfs-progs: inspect-internal logical-resolve: use global verbose
    option
  btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument
  btrfs-progs: device scan: add verbose option
  btrfs-progs: device scan: add quiet option

 btrfs.c              | 20 +++++++++++--
 cmds/balance.c       | 26 +++++++++++------
 cmds/device.c        |  7 +++--
 cmds/filesystem.c    | 18 ++++++------
 cmds/inspect.c       | 45 +++++++++++++++---------------
 cmds/receive.c       | 79 +++++++++++++++++++++++++++++-----------------------
 cmds/rescue.c        | 22 +++++++++++----
 cmds/restore.c       | 57 ++++++++++++++++++-------------------
 cmds/send.c          | 33 ++++++++++++++--------
 cmds/subvolume.c     | 32 +++++++++++----------
 common/device-scan.c |  3 +-
 common/device-scan.h |  2 +-
 common/help.h        | 11 ++++++++
 common/messages.c    | 17 +++++++++++
 common/messages.h    |  3 ++
 common/utils.c       |  3 +-
 common/utils.h       |  3 ++
 disk-io.c            |  2 +-
 18 files changed, 239 insertions(+), 144 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2019-11-04  6:34 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30  8:41 [PATCH v1 00/18] btrfs-progs: global verbose and quiet option Anand Jain
2019-10-30  8:41 ` [PATCH v1 01/18] btrfs-progs: receive: fix option quiet Anand Jain
2019-10-30  8:41 ` [PATCH v1 02/18] btrfs-progs: balance status: fix usage show long verbose Anand Jain
2019-10-30  8:41 ` [PATCH v1 03/18] btrfs-progs: balance start: fix usage add " Anand Jain
2019-10-30  8:41 ` [PATCH v1 04/18] btrfs-progs: add global verbose and quiet options and helper functions Anand Jain
2019-11-01  9:46   ` Antonio Pérez
2019-11-01 10:12     ` David Sterba
2019-11-02  1:15       ` Anand Jain
2019-10-30  8:41 ` [PATCH v1 05/18] btrfs-progs: send: use global verbose and quiet options Anand Jain
2019-10-30  8:41 ` [PATCH v1 06/18] btrfs-progs: receive: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 07/18] btrfs-progs: subvolume delete: use global verbose option Anand Jain
2019-10-30  8:41 ` [PATCH v1 08/18] btrfs-progs: filesystem defragment: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 09/18] btrfs-progs: balance start: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 10/18] btrfs-progs: balance status: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 11/18] btrfs-progs: rescue chunk-recover: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 12/18] btrfs-progs: rescue super-recover: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 13/18] btrfs-progs: restore: " Anand Jain
2019-10-30  8:41 ` [PATCH v1 14/18] btrfs-progs: inspect-internal inode-resolve: use global verbose Anand Jain
2019-10-30  8:41 ` [PATCH v1 15/18] btrfs-progs: inspect-internal logical-resolve: use global verbose option Anand Jain
2019-10-30  8:41 ` [PATCH v1 16/18] btrfs-progs: refactor btrfs_scan_devices() to accept verbose argument Anand Jain
2019-10-30  8:41 ` [PATCH v1 17/18] btrfs-progs: device scan: add verbose option Anand Jain
2019-10-30  8:41 ` [PATCH v1 18/18] btrfs-progs: device scan: add quiet option Anand Jain
2019-11-04  6:32 [PATCH v1.1 00/18] btrfs-progs: global verbose and " Anand Jain
2019-11-04  6:33 ` [PATCH v1 12/18] btrfs-progs: rescue super-recover: use global verbose option Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).