From 752b59ac087658adb50d50a492d228d53081d195 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Mon, 16 Dec 2024 23:37:29 +0100 Subject: Allow to have page aligned writes Read/writes IOs should be page aligned as fuse server might need to copy data to another buffer otherwise in order to fulfill network or device storage requirements. Simple reproducer is example/passthrough* and opening a file with O_DIRECT - without this change writing to that file failed with -EINVAL if the underlying file system was using ext4 (for passthrough_hp the 'passthrough' feature has to be disabled). The mis-alignment from fuse kernel is not ideal, but we can handle it by allocation one page more than needed and then using a buffer that is set up to compensate for kernel misalignment. This also only set se->buf_reallocable to true when called by a libfuse internal caller - we do not know what external callers are doing with the buffer - update to commit 0e0f43b79b9b --- lib/fuse_loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/fuse_loop.c') diff --git a/lib/fuse_loop.c b/lib/fuse_loop.c index cad3a5c..742d169 100644 --- a/lib/fuse_loop.c +++ b/lib/fuse_loop.c @@ -24,7 +24,7 @@ int fuse_session_loop(struct fuse_session *se) }; while (!fuse_session_exited(se)) { - res = fuse_session_receive_buf(se, &fbuf); + res = fuse_session_receive_buf_int(se, &fbuf, NULL); if (res == -EINTR) continue; @@ -34,7 +34,7 @@ int fuse_session_loop(struct fuse_session *se) fuse_session_process_buf(se, &fbuf); } - free(fbuf.mem); + fuse_buf_free(&fbuf); if(res > 0) /* No error, just the length of the most recently read request */ -- cgit v1.2.3