From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, Al Viro <viro@zeniv.linux.org.uk>,
Amerigo Wang <amwang@redhat.com>
Subject: [Patch] vfs: use {set,get}_max_files()
Date: Fri, 25 Sep 2009 03:37:14 -0400 [thread overview]
Message-ID: <20090925073948.4147.839.sendpatchset@localhost.localdomain> (raw)
Use the wrapper functions, {get,set}_max_files().
Signed-off-by: WANG Cong <amwang@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
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);
}
reply other threads:[~2009-09-25 7:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090925073948.4147.839.sendpatchset@localhost.localdomain \
--to=amwang@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome