summaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-08-10 13:46:28 -0400
committerJeff Garzik <jgarzik@pobox.com>2005-08-10 13:46:28 -0400
commit2f058256cb64e346f4fb4499ff4e0f1c2791a4b4 (patch)
tree91e06602f4d3abb6812ea8c9bc9ba4501e14c84e /fs/file_table.c
parent0274aa2506fd2fe89a58dd6cd64d3b3f7b976af8 (diff)
parent86b3786078d63242d3194ffc58ae8dae1d1bbef3 (diff)
downloadlinux-stable-2f058256cb64e346f4fb4499ff4e0f1c2791a4b4.tar.gz
linux-stable-2f058256cb64e346f4fb4499ff4e0f1c2791a4b4.tar.bz2
linux-stable-2f058256cb64e346f4fb4499ff4e0f1c2791a4b4.zip
Merge /spare/repo/linux-2.6/
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index 03d83cb686b1..1d3de78e6bc9 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -16,6 +16,7 @@
#include <linux/eventpoll.h>
#include <linux/mount.h>
#include <linux/cdev.h>
+#include <linux/fsnotify.h>
/* sysctl tunables... */
struct files_stat_struct files_stat = {
@@ -63,42 +64,45 @@ static inline void file_free(struct file *f)
*/
struct file *get_empty_filp(void)
{
-static int old_max;
+ static int old_max;
struct file * f;
/*
* Privileged users can go above max_files
*/
- if (files_stat.nr_files < files_stat.max_files ||
- capable(CAP_SYS_ADMIN)) {
- f = kmem_cache_alloc(filp_cachep, GFP_KERNEL);
- if (f) {
- memset(f, 0, sizeof(*f));
- if (security_file_alloc(f)) {
- file_free(f);
- goto fail;
- }
- eventpoll_init_file(f);
- atomic_set(&f->f_count, 1);
- f->f_uid = current->fsuid;
- f->f_gid = current->fsgid;
- rwlock_init(&f->f_owner.lock);
- /* f->f_version: 0 */
- INIT_LIST_HEAD(&f->f_list);
- f->f_maxcount = INT_MAX;
- return f;
- }
- }
-
+ if (files_stat.nr_files >= files_stat.max_files &&
+ !capable(CAP_SYS_ADMIN))
+ goto over;
+
+ f = kmem_cache_alloc(filp_cachep, GFP_KERNEL);
+ if (f == NULL)
+ goto fail;
+
+ memset(f, 0, sizeof(*f));
+ if (security_file_alloc(f))
+ goto fail_sec;
+
+ eventpoll_init_file(f);
+ atomic_set(&f->f_count, 1);
+ f->f_uid = current->fsuid;
+ f->f_gid = current->fsgid;
+ rwlock_init(&f->f_owner.lock);
+ /* f->f_version: 0 */
+ INIT_LIST_HEAD(&f->f_list);
+ f->f_maxcount = INT_MAX;
+ return f;
+
+over:
/* Ran out of filps - report that */
- if (files_stat.max_files >= old_max) {
+ if (files_stat.nr_files > old_max) {
printk(KERN_INFO "VFS: file-max limit %d reached\n",
files_stat.max_files);
- old_max = files_stat.max_files;
- } else {
- /* Big problems... */
- printk(KERN_WARNING "VFS: filp allocation failed\n");
+ old_max = files_stat.nr_files;
}
+ goto fail;
+
+fail_sec:
+ file_free(f);
fail:
return NULL;
}
@@ -123,6 +127,8 @@ void fastcall __fput(struct file *file)
struct inode *inode = dentry->d_inode;
might_sleep();
+
+ fsnotify_close(file);
/*
* The function eventpoll_release() should be the first called
* in the file cleanup chain.