mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Doug V Johnson <dougvj@dougvj.net>
Cc: Doug Johnson <dougvj@gmail.com>,
	Doug V Johnson <dougvj@dougvj.net>, Song Liu <song@kernel.org>,
	Yu Kuai <yukuai3@huawei.com>,
	linux-raid@vger.kernel.org (open list:SOFTWARE RAID (Multiple
	Disks) SUPPORT), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v2 2/2] md/raid5: warn when failing a read due to bad blocks metadata
Date: Mon, 27 Jan 2025 02:00:42 -0700	[thread overview]
Message-ID: <20250127090049.7952-2-dougvj@dougvj.net> (raw)
In-Reply-To: <20250127090049.7952-1-dougvj@dougvj.net>

It's easy to suspect that there might be some underlying hardware
failures or similar issues when userspace receives a Buffer I/O error
from a raid device.

In order to hopefully send more sysadmins on the right track, lets
report that a read failed at least in part due to bad blocks in the bad
block list on device metadata.

There are real world examples where bad block lists accidentally get
propagated or copied around, so having this warning helps mitigate the
consequences

Signed-off-by: Doug V Johnson <dougvj@dougvj.net>
---
 drivers/md/raid5.c | 10 +++++++++-
 drivers/md/raid5.h |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index bc0b0c2540f0..631ec72e7ab9 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3671,7 +3671,14 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh,
 			       sh->dev[i].sector + RAID5_STRIPE_SECTORS(conf)) {
 				struct bio *nextbi =
 					r5_next_bio(conf, bi, sh->dev[i].sector);
-
+				/* If we recorded bad blocks from the metadata
+				 * on any of the devices then report this to
+				 * userspace in case anyone might suspect
+				 * something more fundamental instead
+				 */
+				if (s->bad_blocks)
+					pr_warn_ratelimited("%s: read encountered block in device bad block list.",
+							    mdname(conf->mddev));
 				bio_io_error(bi);
 				bi = nextbi;
 			}
@@ -4703,6 +4710,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 		if (rdev) {
 			is_bad = rdev_has_badblock(rdev, sh->sector,
 						   RAID5_STRIPE_SECTORS(conf));
+			s->bad_blocks++;
 			if (s->blocked_rdev == NULL) {
 				if (is_bad < 0)
 					set_bit(BlockedBadBlocks, &rdev->flags);
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index eafc6e9ed6ee..c755c321ae36 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -282,7 +282,7 @@ struct stripe_head_state {
 	 * read all devices, just the replacement targets.
 	 */
 	int syncing, expanding, expanded, replacing;
-	int locked, uptodate, to_read, to_write, failed, written;
+	int locked, uptodate, to_read, to_write, failed, written, bad_blocks;
 	int to_fill, compute, req_compute, non_overwrite;
 	int injournal, just_cached;
 	int failed_num[2];
-- 
2.48.1


  reply	other threads:[~2025-01-27  9:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-25  1:26 [PATCH 1/2] md/raid5: skip stripes with bad reads during reshape to avoid stall Doug V Johnson
2025-01-25  1:26 ` [PATCH 2/2] md/raid5: warn when failing a read due to bad blocks metadata Doug V Johnson
2025-01-26  6:27 ` [PATCH 1/2] md/raid5: skip stripes with bad reads during reshape to avoid stall Yu Kuai
2025-01-27  8:51   ` Doug V Johnson
2025-01-27  9:00   ` [PATCH v2 1/2] md/raid5: freeze reshape when encountering a bad read Doug V Johnson
2025-01-27  9:00     ` Doug V Johnson [this message]
2025-02-08  2:49     ` Yu Kuai
2025-02-18  7:20       ` Doug V Johnson
2025-02-24  9:02         ` [PATCH v3 1/3] " Doug V Johnson
2025-02-24  9:02           ` [PATCH v3 2/3] md/raid5: warn when failing a read due to bad blocks metadata Doug V Johnson
2025-02-24  9:02           ` [PATCH v3 3/3] md/raid5: check for overlapping bad blocks before starting reshape Doug V Johnson
2025-03-05  6:36             ` Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250127090049.7952-2-dougvj@dougvj.net \
    --to=dougvj@dougvj.net \
    --cc=dougvj@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®