aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-08-07 07:41:19 -0400
committerNeilBrown <neilb@suse.de>2010-08-08 07:22:45 -0400
commit6e17b0276452912cb13445e5ea552b599984675f (patch)
tree1ccac9c3d01f7ea8c6c0061948b92c901253e676 /drivers/md
parentbb4f1e9d0e2ef93de8e36ca0f5f26625fcd70b7d (diff)
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>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 03dcbfbe250f..d44efb267a69 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4767,7 +4767,6 @@ out:
4767 */ 4767 */
4768static int do_md_stop(mddev_t * mddev, int mode, int is_open) 4768static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4769{ 4769{
4770 int err = 0, revalidate = 0;
4771 struct gendisk *disk = mddev->gendisk; 4770 struct gendisk *disk = mddev->gendisk;
4772 mdk_rdev_t *rdev; 4771 mdk_rdev_t *rdev;
4773 4772
@@ -4775,9 +4774,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4775 if (atomic_read(&mddev->openers) > is_open || 4774 if (atomic_read(&mddev->openers) > is_open ||
4776 mddev->sysfs_active) { 4775 mddev->sysfs_active) {
4777 printk("md: %s still in use.\n",mdname(mddev)); 4776 printk("md: %s still in use.\n",mdname(mddev));
4778 err = -EBUSY; 4777 mutex_unlock(&mddev->open_mutex);
4779 } else if (mddev->pers) { 4778 return -EBUSY;
4779 }
4780 4780
4781 if (mddev->pers) {
4781 if (mddev->ro) 4782 if (mddev->ro)
4782 set_disk_ro(disk, 0); 4783 set_disk_ro(disk, 0);
4783 4784
@@ -4798,23 +4799,17 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4798 } 4799 }
4799 4800
4800 set_capacity(disk, 0); 4801 set_capacity(disk, 0);
4801 revalidate = 1; 4802 mutex_unlock(&mddev->open_mutex);
4803 revalidate_disk(disk);
4802 4804
4803 if (mddev->ro) 4805 if (mddev->ro)
4804 mddev->ro = 0; 4806 mddev->ro = 0;
4805 4807 } else
4806 err = 0; 4808 mutex_unlock(&mddev->open_mutex);
4807 }
4808 mutex_unlock(&mddev->open_mutex);
4809 if (revalidate)
4810 revalidate_disk(disk);
4811 if (err)
4812 return err;
4813 /* 4809 /*
4814 * Free resources if final stop 4810 * Free resources if final stop
4815 */ 4811 */
4816 if (mode == 0) { 4812 if (mode == 0) {
4817
4818 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev)); 4813 printk(KERN_INFO "md: %s stopped.\n", mdname(mddev));
4819 4814
4820 bitmap_destroy(mddev); 4815 bitmap_destroy(mddev);
@@ -4831,13 +4826,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4831 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); 4826 kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
4832 if (mddev->hold_active == UNTIL_STOP) 4827 if (mddev->hold_active == UNTIL_STOP)
4833 mddev->hold_active = 0; 4828 mddev->hold_active = 0;
4834
4835 } 4829 }
4836 err = 0;
4837 blk_integrity_unregister(disk); 4830 blk_integrity_unregister(disk);
4838 md_new_event(mddev); 4831 md_new_event(mddev);
4839 sysfs_notify_dirent_safe(mddev->sysfs_state); 4832 sysfs_notify_dirent_safe(mddev->sysfs_state);
4840 return err; 4833 return 0;
4841} 4834}
4842 4835
4843#ifndef MODULE 4836#ifndef MODULE