]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
btrfs: don't print relocation messages from auto reclaim
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Tue, 8 Jul 2025 06:55:03 +0000 (08:55 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jul 2025 22:09:22 +0000 (00:09 +0200)
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.

Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/relocation.c
fs/btrfs/relocation.h
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index a5479c726e272886c001f2c649d8663492fc9b79..3e895427c7734e5b84fd0e79e7bcb6474f586e01 100644 (file)
@@ -1953,7 +1953,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",
index 175fc3acc38b77482f776ead7a16d0cbb952f1db..47ee3216e1e060157b32ca0171dbf2b1eb5c46eb 100644 (file)
@@ -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);
index 788c86d8633aff2b220166d1af34b054a28e53f7..5c36b3f84b578da39cbe117b71e5f5339b2aee5f 100644 (file)
@@ -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);
index 31aecd291d6cc6f905b1d2baecffca75d71b184d..3f098ce07577d19e81badf034440c160772cdcaf 100644 (file)
@@ -3412,7 +3412,8 @@ out:
        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 @@ again:
                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 @@ again:
                        }
                }
 
-               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 @@ again:
                        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)
index c2c28c71b0da093d213d0e0c317c5d6ee9f91548..a56e873a30295ee25c584a9a5f75c3a117a6379c 100644 (file)
@@ -763,7 +763,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);