Commit 7572e9d8 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: protect dirsteam overflow with lock

Appeases the race detector.
parent 623db2fc
...@@ -26,7 +26,9 @@ type fileEntry struct { ...@@ -26,7 +26,9 @@ type fileEntry struct {
nodeIndex int nodeIndex int
// Directory // Directory
dirStream DirStream dirStream DirStream
mu sync.Mutex
hasOverflow bool hasOverflow bool
overflow fuse.DirEntry overflow fuse.DirEntry
...@@ -833,16 +835,20 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out ...@@ -833,16 +835,20 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out
if errno := b.setStream(cancel, input, n, f); errno != 0 { if errno := b.setStream(cancel, input, n, f); errno != 0 {
return errnoToStatus(errno) return errnoToStatus(errno)
} }
ctx := &fuse.Context{Caller: input.Caller, Cancel: cancel} ctx := &fuse.Context{Caller: input.Caller, Cancel: cancel}
for f.dirStream.HasNext() { for f.dirStream.HasNext() {
var e fuse.DirEntry var e fuse.DirEntry
var errno syscall.Errno var errno syscall.Errno
f.mu.Lock()
if f.hasOverflow { if f.hasOverflow {
e = f.overflow e = f.overflow
f.hasOverflow = false f.hasOverflow = false
} else { } else {
e, errno = f.dirStream.Next() e, errno = f.dirStream.Next()
} }
f.mu.Unlock()
if errno != 0 { if errno != 0 {
return errnoToStatus(errno) return errnoToStatus(errno)
...@@ -850,8 +856,10 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out ...@@ -850,8 +856,10 @@ func (b *rawBridge) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, out
entryOut := out.AddDirLookupEntry(e) entryOut := out.AddDirLookupEntry(e)
if entryOut == nil { if entryOut == nil {
f.mu.Lock()
f.overflow = e f.overflow = e
f.hasOverflow = true f.hasOverflow = true
f.mu.Unlock()
return fuse.OK return fuse.OK
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment