Skip to content

Commit da8dfd1

Browse files
committed
md: Don't clear MD_CLOSING until mddev is freed
JIRA: https://issues.redhat.com/browse/RHEL-123668 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 60ea9ec commit da8dfd1

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
@@ -6498,15 +6498,10 @@ static void md_clean(struct mddev *mddev)
64986498
mddev->persistent = 0;
64996499
mddev->level = LEVEL_NONE;
65006500
mddev->clevel[0] = 0;
6501-
/*
6502-
* Don't clear MD_CLOSING, or mddev can be opened again.
6503-
* 'hold_active != 0' means mddev is still in the creation
6504-
* process and will be used later.
6505-
*/
6506-
if (mddev->hold_active)
6507-
mddev->flags = 0;
6508-
else
6509-
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
6501+
/* if UNTIL_STOP is set, it's cleared here */
6502+
mddev->hold_active = 0;
6503+
/* Don't clear MD_CLOSING, or mddev can be opened again. */
6504+
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
65106505
mddev->sb_flags = 0;
65116506
mddev->ro = MD_RDWR;
65126507
mddev->metadata_type[0] = 0;
@@ -6734,9 +6729,6 @@ static int do_md_stop(struct mddev *mddev, int mode)
67346729
export_array(mddev);
67356730
md_clean(mddev);
67366731
set_bit(MD_DELETED, &mddev->flags);
6737-
6738-
if (mddev->hold_active == UNTIL_STOP)
6739-
mddev->hold_active = 0;
67406732
}
67416733
md_new_event();
67426734
sysfs_notify_dirent_safe(mddev->sysfs_state);

0 commit comments

Comments
 (0)