|
@@ -60,7 +60,7 @@ static inline void file_free(struct file *f)
|
|
/*
|
|
/*
|
|
* Return the total number of open files in the system
|
|
* Return the total number of open files in the system
|
|
*/
|
|
*/
|
|
-static int get_nr_files(void)
|
|
|
|
|
|
+static long get_nr_files(void)
|
|
{
|
|
{
|
|
return percpu_counter_read_positive(&nr_files);
|
|
return percpu_counter_read_positive(&nr_files);
|
|
}
|
|
}
|
|
@@ -68,7 +68,7 @@ static int get_nr_files(void)
|
|
/*
|
|
/*
|
|
* Return the maximum number of open files in the system
|
|
* Return the maximum number of open files in the system
|
|
*/
|
|
*/
|
|
-int get_max_files(void)
|
|
|
|
|
|
+unsigned long get_max_files(void)
|
|
{
|
|
{
|
|
return files_stat.max_files;
|
|
return files_stat.max_files;
|
|
}
|
|
}
|
|
@@ -82,7 +82,7 @@ int proc_nr_files(ctl_table *table, int write,
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
|
void __user *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
{
|
|
files_stat.nr_files = get_nr_files();
|
|
files_stat.nr_files = get_nr_files();
|
|
- return proc_dointvec(table, write, buffer, lenp, ppos);
|
|
|
|
|
|
+ return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
int proc_nr_files(ctl_table *table, int write,
|
|
int proc_nr_files(ctl_table *table, int write,
|
|
@@ -105,7 +105,7 @@ int proc_nr_files(ctl_table *table, int write,
|
|
struct file *get_empty_filp(void)
|
|
struct file *get_empty_filp(void)
|
|
{
|
|
{
|
|
const struct cred *cred = current_cred();
|
|
const struct cred *cred = current_cred();
|
|
- static int old_max;
|
|
|
|
|
|
+ static long old_max;
|
|
struct file * f;
|
|
struct file * f;
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -140,8 +140,7 @@ struct file *get_empty_filp(void)
|
|
over:
|
|
over:
|
|
/* Ran out of filps - report that */
|
|
/* Ran out of filps - report that */
|
|
if (get_nr_files() > old_max) {
|
|
if (get_nr_files() > old_max) {
|
|
- printk(KERN_INFO "VFS: file-max limit %d reached\n",
|
|
|
|
- get_max_files());
|
|
|
|
|
|
+ pr_info("VFS: file-max limit %lu reached\n", get_max_files());
|
|
old_max = get_nr_files();
|
|
old_max = get_nr_files();
|
|
}
|
|
}
|
|
goto fail;
|
|
goto fail;
|
|
@@ -487,7 +486,7 @@ retry:
|
|
|
|
|
|
void __init files_init(unsigned long mempages)
|
|
void __init files_init(unsigned long mempages)
|
|
{
|
|
{
|
|
- int n;
|
|
|
|
|
|
+ unsigned long n;
|
|
|
|
|
|
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
|
|
filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0,
|
|
SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
|
|
SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL);
|
|
@@ -498,9 +497,7 @@ void __init files_init(unsigned long mempages)
|
|
*/
|
|
*/
|
|
|
|
|
|
n = (mempages * (PAGE_SIZE / 1024)) / 10;
|
|
n = (mempages * (PAGE_SIZE / 1024)) / 10;
|
|
- files_stat.max_files = n;
|
|
|
|
- if (files_stat.max_files < NR_FILE)
|
|
|
|
- files_stat.max_files = NR_FILE;
|
|
|
|
|
|
+ files_stat.max_files = max_t(unsigned long, n, NR_FILE);
|
|
files_defer_init();
|
|
files_defer_init();
|
|
lg_lock_init(files_lglock);
|
|
lg_lock_init(files_lglock);
|
|
percpu_counter_init(&nr_files, 0);
|
|
percpu_counter_init(&nr_files, 0);
|