* [PATCH] btrfs-progs: fix the wrong log level of "filesystem defrag"
@ 2022-11-13 2:13 Qu Wenruo
2022-11-14 19:45 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Qu Wenruo @ 2022-11-13 2:13 UTC (permalink / raw)
To: linux-btrfs
[BUG]
Test case fstests:btrfs/021 will fail with v6.0 btrfs-progs, with the
extra output:
QA output created by 021
+/mnt/scratch/padding-0
+/mnt/scratch/padding-1
+/mnt/scratch/padding-2
+/mnt/scratch/padding-3
+/mnt/scratch/padding-4
+/mnt/scratch/padding-5
...
[CAUSE]
Commit db2f85c8751c ("btrfs-progs: fi defrag: add global verbose
option") changed the default message level to 1.
But the original code uses a different log level than the global verbose
level (previously log level 1 is not outputed by default).
Thus this increased the output level by default.
[FIX]
Don't use immediate number, and use LOG_INFO instead.
Fixes: db2f85c8751c ("btrfs-progs: fi defrag: add global verbose option")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
cmds/filesystem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmds/filesystem.c b/cmds/filesystem.c
index 7c8323d9db8a..22f7bf7daeb7 100644
--- a/cmds/filesystem.c
+++ b/cmds/filesystem.c
@@ -878,7 +878,7 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
int fd = 0;
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);
if (fd < 0) {
goto error;
@@ -1050,7 +1050,7 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
/* errors are handled in the callback */
ret = 0;
} else {
- pr_verbose(1, "%s\n", argv[i]);
+ pr_verbose(LOG_INFO, "%s\n", argv[i]);
ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
&defrag_global_range);
defrag_err = errno;
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs-progs: fix the wrong log level of "filesystem defrag"
2022-11-13 2:13 [PATCH] btrfs-progs: fix the wrong log level of "filesystem defrag" Qu Wenruo
@ 2022-11-14 19:45 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-11-14 19:45 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Sun, Nov 13, 2022 at 10:13:08AM +0800, Qu Wenruo wrote:
> [BUG]
> Test case fstests:btrfs/021 will fail with v6.0 btrfs-progs, with the
> extra output:
>
> QA output created by 021
> +/mnt/scratch/padding-0
> +/mnt/scratch/padding-1
> +/mnt/scratch/padding-2
> +/mnt/scratch/padding-3
> +/mnt/scratch/padding-4
> +/mnt/scratch/padding-5
> ...
>
> [CAUSE]
> Commit db2f85c8751c ("btrfs-progs: fi defrag: add global verbose
> option") changed the default message level to 1.
>
> But the original code uses a different log level than the global verbose
> level (previously log level 1 is not outputed by default).
>
> Thus this increased the output level by default.
>
> [FIX]
> Don't use immediate number, and use LOG_INFO instead.
>
> Fixes: db2f85c8751c ("btrfs-progs: fi defrag: add global verbose option")
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> cmds/filesystem.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cmds/filesystem.c b/cmds/filesystem.c
> index 7c8323d9db8a..22f7bf7daeb7 100644
> --- a/cmds/filesystem.c
> +++ b/cmds/filesystem.c
> @@ -878,7 +878,7 @@ static int defrag_callback(const char *fpath, const struct stat *sb,
> int fd = 0;
>
> if ((typeflag == FTW_F) && S_ISREG(sb->st_mode)) {
> - pr_verbose(1, "%s\n", fpath);
> + pr_verbose(LOG_INFO, "%s\n", fpath);
That fixes the levels, yes but unfortunatelly the command line does not
work the same:
"btrfs defrag -v" still does not print the file names because this way
it'll set the verbosity level to 1 and LOG_INFO is 2, -vv works as
before.
> fd = open(fpath, defrag_open_mode);
> if (fd < 0) {
> goto error;
> @@ -1050,7 +1050,7 @@ static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
> /* errors are handled in the callback */
> ret = 0;
> } else {
> - pr_verbose(1, "%s\n", argv[i]);
> + pr_verbose(LOG_INFO, "%s\n", argv[i]);
> ret = ioctl(fd, BTRFS_IOC_DEFRAG_RANGE,
> &defrag_global_range);
> defrag_err = errno;
> --
> 2.38.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-14 19:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-13 2:13 [PATCH] btrfs-progs: fix the wrong log level of "filesystem defrag" Qu Wenruo
2022-11-14 19:45 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.