summaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2000-06-19 22:45:37 +0000
committerRalf Baechle <ralf@linux-mips.org>2000-06-19 22:45:37 +0000
commit6d403070f28cd44860fdb3a53be5da0275c65cf4 (patch)
tree0d0e7fe7b5fb7568d19e11d7d862b77a866ce081 /fs/file_table.c
parentecf1bf5f6c2e668d03b0a9fb026db7aa41e292e1 (diff)
Merge with 2.4.0-test1-ac21 + pile of MIPS cleanups to make merging
possible. Chainsawed RM200 kernel to compile again. Jazz machine status unknown.
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index 7d5bd9e01..ceb3b7069 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -9,15 +9,14 @@
#include <linux/slab.h>
#include <linux/file.h>
#include <linux/init.h>
+#include <linux/module.h>
#include <linux/smp_lock.h>
/* SLAB cache for filp's. */
static kmem_cache_t *filp_cache;
/* sysctl tunables... */
-int nr_files; /* read only */
-int nr_free_files; /* read only */
-int max_files = NR_FILE;/* tunable */
+struct files_stat_struct files_stat = {0, 0, NR_FILE};
/* Here the new files go */
static LIST_HEAD(anon_list);
@@ -52,11 +51,11 @@ struct file * get_empty_filp(void)
struct file * f;
file_list_lock();
- if (nr_free_files > NR_RESERVED_FILES) {
+ if (files_stat.nr_free_files > NR_RESERVED_FILES) {
used_one:
f = list_entry(free_list.next, struct file, f_list);
list_del(&f->f_list);
- nr_free_files--;
+ files_stat.nr_free_files--;
new_one:
file_list_unlock();
memset(f, 0, sizeof(*f));
@@ -72,25 +71,25 @@ struct file * get_empty_filp(void)
/*
* Use a reserved one if we're the superuser
*/
- if (nr_free_files && !current->euid)
+ if (files_stat.nr_free_files && !current->euid)
goto used_one;
/*
* Allocate a new one if we're below the limit.
*/
- if (nr_files < max_files) {
+ if (files_stat.nr_files < files_stat.max_files) {
file_list_unlock();
f = kmem_cache_alloc(filp_cache, SLAB_KERNEL);
file_list_lock();
if (f) {
- nr_files++;
+ files_stat.nr_files++;
goto new_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;
+ } else if (files_stat.max_files > old_max) {
+ printk("VFS: file-max limit %d reached\n", files_stat.max_files);
+ old_max = files_stat.max_files;
}
file_list_unlock();
return NULL;
@@ -99,7 +98,8 @@ struct file * get_empty_filp(void)
/*
* Clear and initialize a (private) struct file for the given dentry,
* and call the open function (if any). The caller must verify that
- * inode->i_fop is not NULL.
+ * inode->i_fop is not NULL. The only user is nfsfh.c and this function
+ * will eventually go away.
*/
int init_private_file(struct file *filp, struct dentry *dentry, int mode)
{
@@ -127,6 +127,7 @@ static void __fput(struct file *filp)
if (filp->f_op && filp->f_op->release)
filp->f_op->release(inode, filp);
+ fops_put(filp->f_op);
filp->f_dentry = NULL;
filp->f_vfsmnt = NULL;
if (filp->f_mode & FMODE_WRITE)
@@ -146,7 +147,7 @@ void _fput(struct file *file)
file_list_lock();
list_del(&file->f_list);
list_add(&file->f_list, &free_list);
- nr_free_files++;
+ files_stat.nr_free_files++;
file_list_unlock();
}
@@ -158,7 +159,7 @@ void put_filp(struct file *file)
file_list_lock();
list_del(&file->f_list);
list_add(&file->f_list, &free_list);
- nr_free_files++;
+ files_stat.nr_free_files++;
file_list_unlock();
}
}