aboutsummaryrefslogtreecommitdiffstats
path: root/include/fuse_common.h
diff options
context:
space:
mode:
authorJoanne Koong <joannelkoong@gmail.com>2024-11-14 20:55:48 -0800
committerBernd Schubert <bernd.schubert@fastmail.fm>2024-11-21 19:18:03 +0100
commit0e0f43b79b9b3e746f2d4c6b96294b8a954c6708 (patch)
treec2bbaa94eef525ba3762819c34b9900b0e25b792 /include/fuse_common.h
parent49f74c9b93e9a3a4127a5f43583f64513c2254fd (diff)
downloadlibfuse-0e0f43b79b9b3e746f2d4c6b96294b8a954c6708.tar.gz
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
Diffstat (limited to 'include/fuse_common.h')
-rw-r--r--include/fuse_common.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/fuse_common.h b/include/fuse_common.h
index 85f0b23..e6c3b5d 100644
--- a/include/fuse_common.h
+++ b/include/fuse_common.h
@@ -868,6 +868,14 @@ struct fuse_buf {
* Used if FUSE_BUF_FD_SEEK flag is set.
*/
off_t pos;
+
+ /**
+ * Size of memory pointer
+ *
+ * Used only if mem was internally allocated.
+ * Not used if mem was user-provided.
+ */
+ size_t mem_size;
};
/**
@@ -924,6 +932,7 @@ struct libfuse_version
/* .mem = */ NULL, \
/* .fd = */ -1, \
/* .pos = */ 0, \
+ /* .mem_size = */ 0, \
} } \
} )