DM-Devel Archive mirror
 help / color / mirror / Atom feed
From: Xiao Ni <xni@redhat.com>
To: song@kernel.org
Cc: yukuai1@huaweicloud.com, bmarzins@redhat.com, heinzm@redhat.com,
	snitzer@kernel.org, ncroxon@redhat.com,
	linux-raid@vger.kernel.org, dm-devel@lists.linux.dev
Subject: [PATCH 3/4] md: Set MD_RECOVERY_FROZEN before stop sync thread
Date: Fri,  1 Mar 2024 23:21:27 +0800	[thread overview]
Message-ID: <20240301152128.13465-4-xni@redhat.com> (raw)
In-Reply-To: <20240301152128.13465-1-xni@redhat.com>

After patch commit f52f5c71f3d4b ("md: fix stopping sync thread"), dmraid
stops sync thread asynchronously. The calling process is:
dev_remove->dm_destroy->__dm_destroy->raid_postsuspend->raid_dtr

raid_postsuspend does two jobs. First, it stops sync thread. Then it
suspend array. Now it can stop sync thread successfully. But it doesn't
set MD_RECOVERY_FROZEN. It's introduced by patch f52f5c71f3d4b. So after
raid_postsuspend, the sync thread starts again. raid_dtr can't stop the
sync thread because the array is already suspended.

This can be reproduced easily by those commands:
while [ 1 ]; do
vgcreate test_vg /dev/loop0 /dev/loop1
lvcreate --type raid1 -L 400M -m 1 -n test_lv test_vg
lvchange -an test_vg
vgremove test_vg -ff
done

Fixes: f52f5c71f3d4 ("md: fix stopping sync thread")
Signed-off-by: Xiao Ni <xni@redhat.com>
---
 drivers/md/md.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c4624814d94c..c96a3bb073c4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6340,6 +6340,7 @@ static void __md_stop_writes(struct mddev *mddev)
 void md_stop_writes(struct mddev *mddev)
 {
 	mddev_lock_nointr(mddev);
+	set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
 	__md_stop_writes(mddev);
 	mddev_unlock(mddev);
 }
-- 
2.32.0 (Apple Git-132)


  parent reply	other threads:[~2024-03-01 15:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-01 15:21 [PATCH V2 0/4] Fix dmraid regression bugs Xiao Ni
2024-03-01 15:21 ` [PATCH 1/4] md: Revert "md: Don't register sync_thread for reshape directly" Xiao Ni
2024-03-01 15:21 ` [PATCH 2/4] md: Revert "md: Don't ignore suspended array in md_check_recovery()" Xiao Ni
2024-03-01 15:21 ` Xiao Ni [this message]
2024-03-01 15:21 ` [PATCH 4/4] md/raid5: Don't check crossing reshape when reshape hasn't started Xiao Ni
2024-03-01 22:28 ` [PATCH V2 0/4] Fix dmraid regression bugs Song Liu
2024-03-02  0:41   ` Xiao Ni

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=20240301152128.13465-4-xni@redhat.com \
    --to=xni@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=heinzm@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=ncroxon@redhat.com \
    --cc=snitzer@kernel.org \
    --cc=song@kernel.org \
    --cc=yukuai1@huaweicloud.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).