summaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index ceb3b7069..ecaa46896 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -16,7 +16,9 @@
static kmem_cache_t *filp_cache;
/* sysctl tunables... */
-struct files_stat_struct files_stat = {0, 0, NR_FILE};
+int nr_files; /* read only */
+int nr_free_files; /* read only */
+int max_files = NR_FILE;/* tunable */
/* Here the new files go */
static LIST_HEAD(anon_list);
@@ -51,11 +53,11 @@ struct file * get_empty_filp(void)
struct file * f;
file_list_lock();
- if (files_stat.nr_free_files > NR_RESERVED_FILES) {
+ if (nr_free_files > NR_RESERVED_FILES) {
used_one:
f = list_entry(free_list.next, struct file, f_list);
list_del(&f->f_list);
- files_stat.nr_free_files--;
+ nr_free_files--;
new_one:
file_list_unlock();
memset(f, 0, sizeof(*f));
@@ -71,25 +73,25 @@ struct file * get_empty_filp(void)
/*
* Use a reserved one if we're the superuser
*/
- if (files_stat.nr_free_files && !current->euid)
+ if (nr_free_files && !current->euid)
goto used_one;
/*
* Allocate a new one if we're below the limit.
*/
- if (files_stat.nr_files < files_stat.max_files) {
+ if (nr_files < max_files) {
file_list_unlock();
f = kmem_cache_alloc(filp_cache, SLAB_KERNEL);
file_list_lock();
if (f) {
- files_stat.nr_files++;
+ nr_files++;
goto new_one;
}
/* Big problems... */
printk("VFS: filp allocation failed\n");
- } 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;
+ } else if (max_files > old_max) {
+ printk("VFS: file-max limit %d reached\n", max_files);
+ old_max = max_files;
}
file_list_unlock();
return NULL;
@@ -98,8 +100,7 @@ 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. The only user is nfsfh.c and this function
- * will eventually go away.
+ * inode->i_fop is not NULL.
*/
int init_private_file(struct file *filp, struct dentry *dentry, int mode)
{
@@ -147,7 +148,7 @@ void _fput(struct file *file)
file_list_lock();
list_del(&file->f_list);
list_add(&file->f_list, &free_list);
- files_stat.nr_free_files++;
+ nr_free_files++;
file_list_unlock();
}
@@ -159,7 +160,7 @@ void put_filp(struct file *file)
file_list_lock();
list_del(&file->f_list);
list_add(&file->f_list, &free_list);
- files_stat.nr_free_files++;
+ nr_free_files++;
file_list_unlock();
}
}