Skip to content

Commit 934d9c2

Browse files
committed
md: destroy partitions and notify udev when md array is stopped.
md arrays are not currently destroyed when they are stopped - they remain in /sys/block. Last time I tried this I tripped over locking too much. A consequence of this is that udev doesn't remove anything from /dev. This is rather ugly. As an interim measure until proper device removal can be achieved, make sure all partitions are removed using the BLKRRPART ioctl, and send a KOBJ_CHANGE when an md array is stopped. Signed-off-by: NeilBrown <[email protected]>
1 parent f8d56f1 commit 934d9c2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/md/md.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3884,6 +3884,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
38843884
if (mode == 0) {
38853885
mdk_rdev_t *rdev;
38863886
struct list_head *tmp;
3887+
struct block_device *bdev;
38873888

38883889
printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
38893890

@@ -3940,6 +3941,12 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
39403941
mddev->degraded = 0;
39413942
mddev->barriers_work = 0;
39423943
mddev->safemode = 0;
3944+
bdev = bdget_disk(mddev->gendisk, 0);
3945+
if (bdev) {
3946+
blkdev_ioctl(bdev, 0, BLKRRPART, 0);
3947+
bdput(bdev);
3948+
}
3949+
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
39433950

39443951
} else if (mddev->pers)
39453952
printk(KERN_INFO "md: %s switched to read-only mode.\n",

0 commit comments

Comments
 (0)