Skip to content

Commit

Permalink
md: factor do_md_run to separate accesses to ->gendisk
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeilBrown committed May 18, 2010
1 parent b821eaa commit fe60b01
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -4297,11 +4297,10 @@ static void md_safemode_timeout(unsigned long data)

static int start_dirty_degraded;

static int do_md_run(mddev_t * mddev)
static int md_run(mddev_t *mddev)
{
int err;
mdk_rdev_t *rdev;
struct gendisk *disk;
struct mdk_personality *pers;

if (list_empty(&mddev->disks))
Expand Down Expand Up @@ -4366,8 +4365,6 @@ static int do_md_run(mddev_t * mddev)
sysfs_notify_dirent(rdev->sysfs_state);
}

disk = mddev->gendisk;

spin_lock(&pers_lock);
pers = find_pers(mddev->level, mddev->clevel);
if (!pers || !try_module_get(pers->owner)) {
Expand Down Expand Up @@ -4495,21 +4492,32 @@ static int do_md_run(mddev_t * mddev)
if (mddev->flags)
md_update_sb(mddev, 0);

set_capacity(disk, mddev->array_sectors);

md_wakeup_thread(mddev->thread);
md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */

revalidate_disk(mddev->gendisk);
md_new_event(mddev);
sysfs_notify_dirent(mddev->sysfs_state);
if (mddev->sysfs_action)
sysfs_notify_dirent(mddev->sysfs_action);
sysfs_notify(&mddev->kobj, NULL, "degraded");
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
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)
{
struct gendisk *disk = mddev->gendisk;
Expand Down

0 comments on commit fe60b01

Please sign in to comment.