提交 af4d2ecb 编写于 作者: K Kirill Korotaev 提交者: 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: NKirill Korotaev <dev@sw.ru>
Signed-Off-By: NDenis Lunev <den@sw.ru>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 c663e5d8
......@@ -63,21 +63,24 @@ 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)) {
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) {
memset(f, 0, sizeof(*f));
if (security_file_alloc(f)) {
file_free(f);
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;
......@@ -87,18 +90,18 @@ static int old_max;
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册