fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustments
authorBernd Schubert <bschubert@ddn.com>
Thu, 26 Sep 2024 22:57:21 +0000 (00:57 +0200)
committerBernd Schubert <bernd.schubert@fastmail.fm>
Sat, 28 Sep 2024 14:24:22 +0000 (16:24 +0200)
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

index 819e435bf5e0ac22cf5617567e3fb3e7600b08c0..84185d5b546e8189b1c40a5c77a710807e40b382 100644 (file)
@@ -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;