Re: [PATCH 1/2] md: factor out a helper exceed_read_errors() to check read_errors

From: Song Liu
Date: Fri Dec 08 2023 - 13:38:47 EST


On Sun, Dec 3, 2023 at 11:04 PM <linan666@xxxxxxxxxxxxxxx> wrote:
>
> From: Li Nan <linan122@xxxxxxxxxx>
>
> Move check_decay_read_errors() to raid1-10.c and factor out a helper
> exceed_read_errors() to check if read_errors exceeds the limit, so that
> raid1 can also use it. There are no functional changes.
>
> Signed-off-by: Li Nan <linan122@xxxxxxxxxx>
[...]
> +static inline bool exceed_read_errors(struct mddev *mddev, struct md_rdev *rdev)
> +{
> + int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
> + int read_errors;
> +
> + check_decay_read_errors(mddev, rdev);
> + read_errors = atomic_inc_return(&rdev->read_errors);
> + if (read_errors > max_read_errors) {
> + pr_notice("md:%s: %pg: Raid device exceeded read_error threshold [cur %d:max %d]\n",
> + mdname(mddev), rdev->bdev, read_errors, max_read_errors);
> + pr_notice("md:%s: %pg: Failing raid device\n",
> + mdname(mddev), rdev->bdev);

This changed the print message from "md/raid10:" to "md:". We should
try to avoid
such changes. How about we do something like the following?

Thanks,
Song

diff --git i/drivers/md/raid1-10.c w/drivers/md/raid1-10.c
index 3f22edec70e7..6c0ef0fe6ba7 100644
--- i/drivers/md/raid1-10.c
+++ w/drivers/md/raid1-10.c
@@ -173,3 +173,10 @@ static inline void
raid1_prepare_flush_writes(struct bitmap *bitmap)
else
md_bitmap_unplug(bitmap);
}
+
+static inline bool exceed_read_errors(struct mddev *mddev, struct
md_rdev *rdev)
+{
+ pr_notice("md/" RAID_1_10_NAME ":%s: %pg: Raid device ...\n",
+ ...);
+ ...
+}
diff --git i/drivers/md/raid1.c w/drivers/md/raid1.c
index 9348f1709512..412e98d02a05 100644
--- i/drivers/md/raid1.c
+++ w/drivers/md/raid1.c
@@ -49,6 +49,7 @@ static void lower_barrier(struct r1conf *conf,
sector_t sector_nr);
#define raid1_log(md, fmt, args...) \
do { if ((md)->queue) blk_add_trace_msg((md)->queue, "raid1 "
fmt, ##args); } while (0)

+#define RAID_1_10_NAME "raid1"
#include "raid1-10.c"

#define START(node) ((node)->start)
diff --git i/drivers/md/raid10.c w/drivers/md/raid10.c
index 375c11d6159f..a1531b5f15e3 100644
--- i/drivers/md/raid10.c
+++ w/drivers/md/raid10.c
@@ -77,6 +77,8 @@ static void end_reshape(struct r10conf *conf);
#define raid10_log(md, fmt, args...) \
do { if ((md)->queue) blk_add_trace_msg((md)->queue, "raid10 "
fmt, ##args); } while (0)

+#define RAID_1_10_NAME "raid10"
+
#include "raid1-10.c"

#define NULL_CMD

[...]