]> err.no Git - linux-2.6/commitdiff
[PATCH] Fix of bogus file max limit messages
authorKirill Korotaev <dev@sw.ru>
Thu, 23 Jun 2005 07:09:50 +0000 (00:09 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 23 Jun 2005 16:45:26 +0000 (09:45 -0700)
This patch fixes incorrect and bogus kernel messages that file-max limit
reached when the allocation fails

Signed-Off-By: Kirill Korotaev <dev@sw.ru>
Signed-Off-By: Denis Lunev <den@sw.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/file_table.c

index 03d83cb686b12598191d97edd55779315d74dc8a..fa7849fae134b371a80b90f95fda9e19bfb185b5 100644 (file)
@@ -63,42 +63,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;
 }