From: Bernd Schubert Date: Thu, 26 Sep 2024 22:57:21 +0000 (+0200) Subject: fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustments X-Git-Tag: fuse-3.17.1-rc0~65 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ba7d362d14757f937a05026a612759f487ffc168;p=qemu-gpiodev%2Flibfuse.git 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. --- 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;