Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: don't print relocation messages from auto reclaim

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>

authored by

Johannes Thumshirn and committed by
David Sterba
5ae011bc a5079040

+21 -13
+1 -1
fs/btrfs/block-group.c
··· 1953 1953 spin_unlock(&bg->lock); 1954 1954 1955 1955 trace_btrfs_reclaim_block_group(bg); 1956 - ret = btrfs_relocate_chunk(fs_info, bg->start); 1956 + ret = btrfs_relocate_chunk(fs_info, bg->start, false); 1957 1957 if (ret) { 1958 1958 btrfs_dec_block_group_ro(bg); 1959 1959 btrfs_err(fs_info, "error relocating chunk %llu",
+8 -4
fs/btrfs/relocation.c
··· 3908 3908 /* 3909 3909 * function to relocate all extents in a block group. 3910 3910 */ 3911 - int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) 3911 + int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start, 3912 + bool verbose) 3912 3913 { 3913 3914 struct btrfs_block_group *bg; 3914 3915 struct btrfs_root *extent_root = btrfs_extent_root(fs_info, group_start); ··· 4001 4000 goto out; 4002 4001 } 4003 4002 4004 - describe_relocation(rc->block_group); 4003 + if (verbose) 4004 + describe_relocation(rc->block_group); 4005 4005 4006 4006 btrfs_wait_block_group_reservations(rc->block_group); 4007 4007 btrfs_wait_nocow_writers(rc->block_group); ··· 4046 4044 if (rc->extents_found == 0) 4047 4045 break; 4048 4046 4049 - btrfs_info(fs_info, "found %llu extents, stage: %s", 4050 - rc->extents_found, stage_to_string(finishes_stage)); 4047 + if (verbose) 4048 + btrfs_info(fs_info, "found %llu extents, stage: %s", 4049 + rc->extents_found, 4050 + stage_to_string(finishes_stage)); 4051 4051 } 4052 4052 4053 4053 WARN_ON(rc->block_group->pinned > 0);
+2 -1
fs/btrfs/relocation.h
··· 12 12 struct btrfs_ordered_extent; 13 13 struct btrfs_pending_snapshot; 14 14 15 - int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start); 15 + int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start, 16 + bool verbose); 16 17 int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root); 17 18 int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, 18 19 struct btrfs_root *root);
+8 -6
fs/btrfs/volumes.c
··· 3412 3412 return ret; 3413 3413 } 3414 3414 3415 - int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset) 3415 + int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset, 3416 + bool verbose) 3416 3417 { 3417 3418 struct btrfs_root *root = fs_info->chunk_root; 3418 3419 struct btrfs_trans_handle *trans; ··· 3443 3442 3444 3443 /* step one, relocate all the extents inside this chunk */ 3445 3444 btrfs_scrub_pause(fs_info); 3446 - ret = btrfs_relocate_block_group(fs_info, chunk_offset); 3445 + ret = btrfs_relocate_block_group(fs_info, chunk_offset, true); 3447 3446 btrfs_scrub_continue(fs_info); 3448 3447 if (ret) { 3449 3448 /* ··· 3553 3552 btrfs_release_path(path); 3554 3553 3555 3554 if (chunk_type & BTRFS_BLOCK_GROUP_SYSTEM) { 3556 - ret = btrfs_relocate_chunk(fs_info, found_key.offset); 3555 + ret = btrfs_relocate_chunk(fs_info, found_key.offset, 3556 + true); 3557 3557 if (ret == -ENOSPC) 3558 3558 failed++; 3559 3559 else ··· 4219 4217 } 4220 4218 } 4221 4219 4222 - ret = btrfs_relocate_chunk(fs_info, found_key.offset); 4220 + ret = btrfs_relocate_chunk(fs_info, found_key.offset, true); 4223 4221 mutex_unlock(&fs_info->reclaim_bgs_lock); 4224 4222 if (ret == -ENOSPC) { 4225 4223 enospc_errors++; ··· 4987 4985 goto done; 4988 4986 } 4989 4987 4990 - ret = btrfs_relocate_chunk(fs_info, chunk_offset); 4988 + ret = btrfs_relocate_chunk(fs_info, chunk_offset, true); 4991 4989 mutex_unlock(&fs_info->reclaim_bgs_lock); 4992 4990 if (ret == -ENOSPC) { 4993 4991 failed++; ··· 8200 8198 btrfs_info(fs_info, 8201 8199 "zoned: relocating block group %llu to repair IO failure", 8202 8200 target); 8203 - ret = btrfs_relocate_chunk(fs_info, target); 8201 + ret = btrfs_relocate_chunk(fs_info, target, true); 8204 8202 8205 8203 out: 8206 8204 if (cache)
+2 -1
fs/btrfs/volumes.h
··· 763 763 int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info); 764 764 int btrfs_recover_balance(struct btrfs_fs_info *fs_info); 765 765 int btrfs_pause_balance(struct btrfs_fs_info *fs_info); 766 - int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset); 766 + int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset, 767 + bool verbose); 767 768 int btrfs_cancel_balance(struct btrfs_fs_info *fs_info); 768 769 bool btrfs_chunk_writeable(struct btrfs_fs_info *fs_info, u64 chunk_offset); 769 770 void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);