All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: fuse-devel@lists.sourceforge.net, linux-kernel@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>
Subject: [RFC PATCH 4/5] fuse: add a sysfs parameter to control maximum request size
Date: Thu, 05 Jul 2012 19:51:07 +0900	[thread overview]
Message-ID: <20120705105107.17812.40720.stgit@ltc137.sdl.hitachi.co.jp> (raw)
In-Reply-To: <20120705105017.17812.95542.stgit@ltc137.sdl.hitachi.co.jp>

The tunable maximum read/write request size changes the size of
fuse request when max_read/max_write mount option is specified.

The libfuse should change the current MIN_BUFSIZE limitation
according to the current maximum request size. If not, the
libfuse must always set MIN_BUFSIZE to the maximum request limit
(= [256 pages * 4KB + 0x1000] in current implementation), which
leads to waste of memory. So, it is necessary to get it from
userspace.

This patch adds a sysfs parameter to achieve it. It can be
changed from 32 to 256 pages and the 32 pages are set by default.

When we want to increase the maximum request size, it is required
to change this parameter before mounting FUSE filesystems.

Signed-off-by: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
Cc: Miklos Szeredi <miklos@szeredi.hu>
---

 fs/fuse/inode.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 51 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index d8d302a..50b78c6 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -47,6 +47,13 @@ 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 from FUSE_DEFAULT_MAX_PAGES_PER_REQ
+ * to FUSE_MAX_PAGES_PER_REQ.
+ */
+static unsigned sysfs_max_req_pages = FUSE_DEFAULT_MAX_PAGES_PER_REQ;
+
 #define FUSE_SUPER_MAGIC 0x65735546
 
 #define FUSE_DEFAULT_BLKSIZE 512
@@ -780,8 +787,7 @@ 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)
 {
 	if (max_pages > fc->max_pages) {
-		fc->max_pages = min_t(unsigned, FUSE_MAX_PAGES_PER_REQ,
-				      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 *);
 	}
@@ -1203,6 +1209,43 @@ 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;
+
+	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, FUSE_MAX_PAGES_PER_REQ);
+
+	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;
@@ -1219,8 +1262,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:


  parent reply	other threads:[~2012-07-05 10:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-05 10:50 [RFC PATCH 0/5] fuse: make maximum read/write request size tunable Mitsuo Hayasaka
2012-07-05 10:50 ` [RFC PATCH 1/5] " Mitsuo Hayasaka
2012-07-05 10:50 ` [RFC PATCH 2/5] fuse: do not create cache for fuse request allocation Mitsuo Hayasaka
2012-07-05 10:51 ` [RFC PATCH 3/5] fuse: make default global limit minimum value Mitsuo Hayasaka
2012-07-05 10:51 ` Mitsuo Hayasaka [this message]
2012-07-05 10:51 ` [RFC PATCH 5/5] fuse: add documentation of sysfs parameter to limit maximum fuse request size Mitsuo Hayasaka
2012-07-06 12:54   ` Rob Landley
2012-07-12 13:13     ` HAYASAKA Mitsuo
2012-07-05 13:04 ` [RFC PATCH 0/5] fuse: make maximum read/write request size tunable Nikolaus Rath
2012-07-06 10:09   ` HAYASAKA Mitsuo
2012-07-06  5:53 ` Liu Yuan
2012-07-06 13:58   ` [fuse-devel] " Han-Wen Nienhuys
2012-07-12  5:58     ` HAYASAKA Mitsuo
2012-07-12  6:13       ` Liu Yuan
2012-07-12 10:13       ` Miklos Szeredi
2012-07-13  7:30         ` HAYASAKA Mitsuo

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=20120705105107.17812.40720.stgit@ltc137.sdl.hitachi.co.jp \
    --to=mitsuo.hayasaka.hu@hitachi.com \
    --cc=fuse-devel@lists.sourceforge.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --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 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.