Messages in this thread Patch in this message | | | Date | Mon, 8 Jun 1998 11:00:19 -0500 (CDT) | From | Brian <> | Subject | filehandle patch for 2.0.34 |
| |
I am looking for the filehandle patch for 2.0.34, that will allow for more file descriptors per process. Below is the one I have now, that works with 2.0.33, but not 2.0.34:
Version 7a
This patch (and it's updates are available from http://www.linux.org.za/filehandle.patch.linux and ftp://ftp.is.co.za/linux/local/kernel/filehandle.patch.linux
The following patch allows you to increase the maximum number of files/network sockets that you can open to 3000. It doesn't use huge amounts of ram immediately as they are allocated dynamically.
Thanks to Michael O'Reilly (michael@metal.iinet.net.au). We have been waiting for this for a long time :) He did the patch itself. All I did was alter the header files that are used.
1) Save this to your home directory (or ~) 2) cd /usr/src/ (The default directory where linux is unpacked) 3) patch < ~/filehandle.patch.linux
At the last stage it will ask you where to patch one of the files. Enter: /usr/include/gnu/types.h and the patch should complete.
Note that you MIGHT have to put something like:
echo 32768 > /proc/sys/kernel/inode-max echo 8192 > /proc/sys/kernel/file-max
in your "rc.local" (or other startup script), otherwise we only increase your per-process limit, and then you have a case where one process uses up all of your "system wide" filehandles. The above 2 lines increase those.
If this doesn't work, please give me a shout at "oskar@is.co.za"
================================================================= diff -u -r linux.original.2.0.30/fs/select.c linux/fs/select.c --- linux.original.2.0.30/fs/select.c Mon Dec 30 15:56:42 1996 +++ linux/fs/select.c Thu Apr 24 11:29:49 1997 @@ -21,6 +21,7 @@ #include <linux/errno.h> #include <linux/personality.h> #include <linux/mm.h> +#include <linux/malloc.h> #include <asm/segment.h> #include <asm/system.h> @@ -237,22 +238,51 @@ * Update: ERESTARTSYS breaks at least the xview clock binary, so * I'm trying ERESTARTNOHAND which restart only when you want to. */ + +#define roundbit(n, type) (((n) + sizeof(type)*8 - 1) & ~(sizeof(type)*8-1)) + +static unsigned long * save_fds[50] = {NULL, }; +static int fds_index = 0; + asmlinkage int sys_select(int n, fd_set *inp, fd_set *outp, fd_set *exp, struct timeval *tvp) { + unsigned long * fds = 0; int error; - limited_fd_set res_in, in; - limited_fd_set res_out, out; - limited_fd_set res_ex, ex; + limited_fd_set *res_in, *in; + limited_fd_set *res_out, *out; + limited_fd_set *res_ex, *ex; unsigned long timeout; + int size; error = -EINVAL; if (n < 0) goto out; if (n > NR_OPEN) n = NR_OPEN; - if ((error = get_fd_set(n, inp, &in)) || - (error = get_fd_set(n, outp, &out)) || - (error = get_fd_set(n, exp, &ex))) goto out; + + size = roundbit(NR_OPEN, unsigned long) / 8; + if (save_fds[fds_index]) { + fds = save_fds[fds_index]; + save_fds[fds_index] = NULL; + if (fds_index > 0) + --fds_index; + } else { + fds = kmalloc(6 * size, GFP_KERNEL); + } + if (!fds) { + error = -ENOMEM; + goto out; + } + in = (limited_fd_set *) fds; + out = (limited_fd_set *) (((char*)fds) + size); + ex = (limited_fd_set *) (((char*)fds) + size*2); + res_in = (limited_fd_set *) (((char*)fds) + size*3); + res_out = (limited_fd_set *) (((char*)fds) + size*4); + res_ex = (limited_fd_set *) (((char*)fds) + size*5); + + if ((error = get_fd_set(n, inp, in)) || + (error = get_fd_set(n, outp, out)) || + (error = get_fd_set(n, exp, ex))) goto out; timeout = ~0UL; if (tvp) { error = verify_area(VERIFY_WRITE, tvp, sizeof(*tvp)); @@ -263,17 +293,17 @@ if (timeout) timeout += jiffies + 1; } - zero_fd_set(n, &res_in); - zero_fd_set(n, &res_out); - zero_fd_set(n, &res_ex); + zero_fd_set(n, res_in); + zero_fd_set(n, res_out); + zero_fd_set(n, res_ex); current->timeout = timeout; error = do_select(n, - (fd_set *) &in, - (fd_set *) &out, - (fd_set *) &ex, - (fd_set *) &res_in, - (fd_set *) &res_out, - (fd_set *) &res_ex); + (fd_set *) in, + (fd_set *) out, + (fd_set *) ex, + (fd_set *) res_in, + (fd_set *) res_out, + (fd_set *) res_ex); timeout = current->timeout - jiffies - 1; current->timeout = 0; if ((long) timeout < 0) @@ -292,9 +322,18 @@ goto out; error = 0; } - set_fd_set(n, inp, &res_in); - set_fd_set(n, outp, &res_out); - set_fd_set(n, exp, &res_ex); + set_fd_set(n, inp, res_in); + set_fd_set(n, outp, res_out); + set_fd_set(n, exp, res_ex); out: + if (fds) { + if (fds_index < 48) { + if (save_fds[fds_index]) + ++fds_index; + save_fds[fds_index] = fds; + } else { + kfree(fds); + } + } return error; } diff -u -r linux.original.2.0.30/include/linux/fs.h linux/include/linux/fs.h --- linux.original.2.0.30/include/linux/fs.h Sat Mar 29 02:07:57 1997 +++ linux/include/linux/fs.h Thu Apr 24 11:29:49 1997 @@ -27,7 +27,7 @@ /* Fixed constants first: */ #undef NR_OPEN -#define NR_OPEN 256 +#define NR_OPEN 3000 #define NR_SUPER 64 #define BLOCK_SIZE 1024 diff -u -r linux.original.2.0.30/include/linux/limits.h linux/include/linux/limits.h --- linux.original.2.0.30/include/linux/limits.h Wed Jul 17 14:09:43 1996 +++ linux/include/linux/limits.h Thu Apr 24 11:30:51 1997 @@ -1,12 +1,12 @@ #ifndef _LINUX_LIMITS_H #define _LINUX_LIMITS_H -#define NR_OPEN 256 +#define NR_OPEN 3000 #define NGROUPS_MAX 32 /* supplemental group IDs are available */ #define ARG_MAX 131072 /* # bytes of args + environ for exec() */ #define CHILD_MAX 999 /* no limit :-) */ -#define OPEN_MAX 256 /* # open files a process may have */ +#define OPEN_MAX 3000 /* # open files a process may have */ #define LINK_MAX 127 /* # links a file may have */ #define MAX_CANON 255 /* size of the canonical input queue */ #define MAX_INPUT 255 /* size of the type-ahead buffer */ diff -u -r linux.original.2.0.30/include/linux/posix_types.h linux/include/linux/posix_types.h --- linux.original.2.0.30/include/linux/posix_types.h Mon Aug 5 09:13:34 1996 +++ linux/include/linux/posix_types.h Thu Apr 24 11:29:49 1997 @@ -30,7 +30,7 @@ #define __NFDBITS (8 * sizeof(unsigned long)) #undef __FD_SETSIZE -#define __FD_SETSIZE 1024 +#define __FD_SETSIZE 4096 #undef __FDSET_LONGS #define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS) diff -u /usr/include/gnu/types.h.orig /usr/include/gnu/types.h --- /usr/include/gnu/types.h.orig Fri Apr 25 08:11:02 1997 +++ /usr/include/gnu/types.h Fri Apr 25 08:11:28 1997 @@ -112,7 +112,7 @@ #else /* __linux__ */ /* Number of descriptors that can fit in an `fd_set'. */ -#define __FD_SETSIZE 256 +#define __FD_SETSIZE 4096 /* It's easier to assume 8-bit bytes than to get CHAR_BIT. */ #define __NFDBITS (sizeof(unsigned long int) * 8)
/-------------------------- signal@shreve.net -----------------------------\ | Brian Feeny | USR TC Hubs | ShreveNet Inc. (318)222-2638 | | Network Administrator | Perl, Linux | Web hosting, online stores, | | ShreveNet Inc. | USR Pilot | Dial-Up 14.4-56k, ISDN & LANs | | 89 CRX DX w/MPFI, lots of |-=*:Quake:*=-| http://www.shreve.net/ | | mods/Homepage coming soon |LordSignal/SN| Quake server: 208.206.76.47 | \-------------------------- 318-222-2638 x109 -----------------------------/
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu
| |