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