diff --git a/cmd/xl-storage.go b/cmd/xl-storage.go index 6d141f4a8..f8e5ee6cd 100644 --- a/cmd/xl-storage.go +++ b/cmd/xl-storage.go @@ -1796,15 +1796,9 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off } or := &xioutil.ODirectReader{ - File: file, - SmallFile: false, - } - - if length <= smallFileThreshold { - or = &xioutil.ODirectReader{ - File: file, - SmallFile: true, - } + File: file, + // Select bigger blocks when reading at least 50% of a big block. + SmallFile: length <= xioutil.BlockSizeLarge/2, } r := struct { diff --git a/internal/ioutil/read_file.go b/internal/ioutil/read_file.go index 38391350d..ab5d35ad4 100644 --- a/internal/ioutil/read_file.go +++ b/internal/ioutil/read_file.go @@ -81,6 +81,10 @@ func ReadFile(name string) ([]byte, error) { if err != nil { return io.ReadAll(r) } + + // Select bigger blocks when reading at least 50% of a big block. + r.SmallFile = st.Size() <= BlockSizeLarge/2 + dst := make([]byte, st.Size()) _, err = io.ReadFull(r, dst) return dst, err