Skip to content

Commit 5f286f3

Browse files
XiaoNi87YuKuai-huawei
authored andcommitted
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 <[email protected]> Signed-off-by: Xiao Ni <[email protected]> Link: https://lore.kernel.org/linux-raid/[email protected] Signed-off-by: Yu Kuai <[email protected]>
1 parent 9e59d60 commit 5f286f3

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

drivers/md/md.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6425,15 +6425,10 @@ static void md_clean(struct mddev *mddev)
64256425
mddev->persistent = 0;
64266426
mddev->level = LEVEL_NONE;
64276427
mddev->clevel[0] = 0;
6428-
/*
6429-
* Don't clear MD_CLOSING, or mddev can be opened again.
6430-
* 'hold_active != 0' means mddev is still in the creation
6431-
* process and will be used later.
6432-
*/
6433-
if (mddev->hold_active)
6434-
mddev->flags = 0;
6435-
else
6436-
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
6428+
/* if UNTIL_STOP is set, it's cleared here */
6429+
mddev->hold_active = 0;
6430+
/* Don't clear MD_CLOSING, or mddev can be opened again. */
6431+
mddev->flags &= BIT_ULL_MASK(MD_CLOSING);
64376432
mddev->sb_flags = 0;
64386433
mddev->ro = MD_RDWR;
64396434
mddev->metadata_type[0] = 0;
@@ -6660,9 +6655,6 @@ static int do_md_stop(struct mddev *mddev, int mode)
66606655
export_array(mddev);
66616656
md_clean(mddev);
66626657
set_bit(MD_DELETED, &mddev->flags);
6663-
6664-
if (mddev->hold_active == UNTIL_STOP)
6665-
mddev->hold_active = 0;
66666658
}
66676659
md_new_event();
66686660
sysfs_notify_dirent_safe(mddev->sysfs_state);

0 commit comments

Comments
 (0)