diff options
author | Jonathan E Brassow <jbrassow@redhat.com> | 2012-07-27 10:08:04 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:04 -0400 |
commit | f999e8fe70bd0b8faa27ccdac14b5942999c6e78 (patch) | |
tree | 13963a8a5187719e11d5bd6271b6259e4d4b4d0a /drivers | |
parent | a58a935d5a1b2ad267017a68c3a1bca26226cc76 (diff) |
dm raid: restructure parse_raid_params
In preparation for RAID10 addition to dm-raid, we change an 'if' conditional
to a 'switch' conditional to make it easier to see what is being checked for
each RAID type.
Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-raid.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 858a8b70811c..1717ed33dd7f 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c | |||
@@ -430,13 +430,28 @@ static int parse_raid_params(struct raid_set *rs, char **argv, | |||
430 | 430 | ||
431 | if (!strcasecmp(key, "rebuild")) { | 431 | if (!strcasecmp(key, "rebuild")) { |
432 | rebuild_cnt++; | 432 | rebuild_cnt++; |
433 | if (((rs->raid_type->level != 1) && | 433 | |
434 | (rebuild_cnt > rs->raid_type->parity_devs)) || | 434 | switch (rs->raid_type->level) { |
435 | ((rs->raid_type->level == 1) && | 435 | case 1: |
436 | (rebuild_cnt > (rs->md.raid_disks - 1)))) { | 436 | if (rebuild_cnt >= rs->md.raid_disks) { |
437 | rs->ti->error = "Too many rebuild devices specified for given RAID type"; | 437 | rs->ti->error = "Too many rebuild devices specified"; |
438 | return -EINVAL; | ||
439 | } | ||
440 | break; | ||
441 | case 4: | ||
442 | case 5: | ||
443 | case 6: | ||
444 | if (rebuild_cnt > rs->raid_type->parity_devs) { | ||
445 | rs->ti->error = "Too many rebuild devices specified for given RAID type"; | ||
446 | return -EINVAL; | ||
447 | } | ||
448 | break; | ||
449 | default: | ||
450 | DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name); | ||
451 | rs->ti->error = "Rebuild not supported for this RAID type"; | ||
438 | return -EINVAL; | 452 | return -EINVAL; |
439 | } | 453 | } |
454 | |||
440 | if (value > rs->md.raid_disks) { | 455 | if (value > rs->md.raid_disks) { |
441 | rs->ti->error = "Invalid rebuild index given"; | 456 | rs->ti->error = "Invalid rebuild index given"; |
442 | return -EINVAL; | 457 | return -EINVAL; |