aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric Dumazet <dada1@cosmosbay.com>2008-02-06 04:37:16 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:06 -0500
commit9cfe015aa424b3c003baba3841a60dd9b5ad319b (patch)
tree5575e06efcf91018f860f2db43979e8e91aba1c3 /fs
parent774ed22c21ab95d582dfff38560f11cf290baeb4 (diff)
get rid of NR_OPEN and introduce a sysctl_nr_open
NR_OPEN (historically set to 1024*1024) actually forbids processes to open more than 1024*1024 handles. Unfortunatly some production servers hit the not so 'ridiculously high value' of 1024*1024 file descriptors per process. Changing NR_OPEN is not considered safe because of vmalloc space potential exhaust. This patch introduces a new sysctl (/proc/sys/fs/nr_open) wich defaults to 1024*1024, so that admins can decide to change this limit if their workload needs it. [akpm@linux-foundation.org: export it for sparc64] Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: "David S. Miller" <davem@davemloft.net> Cc: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/file.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/file.c b/fs/file.c
index c5575de01113..5110acb1c9ef 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -24,6 +24,8 @@ struct fdtable_defer {
24 struct fdtable *next; 24 struct fdtable *next;
25}; 25};
26 26
27int sysctl_nr_open __read_mostly = 1024*1024;
28
27/* 29/*
28 * We use this list to defer free fdtables that have vmalloced 30 * We use this list to defer free fdtables that have vmalloced
29 * sets/arrays. By keeping a per-cpu list, we avoid having to embed 31 * sets/arrays. By keeping a per-cpu list, we avoid having to embed
@@ -147,8 +149,8 @@ static struct fdtable * alloc_fdtable(unsigned int nr)
147 nr /= (1024 / sizeof(struct file *)); 149 nr /= (1024 / sizeof(struct file *));
148 nr = roundup_pow_of_two(nr + 1); 150 nr = roundup_pow_of_two(nr + 1);
149 nr *= (1024 / sizeof(struct file *)); 151 nr *= (1024 / sizeof(struct file *));
150 if (nr > NR_OPEN) 152 if (nr > sysctl_nr_open)
151 nr = NR_OPEN; 153 nr = sysctl_nr_open;
152 154
153 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL); 155 fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL);
154 if (!fdt) 156 if (!fdt)
@@ -233,7 +235,7 @@ int expand_files(struct files_struct *files, int nr)
233 if (nr < fdt->max_fds) 235 if (nr < fdt->max_fds)
234 return 0; 236 return 0;
235 /* Can we expand? */ 237 /* Can we expand? */
236 if (nr >= NR_OPEN) 238 if (nr >= sysctl_nr_open)
237 return -EMFILE; 239 return -EMFILE;
238 240
239 /* All good, so we try */ 241 /* All good, so we try */