From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
To: Miklos Szeredi <miklos@szeredi.hu>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Muthukumar R <muthur@gmail.com>
Cc: fuse-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org,
yrl.pp-manager.tt@hitachi.com,
Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Nikolaus Rath <Nikolaus@rath.org>,
Liu Yuan <namei.unix@gmail.com>,
Has-Wen Nienhuys <hanwen@xs4all.nl>
Subject: [PATCH -v2 5/6] fuse: set default global limit considering tunable request size
Date: Thu, 19 Jul 2012 21:49:58 +0900 [thread overview]
Message-ID: <20120719124958.6250.26758.stgit@ltc137.sdl.hitachi.co.jp> (raw)
In-Reply-To: <20120719124851.6250.43316.stgit@ltc137.sdl.hitachi.co.jp>
Set default global limits for backgrounded requests and congestion
threshold considering the tunable maximum request size.
They are calculated using size of fuse_req structure, which is
variable due to it. This patch sets them according to the current
request size unless they are set via mod_param by the system
administrator.
Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Nikolaus Rath <Nikolaus@rath.org>
Cc: Liu Yuan <namei.unix@gmail.com>
Cc: Has-Wen Nienhuys <hanwen@xs4all.nl>
---
fs/fuse/fuse_i.h | 4 +++
fs/fuse/inode.c | 62 ++++++++++++++++++++++++++++++++++++++++++++----------
2 files changed, 55 insertions(+), 11 deletions(-)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 46df615..2dda6eb 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -27,6 +27,10 @@
/** Default number of pages that can be used in a single read/write request */
#define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
+/** Maximum size of struct fuse_req */
+#define FUSE_CURRENT_REQ_SIZE (sizeof(struct fuse_req) +\
+ sysfs_max_req_pages * sizeof(struct page *))
+
/** Bias for fi->writectr, meaning new writepages must not be sent */
#define FUSE_NOWRITE INT_MIN
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 5f84a40..dc0302f 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -29,25 +29,36 @@ static struct kmem_cache *fuse_inode_cachep;
struct list_head fuse_conn_list;
DEFINE_MUTEX(fuse_mutex);
-static int set_global_limit(const char *val, struct kernel_param *kp);
+static int set_global_limit_bgreq(const char *val, struct kernel_param *kp);
+static int set_global_limit_thresh(const char *val, struct kernel_param *kp);
unsigned max_user_bgreq;
-module_param_call(max_user_bgreq, set_global_limit, param_get_uint,
- &max_user_bgreq, 0644);
+module_param_call(max_user_bgreq, set_global_limit_bgreq,
+ param_get_uint, &max_user_bgreq, 0644);
__MODULE_PARM_TYPE(max_user_bgreq, "uint");
MODULE_PARM_DESC(max_user_bgreq,
"Global limit for the maximum number of backgrounded requests an "
"unprivileged user can set");
unsigned max_user_congthresh;
-module_param_call(max_user_congthresh, set_global_limit, param_get_uint,
- &max_user_congthresh, 0644);
+module_param_call(max_user_congthresh, set_global_limit_thresh,
+ param_get_uint, &max_user_congthresh, 0644);
__MODULE_PARM_TYPE(max_user_congthresh, "uint");
MODULE_PARM_DESC(max_user_congthresh,
"Global limit for the maximum congestion threshold an "
"unprivileged user can set");
/**
+ * The flags below are used in order to distinguish how to set
+ * max_user_bgreq and max_user_congthresh, respectively. They
+ * should be used if they are set via mod_param. If not, we should
+ * check their current limitation using check_global_limit() any
+ * time due to the tunable read/write request size.
+ */
+static bool mod_param_set_flg_bgreq;
+static bool mod_param_set_flg_thresh;
+
+/**
* Maximum number of pages allocated for struct fuse_req.
* It can be changed via sysfs to arbitrary number between
* FUSE_DEFAULT_MAX_PAGES_PER_REQ and nr_pages equivalent
@@ -766,13 +777,39 @@ static void sanitize_global_limit(unsigned *limit)
{
if (*limit == 0)
*limit = ((num_physpages << PAGE_SHIFT) >> 13) /
- sizeof(struct fuse_req);
+ FUSE_CURRENT_REQ_SIZE;
if (*limit >= 1 << 16)
*limit = (1 << 16) - 1;
}
-static int set_global_limit(const char *val, struct kernel_param *kp)
+static void check_global_limit(unsigned *limit, bool mod_param_flg)
+{
+ if (!mod_param_flg) {
+ unsigned cur_global_limit = 0;
+
+ sanitize_global_limit(&cur_global_limit);
+ *limit = cur_global_limit;
+ }
+}
+
+static int set_global_limit_bgreq(const char *val, struct kernel_param *kp)
+{
+ int rv;
+
+ rv = param_set_uint(val, kp);
+ if (rv)
+ return rv;
+
+ sanitize_global_limit((unsigned *)kp->arg);
+
+ /* max_user_bgreq is set via mod_param */
+ mod_param_set_flg_bgreq = true;
+
+ return 0;
+}
+
+static int set_global_limit_thresh(const char *val, struct kernel_param *kp)
{
int rv;
@@ -782,6 +819,9 @@ static int set_global_limit(const char *val, struct kernel_param *kp)
sanitize_global_limit((unsigned *)kp->arg);
+ /* max_user_congthresh is set via mod_param */
+ mod_param_set_flg_thresh = true;
+
return 0;
}
@@ -801,8 +841,8 @@ static void process_init_limits(struct fuse_conn *fc, struct fuse_init_out *arg)
if (arg->minor < 13)
return;
- sanitize_global_limit(&max_user_bgreq);
- sanitize_global_limit(&max_user_congthresh);
+ check_global_limit(&max_user_bgreq, mod_param_set_flg_bgreq);
+ check_global_limit(&max_user_congthresh, mod_param_set_flg_thresh);
if (arg->max_background) {
fc->max_background = arg->max_background;
@@ -1309,8 +1349,8 @@ static int __init fuse_init(void)
if (res)
goto err_sysfs_cleanup;
- sanitize_global_limit(&max_user_bgreq);
- sanitize_global_limit(&max_user_congthresh);
+ check_global_limit(&max_user_bgreq, mod_param_set_flg_bgreq);
+ check_global_limit(&max_user_congthresh, mod_param_set_flg_thresh);
return 0;
next prev parent reply other threads:[~2012-07-19 12:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 12:48 [PATCH -v2 0/6] fuse: make maximum read/write request size tunable Mitsuo Hayasaka
2012-07-19 12:49 ` [PATCH -v2 1/6] pipe: make the maximum pipe size referable from kernel module Mitsuo Hayasaka
2012-07-19 12:49 ` [PATCH -v2 2/6] fuse: make the maximum read/write request size tunable Mitsuo Hayasaka
2012-08-08 14:04 ` Miklos Szeredi
2012-07-19 12:49 ` [PATCH -v2 3/6] fuse: remove cache for fuse request allocation Mitsuo Hayasaka
2012-07-19 12:49 ` [PATCH -v2 4/6] fuse: add a sysfs parameter to control the maximum request size Mitsuo Hayasaka
2012-08-08 14:43 ` Miklos Szeredi
2012-07-19 12:49 ` Mitsuo Hayasaka [this message]
2012-07-19 12:50 ` [PATCH -v2 6/6] fuse: add documentation of sysfs parameter to limit maximum fuse " Mitsuo Hayasaka
2012-07-19 17:51 ` Rob Landley
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=20120719124958.6250.26758.stgit@ltc137.sdl.hitachi.co.jp \
--to=mitsuo.hayasaka.hu@hitachi.com \
--cc=Nikolaus@rath.org \
--cc=akpm@linux-foundation.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=hanwen@xs4all.nl \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=muthur@gmail.com \
--cc=namei.unix@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yrl.pp-manager.tt@hitachi.com \
/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
all inboxes | Powered by JetHome®