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