Improve error message for adding bitmap to a level that cannot support it.

Also give error on --build if no devices given.
This commit is contained in:
Neil Brown 2007-05-21 14:25:47 +10:00
parent 1f48664b8e
commit 5b28bd5672
4 changed files with 26 additions and 5 deletions

View File

@ -146,6 +146,12 @@ int Build(char *mddev, int mdfd, int chunk, int level, int layout,
fprintf(stderr, Name ": bitmaps not supported with this kernel\n");
return 1;
}
if (bitmap_file && level <= 0) {
fprintf(stderr, Name ": bitmaps not meaningful with level %s\n",
map_num(pers, level)?:"given");
return 1;
}
/* now add the devices */
for ((i=0), (dv = devlist) ; dv ; i++, dv=dv->next) {
unsigned long long dsize;

View File

@ -87,11 +87,6 @@ int Create(struct supertype *st, char *mddev, int mdfd,
Name ": a RAID level is needed to create an array.\n");
return 1;
}
if (raiddisks < 1) {
fprintf(stderr,
Name ": a number of --raid-devices must be given to create an array\n");
return 1;
}
if (raiddisks < 4 && level == 6) {
fprintf(stderr,
Name ": at least 4 raid-devices needed for level 6\n");
@ -115,6 +110,11 @@ int Create(struct supertype *st, char *mddev, int mdfd,
fprintf(stderr, Name ": You haven't given enough devices (real or missing) to create this array\n");
return 1;
}
if (bitmap_file && level <= 0) {
fprintf(stderr, Name ": bitmaps not meaningful with level %s\n",
map_num(pers, level)?:"given");
return 1;
}
/* now set some defaults */
if (layout == UnSet)

5
Grow.c
View File

@ -254,6 +254,11 @@ int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int
devname);
return 1;
}
if (array.level <= 0) {
fprintf(stderr, Name ": Bitmaps not meaningful with level %s\n",
map_num(pers, array.level)?:"of this array");
return 1;
}
bitmapsize = array.size;
bitmapsize <<= 1;
if (get_dev_size(fd, NULL, &array_size) &&

10
mdadm.c
View File

@ -1141,6 +1141,11 @@ int main(int argc, char *argv[])
rv = 1;
break;
}
if (raiddisks == 0) {
fprintf(stderr, Name ": no raid-disks specified.\n");
rv = 1;
break;
}
if (bitmap_file) {
if (strcmp(bitmap_file, "internal")==0) {
@ -1160,6 +1165,11 @@ int main(int argc, char *argv[])
rv = 1;
break;
}
if (raiddisks == 0) {
fprintf(stderr, Name ": no raid-disks specified.\n");
rv = 1;
break;
}
rv = Create(ss, devlist->devname, mdfd, chunk, level, layout, size<0 ? 0 : size,
raiddisks, sparedisks, ident.name, homehost,