Some people want to create truely enormous arrays.
As we sometimes need to hold one file descriptor for each
device, this can hit the NOFILE limit.
So raise the limit if it ever looks like it might be a problem.
Signed-off-by: NeilBrown <neilb@suse.de>
pr_err(":%s has an active reshape - checking "
"if critical section needs to be restored\n",
chosen_name);
+ enable_fds(bestcnt/2);
for (i = 0; i < bestcnt/2; i++) {
int j = best[i*2];
if (j >= 0) {
}
infos = xmalloc(sizeof(*infos) * total_slots);
-
+ enable_fds(total_slots);
for (pass=1; pass <=2 ; pass++) {
struct mddev_dev *moved_disk = NULL; /* the disk that was moved out of the insert point */
dprintf("Called restore_backup()\n");
fdlist = xmalloc(sizeof(int) * disk_count);
+ enable_fds(next_spare);
for (i = 0; i < next_spare; i++)
fdlist[i] = -1;
for (dev = content->devs; dev; dev = dev->next) {
int d = 0;
struct mdinfo *sd;
+ enable_fds(nrdisks);
for (d = 0; d <= nrdisks; d++)
fdlist[d] = -1;
d = raid_disks;
extern int is_standard(char *dev, int *nump);
extern int same_dev(char *one, char *two);
extern int compare_paths (char* path1,char* path2);
+extern void enable_fds(int devices);
extern int parse_auto(char *str, char *msg, int config);
extern struct mddev_ident *conf_get_ident(char *dev);
#include <sys/utsname.h>
#include <sys/wait.h>
#include <sys/un.h>
+#include <sys/resource.h>
#include <ctype.h>
#include <dirent.h>
#include <signal.h>
return 0;
return 1;
}
+
+/* Make sure we can open as many devices as needed */
+void enable_fds(int devices)
+{
+ unsigned int fds = 20 + devices;
+ struct rlimit lim;
+ if (getrlimit(RLIMIT_NOFILE, &lim) != 0
+ || lim.rlim_cur >= fds)
+ return;
+ if (lim.rlim_max < fds)
+ lim.rlim_max = fds;
+ lim.rlim_cur = fds;
+ setrlimit(RLIMIT_NOFILE, &lim);
+}