|
@ -7,7 +7,6 @@ import ( |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/glog" |
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|
|
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" |
|
|
"io" |
|
|
"io" |
|
|
"math" |
|
|
|
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func (fh *FileHandle) lockForRead(startOffset int64, size int) { |
|
|
func (fh *FileHandle) lockForRead(startOffset int64, size int) { |
|
@ -56,7 +55,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { |
|
|
|
|
|
|
|
|
var chunkResolveErr error |
|
|
var chunkResolveErr error |
|
|
if fh.entryViewCache == nil { |
|
|
if fh.entryViewCache == nil { |
|
|
fh.entryViewCache, chunkResolveErr = filer.NonOverlappingVisibleIntervals(fh.wfs.LookupFn(), entry.Chunks, 0, math.MaxInt64) |
|
|
|
|
|
|
|
|
fh.entryViewCache, chunkResolveErr = filer.NonOverlappingVisibleIntervals(fh.wfs.LookupFn(), entry.Chunks, 0, fileSize) |
|
|
if chunkResolveErr != nil { |
|
|
if chunkResolveErr != nil { |
|
|
return 0, fmt.Errorf("fail to resolve chunk manifest: %v", chunkResolveErr) |
|
|
return 0, fmt.Errorf("fail to resolve chunk manifest: %v", chunkResolveErr) |
|
|
} |
|
|
} |
|
@ -65,7 +64,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { |
|
|
|
|
|
|
|
|
reader := fh.reader |
|
|
reader := fh.reader |
|
|
if reader == nil { |
|
|
if reader == nil { |
|
|
chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, math.MaxInt64) |
|
|
|
|
|
|
|
|
chunkViews := filer.ViewFromVisibleIntervals(fh.entryViewCache, 0, fileSize) |
|
|
glog.V(4).Infof("file handle read %s [%d,%d) from %d views", fileFullPath, offset, offset+int64(len(buff)), len(chunkViews)) |
|
|
glog.V(4).Infof("file handle read %s [%d,%d) from %d views", fileFullPath, offset, offset+int64(len(buff)), len(chunkViews)) |
|
|
for _, chunkView := range chunkViews { |
|
|
for _, chunkView := range chunkViews { |
|
|
glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId) |
|
|
glog.V(4).Infof(" read %s [%d,%d) from chunk %+v", fileFullPath, chunkView.LogicOffset, chunkView.LogicOffset+int64(chunkView.Size), chunkView.FileId) |
|
@ -80,7 +79,7 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) { |
|
|
glog.Errorf("file handle read %s: %v", fileFullPath, err) |
|
|
glog.Errorf("file handle read %s: %v", fileFullPath, err) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
glog.V(4).Infof("file handle read %s [%d,%d] %d : %v", fileFullPath, offset, offset+int64(totalRead), totalRead, err) |
|
|
|
|
|
|
|
|
// glog.V(4).Infof("file handle read %s [%d,%d] %d : %v", fileFullPath, offset, offset+int64(totalRead), totalRead, err)
|
|
|
|
|
|
|
|
|
return int64(totalRead), err |
|
|
return int64(totalRead), err |
|
|
} |
|
|
} |
|
|