aboutsummaryrefslogtreecommitdiff
path: root/weed/filesys/filehandle.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-03-22 01:00:36 -0700
committerChris Lu <chris.lu@gmail.com>2020-03-22 01:00:36 -0700
commit65d2ea9fb00757320f348835d9761a357264ea98 (patch)
tree18e539c2949b4b270ca4cb02ef544a058c57f149 /weed/filesys/filehandle.go
parent82bfad5b8615d9c2cd21efc059514b8899232a0f (diff)
downloadseaweedfs-65d2ea9fb00757320f348835d9761a357264ea98.tar.xz
seaweedfs-65d2ea9fb00757320f348835d9761a357264ea98.zip
FUSE mount: stream read data with buffer
fix https://github.com/chrislusf/seaweedfs/issues/1244
Diffstat (limited to 'weed/filesys/filehandle.go')
-rw-r--r--weed/filesys/filehandle.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index 100c9eba0..bfdafd580 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -3,6 +3,8 @@ package filesys
import (
"context"
"fmt"
+ "io"
+ "math"
"mime"
"path"
"time"
@@ -85,17 +87,23 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {
if fh.f.entryViewCache == nil {
fh.f.entryViewCache = filer2.NonOverlappingVisibleIntervals(fh.f.entry.Chunks)
+ fh.f.reader = nil
+ }
+ if fh.f.reader == nil {
+ chunkViews := filer2.ViewFromVisibleIntervals(fh.f.entryViewCache, 0, math.MaxInt32)
+ fh.f.reader = filer2.NewChunkStreamReaderFromClient(fh.f.wfs, chunkViews)
}
- chunkViews := filer2.ViewFromVisibleIntervals(fh.f.entryViewCache, offset, len(buff))
-
- totalRead, err := filer2.ReadIntoBuffer(fh.f.wfs, fh.f.fullpath(), buff, chunkViews, offset)
+ fh.f.reader.Seek(offset, io.SeekStart)
+ totalRead, err := fh.f.reader.Read(buff)
if err != nil {
glog.Errorf("file handle read %s: %v", fh.f.fullpath(), err)
}
- return totalRead, err
+ // glog.V(0).Infof("file handle read %s [%d,%d] %d : %v", fh.f.fullpath(), offset, offset+int64(totalRead), totalRead, err)
+
+ return int64(totalRead), err
}
// Write to the file handle