Skip to content

Commit f43dfce

Browse files
committed
md: Don't clear MD_CLOSING until mddev is freed
JIRA: https://issues.redhat.com/browse/RHEL-94433 JIRA: https://issues.redhat.com/browse/RHEL-20191 JIRA: https://issues.redhat.com/browse/RHEL-9656 commit 5f286f3 Author: Xiao Ni <xni@redhat.com> Date: Wed Jun 11 15:31:07 2025 +0800 md: Don't clear MD_CLOSING until mddev is freed 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 efeb53c ("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. Reviewed-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Xiao Ni <xni@redhat.com> Link: https://lore.kernel.org/linux-raid/20250611073108.25463-3-xni@redhat.com Signed-off-by: Yu Kuai <yukuai3@huawei.com> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
1 parent 2434b54 commit f43dfce

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

drivers/md/md.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6451,15 +6451,10 @@ static void md_clean(struct mddev *mddev)
64516451
mddev->persistent = 0;
64526452
mddev->level = LEVEL_NONE;
64536453
mddev->clevel[0] = 0;
6454-
/*
6455-
* Don't clear MD_CLOSING, or mddev can be opened again.
6456-
* 'hold_active != 0' means mddev is still in the creation
6457-
* process and will be used later.
6458-
*/
6459-
if (mddev->hold_active)
6460-
mddev->flags = 0;
6461-
else
6462-
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
6454+
/* if UNTIL_STOP is set, it's cleared here */
6455+
mddev->hold_active = 0;
6456+
/* Don't clear MD_CLOSING, or mddev can be opened again. */
6457+
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
64636458
mddev->sb_flags = 0;
64646459
mddev->ro = MD_RDWR;
64656460
mddev->metadata_type[0] = 0;
@@ -6686,9 +6681,6 @@ static int do_md_stop(struct mddev *mddev, int mode)
66866681
export_array(mddev);
66876682
md_clean(mddev);
66886683
set_bit(MD_DELETED, &mddev->flags);
6689-
6690-
if (mddev->hold_active == UNTIL_STOP)
6691-
mddev->hold_active = 0;
66926684
}
66936685
md_new_event();
66946686
sysfs_notify_dirent_safe(mddev->sysfs_state);

0 commit comments

Comments
 (0)