Commit c39f7320 authored by Neil Brown's avatar Neil Brown Committed by David S. Miller

[PATCH] md - Fix problems with freeing gendisk in md.c

md currently tries to set_capacity() *after* freeing
the gendisk structure.

It also frees the gendisk even when switching to read-only.

That patch open-codes free_mddev (which is only called once)
and cleans all this up.
parent 0713b154
......@@ -601,18 +601,6 @@ static void export_array(mddev_t *mddev)
mddev->raid_disks = 0;
}
static void free_mddev(mddev_t *mddev)
{
if (!mddev) {
MD_BUG();
return;
}
export_array(mddev);
md_size[mdidx(mddev)] = 0;
set_capacity(disks[mdidx(mddev)], 0);
}
#undef BAD_CSUM
#undef BAD_MAGIC
#undef OUT_OF_MEM
......@@ -1530,7 +1518,6 @@ static int do_md_stop(mddev_t * mddev, int ro)
{
int err = 0;
kdev_t dev = mddev_to_kdev(mddev);
struct gendisk *disk;
if (atomic_read(&mddev->active)>1) {
printk(STILL_IN_USE, mdidx(mddev));
......@@ -1579,6 +1566,16 @@ static int do_md_stop(mddev_t * mddev, int ro)
if (ro)
set_device_ro(dev, 1);
}
/*
* Free resources if final stop
*/
if (!ro) {
struct gendisk *disk;
printk(KERN_INFO "md: md%d stopped.\n", mdidx(mddev));
export_array(mddev);
md_size[mdidx(mddev)] = 0;
disk = disks[mdidx(mddev)];
disks[mdidx(mddev)] = NULL;
......@@ -1588,12 +1585,6 @@ static int do_md_stop(mddev_t * mddev, int ro)
kfree(disk);
}
/*
* Free resources if final stop
*/
if (!ro) {
printk(KERN_INFO "md: md%d stopped.\n", mdidx(mddev));
free_mddev(mddev);
} else
printk(KERN_INFO "md: md%d switched to read-only mode.\n", mdidx(mddev));
err = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment