Commit af4d2ecb authored by Kirill Korotaev's avatar Kirill Korotaev Committed by Linus Torvalds

[PATCH] Fix of bogus file max limit messages

This patch fixes incorrect and bogus kernel messages that file-max limit
reached when the allocation fails
Signed-Off-By: default avatarKirill Korotaev <dev@sw.ru>
Signed-Off-By: default avatarDenis Lunev <den@sw.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c663e5d8
...@@ -63,42 +63,45 @@ static inline void file_free(struct file *f) ...@@ -63,42 +63,45 @@ static inline void file_free(struct file *f)
*/ */
struct file *get_empty_filp(void) struct file *get_empty_filp(void)
{ {
static int old_max; static int old_max;
struct file * f; struct file * f;
/* /*
* Privileged users can go above max_files * Privileged users can go above max_files
*/ */
if (files_stat.nr_files < files_stat.max_files || if (files_stat.nr_files >= files_stat.max_files &&
capable(CAP_SYS_ADMIN)) { !capable(CAP_SYS_ADMIN))
f = kmem_cache_alloc(filp_cachep, GFP_KERNEL); goto over;
if (f) {
memset(f, 0, sizeof(*f)); f = kmem_cache_alloc(filp_cachep, GFP_KERNEL);
if (security_file_alloc(f)) { if (f == NULL)
file_free(f); goto fail;
goto fail;
} memset(f, 0, sizeof(*f));
eventpoll_init_file(f); if (security_file_alloc(f))
atomic_set(&f->f_count, 1); goto fail_sec;
f->f_uid = current->fsuid;
f->f_gid = current->fsgid; eventpoll_init_file(f);
rwlock_init(&f->f_owner.lock); atomic_set(&f->f_count, 1);
/* f->f_version: 0 */ f->f_uid = current->fsuid;
INIT_LIST_HEAD(&f->f_list); f->f_gid = current->fsgid;
f->f_maxcount = INT_MAX; rwlock_init(&f->f_owner.lock);
return f; /* f->f_version: 0 */
} INIT_LIST_HEAD(&f->f_list);
} f->f_maxcount = INT_MAX;
return f;
over:
/* Ran out of filps - report that */ /* 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", printk(KERN_INFO "VFS: file-max limit %d reached\n",
files_stat.max_files); files_stat.max_files);
old_max = files_stat.max_files; old_max = files_stat.nr_files;
} else {
/* Big problems... */
printk(KERN_WARNING "VFS: filp allocation failed\n");
} }
goto fail;
fail_sec:
file_free(f);
fail: fail:
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment