aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fuse_lowlevel.c
diff options
context:
space:
mode:
authorBernd Schubert <bschubert@ddn.com>2024-09-27 20:37:51 +0200
committerBernd Schubert <bernd.schubert@fastmail.fm>2024-09-28 16:24:22 +0200
commit2aeef499b84b596608181f9b48d589c4f8ffe24a (patch)
tree3ae531b769874a08bab885590e8377ee0bda3857 /lib/fuse_lowlevel.c
parentba7d362d14757f937a05026a612759f487ffc168 (diff)
downloadlibfuse-2aeef499b84b596608181f9b48d589c4f8ffe24a.tar.gz
fuse_lowlevel FUSE_INIT: Simplify the max_write/bufsize logic
max_write can be limited by se->op.init() and by the buffer size, we use the minimum of these two. Required se->bufsize is then set according to the determined max_write. The current thread will have the old buffer size, though, as it already had to the allocation to handle the FUSE_INIT call (unless splice is used and ths variable and related buffer is not used at all). The given bufsize is just a hint for minimum size, allocation could be actually larger (for example to get huge pages).
Diffstat (limited to 'lib/fuse_lowlevel.c')
-rw-r--r--lib/fuse_lowlevel.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 84185d5..a505552 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -2146,11 +2146,8 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
bufsize = FUSE_MIN_READ_BUFFER;
}
- if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE)
- se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE;
- if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE)
- bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
- se->bufsize = bufsize;
+ se->conn.max_write = MIN(se->conn.max_write, bufsize - FUSE_BUFFER_HEADER_SIZE);
+ se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
if (arg->flags & FUSE_MAX_PAGES) {
outarg.flags |= FUSE_MAX_PAGES;