Skip to content

Commit

Permalink
fuse/test: avoid low-numbered fds for FUSE-backed files
Browse files Browse the repository at this point in the history
As part of the fork/exec sequence, file descriptors that should be
inherited are remapped with dup3() in the chld process. This causes
implicit file close operations. If the file descriptors are backed by
FUSE, this leads to FLUSH operations. If parallelism is limited with
GOMAXPROCS, this can cause a deadlock, as there will not be threads
left to service the FLUSH opcodes.

Fixes #489

Change-Id: I81bf4ab0624495aabb5bb9ec42a55c6f23340beb
  • Loading branch information
hanwen committed Nov 8, 2023
1 parent 22d9c9d commit 27a473d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fuse/test/file_lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ func TestFlockExclusive(t *testing.T) {
contents := []byte{1, 2, 3}
tc.WriteFile(tc.origFile, []byte(contents), 0700)

for {
f, err := os.Open("/dev/null")
if err != nil {
t.Fatalf("Open(/dev/null): %v", err)
}
defer f.Close()
if f.Fd() > 3 {
break
}
}

f, err := os.OpenFile(tc.mountFile, os.O_WRONLY, 0)
if err != nil {
t.Fatalf("OpenFile(%q): %v", tc.mountFile, err)
Expand Down

0 comments on commit 27a473d

Please sign in to comment.