mirror of
https://github.com/ceph/go-ceph
synced 2024-12-25 23:52:27 +00:00
rbd: WriteAt() should return io.EOF on short reads
The case of a short read is not detected correctly. This causes ReadAt() to not return io.EOF where it is expected. By comparing 'len(data)' instead of unassigned 'n' (set to 0), the number of bytes that have been read can be compared to the number of bytes that were requested. Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
224217212d
commit
508f808017
@ -955,7 +955,7 @@ func (image *Image) Discard(ofs uint64, length uint64) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
func (image *Image) ReadAt(data []byte, off int64) (n int, err error) {
|
||||
func (image *Image) ReadAt(data []byte, off int64) (int, error) {
|
||||
if err := image.validate(imageIsOpen); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -974,7 +974,7 @@ func (image *Image) ReadAt(data []byte, off int64) (n int, err error) {
|
||||
return 0, RBDError(ret)
|
||||
}
|
||||
|
||||
if ret < n {
|
||||
if ret < len(data) {
|
||||
return ret, io.EOF
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user