Repository navigation
Take the FUSE file slot before the session lock - #509
Merged
Merged
Conversation
jserv
reviewed
Nov 11, 2026
jserv
requested changes
Nov 11, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Rebase onto latest main branch which resolves regressions.
xalestar
reviewed
Nov 12, 2026
xalestar
reviewed
Nov 12, 2026
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
2 times, most recently
from
November 12, 2026 04:25
97110b4 to
994f570
Compare
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
View guided diff | Re-trigger cubic
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 12, 2026 11:26
994f570 to
de8b57d
Compare
Benchmark changes outside ±20%Compared Improvements
Workflow run · commit |
jserv
reviewed
Nov 12, 2026
jserv
reviewed
Nov 12, 2026
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 12, 2026 16:18
de8b57d to
12ca88e
Compare
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 12, 2026 16:24
12ca88e to
585add9
Compare
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 13, 2026 02:17
585add9 to
9e02c9c
Compare
jserv
reviewed
Nov 13, 2026
jserv
reviewed
Nov 13, 2026
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 13, 2026 04:26
9e02c9c to
ee82b6e
Compare
fuse_open_path held session->lock across the path walk and then took fuse_lock to allocate the file slot, while fuse_path_lookup takes fuse_lock and then session->lock. An open holding the session lock and waiting on fuse_lock, and a lookup holding fuse_lock and waiting on the session lock, deadlock each other. The slot is now reserved under the fuse_lock the open already holds for the mount lookup, before it takes session->lock, and every early return hands it back. Nothing reaches the daemon for an open that cannot get a slot. That matters because FUSE_OPEN carries the open flags, O_TRUNC included, so a slot check after it could fail an open whose truncation had already happened. Linux likewise allocates the struct file in path_openat before the walk. Two effects follow. Each open holds a slot for the whole walk, so a burst of concurrent opens can fill the table and turn away an open that would have succeeded. And a full table fails the open before the walk, so a missing name reports ENFILE rather than ENOENT, as Linux does when alloc_empty_file fails. The table does not grow with RLIMIT_NOFILE, so the failure is ENFILE rather than the earlier ENOMEM. test-fuse-open-lock fails each early return of the open more times than the table has slots, then fills the table and checks that every open reports ENFILE without a FUSE_OPEN reaching the daemon, and that every successful FUSE_OPEN is released. It also holds an open inside the session lock with a new ELFUSE_FUSE_OPEN_LOCK_DELAY_US hook while a stat starts, and fails unless the stat waited on the open. Before this change that case deadlocked on every run.
Max042004
force-pushed
the
fuse-slot-before-session-lock
branch
from
November 14, 2026 12:39
ee82b6e to
c442ee8
Compare
Contributor
|
Thank @Max042004 for contributing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fuse_open_path held session->lock across the path walk and then took fuse_lock to allocate the file slot, while fuse_path_lookup takes fuse_lock and then session->lock. The session lock is held across daemon round trips, so a lookup waiting on it while holding fuse_lock and an open waiting on fuse_lock while holding it deadlock each other.
The slot is now allocated under the fuse_lock the open already holds after it the session.
Summary by cubic
Fixes a deadlock in the FUSE open path by reserving the file slot before taking the session lock.
fuse_open_pathheldsession->lockacross the path walk and then tookfuse_lockfor the slot, whilefuse_path_lookuptakesfuse_lockthensession->lock. An open waiting onfuse_lockwhile holding the session lock and a lookup waiting on the session lock while holdingfuse_lockdeadlocked. The slot is now reserved under thefuse_lockthe open already holds for the mount lookup, before the session lock is taken, and every early return hands it back.Nothing reaches the daemon for an open that cannot get a slot, so a full table reports
ENFILEinstead of the earlierENOMEMfor a name that resolves, andENFILEinstead ofENOENTfor a missing name. AnO_TRUNCopen cannot truncate a file it then fails to open. Each open holds a slot for the whole walk, so a burst of concurrent opens can fill the table and turn away an open that would have succeeded.test-fuse-open-lockand theELFUSE_FUSE_OPEN_LOCK_DELAY_UShook to hold an open inside the session lock while a stat starts, which deadlocked on every run before this change.Written for commit c442ee8. Summary will update on new commits.