From ba7d362d14757f937a05026a612759f487ffc168 Mon Sep 17 00:00:00 2001 From: Bernd Schubert Date: Fri, 27 Sep 2024 00:57:21 +0200 Subject: [PATCH] fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustments The further these lines are separated from each other the harder it is to read the code. There shouldn't be any code change behavior here. --- lib/fuse_lowlevel.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 819e435..84185d5 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -2114,20 +2114,10 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) se->conn.time_gran = 1; - if (bufsize < FUSE_MIN_READ_BUFFER) { - fuse_log(FUSE_LOG_ERR, "fuse: warning: buffer size too small: %zu\n", - bufsize); - bufsize = FUSE_MIN_READ_BUFFER; - } - se->bufsize = bufsize; - se->got_init = 1; if (se->op.init) se->op.init(se->userdata, &se->conn); - if (se->conn.max_write > bufsize - FUSE_BUFFER_HEADER_SIZE) - se->conn.max_write = bufsize - FUSE_BUFFER_HEADER_SIZE; - if (se->conn.want & (~se->conn.capable)) { fuse_log(FUSE_LOG_ERR, "fuse: error: filesystem requested capabilities " "0x%x that are not supported by kernel, aborting.\n", @@ -2149,9 +2139,19 @@ void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) return; } - if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) { - se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE; + if (bufsize < FUSE_MIN_READ_BUFFER) { + fuse_log(FUSE_LOG_ERR, + "fuse: warning: buffer size too small: %zu\n", + bufsize); + 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; + if (arg->flags & FUSE_MAX_PAGES) { outarg.flags |= FUSE_MAX_PAGES; outarg.max_pages = (se->conn.max_write - 1) / getpagesize() + 1; -- 2.30.2