🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: muc.lists.freebsd.bugs
3 messages
3 total messages Started by bugzilla-noreply Sun, 15 Nov 2026 02:20
[Bug 300785] [fusefs]: timed-out writes return bogus EINTR and the buffer is re-dirtied without recording the error
#468
Author: bugzilla-noreply
Date: Sun, 15 Nov 2026 02:20
135 lines
6969 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300785

            Bug ID: 300785
           Summary: [fusefs]: timed-out writes return bogus EINTR and the
                    buffer is re-dirtied without recording the error
           Product: Base System
           Version: 15.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: e@4779.name

Created attachment 277313
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277313&action=edit
fuse_io.c: record ETIMEDOUT on the buffer, reserve B_EINTR for genuine EINTR
(git diff, main and stable/15)

Environment:

FreeBSD 15.1-RELEASE-p6 amd64. The cited code is identical in
stable/15 (release/15.1.0) and current main. FUSE server: bcachefs
over FUSE (https://github.com/e4779/bcachefs-freebsd), default
daemon_timeout (60 s). Observed live in production, then confirmed
by code reading and a deterministic test.


Description:

fuse_ipc.c waits daemon_timeout seconds for a reply and then returns
ETIMEDOUT (sys/fs/fuse/fuse_ipc.c:436-444, main; stable/15
identical). The write path discards that knowledge.

fuse_io_strategy (sys/fs/fuse/fuse_io.c:896-904) receives ETIMEDOUT,
re-dirties the buffer (bdirty, clears B_DONE) and records nothing: no
BIO_ERROR, no b_error. For synchronous callers (!B_ASYNC) it sets the
B_EINTR flag - for both EINTR and ETIMEDOUT. bwait
(sys/kern/vfs_bio.c:4574-4577) then converts B_EINTR into a bare EINTR
return.

Consequences:

1. A synchronous writer gets EINTR for a syscall that was never
   signalled. EINTR reads as "retry me": applications retry, and each
   retry burns another full daemon_timeout window inside
   fdisp_wait_answ. In our production this surfaced as an endless
   EINTR-retry loop (qbittorrent/libtorrent retrying a write against a
   healthy daemon).

2. An asynchronous writeback buffer is re-dirtied with no error marker
   and no retry scheduling; the failure is invisible to every consumer
   reading b_error or BIO_ERROR.

3. fsync(2): vn_fsync_buf (sys/kern/vfs_vnops.c:3245; maxretry = 10000
   at :3253) reads b_error == 0 on the re-dirtied buffer and keeps
   flushing; each pass costs one daemon_timeout window; after maxretry
   passes it returns EAGAIN instead of the real error.

What we ruled out:

- The FUSE server. At every observed wedge the daemon was alive and
  serving: thread stacks on both sides show the client parked in
  fdisp_wait_answ inside fuse_vnop_write / fuse_vnop_read while the
  daemon slept in poll/accept; the daemon web UI answered 200 during
  the same wedge, and dtrace measured ~65k ops/s throughput.

- Server-side reply-path bugs (lost writev, MT lockups) existed and
  were fixed in our server earlier; this wedge class survived those
  fixes.

- A non-serving daemon is detectable and distinct: with the daemon
  SIGSTOPped, ops time out with ETIMEDOUT after one window (verified
  on a test mount).


How-To-Repeat:

1. Deterministic test against a stock kernel. The gtest suite
   tests/sys/fs/fusefs/fusefs_timeout.cc (full patch attached:
   fusefs-tests-etimedout.patch) mounts a mock
   FUSE server that delays FUSE_WRITE replies beyond daemon_timeout;
   a writer then times out. On stock fusefs(4),
   Timeout.append_lane_etimedout fails: the writer observes EINTR and
   the buffer stays dirty. With the attached fix the test passes
   (ETIMEDOUT in one window, 3.0 s wall-clock assert); the
   neighbouring Fsync and Interrupt suites pass unchanged on both
   kernels.

2. Live stacks from a production wedge (2026-11-06, qbittorrent
   writing):

       client: fdisp_wait_answ+0x150
           <- fuse_write_directbackend <- fuse_io_strategy
           <- bufwrite <- fuse_write_biobackend <- fuse_vnop_write
           <- sys_write
       daemon: FUSE reader in poll, control socket in accept, workers
           asleep

   Full procstat -k excerpts of both sides attached.


Fix:

Record the error on the buffer and reserve B_EINTR for genuine EINTR.
In the timeout branch of fuse_io_strategy:

    bp->b_ioflags |= BIO_ERROR;
    bp->b_error = ETIMEDOUT;

keep bdirty so data is not lost. Our working patch covers all three
write lanes (IO_SYNC, discontiguous appends, fsync) and includes the
test suite above. Attached as a git diff
(fusefs-151-inverse-fuse_io.patch; tests patch attached separately).

Related but distinct:
- bug #236474 (fsync returns asynchronously - completion semantics, not
timeout errno handling);
- bug #293028 (EINTR in cp(1) and
copy_file_range(2) over fuse - userland copy path).

Note on tooling: prepared with LLM-assisted tooling under my
supervision.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300785] [fusefs]: timed-out writes return bogus EINTR and the buffer is re-dirtied without recording the error
#469
Author: bugzilla-noreply
Date: Sun, 15 Nov 2026 02:21
24 lines
2899 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300785

--- Comment #1 from Nick <e@4779.name> ---
Created attachment 277314
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=277314&action=edit
fusefs_timeout gtest suite: fails on stock (bogus EINTR), passes with the fix
(git diff)

git diff: tests/sys/fs/fusefs/fusefs_timeout.cc + Makefile. gtest
suite: on stock fusefs.ko Timeout.append_lane_etimedout fails with
bogus EINTR; with the fix patch it passes (ETIMEDOUT in one
window). Neighbouring Fsync and Interrupt suites pass unchanged on
both kernels. Apply: git apply from the src root.

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300785] [fusefs]: timed-out writes return bogus EINTR and the buffer is re-dirtied without recording the error
#471
Author: bugzilla-noreply
Date: Sun, 15 Nov 2026 08:50
16 lines
2573 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300785

Mark Linimon <linimon@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|bugs@FreeBSD.org            |fs@FreeBSD.org

-- 
You are receiving this mail because:
You are the assignee for the bug.

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads