Check on upper limit of number of devices was in the wrong place.
Result was could not create array with more than 27 devices without
explicitly setting metadata, even though default metadata allows more.
Fixed, and also perform check when growing an array.
Signed-off-by: NeilBrown <neilb@suse.de>
int Create(struct supertype *st, char *mddev,
int Create(struct supertype *st, char *mddev,
- int chunk, int level, int layout, unsigned long long size, int raiddisks, int sparedisks,
+ int chunk, int level, int layout, unsigned long long size,
+ int raiddisks, int sparedisks,
char *name, char *homehost, int *uuid,
int subdevs, mddev_dev_t devlist,
int runstop, int verbose, int force, int assume_clean,
char *name, char *homehost, int *uuid,
int subdevs, mddev_dev_t devlist,
int runstop, int verbose, int force, int assume_clean,
- char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int autof)
+ char *bitmap_file, int bitmap_chunk, int write_behind,
+ int delay, int autof)
{
/*
* Create a new raid array.
{
/*
* Create a new raid array.
+ if (raiddisks + sparedisks > st->max_devs) {
+ fprintf(stderr, Name ": Too many devices:"
+ " %s metadata only supports %d\n",
+ st->ss->name, st->max_devs);
+ return 1;
+ }
if (have_container)
info.array.working_disks = raiddisks;
if (fail) {
if (have_container)
info.array.working_disks = raiddisks;
if (fail) {
+ if (raid_disks > st->max_devs) {
+ fprintf(stderr, Name ": Cannot increase raid-disks on "
+ "this array beyond %d\n", st->max_devs);
+ rv = 1;
+ break;
+ }
+
/*
* There are three possibilities.
* 1/ The array will shrink.
/*
* There are three possibilities.
* 1/ The array will shrink.
int layout = UnSet;
char *layout_str = NULL;
int raiddisks = 0;
int layout = UnSet;
char *layout_str = NULL;
int raiddisks = 0;
- int max_disks = MD_SB_DISKS; /* just a default */
int sparedisks = 0;
struct mddev_ident_s ident;
char *configfile = NULL;
int sparedisks = 0;
struct mddev_ident_s ident;
char *configfile = NULL;
fprintf(stderr, Name ": unrecognised metadata identifier: %s\n", optarg);
exit(2);
}
fprintf(stderr, Name ": unrecognised metadata identifier: %s\n", optarg);
exit(2);
}
- max_disks = ss->max_devs;
continue;
case O(MANAGE,'W'):
continue;
case O(MANAGE,'W'):
- if (raiddisks > max_disks) {
- fprintf(stderr, Name ": invalid number of raid devices: %d\n",
- raiddisks);
- exit(2);
- }
if (raiddisks == 1 && !force && level != -5) {
fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n"
" a mistake. If you really mean it you will need to specify --force before\n"
if (raiddisks == 1 && !force && level != -5) {
fprintf(stderr, Name ": '1' is an unusual number of drives for an array, so it is probably\n"
" a mistake. If you really mean it you will need to specify --force before\n"
- if (sparedisks) {
- if ( sparedisks > max_disks - raiddisks) {
- fprintf(stderr, Name ": invalid number of spare-devices: %d\n",
- sparedisks);
- exit(2);
- }
- }
if (homehost == NULL)
homehost = conf_get_homehost(&require_homehost);
if (homehost == NULL)
homehost = conf_get_homehost(&require_homehost);