Commit fe60b014 authored by NeilBrown's avatar NeilBrown

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: default avatarNeilBrown <neilb@suse.de>
parent b821eaa5
...@@ -4297,11 +4297,10 @@ static void md_safemode_timeout(unsigned long data) ...@@ -4297,11 +4297,10 @@ static void md_safemode_timeout(unsigned long data)
static int start_dirty_degraded; static int start_dirty_degraded;
static int do_md_run(mddev_t * mddev) static int md_run(mddev_t *mddev)
{ {
int err; int err;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
struct gendisk *disk;
struct mdk_personality *pers; struct mdk_personality *pers;
if (list_empty(&mddev->disks)) if (list_empty(&mddev->disks))
...@@ -4366,8 +4365,6 @@ static int do_md_run(mddev_t * mddev) ...@@ -4366,8 +4365,6 @@ static int do_md_run(mddev_t * mddev)
sysfs_notify_dirent(rdev->sysfs_state); sysfs_notify_dirent(rdev->sysfs_state);
} }
disk = mddev->gendisk;
spin_lock(&pers_lock); spin_lock(&pers_lock);
pers = find_pers(mddev->level, mddev->clevel); pers = find_pers(mddev->level, mddev->clevel);
if (!pers || !try_module_get(pers->owner)) { if (!pers || !try_module_get(pers->owner)) {
...@@ -4495,21 +4492,32 @@ static int do_md_run(mddev_t * mddev) ...@@ -4495,21 +4492,32 @@ static int do_md_run(mddev_t * mddev)
if (mddev->flags) if (mddev->flags)
md_update_sb(mddev, 0); md_update_sb(mddev, 0);
set_capacity(disk, mddev->array_sectors);
md_wakeup_thread(mddev->thread); md_wakeup_thread(mddev->thread);
md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
revalidate_disk(mddev->gendisk);
md_new_event(mddev); md_new_event(mddev);
sysfs_notify_dirent(mddev->sysfs_state); sysfs_notify_dirent(mddev->sysfs_state);
if (mddev->sysfs_action) if (mddev->sysfs_action)
sysfs_notify_dirent(mddev->sysfs_action); sysfs_notify_dirent(mddev->sysfs_action);
sysfs_notify(&mddev->kobj, NULL, "degraded"); sysfs_notify(&mddev->kobj, NULL, "degraded");
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
return 0; return 0;
} }
static int do_md_run(mddev_t *mddev)
{
int err;
err = md_run(mddev);
if (err)
goto out;
set_capacity(mddev->gendisk, mddev->array_sectors);
revalidate_disk(mddev->gendisk);
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
out:
return err;
}
static int restart_array(mddev_t *mddev) static int restart_array(mddev_t *mddev)
{ {
struct gendisk *disk = mddev->gendisk; struct gendisk *disk = mddev->gendisk;
......
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