fix: ReadFileStream should return an error when size mismatches (#13435)

offset+length should match the Size() of the individual parts
return 'errFileCorrupt' otherwise, to trigger healing of the individual 
parts do not error out prematurely when healing such bitrot's upon
successful parts being written to the client.

another issue this PR fixes is to not return and error to
the client if we have just triggered a heal on a specific
part of the object, instead continue to read all the content
and let the heal happen asynchronously later.
This commit is contained in:
Harshavardhana
2021-10-13 19:49:14 -07:00
committed by GitHub
parent bedf739d16
commit d693431183
2 changed files with 19 additions and 5 deletions
+7
View File
@@ -1454,6 +1454,13 @@ func (s *xlStorage) ReadFileStream(ctx context.Context, volume, path string, off
return nil, errIsNotRegular
}
if st.Size() < offset+length {
// Expected size cannot be satisfied for
// requested offset and length
file.Close()
return nil, errFileCorrupt
}
alignment := offset%xioutil.DirectioAlignSize == 0
if !alignment {
if err = disk.DisableDirectIO(file); err != nil {