]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Raid limit of 1024 when scanning for devices.
authorNeilBrown <neilb@suse.de>
Tue, 17 Apr 2012 23:06:02 +0000 (09:06 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 17 Apr 2012 23:06:02 +0000 (09:06 +1000)
When we can for devices using GET_DISK_INFO we currently
limit to 1024.  But some arrays can have more than this.
So raise it to 4096 and make the constant a #define.

Signed-off-by: NeilBrown <neilb@suse.de>
Manage.c
mdadm.h
util.c

index 102c013b0e809a2a754445ab32e696c539873970..3767f019740db61db57dbd22c7768d4fffd9d2be 100644 (file)
--- a/Manage.c
+++ b/Manage.c
@@ -462,7 +462,7 @@ int Manage_subdevs(char *devname, int fd,
                                        dv->devname, dv->disposition);
                                goto abort;
                        }
-                       for (; j < 1024 && remaining_disks > 0; j++) {
+                       for (; j < MAX_DISKS && remaining_disks > 0; j++) {
                                unsigned dev;
                                disc.number = j;
                                if (ioctl(fd, GET_DISK_INFO, &disc))
@@ -495,7 +495,7 @@ int Manage_subdevs(char *devname, int fd,
                                        dv->devname, dv->disposition);
                                goto abort;
                        }
-                       for (; j < 1024 && remaining_disks > 0; j++) {
+                       for (; j < MAX_DISKS && remaining_disks > 0; j++) {
                                int sfd;
                                unsigned dev;
                                disc.number = j;
diff --git a/mdadm.h b/mdadm.h
index 686d4b489e7645bb25f60a3b3ed08eeb0165f40a..71cef38f61448996ef91c1da203a0f2bf2dbc142 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1388,4 +1388,12 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 #define PROCESS_DELAYED -2
 #define PROCESS_PENDING -3
 
+/* When using "GET_DISK_INFO" it isn't certain how high
+ * we need to check.  So we impose an absolute limit of
+ * MAX_DISKS.  This needs to be much more than the largest
+ * number of devices any metadata can support.  Currently
+ * v1.x can support 1920
+ */
+#define MAX_DISKS      4096
+
 extern int __offroot;
diff --git a/util.c b/util.c
index b94205856bddf056aff7002f4416f3f4e06db05d..ac0f78c50189d14e910caf7ed4e4245aac9a62f1 100644 (file)
--- a/util.c
+++ b/util.c
@@ -378,7 +378,7 @@ int enough_fd(int fd)
            array.raid_disks <= 0)
                return 0;
        avail = calloc(array.raid_disks, 1);
-       for (i=0; i < 1024 && array.nr_disks > 0; i++) {
+       for (i=0; i < MAX_DISKS && array.nr_disks > 0; i++) {
                disk.number = i;
                if (ioctl(fd, GET_DISK_INFO, &disk) != 0)
                        continue;
@@ -1275,7 +1275,7 @@ void get_one_disk(int mdfd, mdu_array_info_t *ainf, mdu_disk_info_t *disk)
        int d;
 
        ioctl(mdfd, GET_ARRAY_INFO, ainf);
-       for (d = 0 ; d < 1024 ; d++) {
+       for (d = 0 ; d < MAX_DISKS ; d++) {
                if (ioctl(mdfd, GET_DISK_INFO, disk) == 0 &&
                    (disk->major || disk->minor))
                        return;