Blame SOURCES/fuse2-0003-make-buffer-size-match-kernel-max-transfer-size.patch

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