Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2954
b: refs/heads/master
c: af4d2ec
h: refs/heads/master
v: v3
  • Loading branch information
Kirill Korotaev authored and Linus Torvalds committed Jun 23, 2005
1 parent 4096dea commit 0259cbe
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c663e5d80ebec426916ad2aa5400c7ec99aa572e
refs/heads/master: af4d2ecbf007b7df3db7a41eedccdc05b8006d0b
57 changes: 30 additions & 27 deletions trunk/fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0259cbe

Please sign in to comment.