Skip to content

Commit 59cbbb9

Browse files
morbidrsakdave
authored andcommitted
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> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 367cd87 commit 59cbbb9

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

fs/btrfs/block-group.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1953,7 +1953,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)
19531953
spin_unlock(&bg->lock);
19541954

19551955
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);
19571957
if (ret) {
19581958
btrfs_dec_block_group_ro(bg);
19591959
btrfs_err(fs_info, "error relocating chunk %llu",

fs/btrfs/relocation.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3908,7 +3908,8 @@ static const char *stage_to_string(enum reloc_stage stage)
39083908
/*
39093909
* function to relocate all extents in a block group.
39103910
*/
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)
39123913
{
39133914
struct btrfs_block_group *bg;
39143915
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)
40004001
goto out;
40014002
}
40024003

4003-
describe_relocation(rc->block_group);
4004+
if (verbose)
4005+
describe_relocation(rc->block_group);
40044006

40054007
btrfs_wait_block_group_reservations(rc->block_group);
40064008
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)
40444046
if (rc->extents_found == 0)
40454047
break;
40464048

4047-
btrfs_info(fs_info, "found %llu extents, stage: %s",
4048-
rc->extents_found, stage_to_string(finishes_stage));
4049+
if (verbose)
4050+
btrfs_info(fs_info, "found %llu extents, stage: %s",
4051+
rc->extents_found,
4052+
stage_to_string(finishes_stage));
40494053
}
40504054

40514055
WARN_ON(rc->block_group->pinned > 0);

fs/btrfs/relocation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ struct btrfs_trans_handle;
1212
struct btrfs_ordered_extent;
1313
struct btrfs_pending_snapshot;
1414

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);
1617
int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, struct btrfs_root *root);
1718
int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
1819
struct btrfs_root *root);

fs/btrfs/volumes.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,7 +3412,8 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans, u64 chunk_offset)
34123412
return ret;
34133413
}
34143414

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)
34163417
{
34173418
struct btrfs_root *root = fs_info->chunk_root;
34183419
struct btrfs_trans_handle *trans;
@@ -3442,7 +3443,7 @@ int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
34423443

34433444
/* step one, relocate all the extents inside this chunk */
34443445
btrfs_scrub_pause(fs_info);
3445-
ret = btrfs_relocate_block_group(fs_info, chunk_offset);
3446+
ret = btrfs_relocate_block_group(fs_info, chunk_offset, true);
34463447
btrfs_scrub_continue(fs_info);
34473448
if (ret) {
34483449
/*
@@ -3552,7 +3553,8 @@ static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info)
35523553
btrfs_release_path(path);
35533554

35543555
if (chunk_type & BTRFS_BLOCK_GROUP_SYSTEM) {
3555-
ret = btrfs_relocate_chunk(fs_info, found_key.offset);
3556+
ret = btrfs_relocate_chunk(fs_info, found_key.offset,
3557+
true);
35563558
if (ret == -ENOSPC)
35573559
failed++;
35583560
else
@@ -4217,7 +4219,7 @@ static int __btrfs_balance(struct btrfs_fs_info *fs_info)
42174219
}
42184220
}
42194221

4220-
ret = btrfs_relocate_chunk(fs_info, found_key.offset);
4222+
ret = btrfs_relocate_chunk(fs_info, found_key.offset, true);
42214223
mutex_unlock(&fs_info->reclaim_bgs_lock);
42224224
if (ret == -ENOSPC) {
42234225
enospc_errors++;
@@ -4985,7 +4987,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size)
49854987
goto done;
49864988
}
49874989

4988-
ret = btrfs_relocate_chunk(fs_info, chunk_offset);
4990+
ret = btrfs_relocate_chunk(fs_info, chunk_offset, true);
49894991
mutex_unlock(&fs_info->reclaim_bgs_lock);
49904992
if (ret == -ENOSPC) {
49914993
failed++;
@@ -8198,7 +8200,7 @@ static int relocating_repair_kthread(void *data)
81988200
btrfs_info(fs_info,
81998201
"zoned: relocating block group %llu to repair IO failure",
82008202
target);
8201-
ret = btrfs_relocate_chunk(fs_info, target);
8203+
ret = btrfs_relocate_chunk(fs_info, target, true);
82028204

82038205
out:
82048206
if (cache)

fs/btrfs/volumes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,8 @@ void btrfs_describe_block_groups(u64 flags, char *buf, u32 size_buf);
763763
int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info);
764764
int btrfs_recover_balance(struct btrfs_fs_info *fs_info);
765765
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);
767768
int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
768769
bool btrfs_chunk_writeable(struct btrfs_fs_info *fs_info, u64 chunk_offset);
769770
void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index);

0 commit comments

Comments
 (0)