|
|
|
[PATCH -v2 4/6] fuse: add a sysfs parameter to control the maximum request size | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
|
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@xxxxxxxxxxx>
Cc: Miklos Szeredi <miklos@xxxxxxxxxx>
Cc: Nikolaus Rath <Nikolaus@xxxxxxxx>
Cc: Liu Yuan <namei.unix@xxxxxxxxx>
Cc: Has-Wen Nienhuys <hanwen@xxxxxxxxx>
---
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:
--
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/
[Other Archives] [Linux Kernel Newbies] [Linux Driver Development] [Linux Kbuild] [Fedora Kernel] [Linux Kernel Testers] [Linux SH] [Linux Omap] [Linux Tape] [Linux Input] [Linux Kernel Janitors] [Linux Kernel Packagers] [Linux Doc] [Linux Man Pages] [Linux API] [Linux Memory Management] [Linux Modules] [Linux Standards] [Kernel Announce] [Netdev] [Git] [Linux PCI] Linux CAN Development [Linux I2C] [Linux RDMA] [Linux NUMA] [Netfilter] [Netfilter Devel] [SELinux] [Bugtraq] [FIO] [Linux Perf Users] [Linux Serial] [Linux PPP] [Linux ISDN] [Linux Next] [Kernel Stable Commits] [Linux Tip Commits] [Kernel MM Commits] [Linux Security Module] [AutoFS] [Filesystem Development] [Ext3 Filesystem] [Linux bcache] [Ext4 Filesystem] [Linux BTRFS] [Linux CEPH Filesystem] [Linux XFS] [XFS] [Linux NFS] [Linux CIFS] [Ecryptfs] [Linux NILFS] [Linux Cachefs] [Reiser FS] [Initramfs] [Linux FB Devel] [Linux OpenGL] [DRI Devel] [Fastboot] [Linux RT Users] [Linux RT Stable] [eCos] [Corosync] [Linux Clusters] [LVS Devel] [Hot Plug] [Linux Virtualization] [KVM] [KVM PPC] [KVM ia64] [Linux Containers] [Linux Hexagon] [Linux Cgroups] [Util Linux] [Wireless] [Linux Bluetooth] [Bluez Devel] [Ethernet Bridging] [Embedded Linux] [Barebox] [Linux MMC] [Linux IIO] [Sparse] [Smatch] [Linux Arch] [x86 Platform Driver] [Linux ACPI] [Linux IBM ACPI] [LM Sensors] [CPU Freq] [Linux Power Management] [Linmodems] [Linux DCCP] [Linux SCTP] [ALSA Devel] [Linux USB] [Linux PA RISC] [Linux Samsung SOC] [MIPS Linux] [IBM S/390 Linux] [ARM Linux] [ARM Kernel] [ARM MSM] [Tegra Devel] [Sparc Linux] [Linux Security] [Linux Sound] [Linux Media] [Video 4 Linux] [Linux IRDA Users] [Linux for the blind] [Linux RAID] [Linux ATA RAID] [Device Mapper] [Linux SCSI] [SCSI Target Devel] [Linux SCSI Target Infrastructure] [Linux IDE] [Linux SMP] [Linux AXP] [Linux Alpha] [Linux M68K] [Linux ia64] [Linux 8086] [Linux x86_64] [Linux Config] [Linux Apps] [Linux MSDOS] [Linux X.25] [Linux Crypto] [DM Crypt] [Linux Trace Users] [Linux Btrace] [Linux Watchdog] [Utrace Devel] [Linux C Programming] [Linux Assembly] [Dash] [DWARVES] [Hail Devel] [Linux Kernel Debugger] [Linux gcc] [Gcc Help] [X.Org] [Wine]
![]() |
![]() |
[Older Kernel Discussion] [Yosemite National Park Forum] [Large Format Photos] [Gimp] [Yosemite Photos] [Stuff]