Skip to content

Commit

Permalink
Revert most of "fusefrontend: clamp oversized reads"
Browse files Browse the repository at this point in the history
We cannot return less data than requested to the kernel!

From https://libfuse.github.io/doxygen/structfuse__operations.html:

  Read should return exactly the number of bytes
  requested except on EOF or error, otherwise the
  rest of the data will be substituted with
  zeroes.

Reverts commit 3009ec9 minus
the formatting improvements we want to keep.

Fixes #147
Reopens #145
  • Loading branch information
rfjakob committed Oct 21, 2017
1 parent b3c20e5 commit 268e048
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions internal/fusefrontend/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ func (f *file) createHeader() (fileID []byte, err error) {
return h.ID, err
}

var oversizedReadWarn sync.Once

// doRead - read "length" plaintext bytes from plaintext offset "off" and append
// to "dst".
// Arguments "length" and "off" do not have to be block-aligned.
Expand All @@ -144,16 +142,6 @@ var oversizedReadWarn sync.Once
// Called by Read() for normal reading,
// by Write() and Truncate() for Read-Modify-Write
func (f *file) doRead(dst []byte, off uint64, length uint64) ([]byte, fuse.Status) {
// Our byte cache pools are sized acc. to MAX_KERNEL_WRITE, but the
// running kernel may have a higher limit set. Clamp to what we can
// handle.
if length > fuse.MAX_KERNEL_WRITE {
oversizedReadWarn.Do(func() {
tlog.Warn.Printf("doRead: truncating oversized read: %d to %d bytes",
length, fuse.MAX_KERNEL_WRITE)
})
length = fuse.MAX_KERNEL_WRITE
}
// Make sure we have the file ID.
f.fileTableEntry.HeaderLock.RLock()
if f.fileTableEntry.ID == nil {
Expand Down

0 comments on commit 268e048

Please sign in to comment.