Repository navigation
Conversation
InvalidateInode and InvalidateEntry sent on an unbuffered channel that only the goroutine NewServerWithNotifier starts in ServeOps receives from. Before ServeOps started, or once it had returned, they blocked forever. They now return ENOTCONN while no server wrapped with the Notifier serves. ServeOps waits for the notification in progress before it returns, so that notification is sent on an open connection and every later call returns ENOTCONN.
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.
Summary
Notifier.InvalidateInodeandInvalidateEntrysend their command on an unbuffered channel and wait for the answer (notifier.go L48-L51, L62-L65). Only the goroutine thatnotifierServer.ServeOpsstarts receives from that channel, and it stops once the wrapped server'sServeOpsreturns (L104-L128). A call made before the server starts serving, or after it has stopped, for example after an unmount, blocks forever. A file system that invalidates from a background goroutine leaks that goroutine, or hangs whatever waits for it.InvalidateInodeandInvalidateEntryreturn ENOTCONN while no server wrapped with the Notifier serves: before itsServeOpsstarts, and once it has returned. They send nothing then.notifierServer.ServeOpswaits for its notification goroutine before it returns. A notification in progress when the wrapped server returns is still written to an open connection, becauseMountcloses the connection only afterServeOpsreturns (mount.go L93-L97). Every call afterServeOpsreturns gets ENOTCONN.Why ENOTCONN
Until
ServeOpsstarts, the server has answered nothing, so the kernel holds nothing of it to invalidate. OnceServeOpshas returned, the connection is closing or closed. ENOTCONN is an errno, like the ENOSYS these methods already document, so callers can compare it as they do ENOSYS. Blocking untilServeOpsstarts was the alternative, but that blocks forever whenMountfails.Tests
Neither test mounts. Run them with:
TestNotifierReturnsENOTCONNWhileNothingServes: both methods return ENOTCONN on a new Notifier, and again afterServeOpsof a server wrapped with it has returned.TestNotifierSendsWhileServing: while the wrapped server serves,InvalidateInodewrites the notification to the connection, here the write end of a pipe, and returns nil. The test checks thefuse_out_header(notify code 2, unique 0) and thefuse_notify_inval_inode_outbody. It passes on master too, and pins the path this PR keeps.The tests set no timeout of their own. On master (a124548), the first test blocks in its first
InvalidateInodecall untilgo test -timeoutends it (excerpt, paths shortened):With this PR, both tests pass, also under
-race.No test pins the new wait in
ServeOps. With the wait removed,TestNotifierReturnsENOTCONNWhileNothingServesstill passed in 2000 runs.Validation
CI runs no
go test, so these local runs are the test evidence.gofmt -l .prints nothing.go build ./...passes withGOOS=linuxand withGOOS=darwin.go vet ./...reports the same findings as on master, withGOOS=linuxand withGOOS=darwin, all in files this PR does not touch: unkeyedfusekernel.Protocolliterals,reflect.SliceHeaderuses and, on linux/arm64,syscall.SYS_DUP2insamples/flushfs.Not changed