mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-10 03:01:28 +00:00
btrfs-progs: defrag: fix verbosity with default level
Defrag should not print the filenames by default, this got accidentally changed in v6.0. Do a workaround that restores the original behaviour, ie. no filenames and print them with -v, either as global or local option. Proper fix is not to initialize with BTRFS_BCONF_UNSET and only adjust the levels by -v/-q options. Issue: #540 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
fbb1170111
commit
9b9216668d
@ -880,7 +880,7 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
|
|||||||
int fd = 0;
|
int fd = 0;
|
||||||
|
|
||||||
if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
|
if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
|
||||||
pr_verbose(1, "%s\n", fpath);
|
pr_verbose(LOG_INFO, "%s\n", fpath);
|
||||||
fd = open(fpath, defrag_open_mode);
|
fd = open(fpath, defrag_open_mode);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
goto error;
|
goto error;
|
||||||
@ -934,6 +934,19 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
|
|||||||
*/
|
*/
|
||||||
thresh = SZ_32M;
|
thresh = SZ_32M;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Workaround to emulate previous behaviour, the log level has to be
|
||||||
|
* adjusted:
|
||||||
|
*
|
||||||
|
* - btrfs fi defrag - no file names printed (LOG_DEFAULT)
|
||||||
|
* - btrfs fi defrag -v - filenames printed (LOG_INFO)
|
||||||
|
* - btrfs -v fi defrag - filenames printed (LOG_INFO)
|
||||||
|
* - btrfs -v fi defrag -v - filenames printed (LOG_VERBOSE)
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (bconf.verbose != BTRFS_BCONF_UNSET)
|
||||||
|
bconf.verbose++;
|
||||||
|
|
||||||
defrag_global_errors = 0;
|
defrag_global_errors = 0;
|
||||||
defrag_global_errors = 0;
|
defrag_global_errors = 0;
|
||||||
optind = 0;
|
optind = 0;
|
||||||
@ -952,7 +965,10 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
|
|||||||
flush = true;
|
flush = true;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
bconf_be_verbose();
|
if (bconf.verbose == BTRFS_BCONF_UNSET)
|
||||||
|
bconf.verbose = LOG_INFO;
|
||||||
|
else
|
||||||
|
bconf_be_verbose();
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
start = parse_size_from_string(optarg);
|
start = parse_size_from_string(optarg);
|
||||||
@ -1052,7 +1068,7 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
|
|||||||
/* errors are handled in the callback */
|
/* errors are handled in the callback */
|
||||||
ret = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
pr_verbose(1, "%s\n", argv[i]);
|
pr_verbose(LOG_INFO, "%s\n", argv[i]);
|
||||||
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
|
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
|
||||||
&defrag_global_range);
|
&defrag_global_range);
|
||||||
defrag_err = errno;
|
defrag_err = errno;
|
||||||
|
Loading…
Reference in New Issue
Block a user