summaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-09-12 01:29:55 +0000
committerRalf Baechle <ralf@linux-mips.org>1997-09-12 01:29:55 +0000
commit545f435ebcfd94a1e7c20b46efe81b4d6ac4e698 (patch)
treee9ce4bc598d06374bda906f18365984bf22a526a /fs/file_table.c
parent4291a610eef89d0d5c69d9a10ee6560e1aa36c74 (diff)
Merge with Linux 2.1.55. More bugfixes and goodies from my private
CVS archive.
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index 6413218ff..42f9255d2 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -43,26 +43,6 @@ static inline void put_inuse(struct file *file)
file->f_pprev = &inuse_filps;
}
-/* Get more free filp's. */
-static int grow_files(void)
-{
- int i = 16;
-
- while(i--) {
- struct file * file = kmem_cache_alloc(filp_cache, SLAB_KERNEL);
- if(!file) {
- if(i == 15)
- return 0;
- goto got_some;
- }
-
- insert_file_free(file);
- nr_files++;
- }
-got_some:
- return 1;
-}
-
void file_table_init(void)
{
filp_cache = kmem_cache_create("filp", sizeof(struct file),
@@ -78,28 +58,36 @@ void file_table_init(void)
*/
struct file * get_empty_filp(void)
{
+ static int old_max = 0;
struct file * f;
-again:
- if((f = free_filps) != NULL) {
- remove_filp(f);
- memset(f, 0, sizeof(*f));
- f->f_count = 1;
- f->f_version = ++event;
- put_inuse(f);
- } else {
- int max = max_files;
-
- /* Reserve a few files for the super-user.. */
- if (current->euid)
- max -= 10;
-
- if (nr_files < max && grow_files())
- goto again;
+ f = free_filps;
+ if (!f)
+ goto get_more;
+ remove_filp(f);
+got_one:
+ memset(f, 0, sizeof(*f));
+ f->f_count = 1;
+ f->f_version = ++event;
+ put_inuse(f);
+ return f;
+get_more:
+ /* Reserve a few files for the super-user.. */
+ if (nr_files < (current->euid ? max_files - 10 : max_files)) {
+ f = kmem_cache_alloc(filp_cache, SLAB_KERNEL);
+ if (f) {
+ nr_files++;
+ goto got_one;
+ }
/* Big problems... */
+ printk("VFS: filp allocation failed\n");
+
+ } else if (max_files > old_max) {
+ printk("VFS: file-max limit %d reached\n", max_files);
+ old_max = max_files;
}
- return f;
+ return NULL;
}
/*