diff --git a/cmds/filesystem.c b/cmds/filesystem.c index 936db672..9a88e24e 100644 --- a/cmds/filesystem.c +++ b/cmds/filesystem.c @@ -841,6 +841,8 @@ static const char * const cmd_filesystem_defrag_usage[] = { "-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", "considerable increase of space usage. See btrfs-filesystem(8) for", @@ -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;