From: "Li Youhong" <dayou5941@163.com>
To: song@kernel.org, yukuai@fygo.io, agk@redhat.com,
snitzer@kernel.org, mpatocka@redhat.com, bmarzins@redhat.com
Cc: magiclinan@didiglobal.com, xiao@kernel.org,
linux-raid@vger.kernel.org, dm-devel@lists.linux.dev,
linux-kernel@vger.kernel.org,
syzbot+a53c2918175b36cfd601@syzkaller.appspotmail.com,
liyouhong@kylinos.cn, stable@vger.kernel.org
Subject: [PATCH v7 1/2] md: use work_busy() to flush sync_work in stop_sync_thread()
Date: Thu, 26 Nov 2026 16:32:09 +0800 [thread overview]
Message-ID: <20261126083210.210866-2-dayou5941@163.com> (raw)
In-Reply-To: <20261126083210.210866-1-dayou5941@163.com>
From: Li Youhong <liyouhong@kylinos.cn>
stop_sync_thread() only flushes sync_work when work_pending() is true.
Once the work is running, PENDING is cleared, so an in-flight
md_start_sync() can be missed and teardown can race with it.
Use work_busy() instead, so both queued and executing sync_work are
flushed.
Fixes: db5e653d7c9f ("md: delay choosing sync action to md_start_sync()")
Cc: stable@vger.kernel.org
Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 03e35386a802..1974943bf746 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5213,7 +5213,7 @@ static void stop_sync_thread(struct mddev *mddev, bool locked)
* never happen
*/
md_wakeup_thread_directly(&mddev->sync_thread);
- if (work_pending(&mddev->sync_work))
+ if (work_busy(&mddev->sync_work))
flush_work(&mddev->sync_work);
wait_event(resync_wait,
next prev parent reply other threads:[~2026-11-26 8:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 8:32 [PATCH v7 0/2] md: fix sync_work vs array teardown races Li Youhong
2026-11-26 8:32 ` Li Youhong [this message]
2026-11-26 8:32 ` [PATCH v7 2/2] " Li Youhong
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=20261126083210.210866-2-dayou5941@163.com \
--to=dayou5941@163.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
--cc=magiclinan@didiglobal.com \
--cc=mpatocka@redhat.com \
--cc=snitzer@kernel.org \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+a53c2918175b36cfd601@syzkaller.appspotmail.com \
--cc=xiao@kernel.org \
--cc=yukuai@fygo.io \
/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®