提交 6e17b027 编写于 作者: N NeilBrown

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: NNeilBrown <neilb@suse.de>
上级 bb4f1e9d
......@@ -4767,7 +4767,6 @@ static int md_set_readonly(mddev_t *mddev, 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;
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 ||
mddev->sysfs_active) {
printk("md: %s still in use.\n",mdname(mddev));
err = -EBUSY;
} else if (mddev->pers) {
mutex_unlock(&mddev->open_mutex);
return -EBUSY;
}
if (mddev->pers) {
if (mddev->ro)
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);
revalidate = 1;
mutex_unlock(&mddev->open_mutex);
revalidate_disk(disk);
if (mddev->ro)
mddev->ro = 0;
err = 0;
}
mutex_unlock(&mddev->open_mutex);
if (revalidate)
revalidate_disk(disk);
if (err)
return err;
} else
mutex_unlock(&mddev->open_mutex);
/*
* Free resources if final stop
*/
if (mode == 0) {
printk(KERN_INFO "md: %s stopped.\n", mdname(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);
if (mddev->hold_active == UNTIL_STOP)
mddev->hold_active = 0;
}
err = 0;
blk_integrity_unregister(disk);
md_new_event(mddev);
sysfs_notify_dirent_safe(mddev->sysfs_state);
return err;
return 0;
}
#ifndef MODULE
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册