From 0e0f43b79b9b3e746f2d4c6b96294b8a954c6708 Mon Sep 17 00:00:00 2001 From: Joanne Koong Date: Thu, 14 Nov 2024 20:55:48 -0800 Subject: Reallocate fuse_session buffer transparently for extended max writes A previous PR supported extended max writes (eg write requests larger than 1 MB) by initializing the fuse session buffer size to use the max_pages_limit set in /proc/sys/fs/fuse. However, this is a huge problem for machines where multiple fuse servers may be running but only one server needs large writes. In this case, a lot of memory will be wasted and will lead to OOM issues. This PR does a reallocation of the session buffer transparently if the server set "se->conn.max_write" to a value larger than 1 MiB. This is only for buffers that are "owned" by libfuse - if the server wishes to provide its own allocated buffer for receiving/processing requests, then it should ensure that buffer is allocated to the proper size from the start. Local testing showed: echo 65535 | sudo tee /proc/sys/fs/fuse/max_pages_limit dd if=/dev/urandom of=hello_file bs=6M count=2 write requests: write request size is 5242880 write request size is 1048576 write request size is 5242880 write request size is 1048576 --- lib/fuse_i.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/fuse_i.h') diff --git a/lib/fuse_i.h b/lib/fuse_i.h index f7924eb..d4421f2 100644 --- a/lib/fuse_i.h +++ b/lib/fuse_i.h @@ -9,6 +9,8 @@ #include "fuse.h" #include "fuse_lowlevel.h" +#include + #define MIN(a, b) \ ({ \ typeof(a) _a = (a); \ @@ -77,6 +79,7 @@ struct fuse_session { * a later version, to 'fix' it at run time. */ struct libfuse_version version; + bool buf_reallocable; }; struct fuse_chan { -- cgit v1.2.3