Commit f999e8fe authored by Jonathan E Brassow's avatar Jonathan E Brassow Committed by Alasdair G Kergon

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: default avatarJonathan Brassow <jbrassow@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent a58a935d
...@@ -430,13 +430,28 @@ static int parse_raid_params(struct raid_set *rs, char **argv, ...@@ -430,13 +430,28 @@ static int parse_raid_params(struct raid_set *rs, char **argv,
if (!strcasecmp(key, "rebuild")) { if (!strcasecmp(key, "rebuild")) {
rebuild_cnt++; rebuild_cnt++;
if (((rs->raid_type->level != 1) &&
(rebuild_cnt > rs->raid_type->parity_devs)) || switch (rs->raid_type->level) {
((rs->raid_type->level == 1) && case 1:
(rebuild_cnt > (rs->md.raid_disks - 1)))) { if (rebuild_cnt >= rs->md.raid_disks) {
rs->ti->error = "Too many rebuild devices specified for given RAID type"; rs->ti->error = "Too many rebuild devices specified";
return -EINVAL;
}
break;
case 4:
case 5:
case 6:
if (rebuild_cnt > rs->raid_type->parity_devs) {
rs->ti->error = "Too many rebuild devices specified for given RAID type";
return -EINVAL;
}
break;
default:
DMERR("The rebuild parameter is not supported for %s", rs->raid_type->name);
rs->ti->error = "Rebuild not supported for this RAID type";
return -EINVAL; return -EINVAL;
} }
if (value > rs->md.raid_disks) { if (value > rs->md.raid_disks) {
rs->ti->error = "Invalid rebuild index given"; rs->ti->error = "Invalid rebuild index given";
return -EINVAL; return -EINVAL;
......
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