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 4/6] fuse: add a sysfs parameter to control the maximum request size Date: Thu, 19 Jul 2012 21:49:48 +0900 [thread overview] Message-ID: <20120719124948.6250.8088.stgit@ltc137.sdl.hitachi.co.jp> (raw) In-Reply-To: <20120719124851.6250.43316.stgit@ltc137.sdl.hitachi.co.jp> Add a max_pages_per_req sysfs paramater to limit the maximum read/write request size. It can be changed to arbitrary number between 32 and the nr_pages equivalent to pipe_max_size, and the 32 pages are set by default. The sysfs parameter control is required, as follows. * The libfuse should change the current MIN_BUFSIZE limitation according to the current maximum request size in FUSE. If not, the libfuse must always set MIN_BUFSIZE to the maximum request limit (= [nr_pages (equivalent to pipe_max_size) * 4KB + 0x1000]), which leads to waste of memory. * It is easy to find and set the paramter to the optimized value in order to improve the read/write throughput, since the maximum request limit does not always provides the highest throughput. So, it is necessary to get and set the maximum size from userspace. Existing FUSE mounts must be remounted for this change to take effect. 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/inode.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 54 insertions(+), 4 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index f7f3c5d..5f84a40 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -47,6 +47,14 @@ MODULE_PARM_DESC(max_user_congthresh, "Global limit for the maximum congestion threshold an " "unprivileged user can set"); +/** + * 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 + * to pipe_max_size. + */ +static unsigned sysfs_max_req_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; + #define FUSE_SUPER_MAGIC 0x65735546 #define FUSE_DEFAULT_BLKSIZE 512 @@ -779,11 +787,8 @@ static int set_global_limit(const char *val, struct kernel_param *kp) static void set_conn_max_pages(struct fuse_conn *fc, unsigned max_pages) { - unsigned pipe_max_size = pipe_get_max_size(); - unsigned pipe_max_pages = DIV_ROUND_UP(pipe_max_size, PAGE_SIZE); - if (max_pages > fc->max_pages) { - fc->max_pages = min_t(unsigned, pipe_max_pages, max_pages); + fc->max_pages = min_t(unsigned, sysfs_max_req_pages, max_pages); fc->fuse_req_size = sizeof(struct fuse_req) + fc->max_pages * sizeof(struct page *); } @@ -1205,6 +1210,45 @@ static void fuse_fs_cleanup(void) static struct kobject *fuse_kobj; static struct kobject *connections_kobj; +static ssize_t max_req_pages_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", sysfs_max_req_pages); +} + +static ssize_t max_req_pages_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int err; + unsigned long t; + unsigned pipe_max_size = pipe_get_max_size(); + unsigned pipe_max_pages = DIV_ROUND_UP(pipe_max_size, PAGE_SIZE); + + err = kstrtoul(skip_spaces(buf), 0, &t); + if (err) + return err; + + t = max_t(unsigned long, t, FUSE_DEFAULT_MAX_PAGES_PER_REQ); + t = min_t(unsigned long, t, pipe_max_pages); + + sysfs_max_req_pages = t; + return count; +} + +static struct kobj_attribute max_req_pages_attr = + __ATTR(max_pages_per_req, 0644, max_req_pages_show, + max_req_pages_store); + +static struct attribute *fuse_attrs[] = { + &max_req_pages_attr.attr, + NULL, +}; + +static struct attribute_group fuse_attr_grp = { + .attrs = fuse_attrs, +}; + static int fuse_sysfs_init(void) { int err; @@ -1221,8 +1265,14 @@ static int fuse_sysfs_init(void) goto out_fuse_unregister; } + err = sysfs_create_group(fuse_kobj, &fuse_attr_grp); + if (err) + goto out_conn_unregister; + return 0; + out_conn_unregister: + kobject_put(connections_kobj); out_fuse_unregister: kobject_put(fuse_kobj); out_err:
WARNING: multiple messages have this Message-ID (diff)
From: Mitsuo Hayasaka <mitsuo.hayasaka.hu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org> To: Miklos Szeredi <miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org>, Alexander Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>, Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>, Muthukumar R <muthur-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, fuse-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, Miklos Szeredi <miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org>, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Nikolaus Rath <Nikolaus-BTH8mxji4b0@public.gmane.org>, yrl.pp-manager.tt-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org, linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Subject: [PATCH -v2 4/6] fuse: add a sysfs parameter to control the maximum request size Date: Thu, 19 Jul 2012 21:49:48 +0900 [thread overview] Message-ID: <20120719124948.6250.8088.stgit@ltc137.sdl.hitachi.co.jp> (raw) In-Reply-To: <20120719124851.6250.43316.stgit-1LHq5NA/h4JbBxankqS+oUK/SjQzz50+@public.gmane.org> Add a max_pages_per_req sysfs paramater to limit the maximum read/write request size. It can be changed to arbitrary number between 32 and the nr_pages equivalent to pipe_max_size, and the 32 pages are set by default. The sysfs parameter control is required, as follows. * The libfuse should change the current MIN_BUFSIZE limitation according to the current maximum request size in FUSE. If not, the libfuse must always set MIN_BUFSIZE to the maximum request limit (= [nr_pages (equivalent to pipe_max_size) * 4KB + 0x1000]), which leads to waste of memory. * It is easy to find and set the paramter to the optimized value in order to improve the read/write throughput, since the maximum request limit does not always provides the highest throughput. So, it is necessary to get and set the maximum size from userspace. Existing FUSE mounts must be remounted for this change to take effect. Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu-FCd8Q96Dh0JBDgjK7y7TUQ@public.gmane.org> Cc: Miklos Szeredi <miklos-sUDqSbJrdHQHWmgEVkV9KA@public.gmane.org> Cc: Nikolaus Rath <Nikolaus-BTH8mxji4b0@public.gmane.org> Cc: Liu Yuan <namei.unix-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Cc: Has-Wen Nienhuys <hanwen-qWit8jRvyhVmR6Xm/wNWPw@public.gmane.org> --- fs/fuse/inode.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 54 insertions(+), 4 deletions(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index f7f3c5d..5f84a40 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -47,6 +47,14 @@ MODULE_PARM_DESC(max_user_congthresh, "Global limit for the maximum congestion threshold an " "unprivileged user can set"); +/** + * 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 + * to pipe_max_size. + */ +static unsigned sysfs_max_req_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ; + #define FUSE_SUPER_MAGIC 0x65735546 #define FUSE_DEFAULT_BLKSIZE 512 @@ -779,11 +787,8 @@ static int set_global_limit(const char *val, struct kernel_param *kp) static void set_conn_max_pages(struct fuse_conn *fc, unsigned max_pages) { - unsigned pipe_max_size = pipe_get_max_size(); - unsigned pipe_max_pages = DIV_ROUND_UP(pipe_max_size, PAGE_SIZE); - if (max_pages > fc->max_pages) { - fc->max_pages = min_t(unsigned, pipe_max_pages, max_pages); + fc->max_pages = min_t(unsigned, sysfs_max_req_pages, max_pages); fc->fuse_req_size = sizeof(struct fuse_req) + fc->max_pages * sizeof(struct page *); } @@ -1205,6 +1210,45 @@ static void fuse_fs_cleanup(void) static struct kobject *fuse_kobj; static struct kobject *connections_kobj; +static ssize_t max_req_pages_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%u\n", sysfs_max_req_pages); +} + +static ssize_t max_req_pages_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int err; + unsigned long t; + unsigned pipe_max_size = pipe_get_max_size(); + unsigned pipe_max_pages = DIV_ROUND_UP(pipe_max_size, PAGE_SIZE); + + err = kstrtoul(skip_spaces(buf), 0, &t); + if (err) + return err; + + t = max_t(unsigned long, t, FUSE_DEFAULT_MAX_PAGES_PER_REQ); + t = min_t(unsigned long, t, pipe_max_pages); + + sysfs_max_req_pages = t; + return count; +} + +static struct kobj_attribute max_req_pages_attr = + __ATTR(max_pages_per_req, 0644, max_req_pages_show, + max_req_pages_store); + +static struct attribute *fuse_attrs[] = { + &max_req_pages_attr.attr, + NULL, +}; + +static struct attribute_group fuse_attr_grp = { + .attrs = fuse_attrs, +}; + static int fuse_sysfs_init(void) { int err; @@ -1221,8 +1265,14 @@ static int fuse_sysfs_init(void) goto out_fuse_unregister; } + err = sysfs_create_group(fuse_kobj, &fuse_attr_grp); + if (err) + goto out_conn_unregister; + return 0; + out_conn_unregister: + kobject_put(connections_kobj); out_fuse_unregister: kobject_put(fuse_kobj); out_err: ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
next prev parent reply other threads:[~2012-07-19 12:42 UTC|newest] Thread overview: 14+ 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 ` Mitsuo Hayasaka 2012-07-19 12:49 ` Mitsuo Hayasaka [this message] 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 ` [PATCH -v2 5/6] fuse: set default global limit considering tunable " Mitsuo Hayasaka 2012-07-19 12:49 ` Mitsuo Hayasaka 2012-07-19 12:50 ` [PATCH -v2 6/6] fuse: add documentation of sysfs parameter to limit maximum fuse " Mitsuo Hayasaka 2012-07-19 12:50 ` 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=20120719124948.6250.8088.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.