From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN4j8-0003VO-14 for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN4j2-0005ET-1h for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN4j1-0005EK-QQ for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:39 -0400 From: Stefan Hajnoczi Date: Fri, 20 Sep 2013 19:42:09 +0200 Message-Id: <1379698931-946-10-git-send-email-stefanha@redhat.com> In-Reply-To: <1379698931-946-1-git-send-email-stefanha@redhat.com> References: <1379698931-946-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 09/11] block: don't lose data from last incomplete sector List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Fam Zheng , Stefan Hajnoczi , Anthony Liguori From: Fam Zheng 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 Signed-off-by: Stefan Hajnoczi --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index e176c6f..ea4956d 100644 --- a/block.c +++ b/block.c @@ -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, -- 1.8.3.1