[Patch] vfs: use {set,get}_max_files()

From: Amerigo Wang
Date: Fri Sep 25 2009 - 03:46:32 EST



Use the wrapper functions, {get,set}_max_files().

Signed-off-by: WANG Cong <amwang@xxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

---
diff --git a/fs/file_table.c b/fs/file_table.c
index 8eb4404..840f71d 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -70,6 +70,11 @@ int get_max_files(void)
}
EXPORT_SYMBOL_GPL(get_max_files);

+static void set_max_files(int new_value)
+{
+ files_stat.max_files = new_value;
+}
+
/*
* Handle nr_files sysctl
*/
@@ -107,12 +112,12 @@ struct file *get_empty_filp(void)
/*
* Privileged users can go above max_files
*/
- if (get_nr_files() >= files_stat.max_files && !capable(CAP_SYS_ADMIN)) {
+ if (get_nr_files() >= get_max_files() && !capable(CAP_SYS_ADMIN)) {
/*
* percpu_counters are inaccurate. Do an expensive check before
* we go and fail.
*/
- if (percpu_counter_sum_positive(&nr_files) >= files_stat.max_files)
+ if (percpu_counter_sum_positive(&nr_files) >= get_max_files())
goto over;
}

@@ -450,9 +455,9 @@ void __init files_init(unsigned long mempages)
*/

n = (mempages * (PAGE_SIZE / 1024)) / 10;
- files_stat.max_files = n;
- if (files_stat.max_files < NR_FILE)
- files_stat.max_files = NR_FILE;
+ set_max_files(n);
+ if (get_max_files() < NR_FILE)
+ set_max_files(NR_FILE);
files_defer_init();
percpu_counter_init(&nr_files, 0);
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/