Commit 19887fb2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse/nodefs: return OK for OOB readdir(plus)

This apparently happens in NFS mounts of FUSE file systems when
combined with lots of FS activity. Maybe some part of the client is
caching readdir results in the wrong way?

In any event, returning OK (signifying EOF on the dirstream) is
harmless.

Change-Id: Ib09d77eae0f1af8bce46b07f386fdda20b2ccb95
parent 509d146f
...@@ -40,8 +40,12 @@ func (d *connectorDir) ReadDir(cancel <-chan struct{}, input *fuse.ReadIn, out * ...@@ -40,8 +40,12 @@ func (d *connectorDir) ReadDir(cancel <-chan struct{}, input *fuse.ReadIn, out *
} }
if input.Offset > uint64(len(d.stream)) { if input.Offset > uint64(len(d.stream)) {
// This shouldn't happen, but let's not crash. // See https://github.com/hanwen/go-fuse/issues/297
return fuse.EINVAL // This can happen for FUSE exported over NFS. This
// seems incorrect, (maybe the kernel is using offsets
// from other opendir/readdir calls), it is harmless to reinforce that
// we have reached EOF.
return fuse.OK
} }
todo := d.stream[input.Offset:] todo := d.stream[input.Offset:]
...@@ -75,8 +79,8 @@ func (d *connectorDir) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, o ...@@ -75,8 +79,8 @@ func (d *connectorDir) ReadDirPlus(cancel <-chan struct{}, input *fuse.ReadIn, o
} }
if input.Offset > uint64(len(d.stream)) { if input.Offset > uint64(len(d.stream)) {
// This shouldn't happen, but let's not crash. // See comment in Readdir
return fuse.EINVAL return fuse.OK
} }
todo := d.stream[input.Offset:] todo := d.stream[input.Offset:]
for _, e := range todo { for _, e := range todo {
......
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