From: linan666@huaweicloud.com
To: song@kernel.org, bingjingc@synology.com, allenpeng@synology.com,
alexwu@synology.com, shli@fb.com, neilb@suse.de
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com,
houtao1@huawei.com, yangerkun@huawei.com
Subject: [PATCH v2 3/4] md/raid10: fix incorrect done of recovery
Date: Fri, 26 May 2023 15:45:50 +0800 [thread overview]
Message-ID: <20230526074551.669792-4-linan666@huaweicloud.com> (raw)
In-Reply-To: <20230526074551.669792-1-linan666@huaweicloud.com>
From: Li Nan <linan122@huawei.com>
Recovery will go to giveup and let chunks_skipped++ in
raid10_sync_request() if there are some bad_blocks, and it will return
max_sector when chunks_skipped >= geo.raid_disks. Now, recovery fail and
data is inconsistent but user think recovery is done, it is wrong.
Fix it by set mirror's recovery_disabled, spare device will not be added
to here. The same issue alos exists on resync, it will be fixd in future.
Signed-off-by: Li Nan <linan122@huawei.com>
---
drivers/md/raid10.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9de9eabff209..aa22782a7330 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3303,6 +3303,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
int chunks_skipped = 0;
sector_t chunk_mask = conf->geo.chunk_mask;
int page_idx = 0;
+ int error_disk = -1;
/*
* Allow skipping a full rebuild for incremental assembly
@@ -3386,7 +3387,20 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
return reshape_request(mddev, sector_nr, skipped);
if (chunks_skipped >= conf->geo.raid_disks) {
- /* if there has been nothing to do on any drive,
+ pr_err("md/raid10:%s: %s fail\n", mdname(mddev),
+ test_bit(MD_RECOVERY_SYNC, &mddev->recovery) ? "resync" : "recovery");
+ if (error_disk >= 0 &&
+ !test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
+ /*
+ * recovery fail, set mirrors.recovory_disabled,
+ * device shouldn't be added to there.
+ */
+ conf->mirrors[error_disk].recovery_disabled =
+ mddev->recovery_disabled;
+ return 0;
+ }
+ /*
+ * if there has been nothing to do on any drive,
* then there is nothing to do at all..
*/
*skipped = 1;
@@ -3640,6 +3654,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
mdname(mddev));
mirror->recovery_disabled
= mddev->recovery_disabled;
+ } else {
+ error_disk = i;
}
put_buf(r10_bio);
if (rb2)
--
2.31.1
next prev parent reply other threads:[~2023-05-26 7:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 7:45 [PATCH v2 0/4] raid10 bugfix linan666
2023-05-26 7:45 ` [PATCH v2 1/4] md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request linan666
2023-05-26 21:38 ` Song Liu
2023-05-27 1:17 ` Yu Kuai
2023-05-27 1:28 ` Li Nan
2023-05-27 1:21 ` Yu Kuai
2023-05-27 1:29 ` Li Nan
2023-05-26 7:45 ` [PATCH v2 2/4] md/raid10: improve code of mrdev " linan666
2023-05-27 1:41 ` Yu Kuai
2023-05-26 7:45 ` linan666 [this message]
2023-05-26 7:45 ` [PATCH v2 4/4] md/raid10: fix io loss while replacement replace rdev linan666
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=20230526074551.669792-4-linan666@huaweicloud.com \
--to=linan666@huaweicloud.com \
--cc=alexwu@synology.com \
--cc=allenpeng@synology.com \
--cc=bingjingc@synology.com \
--cc=houtao1@huawei.com \
--cc=linan122@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.de \
--cc=shli@fb.com \
--cc=song@kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--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®