aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/md.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2009-01-08 16:31:09 -0500
committerNeilBrown <neilb@suse.de>2009-01-08 16:31:09 -0500
commita21d15042d8cd736caf82c2bac564f3f93f3d017 (patch)
treed430b6ae126e9bc8139d1c491b80a18cc86b27f1 /drivers/md/md.c
parent8b76539823d71576927e3eb08b395eb6620f628d (diff)
md: centralise all freeing of an 'mddev' in 'md_free'
md_free is the .release handler for the md kobj_type. So it makes sense to release all the objects referenced by the mddev in there, rather than just prior to calling kobject_put for what we think is the last time. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/md.c')
-rw-r--r--drivers/md/md.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index da838cc32cc9..970a8c42ba92 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -221,12 +221,6 @@ static void mddev_put(mddev_t *mddev)
221 if (!mddev->raid_disks && list_empty(&mddev->disks)) { 221 if (!mddev->raid_disks && list_empty(&mddev->disks)) {
222 list_del(&mddev->all_mddevs); 222 list_del(&mddev->all_mddevs);
223 spin_unlock(&all_mddevs_lock); 223 spin_unlock(&all_mddevs_lock);
224 if (mddev->queue)
225 blk_cleanup_queue(mddev->queue);
226 mddev->queue = NULL;
227 if (mddev->sysfs_state)
228 sysfs_put(mddev->sysfs_state);
229 mddev->sysfs_state = NULL;
230 kobject_put(&mddev->kobj); 224 kobject_put(&mddev->kobj);
231 } else 225 } else
232 spin_unlock(&all_mddevs_lock); 226 spin_unlock(&all_mddevs_lock);
@@ -3451,6 +3445,17 @@ md_attr_store(struct kobject *kobj, struct attribute *attr,
3451static void md_free(struct kobject *ko) 3445static void md_free(struct kobject *ko)
3452{ 3446{
3453 mddev_t *mddev = container_of(ko, mddev_t, kobj); 3447 mddev_t *mddev = container_of(ko, mddev_t, kobj);
3448
3449 if (mddev->sysfs_state)
3450 sysfs_put(mddev->sysfs_state);
3451
3452 if (mddev->gendisk) {
3453 del_gendisk(mddev->gendisk);
3454 put_disk(mddev->gendisk);
3455 }
3456 if (mddev->queue)
3457 blk_cleanup_queue(mddev->queue);
3458
3454 kfree(mddev); 3459 kfree(mddev);
3455} 3460}
3456 3461
@@ -6435,9 +6440,6 @@ static __exit void md_exit(void)
6435 if (!disk) 6440 if (!disk)
6436 continue; 6441 continue;
6437 export_array(mddev); 6442 export_array(mddev);
6438 del_gendisk(disk);
6439 put_disk(disk);
6440 mddev->gendisk = NULL;
6441 mddev_put(mddev); 6443 mddev_put(mddev);
6442 } 6444 }
6443} 6445}