mdadm/mdadm-3.2.3-Raid-limit-of-1024-when-scanning-for-devices.patch

82 lines
2.4 KiB
Diff
Raw Normal View History

From 480f3566411675ec41f18e5f6e15429f891e144c Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 18 Apr 2012 09:06:02 +1000
Subject: [PATCH] Raid limit of 1024 when scanning for devices.
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 | 4 ++--
mdadm.h | 8 ++++++++
util.c | 4 ++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Manage.c b/Manage.c
index 102c013..3767f01 100644
--- 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 686d4b4..71cef38 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -1388,4 +1388,13 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
#define PROCESS_DELAYED -2
#define PROCESS_PENDING -3
extern int __offroot;
+
+/* 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
+
diff --git a/util.c b/util.c
index b942058..ac0f78c 100644
--- 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;
--
1.7.7.6