Skip to content

Commit

Permalink
fuse_lowlevel FUSE_INIT: group bufsize and max_write adjustments
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bsbernd committed Sep 28, 2024
1 parent 9069ad9 commit ba7d362
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/fuse_lowlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
Expand Down

0 comments on commit ba7d362

Please sign in to comment.