Page MenuHomeFreeBSD

fusefs: change how poll() on /dev/fuse works on unmount
AcceptedPublic

Authored by asomers on Jun 12 2025, 10:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 2, 12:34 PM
Unknown Object (File)
Fri, Sep 26, 12:52 PM
Unknown Object (File)
Thu, Sep 18, 1:27 PM
Unknown Object (File)
Thu, Sep 18, 12:57 PM
Unknown Object (File)
Mon, Sep 15, 8:26 PM
Unknown Object (File)
Fri, Sep 12, 7:47 AM
Unknown Object (File)
Fri, Sep 12, 1:22 AM
Unknown Object (File)
Thu, Sep 11, 7:35 AM
Subscribers

Details

Reviewers
arrowd
Summary

If the file system has been unmounted or is marked as dead due to server
misbehavior:

  • Don't return POLLIN or POLLRDNORM. We shouldn't, since a subsequent read() won't return any data.
  • Do return POLLHUP since we'll never again return data on read().
  • Don't return POLLOUT. According to poll(2), POLLHUP and POLLOUT should never be returned at the same time.

Don't MFC this change, as there's a small risk of breakage for fuse
servers that depend on the old behavior. Note that libfuse is not
affected; while it does use poll() it doesn't check revents. Nor are
any applications affect that use kqueue, select, or plain blocking
reads.

Reported by: arrowd
MFC after: Never
Sponsored by: ConnectWise

Test Plan

Test case added

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 64835
Build 61718: arc lint + arc unit

Event Timeline

sys/fs/fuse/fuse_device.c
284

I think, to be in line with that FreeBSD does for other descriptor types, this should be

revents = POLLHUP;

See my test program from this post: https://lists.freebsd.org/archives/freebsd-hackers/2025-June/004569.html

In that code I don't even request POLLHUP in events, but FreeBSD returns its nevertheless.

sys/fs/fuse/fuse_device.c
284

Yes, good catch. We should output POLLHUP regardless of the input events.

  • fixup: output POLLHUP regardless of the contents of events

LGTM, but you're still ORing POLLHUP into revents, not setting it. As I mentioned in comment, it seems that the FreeBSD way to report EOF is to return POLLHUP only.

This revision is now accepted and ready to land.Jun 16 2025, 5:01 AM

LGTM, but you're still ORing POLLHUP into revents, not setting it. As I mentioned in comment, it seems that the FreeBSD way to report EOF is to return POLLHUP only.

How about if I change it to return POLLIN if there are still any events to read, and only return POLLHUP once there are no more events _and_ the mountpoint is dead?

Is this going to be landed?

Not until I've at least tried the "How about if I change it to return POLLIN if there are still any events to read, and only return POLLHUP once there are no more events _and_ the mountpoint is dead?" option.