summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-12-01 14:51:27 +1100
committerNeilBrown <neilb@suse.de>2011-03-10 17:18:26 +1100
commit0f3bd5b6c47433628970115bfbe8be00641ecc39 (patch)
tree93af5b73c7b29241d127e2e43ad850cf7106d096
parent5101e4681fd58566cddf500d48f9ee80067ece17 (diff)
downloadmdadm-0f3bd5b6c47433628970115bfbe8be00641ecc39.tar.gz
Create/grow: improve checks on number of devices.
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>
-rw-r--r--Create.c12
-rw-r--r--Grow.c7
-rw-r--r--mdadm.c14
3 files changed, 17 insertions, 16 deletions
diff --git a/Create.c b/Create.c
index 2bf7ebe..daf64d7 100644
--- a/Create.c
+++ b/Create.c
@@ -66,11 +66,13 @@ static int default_layout(struct supertype *st, int level, int verbose)
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 *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.
@@ -404,6 +406,12 @@ int Create(struct supertype *st, char *mddev,
close(fd);
}
}
+ 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) {
diff --git a/Grow.c b/Grow.c
index bcd77ac..bcb84a8 100644
--- a/Grow.c
+++ b/Grow.c
@@ -831,6 +831,13 @@ int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
*/
st = super_by_fd(fd);
+ 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.
diff --git a/mdadm.c b/mdadm.c
index 08e8ea4..78a4d3d 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -46,7 +46,6 @@ int main(int argc, char *argv[])
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;
@@ -369,7 +368,6 @@ int main(int argc, char *argv[])
fprintf(stderr, Name ": unrecognised metadata identifier: %s\n", optarg);
exit(2);
}
- max_disks = ss->max_devs;
continue;
case O(MANAGE,'W'):
@@ -1055,11 +1053,6 @@ int main(int argc, char *argv[])
}
if (raiddisks) {
- 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"
@@ -1067,13 +1060,6 @@ int main(int argc, char *argv[])
exit(2);
}
}
- 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);