Commit c02c0aeb authored by NeilBrown's avatar NeilBrown

md.c: re-indent various 'switch' statements.

Intent was unnecessarily deep.

Also change one 'switch' which has a single case element, into an
'if'.
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent a7a3f08d
...@@ -6347,24 +6347,23 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6347,24 +6347,23 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
* Commands dealing with the RAID driver but not any * Commands dealing with the RAID driver but not any
* particular array: * particular array:
*/ */
switch (cmd) switch (cmd) {
{ case RAID_VERSION:
case RAID_VERSION: err = get_version(argp);
err = get_version(argp); goto done;
goto done;
case PRINT_RAID_DEBUG: case PRINT_RAID_DEBUG:
err = 0; err = 0;
md_print_devices(); md_print_devices();
goto done; goto done;
#ifndef MODULE #ifndef MODULE
case RAID_AUTORUN: case RAID_AUTORUN:
err = 0; err = 0;
autostart_arrays(arg); autostart_arrays(arg);
goto done; goto done;
#endif #endif
default:; default:;
} }
/* /*
...@@ -6411,50 +6410,44 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6411,50 +6410,44 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
goto abort; goto abort;
} }
switch (cmd) if (cmd == SET_ARRAY_INFO) {
{ mdu_array_info_t info;
case SET_ARRAY_INFO: if (!arg)
{ memset(&info, 0, sizeof(info));
mdu_array_info_t info; else if (copy_from_user(&info, argp, sizeof(info))) {
if (!arg) err = -EFAULT;
memset(&info, 0, sizeof(info)); goto abort_unlock;
else if (copy_from_user(&info, argp, sizeof(info))) { }
err = -EFAULT; if (mddev->pers) {
goto abort_unlock; err = update_array_info(mddev, &info);
} if (err) {
if (mddev->pers) { printk(KERN_WARNING "md: couldn't update"
err = update_array_info(mddev, &info); " array info. %d\n", err);
if (err) { goto abort_unlock;
printk(KERN_WARNING "md: couldn't update"
" array info. %d\n", err);
goto abort_unlock;
}
goto done_unlock;
}
if (!list_empty(&mddev->disks)) {
printk(KERN_WARNING
"md: array %s already has disks!\n",
mdname(mddev));
err = -EBUSY;
goto abort_unlock;
}
if (mddev->raid_disks) {
printk(KERN_WARNING
"md: array %s already initialised!\n",
mdname(mddev));
err = -EBUSY;
goto abort_unlock;
}
err = set_array_info(mddev, &info);
if (err) {
printk(KERN_WARNING "md: couldn't set"
" array info. %d\n", err);
goto abort_unlock;
}
} }
goto done_unlock; goto done_unlock;
}
default:; if (!list_empty(&mddev->disks)) {
printk(KERN_WARNING
"md: array %s already has disks!\n",
mdname(mddev));
err = -EBUSY;
goto abort_unlock;
}
if (mddev->raid_disks) {
printk(KERN_WARNING
"md: array %s already initialised!\n",
mdname(mddev));
err = -EBUSY;
goto abort_unlock;
}
err = set_array_info(mddev, &info);
if (err) {
printk(KERN_WARNING "md: couldn't set"
" array info. %d\n", err);
goto abort_unlock;
}
goto done_unlock;
} }
/* /*
...@@ -6473,52 +6466,51 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6473,52 +6466,51 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
/* /*
* Commands even a read-only array can execute: * Commands even a read-only array can execute:
*/ */
switch (cmd) switch (cmd) {
{ case GET_BITMAP_FILE:
case GET_BITMAP_FILE: err = get_bitmap_file(mddev, argp);
err = get_bitmap_file(mddev, argp); goto done_unlock;
goto done_unlock;
case RESTART_ARRAY_RW: case RESTART_ARRAY_RW:
err = restart_array(mddev); err = restart_array(mddev);
goto done_unlock; goto done_unlock;
case STOP_ARRAY: case STOP_ARRAY:
err = do_md_stop(mddev, 0, bdev); err = do_md_stop(mddev, 0, bdev);
goto done_unlock; goto done_unlock;
case STOP_ARRAY_RO: case STOP_ARRAY_RO:
err = md_set_readonly(mddev, bdev); err = md_set_readonly(mddev, bdev);
goto done_unlock; goto done_unlock;
case BLKROSET: case BLKROSET:
if (get_user(ro, (int __user *)(arg))) { if (get_user(ro, (int __user *)(arg))) {
err = -EFAULT; err = -EFAULT;
goto done_unlock; goto done_unlock;
} }
err = -EINVAL; err = -EINVAL;
/* if the bdev is going readonly the value of mddev->ro /* if the bdev is going readonly the value of mddev->ro
* does not matter, no writes are coming * does not matter, no writes are coming
*/ */
if (ro) if (ro)
goto done_unlock; goto done_unlock;
/* are we are already prepared for writes? */ /* are we are already prepared for writes? */
if (mddev->ro != 1) if (mddev->ro != 1)
goto done_unlock; goto done_unlock;
/* transitioning to readauto need only happen for /* transitioning to readauto need only happen for
* arrays that call md_write_start * arrays that call md_write_start
*/ */
if (mddev->pers) { if (mddev->pers) {
err = restart_array(mddev); err = restart_array(mddev);
if (err == 0) { if (err == 0) {
mddev->ro = 2; mddev->ro = 2;
set_disk_ro(mddev->gendisk, 0); set_disk_ro(mddev->gendisk, 0);
}
} }
goto done_unlock; }
goto done_unlock;
} }
/* /*
...@@ -6540,37 +6532,36 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -6540,37 +6532,36 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
} }
} }
switch (cmd) switch (cmd) {
case ADD_NEW_DISK:
{ {
case ADD_NEW_DISK: mdu_disk_info_t info;
{ if (copy_from_user(&info, argp, sizeof(info)))
mdu_disk_info_t info; err = -EFAULT;
if (copy_from_user(&info, argp, sizeof(info))) else
err = -EFAULT; err = add_new_disk(mddev, &info);
else goto done_unlock;
err = add_new_disk(mddev, &info); }
goto done_unlock;
}
case HOT_REMOVE_DISK: case HOT_REMOVE_DISK:
err = hot_remove_disk(mddev, new_decode_dev(arg)); err = hot_remove_disk(mddev, new_decode_dev(arg));
goto done_unlock; goto done_unlock;
case HOT_ADD_DISK: case HOT_ADD_DISK:
err = hot_add_disk(mddev, new_decode_dev(arg)); err = hot_add_disk(mddev, new_decode_dev(arg));
goto done_unlock; goto done_unlock;
case RUN_ARRAY: case RUN_ARRAY:
err = do_md_run(mddev); err = do_md_run(mddev);
goto done_unlock; goto done_unlock;
case SET_BITMAP_FILE: case SET_BITMAP_FILE:
err = set_bitmap_file(mddev, (int)arg); err = set_bitmap_file(mddev, (int)arg);
goto done_unlock; goto done_unlock;
default: default:
err = -EINVAL; err = -EINVAL;
goto abort_unlock; goto abort_unlock;
} }
done_unlock: done_unlock:
......
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