98f44a
From a83b3ec1d7ce2d656a4c476d65486371d1a659b2 Mon Sep 17 00:00:00 2001
98f44a
From: Carlos Maiolino <cmaiolino@redhat.com>
98f44a
Date: Tue, 2 May 2017 12:46:10 +0200
98f44a
Subject: [PATCH] From 4f8f034a8969a48f210bf00be78a67cfb6964c72 Mon Sep 17
98f44a
 00:00:00 2001 From: Carlos Maiolino
98f44a
 <cmaiolino-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> Date: Thu, 20 Apr 2017
98f44a
 14:53:01 +0200 Subject: [PATCH] make buffer size match kernel max transfer
98f44a
 size
98f44a
98f44a
Currently libfuse has a hardcoded buffer limit to 128kib, while fuse
98f44a
kernel module has a limit up to 32 pages.
98f44a
98f44a
This patch changes buffer limit to match the current page size, instead
98f44a
of assuming 4096 bytes pages, enabling architectures with bigger pages
98f44a
to use larger buffers, improving performance.
98f44a
98f44a
Also, add a new macro (HEADER_SIZE) to specify the space needed to
98f44a
accommodate the header, making it easier to understand why those extra
98f44a
4096 bytes are needed
98f44a
98f44a
Signed-off-by: Carlos Maiolino <cmaiolino-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
98f44a
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
98f44a
---
98f44a
 lib/fuse_kern_chan.c | 8 +++++---
98f44a
 1 file changed, 5 insertions(+), 3 deletions(-)
98f44a
98f44a
diff --git a/lib/fuse_kern_chan.c b/lib/fuse_kern_chan.c
98f44a
index 5f77bbf..4cc9b73 100644
98f44a
--- a/lib/fuse_kern_chan.c
98f44a
+++ b/lib/fuse_kern_chan.c
98f44a
@@ -80,7 +80,10 @@ static void fuse_kern_chan_destroy(struct fuse_chan *ch)
98f44a
 		close(fd);
98f44a
 }
98f44a
 
98f44a
-#define MIN_BUFSIZE 0x21000
98f44a
+#define KERNEL_BUF_PAGES 32
98f44a
+
98f44a
+/* room needed in buffer to accommodate header */
98f44a
+#define HEADER_SIZE 0x1000
98f44a
 
98f44a
 struct fuse_chan *fuse_kern_chan_new(int fd)
98f44a
 {
98f44a
@@ -89,7 +92,6 @@ struct fuse_chan *fuse_kern_chan_new(int fd)
98f44a
 		.send = fuse_kern_chan_send,
98f44a
 		.destroy = fuse_kern_chan_destroy,
98f44a
 	};
98f44a
-	size_t bufsize = getpagesize() + 0x1000;
98f44a
-	bufsize = bufsize < MIN_BUFSIZE ? MIN_BUFSIZE : bufsize;
98f44a
+	size_t bufsize = KERNEL_BUF_PAGES * getpagesize() + HEADER_SIZE;
98f44a
 	return fuse_chan_new(&op, fd, bufsize, NULL);
98f44a
 }
98f44a
-- 
98f44a
2.9.3
98f44a