From: Yu Kuai <yukuai1@huaweicloud.com>
To: mpatocka@redhat.com, dm-devel@lists.linux.dev,
msnitzer@redhat.com, heinzm@redhat.com, song@kernel.org,
yukuai3@huawei.com
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
yukuai1@huaweicloud.com, yi.zhang@huawei.com,
yangerkun@huawei.com
Subject: [PATCH 3/5] md: make sure md_do_sync() will set MD_RECOVERY_DONE
Date: Sat, 20 Jan 2024 18:37:32 +0800 [thread overview]
Message-ID: <20240120103734.4155446-4-yukuai1@huaweicloud.com> (raw)
In-Reply-To: <20240120103734.4155446-1-yukuai1@huaweicloud.com>
From: Yu Kuai <yukuai3@huawei.com>
stop_sync_thread() will interrupt md_do_sync(), and md_do_sync() must
set MD_RECOVERY_DONE, so that follow up md_check_recovery() will
unregister sync_thread, clear MD_RECOVERY_RUNNING and wake up
stop_sync_thread().
Before this patch, if MD_RECOVERY_WAIT is set or the array is read-only,
md_do_sync() will return without setting MD_RECOVERY_DONE, hence use
stop_sync_thread() directly will hang because md_check_recovery() can't
clear MD_RECOVERY_RUNNING, which is possible for dm-raid.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6906d023f1d6..ba45c7be3dbe 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8788,12 +8788,13 @@ void md_do_sync(struct md_thread *thread)
int ret;
/* just incase thread restarts... */
- if (test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
- test_bit(MD_RECOVERY_WAIT, &mddev->recovery))
+ if (test_bit(MD_RECOVERY_DONE, &mddev->recovery))
return;
- if (!md_is_rdwr(mddev)) {/* never try to sync a read-only array */
+
+ if (test_bit(MD_RECOVERY_WAIT, &mddev->recovery) ||
+ !md_is_rdwr(mddev)) {/* never try to sync a read-only array */
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
- return;
+ goto out;
}
if (mddev_is_clustered(mddev)) {
@@ -9171,6 +9172,7 @@ void md_do_sync(struct md_thread *thread)
mddev->array_sectors);
}
+out:
spin_lock(&mddev->lock);
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
/* We completed so min/max setting can be forgotten if used. */
--
2.39.2
next prev parent reply other threads:[~2024-01-20 10:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-20 10:37 [PATCH 0/5] md: fix/prevent dm-raid regressions Yu Kuai
2024-01-20 10:37 ` [PATCH 1/5] md: don't ignore suspended array in md_check_recovery() Yu Kuai
2024-01-20 10:37 ` [PATCH 2/5] md: don't ignore read-only " Yu Kuai
2024-01-20 10:37 ` Yu Kuai [this message]
2024-01-24 2:58 ` [PATCH 3/5] md: make sure md_do_sync() will set MD_RECOVERY_DONE Xiao Ni
2024-01-24 3:14 ` Yu Kuai
2024-01-20 10:37 ` [PATCH RFC 4/5] md: revert commit fa2bbff7b0b4 ("md: synchronize flush io with array reconfiguration") for dm-raid Yu Kuai
2024-01-20 10:37 ` [PATCH RFC 5/5] md: use md_reap_sync_thread() directly " Yu Kuai
2024-01-22 13:17 ` Yu Kuai
2024-01-21 4:41 ` [PATCH 0/5] md: fix/prevent dm-raid regressions Song Liu
2024-01-22 1:19 ` Yu Kuai
2024-01-22 8:24 ` Yu Kuai
2024-01-22 10:09 ` Song Liu
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=20240120103734.4155446-4-yukuai1@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=dm-devel@lists.linux.dev \
--cc=heinzm@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=msnitzer@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).