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:
parent
5cda096425
commit
570510ba32
19
Create.c
19
Create.c
|
@ -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");
|
Name ": at least 2 raid-devices needed for level 4 or 5\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (level <= 0 && sparedisks) {
|
||||||
|
fprintf(stderr,
|
||||||
|
Name ": This level does not support spare devices\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
if (subdevs > raiddisks+sparedisks) {
|
if (subdevs > raiddisks+sparedisks) {
|
||||||
fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
|
fprintf(stderr, Name ": You have listed more devices (%d) than are in the array(%d)!\n", subdevs, raiddisks+sparedisks);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -167,20 +172,24 @@ int Create(struct supertype *st, char *mddev, int mdfd,
|
||||||
case 10:
|
case 10:
|
||||||
case 6:
|
case 6:
|
||||||
case 0:
|
case 0:
|
||||||
case -1: /* linear */
|
case LEVEL_LINEAR: /* linear */
|
||||||
if (chunk == 0) {
|
if (chunk == 0) {
|
||||||
chunk = 64;
|
chunk = 64;
|
||||||
if (verbose > 0)
|
if (verbose > 0)
|
||||||
fprintf(stderr, Name ": chunk size defaults to 64K\n");
|
fprintf(stderr, Name ": chunk size defaults to 64K\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: /* raid1, multipath */
|
case 1:
|
||||||
|
case LEVEL_MULTIPATH:
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
chunk = 0;
|
chunk = 0;
|
||||||
if (verbose > 0)
|
if (verbose > 0)
|
||||||
fprintf(stderr, Name ": chunk size ignored for this level\n");
|
fprintf(stderr, Name ": chunk size ignored for this level\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, Name ": unknown level %d\n", level);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now look at the subdevs */
|
/* now look at the subdevs */
|
||||||
|
@ -332,6 +341,12 @@ int Create(struct supertype *st, char *mddev, int mdfd,
|
||||||
break;
|
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 */
|
/* Ok, lets try some ioctls */
|
||||||
|
|
||||||
|
|
8
ReadMe.c
8
ReadMe.c
|
@ -592,7 +592,7 @@ mapping_t r5layout[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
mapping_t pers[] = {
|
mapping_t pers[] = {
|
||||||
{ "linear", -1},
|
{ "linear", LEVEL_LINEAR},
|
||||||
{ "raid0", 0},
|
{ "raid0", 0},
|
||||||
{ "0", 0},
|
{ "0", 0},
|
||||||
{ "stripe", 0},
|
{ "stripe", 0},
|
||||||
|
@ -603,13 +603,13 @@ mapping_t pers[] = {
|
||||||
{ "4", 4},
|
{ "4", 4},
|
||||||
{ "raid5", 5},
|
{ "raid5", 5},
|
||||||
{ "5", 5},
|
{ "5", 5},
|
||||||
{ "multipath", -4},
|
{ "multipath", LEVEL_MULTIPATH},
|
||||||
{ "mp", -4},
|
{ "mp", LEVEL_MULTIPATH},
|
||||||
{ "raid6", 6},
|
{ "raid6", 6},
|
||||||
{ "6", 6},
|
{ "6", 6},
|
||||||
{ "raid10", 10},
|
{ "raid10", 10},
|
||||||
{ "10", 10},
|
{ "10", 10},
|
||||||
{ "faulty", -5},
|
{ "faulty", LEVEL_FAULTY},
|
||||||
{ NULL, 0}
|
{ NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue