From: Xiao Ni <xni@redhat.com>
To: linux-raid@vger.kernel.org
Cc: yukuai3@huawei.com, song@kernel.org, ncroxon@redhat.com
Subject: [PATCH 2/3] md: Don't clear MD_CLOSING until mddev is freed
Date: Tue, 3 Jun 2025 13:20:22 +0800 [thread overview]
Message-ID: <20250603052023.7922-3-xni@redhat.com> (raw)
In-Reply-To: <20250603052023.7922-1-xni@redhat.com>
UNTIL_STOP is used to avoid mddev is freed on the last close before adding
disks to mddev. And it should be cleared when stopping an array which is
mentioned in commit efeb53c0e572 ("md: Allow md devices to be created by
name."). So reset ->hold_active to 0 in md_clean.
And MD_CLOSING should be kept until mddev is freed to avoid reopen.
Signed-off-by: Xiao Ni <xni@redhat.com>
---
drivers/md/md.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index fd6c5ff0e3c1..0913b8236471 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6377,15 +6377,10 @@ static void md_clean(struct mddev *mddev)
mddev->persistent = 0;
mddev->level = LEVEL_NONE;
mddev->clevel[0] = 0;
- /*
- * Don't clear MD_CLOSING, or mddev can be opened again.
- * 'hold_active != 0' means mddev is still in the creation
- * process and will be used later.
- */
- if (mddev->hold_active)
- mddev->flags = 0;
- else
- mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
+ /* if UNTIL_STOP is set, it's cleared here */
+ mddev->hold_active = 0;
+ /* Don't clear MD_CLOSING, or mddev can be opened again. */
+ mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
mddev->sb_flags = 0;
mddev->ro = MD_RDWR;
mddev->metadata_type[0] = 0;
@@ -6612,9 +6607,6 @@ static int do_md_stop(struct mddev *mddev, int mode)
export_array(mddev);
md_clean(mddev);
set_bit(MD_DELETED, &mddev->flags);
-
- if (mddev->hold_active == UNTIL_STOP)
- mddev->hold_active = 0;
}
md_new_event();
sysfs_notify_dirent_safe(mddev->sysfs_state);
--
2.32.0 (Apple Git-132)
next prev parent reply other threads:[~2025-06-03 5:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 5:20 [PATCH V3 0/2] md: call del_gendisk in sync way Xiao Ni
2025-06-03 5:20 ` [PATCH 1/3] md: call del_gendisk in control path Xiao Ni
2025-06-03 5:20 ` Xiao Ni [this message]
2025-06-03 5:20 ` [PATCH 3/3] md: remove/add redundancy group only in level change Xiao Ni
-- strict thread matches above, loose matches on Subject: below --
2025-06-04 9:07 [PATCH V4 0/3] md: call del_gendisk in sync way Xiao Ni
2025-06-04 9:07 ` [PATCH 2/3] md: Don't clear MD_CLOSING until mddev is freed Xiao Ni
2025-06-10 7:20 [PATCH V5 0/3] md: call del_gendisk in sync way Xiao Ni
2025-06-10 7:20 ` [PATCH 2/3] md: Don't clear MD_CLOSING until mddev is freed Xiao Ni
2025-06-11 6:11 ` Yu Kuai
2025-06-11 7:31 [PATCH V6 0/3] md: call del_gendisk in sync way Xiao Ni
2025-06-11 7:31 ` [PATCH 2/3] md: Don't clear MD_CLOSING until mddev is freed 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=20250603052023.7922-3-xni@redhat.com \
--to=xni@redhat.com \
--cc=linux-raid@vger.kernel.org \
--cc=ncroxon@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).