Skip to content

Commit 65d5112

Browse files
asjkdave
authored andcommitted
btrfs: scrub: add prefix for the error messages
Add a "scrub: " prefix to all messages logged by scrub so that it's easy to filter them from dmesg for analysis. Reviewed-by: Filipe Manana <[email protected]> Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Anand Jain <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 186b9dc commit 65d5112

File tree

2 files changed

+27
-28
lines changed

2 files changed

+27
-28
lines changed

fs/btrfs/ioctl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3142,7 +3142,7 @@ static long btrfs_ioctl_scrub(struct file *file, void __user *arg)
31423142
return -EPERM;
31433143

31443144
if (btrfs_fs_incompat(fs_info, EXTENT_TREE_V2)) {
3145-
btrfs_err(fs_info, "scrub is not supported on extent tree v2 yet");
3145+
btrfs_err(fs_info, "scrub: extent tree v2 not yet supported");
31463146
return -EINVAL;
31473147
}
31483148

fs/btrfs/scrub.c

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
557557
*/
558558
for (i = 0; i < ipath->fspath->elem_cnt; ++i)
559559
btrfs_warn_in_rcu(fs_info,
560-
"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu, length %u, links %u (path: %s)",
560+
"scrub: %s at logical %llu on dev %s, physical %llu root %llu inode %llu offset %llu length %u links %u (path: %s)",
561561
swarn->errstr, swarn->logical,
562562
btrfs_dev_name(swarn->dev),
563563
swarn->physical,
@@ -571,7 +571,7 @@ static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
571571

572572
err:
573573
btrfs_warn_in_rcu(fs_info,
574-
"%s at logical %llu on dev %s, physical %llu, root %llu, inode %llu, offset %llu: path resolving failed with ret=%d",
574+
"scrub: %s at logical %llu on dev %s, physical %llu root %llu inode %llu offset %llu: path resolving failed with ret=%d",
575575
swarn->errstr, swarn->logical,
576576
btrfs_dev_name(swarn->dev),
577577
swarn->physical,
@@ -596,7 +596,7 @@ static void scrub_print_common_warning(const char *errstr, struct btrfs_device *
596596

597597
/* Super block error, no need to search extent tree. */
598598
if (is_super) {
599-
btrfs_warn_in_rcu(fs_info, "%s on device %s, physical %llu",
599+
btrfs_warn_in_rcu(fs_info, "scrub: %s on device %s, physical %llu",
600600
errstr, btrfs_dev_name(dev), physical);
601601
return;
602602
}
@@ -631,14 +631,14 @@ static void scrub_print_common_warning(const char *errstr, struct btrfs_device *
631631
&ref_level);
632632
if (ret < 0) {
633633
btrfs_warn(fs_info,
634-
"failed to resolve tree backref for logical %llu: %d",
635-
swarn.logical, ret);
634+
"scrub: failed to resolve tree backref for logical %llu: %d",
635+
swarn.logical, ret);
636636
break;
637637
}
638638
if (ret > 0)
639639
break;
640640
btrfs_warn_in_rcu(fs_info,
641-
"%s at logical %llu on dev %s, physical %llu: metadata %s (level %d) in tree %llu",
641+
"scrub: %s at logical %llu on dev %s, physical %llu: metadata %s (level %d) in tree %llu",
642642
errstr, swarn.logical, btrfs_dev_name(dev),
643643
swarn.physical, (ref_level ? "node" : "leaf"),
644644
ref_level, ref_root);
@@ -718,7 +718,7 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
718718
scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
719719
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
720720
btrfs_warn_rl(fs_info,
721-
"tree block %llu mirror %u has bad bytenr, has %llu want %llu",
721+
"scrub: tree block %llu mirror %u has bad bytenr, has %llu want %llu",
722722
logical, stripe->mirror_num,
723723
btrfs_stack_header_bytenr(header), logical);
724724
return;
@@ -728,7 +728,7 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
728728
scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
729729
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
730730
btrfs_warn_rl(fs_info,
731-
"tree block %llu mirror %u has bad fsid, has %pU want %pU",
731+
"scrub: tree block %llu mirror %u has bad fsid, has %pU want %pU",
732732
logical, stripe->mirror_num,
733733
header->fsid, fs_info->fs_devices->fsid);
734734
return;
@@ -738,7 +738,7 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
738738
scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
739739
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
740740
btrfs_warn_rl(fs_info,
741-
"tree block %llu mirror %u has bad chunk tree uuid, has %pU want %pU",
741+
"scrub: tree block %llu mirror %u has bad chunk tree uuid, has %pU want %pU",
742742
logical, stripe->mirror_num,
743743
header->chunk_tree_uuid, fs_info->chunk_tree_uuid);
744744
return;
@@ -760,7 +760,7 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
760760
scrub_bitmap_set_meta_error(stripe, sector_nr, sectors_per_tree);
761761
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
762762
btrfs_warn_rl(fs_info,
763-
"tree block %llu mirror %u has bad csum, has " CSUM_FMT " want " CSUM_FMT,
763+
"scrub: tree block %llu mirror %u has bad csum, has " CSUM_FMT " want " CSUM_FMT,
764764
logical, stripe->mirror_num,
765765
CSUM_FMT_VALUE(fs_info->csum_size, on_disk_csum),
766766
CSUM_FMT_VALUE(fs_info->csum_size, calculated_csum));
@@ -771,7 +771,7 @@ static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr
771771
scrub_bitmap_set_meta_gen_error(stripe, sector_nr, sectors_per_tree);
772772
scrub_bitmap_set_error(stripe, sector_nr, sectors_per_tree);
773773
btrfs_warn_rl(fs_info,
774-
"tree block %llu mirror %u has bad generation, has %llu want %llu",
774+
"scrub: tree block %llu mirror %u has bad generation, has %llu want %llu",
775775
logical, stripe->mirror_num,
776776
btrfs_stack_header_generation(header),
777777
stripe->sectors[sector_nr].generation);
@@ -814,7 +814,7 @@ static void scrub_verify_one_sector(struct scrub_stripe *stripe, int sector_nr)
814814
*/
815815
if (unlikely(sector_nr + sectors_per_tree > stripe->nr_sectors)) {
816816
btrfs_warn_rl(fs_info,
817-
"tree block at %llu crosses stripe boundary %llu",
817+
"scrub: tree block at %llu crosses stripe boundary %llu",
818818
stripe->logical +
819819
(sector_nr << fs_info->sectorsize_bits),
820820
stripe->logical);
@@ -1046,12 +1046,12 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
10461046
if (repaired) {
10471047
if (dev) {
10481048
btrfs_err_rl_in_rcu(fs_info,
1049-
"fixed up error at logical %llu on dev %s physical %llu",
1049+
"scrub: fixed up error at logical %llu on dev %s physical %llu",
10501050
stripe->logical, btrfs_dev_name(dev),
10511051
physical);
10521052
} else {
10531053
btrfs_err_rl_in_rcu(fs_info,
1054-
"fixed up error at logical %llu on mirror %u",
1054+
"scrub: fixed up error at logical %llu on mirror %u",
10551055
stripe->logical, stripe->mirror_num);
10561056
}
10571057
continue;
@@ -1060,12 +1060,12 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
10601060
/* The remaining are all for unrepaired. */
10611061
if (dev) {
10621062
btrfs_err_rl_in_rcu(fs_info,
1063-
"unable to fixup (regular) error at logical %llu on dev %s physical %llu",
1063+
"scrub: unable to fixup (regular) error at logical %llu on dev %s physical %llu",
10641064
stripe->logical, btrfs_dev_name(dev),
10651065
physical);
10661066
} else {
10671067
btrfs_err_rl_in_rcu(fs_info,
1068-
"unable to fixup (regular) error at logical %llu on mirror %u",
1068+
"scrub: unable to fixup (regular) error at logical %llu on mirror %u",
10691069
stripe->logical, stripe->mirror_num);
10701070
}
10711071

@@ -1593,8 +1593,7 @@ static int sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical,
15931593
physical,
15941594
sctx->write_pointer);
15951595
if (ret)
1596-
btrfs_err(fs_info,
1597-
"zoned: failed to recover write pointer");
1596+
btrfs_err(fs_info, "scrub: zoned: failed to recover write pointer");
15981597
}
15991598
mutex_unlock(&sctx->wr_lock);
16001599
btrfs_dev_clear_zone_empty(sctx->wr_tgtdev, physical);
@@ -1658,7 +1657,7 @@ static int scrub_find_fill_first_stripe(struct btrfs_block_group *bg,
16581657
int ret;
16591658

16601659
if (unlikely(!extent_root || !csum_root)) {
1661-
btrfs_err(fs_info, "no valid extent or csum root for scrub");
1660+
btrfs_err(fs_info, "scrub: no valid extent or csum root found");
16621661
return -EUCLEAN;
16631662
}
16641663
memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) *
@@ -1907,7 +1906,7 @@ static bool stripe_has_metadata_error(struct scrub_stripe *stripe)
19071906
struct btrfs_fs_info *fs_info = stripe->bg->fs_info;
19081907

19091908
btrfs_err(fs_info,
1910-
"stripe %llu has unrepaired metadata sector at %llu",
1909+
"scrub: stripe %llu has unrepaired metadata sector at logical %llu",
19111910
stripe->logical,
19121911
stripe->logical + (i << fs_info->sectorsize_bits));
19131912
return true;
@@ -2167,7 +2166,7 @@ static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
21672166
bitmap_and(&error, &error, &has_extent, stripe->nr_sectors);
21682167
if (!bitmap_empty(&error, stripe->nr_sectors)) {
21692168
btrfs_err(fs_info,
2170-
"unrepaired sectors detected, full stripe %llu data stripe %u errors %*pbl",
2169+
"scrub: unrepaired sectors detected, full stripe %llu data stripe %u errors %*pbl",
21712170
full_stripe_start, i, stripe->nr_sectors,
21722171
&error);
21732172
ret = -EIO;
@@ -2789,14 +2788,14 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx,
27892788
ro_set = 0;
27902789
} else if (ret == -ETXTBSY) {
27912790
btrfs_warn(fs_info,
2792-
"skipping scrub of block group %llu due to active swapfile",
2791+
"scrub: skipping scrub of block group %llu due to active swapfile",
27932792
cache->start);
27942793
scrub_pause_off(fs_info);
27952794
ret = 0;
27962795
goto skip_unfreeze;
27972796
} else {
2798-
btrfs_warn(fs_info,
2799-
"failed setting block group ro: %d", ret);
2797+
btrfs_warn(fs_info, "scrub: failed setting block group ro: %d",
2798+
ret);
28002799
btrfs_unfreeze_block_group(cache);
28012800
btrfs_put_block_group(cache);
28022801
scrub_pause_off(fs_info);
@@ -2898,13 +2897,13 @@ static int scrub_one_super(struct scrub_ctx *sctx, struct btrfs_device *dev,
28982897
ret = btrfs_check_super_csum(fs_info, sb);
28992898
if (ret != 0) {
29002899
btrfs_err_rl(fs_info,
2901-
"super block at physical %llu devid %llu has bad csum",
2900+
"scrub: super block at physical %llu devid %llu has bad csum",
29022901
physical, dev->devid);
29032902
return -EIO;
29042903
}
29052904
if (btrfs_super_generation(sb) != generation) {
29062905
btrfs_err_rl(fs_info,
2907-
"super block at physical %llu devid %llu has bad generation %llu expect %llu",
2906+
"scrub: super block at physical %llu devid %llu has bad generation %llu expect %llu",
29082907
physical, dev->devid,
29092908
btrfs_super_generation(sb), generation);
29102909
return -EUCLEAN;
@@ -3065,7 +3064,7 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
30653064
!test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state)) {
30663065
mutex_unlock(&fs_info->fs_devices->device_list_mutex);
30673066
btrfs_err_in_rcu(fs_info,
3068-
"scrub on devid %llu: filesystem on %s is not writable",
3067+
"scrub: devid %llu: filesystem on %s is not writable",
30693068
devid, btrfs_dev_name(dev));
30703069
ret = -EROFS;
30713070
goto out;

0 commit comments

Comments
 (0)