aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-12-10 21:39:21 -0500
committerNeilBrown <neilb@suse.de>2012-12-10 21:39:21 -0500
commitc02c0aeb6c728e5ad705dba86784bd553cb6f059 (patch)
tree35984ce2a006118d687448de64e17624d5ef29b0 /drivers/md
parenta7a3f08dc24690ae00c75cfe4b4701a970dd0155 (diff)
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: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/md.c229
1 files changed, 110 insertions, 119 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 8b0e3d21f736..520056a88739 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6347,24 +6347,23 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6347 * Commands dealing with the RAID driver but not any 6347 * Commands dealing with the RAID driver but not any
6348 * particular array: 6348 * particular array:
6349 */ 6349 */
6350 switch (cmd) 6350 switch (cmd) {
6351 { 6351 case RAID_VERSION:
6352 case RAID_VERSION: 6352 err = get_version(argp);
6353 err = get_version(argp); 6353 goto done;
6354 goto done;
6355 6354
6356 case PRINT_RAID_DEBUG: 6355 case PRINT_RAID_DEBUG:
6357 err = 0; 6356 err = 0;
6358 md_print_devices(); 6357 md_print_devices();
6359 goto done; 6358 goto done;
6360 6359
6361#ifndef MODULE 6360#ifndef MODULE
6362 case RAID_AUTORUN: 6361 case RAID_AUTORUN:
6363 err = 0; 6362 err = 0;
6364 autostart_arrays(arg); 6363 autostart_arrays(arg);
6365 goto done; 6364 goto done;
6366#endif 6365#endif
6367 default:; 6366 default:;
6368 } 6367 }
6369 6368
6370 /* 6369 /*
@@ -6411,50 +6410,44 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6411 goto abort; 6410 goto abort;
6412 } 6411 }
6413 6412
6414 switch (cmd) 6413 if (cmd == SET_ARRAY_INFO) {
6415 { 6414 mdu_array_info_t info;
6416 case SET_ARRAY_INFO: 6415 if (!arg)
6417 { 6416 memset(&info, 0, sizeof(info));
6418 mdu_array_info_t info; 6417 else if (copy_from_user(&info, argp, sizeof(info))) {
6419 if (!arg) 6418 err = -EFAULT;
6420 memset(&info, 0, sizeof(info)); 6419 goto abort_unlock;
6421 else if (copy_from_user(&info, argp, sizeof(info))) { 6420 }
6422 err = -EFAULT; 6421 if (mddev->pers) {
6423 goto abort_unlock; 6422 err = update_array_info(mddev, &info);
6424 } 6423 if (err) {
6425 if (mddev->pers) { 6424 printk(KERN_WARNING "md: couldn't update"
6426 err = update_array_info(mddev, &info); 6425 " array info. %d\n", err);
6427 if (err) { 6426 goto abort_unlock;
6428 printk(KERN_WARNING "md: couldn't update"
6429 " array info. %d\n", err);
6430 goto abort_unlock;
6431 }
6432 goto done_unlock;
6433 }
6434 if (!list_empty(&mddev->disks)) {
6435 printk(KERN_WARNING
6436 "md: array %s already has disks!\n",
6437 mdname(mddev));
6438 err = -EBUSY;
6439 goto abort_unlock;
6440 }
6441 if (mddev->raid_disks) {
6442 printk(KERN_WARNING
6443 "md: array %s already initialised!\n",
6444 mdname(mddev));
6445 err = -EBUSY;
6446 goto abort_unlock;
6447 }
6448 err = set_array_info(mddev, &info);
6449 if (err) {
6450 printk(KERN_WARNING "md: couldn't set"
6451 " array info. %d\n", err);
6452 goto abort_unlock;
6453 }
6454 } 6427 }
6455 goto done_unlock; 6428 goto done_unlock;
6456 6429 }
6457 default:; 6430 if (!list_empty(&mddev->disks)) {
6431 printk(KERN_WARNING
6432 "md: array %s already has disks!\n",
6433 mdname(mddev));
6434 err = -EBUSY;
6435 goto abort_unlock;
6436 }
6437 if (mddev->raid_disks) {
6438 printk(KERN_WARNING
6439 "md: array %s already initialised!\n",
6440 mdname(mddev));
6441 err = -EBUSY;
6442 goto abort_unlock;
6443 }
6444 err = set_array_info(mddev, &info);
6445 if (err) {
6446 printk(KERN_WARNING "md: couldn't set"
6447 " array info. %d\n", err);
6448 goto abort_unlock;
6449 }
6450 goto done_unlock;
6458 } 6451 }
6459 6452
6460 /* 6453 /*
@@ -6473,52 +6466,51 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6473 /* 6466 /*
6474 * Commands even a read-only array can execute: 6467 * Commands even a read-only array can execute:
6475 */ 6468 */
6476 switch (cmd) 6469 switch (cmd) {
6477 { 6470 case GET_BITMAP_FILE:
6478 case GET_BITMAP_FILE: 6471 err = get_bitmap_file(mddev, argp);
6479 err = get_bitmap_file(mddev, argp); 6472 goto done_unlock;
6480 goto done_unlock;
6481 6473
6482 case RESTART_ARRAY_RW: 6474 case RESTART_ARRAY_RW:
6483 err = restart_array(mddev); 6475 err = restart_array(mddev);
6484 goto done_unlock; 6476 goto done_unlock;
6485 6477
6486 case STOP_ARRAY: 6478 case STOP_ARRAY:
6487 err = do_md_stop(mddev, 0, bdev); 6479 err = do_md_stop(mddev, 0, bdev);
6488 goto done_unlock; 6480 goto done_unlock;
6489 6481
6490 case STOP_ARRAY_RO: 6482 case STOP_ARRAY_RO:
6491 err = md_set_readonly(mddev, bdev); 6483 err = md_set_readonly(mddev, bdev);
6492 goto done_unlock; 6484 goto done_unlock;
6493 6485
6494 case BLKROSET: 6486 case BLKROSET:
6495 if (get_user(ro, (int __user *)(arg))) { 6487 if (get_user(ro, (int __user *)(arg))) {
6496 err = -EFAULT; 6488 err = -EFAULT;
6497 goto done_unlock; 6489 goto done_unlock;
6498 } 6490 }
6499 err = -EINVAL; 6491 err = -EINVAL;
6500 6492
6501 /* if the bdev is going readonly the value of mddev->ro 6493 /* if the bdev is going readonly the value of mddev->ro
6502 * does not matter, no writes are coming 6494 * does not matter, no writes are coming
6503 */ 6495 */
6504 if (ro) 6496 if (ro)
6505 goto done_unlock; 6497 goto done_unlock;
6506 6498
6507 /* are we are already prepared for writes? */ 6499 /* are we are already prepared for writes? */
6508 if (mddev->ro != 1) 6500 if (mddev->ro != 1)
6509 goto done_unlock; 6501 goto done_unlock;
6510 6502
6511 /* transitioning to readauto need only happen for 6503 /* transitioning to readauto need only happen for
6512 * arrays that call md_write_start 6504 * arrays that call md_write_start
6513 */ 6505 */
6514 if (mddev->pers) { 6506 if (mddev->pers) {
6515 err = restart_array(mddev); 6507 err = restart_array(mddev);
6516 if (err == 0) { 6508 if (err == 0) {
6517 mddev->ro = 2; 6509 mddev->ro = 2;
6518 set_disk_ro(mddev->gendisk, 0); 6510 set_disk_ro(mddev->gendisk, 0);
6519 }
6520 } 6511 }
6521 goto done_unlock; 6512 }
6513 goto done_unlock;
6522 } 6514 }
6523 6515
6524 /* 6516 /*
@@ -6540,37 +6532,36 @@ static int md_ioctl(struct block_device *bdev, fmode_t mode,
6540 } 6532 }
6541 } 6533 }
6542 6534
6543 switch (cmd) 6535 switch (cmd) {
6536 case ADD_NEW_DISK:
6544 { 6537 {
6545 case ADD_NEW_DISK: 6538 mdu_disk_info_t info;
6546 { 6539 if (copy_from_user(&info, argp, sizeof(info)))
6547 mdu_disk_info_t info; 6540 err = -EFAULT;
6548 if (copy_from_user(&info, argp, sizeof(info))) 6541 else
6549 err = -EFAULT; 6542 err = add_new_disk(mddev, &info);
6550 else 6543 goto done_unlock;
6551 err = add_new_disk(mddev, &info); 6544 }
6552 goto done_unlock;
6553 }
6554 6545
6555 case HOT_REMOVE_DISK: 6546 case HOT_REMOVE_DISK:
6556 err = hot_remove_disk(mddev, new_decode_dev(arg)); 6547 err = hot_remove_disk(mddev, new_decode_dev(arg));
6557 goto done_unlock; 6548 goto done_unlock;
6558 6549
6559 case HOT_ADD_DISK: 6550 case HOT_ADD_DISK:
6560 err = hot_add_disk(mddev, new_decode_dev(arg)); 6551 err = hot_add_disk(mddev, new_decode_dev(arg));
6561 goto done_unlock; 6552 goto done_unlock;
6562 6553
6563 case RUN_ARRAY: 6554 case RUN_ARRAY:
6564 err = do_md_run(mddev); 6555 err = do_md_run(mddev);
6565 goto done_unlock; 6556 goto done_unlock;
6566 6557
6567 case SET_BITMAP_FILE: 6558 case SET_BITMAP_FILE:
6568 err = set_bitmap_file(mddev, (int)arg); 6559 err = set_bitmap_file(mddev, (int)arg);
6569 goto done_unlock; 6560 goto done_unlock;
6570 6561
6571 default: 6562 default:
6572 err = -EINVAL; 6563 err = -EINVAL;
6573 goto abort_unlock; 6564 goto abort_unlock;
6574 } 6565 }
6575 6566
6576done_unlock: 6567done_unlock: