@@ -840,6 +840,8 @@ static const char * const cmd_filesystem_defrag_usage[] = {
"-s start defragment only from byte onward",
"-l len defragment only up to len bytes",
"-t size target extent size hint (default: 32M)",
+ HELPINFO_INSERT_GLOBALS,
+ HELPINFO_INSERT_VERBOSE,
"",
"Warning: most Linux kernels will break up the ref-links of COW data",
"(e.g., files copied with 'cp --reflink', snapshots) which may cause",
@@ -849,7 +851,6 @@ static const char * const cmd_filesystem_defrag_usage[] = {
};
static struct btrfs_ioctl_defrag_range_args defrag_global_range;
-static int defrag_global_verbose;
static int defrag_global_errors;
static int defrag_callback(const char *fpath, const struct stat *sb,
int typeflag, struct FTW *ftwbuf)
@@ -858,8 +859,7 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
int fd = 0;
if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
- if (defrag_global_verbose)
- printf("%s\n", fpath);
+ pr_verbose(1, "%s\n", fpath);
fd = open(fpath, defrag_open_mode);
if (fd < 0) {
goto error;
@@ -914,7 +914,6 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
thresh = SZ_32M;
defrag_global_errors = 0;
- defrag_global_verbose = 0;
defrag_global_errors = 0;
optind = 0;
while(1) {
@@ -932,7 +931,7 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
flush = 1;
break;
case 'v':
- defrag_global_verbose = 1;
+ bconf_be_verbose();
break;
case 's':
start = parse_size(optarg);
@@ -1032,8 +1031,7 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
/* errors are handled in the callback */
ret = 0;
} else {
- if (defrag_global_verbose)
- printf("%s\n", argv[i]);
+ pr_verbose(1, "%s\n", argv[i]);
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
&defrag_global_range);
defrag_err = errno;
Transpire global --verbose option down to the btrfs receive sub-command. Suggested-by: David Sterba <dsterba@suse.com> Signed-off-by: Anand Jain <anand.jain@oracle.com> --- v3: Space after HELPINFO_INSERT_VERBOSE, in the usage. v2: Use new helper functions and defines HELPINFO_INSERT_GLOBALS, BTRFS_BCONF_UNSET, BTRFS_BCONF_QUIET bconf_be_verbose() No need to init bconf.verbose in the sub command. Move the HELPINFO_INSERT_GLOBALS, and HELPINFO_INSERT_VERBOSE, right after the command options. cmds/filesystem.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)