md: clean up do_md_stop
There is only one error exit from do_md_stop, so make that more explicit and discard the 'err' variable. Also drop the 'revalidate' variable by moving the unlock calls around. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
parent
bb4f1e9d0e
commit
6e17b02764
|
@ -4767,7 +4767,6 @@ out:
|
||||||
*/
|
*/
|
||||||
static int do_md_stop(mddev_t * mddev, int mode, int is_open)
|
static int do_md_stop(mddev_t * mddev, int mode, int is_open)
|
||||||
{
|
{
|
||||||
int err = 0, revalidate = 0;
|
|
||||||
struct gendisk *disk = mddev->gendisk;
|
struct gendisk *disk = mddev->gendisk;
|
||||||
mdk_rdev_t *rdev;
|
mdk_rdev_t *rdev;
|
||||||
|
|
||||||
|
@ -4775,9 +4774,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
|
||||||
if (atomic_read(&mddev->openers) > is_open ||
|
if (atomic_read(&mddev->openers) > is_open ||
|
||||||
mddev->sysfs_active) {
|
mddev->sysfs_active) {
|
||||||
printk("md: %s still in use.\n",mdname(mddev));
|
printk("md: %s still in use.\n",mdname(mddev));
|
||||||
err = -EBUSY;
|
mutex_unlock(&mddev->open_mutex);
|
||||||
} else if (mddev->pers) {
|
return -EBUSY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mddev->pers) {
|
||||||
if (mddev->ro)
|
if (mddev->ro)
|
||||||
set_disk_ro(disk, 0);
|
set_disk_ro(disk, 0);
|
||||||
|
|
||||||
|
@ -4798,23 +4799,17 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
|
||||||
}
|
}
|
||||||
|
|
||||||
set_capacity(disk, 0);
|
set_capacity(disk, 0);
|
||||||
revalidate = 1;
|
mutex_unlock(&mddev->open_mutex);
|
||||||
|
revalidate_disk(disk);
|
||||||
|
|
||||||
if (mddev->ro)
|
if (mddev->ro)
|
||||||
mddev->ro = 0;
|
mddev->ro = 0;
|
||||||
|
} else
|
||||||
err = 0;
|
mutex_unlock(&mddev->open_mutex);
|
||||||
}
|
|
||||||
mutex_unlock(&mddev->open_mutex);
|
|
||||||
if (revalidate)
|
|
||||||
revalidate_disk(disk);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
/*
|
/*
|
||||||
* Free resources if final stop
|
* Free resources if final stop
|
||||||
*/
|
*/
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
|
|
||||||
printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
|
printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
|
||||||
|
|
||||||
bitmap_destroy(mddev);
|
bitmap_destroy(mddev);
|
||||||
|
@ -4831,13 +4826,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
|
||||||
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
|
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
|
||||||
if (mddev->hold_active == UNTIL_STOP)
|
if (mddev->hold_active == UNTIL_STOP)
|
||||||
mddev->hold_active = 0;
|
mddev->hold_active = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
err = 0;
|
|
||||||
blk_integrity_unregister(disk);
|
blk_integrity_unregister(disk);
|
||||||
md_new_event(mddev);
|
md_new_event(mddev);
|
||||||
sysfs_notify_dirent_safe(mddev->sysfs_state);
|
sysfs_notify_dirent_safe(mddev->sysfs_state);
|
||||||
return err;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MODULE
|
#ifndef MODULE
|
||||||
|
|
Loading…
Reference in New Issue