Message ID | 1379502855-27759-2-git-send-email-famz@redhat.com |
---|---|
State | New |
Headers | show |
On Wed, Sep 18, 2013 at 07:14:14PM +0800, Fam Zheng wrote: > To read the last sector that is not aligned to sector boundary, current > code for growable backends, since commit 893a8f6 "block: Produce zeros > when protocols reading beyond end of file", drops the data and directly > returns zeroes. That is incorrect. > > Signed-off-by: Fam Zheng <famz@redhat.com> > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) I merged this patch because I hit the problem myself today. And my code includes a test case which will be posted soon. So don't worry about writing a test case for this patch. I still don't fully understand the vmdk patch and would like a test case for it. Thanks, applied to my block tree: https://github.com/stefanha/qemu/commits/block Stefan
diff --git a/block.c b/block.c index a325efc..9b28ef9 100644 --- a/block.c +++ b/block.c @@ -2613,7 +2613,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,
To read the last sector that is not aligned to sector boundary, current code for growable backends, since commit 893a8f6 "block: Produce zeros when protocols reading beyond end of file", drops the data and directly returns zeroes. That is incorrect. Signed-off-by: Fam Zheng <famz@redhat.com> --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)