Commit bcb9d66e authored by Fam Zheng's avatar Fam Zheng Committed by Stefan Hajnoczi
Browse files

block: don't lose data from last incomplete sector



To read the last sector that is not aligned to sector boundary, current
code for growable backends, since commit 893a8f62 "block: Produce zeros
when protocols reading beyond end of file", drops the data and directly
returns zeroes. That is incorrect.

Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 0f39ac9a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2669,7 +2669,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
            goto out;
        }

        total_sectors = len >> BDRV_SECTOR_BITS;
        total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
        max_nb_sectors = MAX(0, total_sectors - sector_num);
        if (max_nb_sectors > 0) {
            ret = drv->bdrv_co_readv(bs, sector_num,