* [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim
@ 2025-07-08 6:55 Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 1/2] btrfs: remove redundant auto reclaim log message Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2025-07-08 6:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Johannes Thumshirn
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
BTRFS filesystems with active automatic block-group reclaim (this
especially hits zoned file systems where automatic block-group reclaim is
used for garbage collection) do a lot of log spamming, because every
relocated block group is accompanied by three prints at info level.
The first patch removes the info message that is only present with
automatic block group reclaim, we have a tracepoint right next to it so
there's no need for the message at all.
The second patch introduces a `verbose` parameter for
`btrfs_relocate_chunk()` and `btrfs_relocate_block_group()` to control if
we want to add printks or not. Automatic reclaim calls into
`btrfs_relocate_chunk()` setting `verbose` to false while the user-space
triggered balance code path sets `verbose` to true retaining the old
behaviour.
Johannes Thumshirn (2):
btrfs: remove redundant auto reclaim log message
btrfs: don't print relocation messages from auto reclaim
fs/btrfs/block-group.c | 8 +-------
fs/btrfs/relocation.c | 12 ++++++++----
fs/btrfs/relocation.h | 3 ++-
fs/btrfs/volumes.c | 14 ++++++++------
fs/btrfs/volumes.h | 3 ++-
5 files changed, 21 insertions(+), 19 deletions(-)
--
2.50.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] btrfs: remove redundant auto reclaim log message
2025-07-08 6:55 [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Johannes Thumshirn
@ 2025-07-08 6:55 ` Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 2/2] btrfs: don't print relocation messages from auto reclaim Johannes Thumshirn
2025-07-08 16:01 ` [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Boris Burkov
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2025-07-08 6:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Johannes Thumshirn
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Remove the log message before reclaiming a chunk in
`btrfs_reclaim_bgs_work()`. Especially with automatic block-group
reclaiming these messages spam the kernel log.
Note there is also a tracepoint for the same condition to ease debugging.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/block-group.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index fb62a8cf03b3..b01408f0b92a 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1963,12 +1963,6 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
reserved = bg->reserved;
spin_unlock(&bg->lock);
- btrfs_info(fs_info,
- "reclaiming chunk %llu with %llu%% used %llu%% reserved %llu%% unusable",
- bg->start,
- div64_u64(used * 100, bg->length),
- div64_u64(reserved * 100, bg->length),
- div64_u64(zone_unusable * 100, bg->length));
trace_btrfs_reclaim_block_group(bg);
ret = btrfs_relocate_chunk(fs_info, bg->start);
if (ret) {
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] btrfs: don't print relocation messages from auto reclaim
2025-07-08 6:55 [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 1/2] btrfs: remove redundant auto reclaim log message Johannes Thumshirn
@ 2025-07-08 6:55 ` Johannes Thumshirn
2025-07-08 16:01 ` [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Boris Burkov
2 siblings, 0 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2025-07-08 6:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Johannes Thumshirn
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
When BTRFS is doing automatic block-group reclaim, it is spamming the
kernel log messages a lot.
Add a `verbose` parameter to `btrfs_relocate_chunk()` and
`btrfs_relocate_block_group()` to control the verbosity of these log
message. This way the old behaviour of printing log messages on a
user-space initiated balance operation can be kept while excessive log
spamming due to auto reclaim is mitigated.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
fs/btrfs/block-group.c | 2 +-
fs/btrfs/relocation.c | 12 ++++++++----
fs/btrfs/relocation.h | 3 ++-
fs/btrfs/volumes.c | 14 ++++++++------
fs/btrfs/volumes.h | 3 ++-
5 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c
index b01408f0b92a..042f8566c7cc 100644
--- a/fs/btrfs/block-group.c
+++ b/fs/btrfs/block-group.c
@@ -1964,7 +1964,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
spin_unlock(&bg->lock);
trace_btrfs_reclaim_block_group(bg);
- ret = btrfs_relocate_chunk(fs_info, bg->start);
+ ret = btrfs_relocate_chunk(fs_info, bg->start, false);
if (ret) {
btrfs_dec_block_group_ro(bg);
btrfs_err(fs_info, "error relocating chunk %llu",
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 175fc3acc38b..47ee3216e1e0 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3908,7 +3908,8 @@ static const char *stage_to_string(enum reloc_stage stage)
/*
* function to relocate all extents in a block group.
*/
-int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
+int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start,
+ bool verbose)
{
struct btrfs_block_group *bg;
struct btrfs_root *extent_root = btrfs_extent_root(fs_info, group_start);
@@ -4000,7 +4001,8 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
goto out;
}
- describe_relocation(rc->block_group);
+ if (verbose)
+ describe_relocation(rc->block_group);
btrfs_wait_block_group_reservations(rc->block_group);
btrfs_wait_nocow_writers(rc->block_group);
@@ -4044,8 +4046,10 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
if (rc->extents_found == 0)
break;
- btrfs_info(fs_info, "found %llu extents, stage: %s",
- rc->extents_found, stage_to_string(finishes_stage));
+ if (verbose)
+ btrfs_info(fs_info, "found %llu extents, stage: %s",
+ rc->extents_found,
+ stage_to_string(finishes_stage));
}
WARN_ON(rc->block_group->pinned > 0);
diff --git a/fs/btrfs/relocation.h b/fs/btrfs/relocation.h
index 788c86d8633a..5c36b3f84b57 100644
--- a/fs/btrfs/relocation.h
+++ b/fs/btrfs/relocation.h
@@ -12,7 +12,8 @@ struct btrfs_trans_handle;
struct btrfs_ordered_extent;
struct btrfs_pending_snapshot;
-int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start);
+int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start,
+ bool verbose);
int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root);
int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
struct btrfs_root *root);
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 31aecd291d6c..3f098ce07577 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3412,7 +3412,8 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
return ret;
}
-int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
+int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset,
+ bool verbose)
{
struct btrfs_root *root = fs_info->chunk_root;
struct btrfs_trans_handle *trans;
@@ -3442,7 +3443,7 @@ int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
/* step one, relocate all the extents inside this chunk */
btrfs_scrub_pause(fs_info);
- ret = btrfs_relocate_block_group(fs_info, chunk_offset);
+ ret = btrfs_relocate_block_group(fs_info, chunk_offset, true);
btrfs_scrub_continue(fs_info);
if (ret) {
/*
@@ -3552,7 +3553,8 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
btrfs_release_path(path);
if (chunk_type & BTRFS_BLOCK_GROUP_SYSTEM) {
- ret = btrfs_relocate_chunk(fs_info, found_key.offset);
+ ret = btrfs_relocate_chunk(fs_info, found_key.offset,
+ true);
if (ret == -ENOSPC)
failed++;
else
@@ -4217,7 +4219,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
}
}
- ret = btrfs_relocate_chunk(fs_info, found_key.offset);
+ ret = btrfs_relocate_chunk(fs_info, found_key.offset, true);
mutex_unlock(&fs_info->reclaim_bgs_lock);
if (ret == -ENOSPC) {
enospc_errors++;
@@ -4985,7 +4987,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
goto done;
}
- ret = btrfs_relocate_chunk(fs_info, chunk_offset);
+ ret = btrfs_relocate_chunk(fs_info, chunk_offset, true);
mutex_unlock(&fs_info->reclaim_bgs_lock);
if (ret == -ENOSPC) {
failed++;
@@ -8198,7 +8200,7 @@ static int relocating_repair_kthread(void *data)
btrfs_info(fs_info,
"zoned: relocating block group %llu to repair IO failure",
target);
- ret = btrfs_relocate_chunk(fs_info, target);
+ ret = btrfs_relocate_chunk(fs_info, target, true);
out:
if (cache)
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 7395cb5e1238..ab3163897049 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -765,7 +765,8 @@ void btrfs_describe_block_groups(u64 flags, char *buf, u32 size_buf);
int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info);
int btrfs_recover_balance(struct btrfs_fs_info *fs_info);
int btrfs_pause_balance(struct btrfs_fs_info *fs_info);
-int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset);
+int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset,
+ bool verbose);
int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
bool btrfs_chunk_writeable(struct btrfs_fs_info *fs_info, u64 chunk_offset);
void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);
--
2.50.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim
2025-07-08 6:55 [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 1/2] btrfs: remove redundant auto reclaim log message Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 2/2] btrfs: don't print relocation messages from auto reclaim Johannes Thumshirn
@ 2025-07-08 16:01 ` Boris Burkov
2 siblings, 0 replies; 4+ messages in thread
From: Boris Burkov @ 2025-07-08 16:01 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-btrfs, Johannes Thumshirn
On Tue, Jul 08, 2025 at 08:55:01AM +0200, Johannes Thumshirn wrote:
> From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
>
> BTRFS filesystems with active automatic block-group reclaim (this
> especially hits zoned file systems where automatic block-group reclaim is
> used for garbage collection) do a lot of log spamming, because every
> relocated block group is accompanied by three prints at info level.
>
> The first patch removes the info message that is only present with
> automatic block group reclaim, we have a tracepoint right next to it so
> there's no need for the message at all.
>
> The second patch introduces a `verbose` parameter for
> `btrfs_relocate_chunk()` and `btrfs_relocate_block_group()` to control if
> we want to add printks or not. Automatic reclaim calls into
> `btrfs_relocate_chunk()` setting `verbose` to false while the user-space
> triggered balance code path sets `verbose` to true retaining the old
> behaviour.
We also struggle with the spam at Meta with automatic reclaim enabled
though quite a bit less with dynamic.. :) In particular, users often
think it means there is some kind of btrfs error happening.
This looks like a good compromise to me, and I'd be quite happy to see
it go in.
Reviewed-by: Boris Burkov <boris@bur.io>
Thanks!
>
> Johannes Thumshirn (2):
> btrfs: remove redundant auto reclaim log message
> btrfs: don't print relocation messages from auto reclaim
>
> fs/btrfs/block-group.c | 8 +-------
> fs/btrfs/relocation.c | 12 ++++++++----
> fs/btrfs/relocation.h | 3 ++-
> fs/btrfs/volumes.c | 14 ++++++++------
> fs/btrfs/volumes.h | 3 ++-
> 5 files changed, 21 insertions(+), 19 deletions(-)
>
> --
> 2.50.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-08 16:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 6:55 [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 1/2] btrfs: remove redundant auto reclaim log message Johannes Thumshirn
2025-07-08 6:55 ` [PATCH 2/2] btrfs: don't print relocation messages from auto reclaim Johannes Thumshirn
2025-07-08 16:01 ` [PATCH 0/2] btrfs: be less verbose on automatic bg reclaim Boris Burkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox