aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-03-28 20:10:42 -0400
committerNeilBrown <neilb@suse.de>2010-05-18 01:27:53 -0400
commitfe60b0142813002be16dfae28780d9779ee22473 (patch)
tree1b2337036bbb30857531cd2d54729d38fdd75a3a /drivers
parentb821eaa572fd737faaf6928ba046e571526c36c6 (diff)
md: factor do_md_run to separate accesses to ->gendisk
As part of relaxing the binding between an mddev and gendisk, we separate do_md_run into two functions. md_run does all the work internal to md do_md_run calls md_run and makes and changes to gendisk that are required. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/md.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index f2b30019b1cb..e752332268d2 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4297,11 +4297,10 @@ static void md_safemode_timeout(unsigned long data)
4297 4297
4298static int start_dirty_degraded; 4298static int start_dirty_degraded;
4299 4299
4300static int do_md_run(mddev_t * mddev) 4300static int md_run(mddev_t *mddev)
4301{ 4301{
4302 int err; 4302 int err;
4303 mdk_rdev_t *rdev; 4303 mdk_rdev_t *rdev;
4304 struct gendisk *disk;
4305 struct mdk_personality *pers; 4304 struct mdk_personality *pers;
4306 4305
4307 if (list_empty(&mddev->disks)) 4306 if (list_empty(&mddev->disks))
@@ -4366,8 +4365,6 @@ static int do_md_run(mddev_t * mddev)
4366 sysfs_notify_dirent(rdev->sysfs_state); 4365 sysfs_notify_dirent(rdev->sysfs_state);
4367 } 4366 }
4368 4367
4369 disk = mddev->gendisk;
4370
4371 spin_lock(&pers_lock); 4368 spin_lock(&pers_lock);
4372 pers = find_pers(mddev->level, mddev->clevel); 4369 pers = find_pers(mddev->level, mddev->clevel);
4373 if (!pers || !try_module_get(pers->owner)) { 4370 if (!pers || !try_module_get(pers->owner)) {
@@ -4495,21 +4492,32 @@ static int do_md_run(mddev_t * mddev)
4495 if (mddev->flags) 4492 if (mddev->flags)
4496 md_update_sb(mddev, 0); 4493 md_update_sb(mddev, 0);
4497 4494
4498 set_capacity(disk, mddev->array_sectors);
4499
4500 md_wakeup_thread(mddev->thread); 4495 md_wakeup_thread(mddev->thread);
4501 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ 4496 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
4502 4497
4503 revalidate_disk(mddev->gendisk);
4504 md_new_event(mddev); 4498 md_new_event(mddev);
4505 sysfs_notify_dirent(mddev->sysfs_state); 4499 sysfs_notify_dirent(mddev->sysfs_state);
4506 if (mddev->sysfs_action) 4500 if (mddev->sysfs_action)
4507 sysfs_notify_dirent(mddev->sysfs_action); 4501 sysfs_notify_dirent(mddev->sysfs_action);
4508 sysfs_notify(&mddev->kobj, NULL, "degraded"); 4502 sysfs_notify(&mddev->kobj, NULL, "degraded");
4509 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
4510 return 0; 4503 return 0;
4511} 4504}
4512 4505
4506static int do_md_run(mddev_t *mddev)
4507{
4508 int err;
4509
4510 err = md_run(mddev);
4511 if (err)
4512 goto out;
4513
4514 set_capacity(mddev->gendisk, mddev->array_sectors);
4515 revalidate_disk(mddev->gendisk);
4516 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
4517out:
4518 return err;
4519}
4520
4513static int restart_array(mddev_t *mddev) 4521static int restart_array(mddev_t *mddev)
4514{ 4522{
4515 struct gendisk *disk = mddev->gendisk; 4523 struct gendisk *disk = mddev->gendisk;