Add some extra consistency checks based on level.

Also use LEVEL_LINEAR, LEVEL_MULTIPATH in place of -1 or -4 in a few places.
This commit is contained in:
Neil Brown 2007-10-17 13:08:12 +10:00
parent 5cda096425
commit 570510ba32
2 changed files with 21 additions and 6 deletions

View File

@ -111,6 +111,11 @@ int Create(struct supertype *st, char *mddev, int mdfd,
Name ": at least 2 raid-devices needed for level 4 or 5\n");
return 1;
}
if (level <= 0 && sparedisks) {
fprintf(stderr,
Name ": This level does not support spare devices\n");
return 1;
}
if (subdevs > raiddisks+sparedisks) {
fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
return 1;
@ -167,20 +172,24 @@ int Create(struct supertype *st, char *mddev, int mdfd,
case 10:
case 6:
case 0:
case -1: /* linear */
case LEVEL_LINEAR: /* linear */
if (chunk == 0) {
chunk = 64;
if (verbose > 0)
fprintf(stderr, Name ": chunk size defaults to 64K\n");
}
break;
default: /* raid1, multipath */
case 1:
case LEVEL_MULTIPATH:
if (chunk) {
chunk = 0;
if (verbose > 0)
fprintf(stderr, Name ": chunk size ignored for this level\n");
}
break;
default:
fprintf(stderr, Name ": unknown level %d\n", level);
return 1;
}
/* now look at the subdevs */
@ -332,6 +341,12 @@ int Create(struct supertype *st, char *mddev, int mdfd,
break;
}
}
if (level <= 0 && first_missing != subdevs * 2) {
fprintf(stderr,
Name ": This level does not support missing devices\n");
return 1;
}
/* Ok, lets try some ioctls */

View File

@ -592,7 +592,7 @@ mapping_t r5layout[] = {
};
mapping_t pers[] = {
{ "linear", -1},
{ "linear", LEVEL_LINEAR},
{ "raid0", 0},
{ "0", 0},
{ "stripe", 0},
@ -603,13 +603,13 @@ mapping_t pers[] = {
{ "4", 4},
{ "raid5", 5},
{ "5", 5},
{ "multipath", -4},
{ "mp", -4},
{ "multipath", LEVEL_MULTIPATH},
{ "mp", LEVEL_MULTIPATH},
{ "raid6", 6},
{ "6", 6},
{ "raid10", 10},
{ "10", 10},
{ "faulty", -5},
{ "faulty", LEVEL_FAULTY},
{ NULL, 0}
};