yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From f0623f334b23dc9334ac9d227cc467c266b8b2c6 Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Wed, 9 Oct 2013 09:50:21 +0200
9ae3a8
Subject: [PATCH 09/11] block: don't lose data from last incomplete sector
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1381312223-7074-2-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 54793
9ae3a8
O-Subject: [RHEL-7 qemu-kvm PATCH 1/3] block: don't lose data from last incomplete sector
9ae3a8
Bugzilla: 1017049
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
9ae3a8
To read the last sector that is not aligned to sector boundary, current
9ae3a8
code for growable backends, since commit 893a8f6 "block: Produce zeros
9ae3a8
when protocols reading beyond end of file", drops the data and directly
9ae3a8
returns zeroes. That is incorrect.
9ae3a8
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit bcb9d66e8590151967e1dbe3724eec7ec71392e0)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
---
9ae3a8
 block.c | 2 +-
9ae3a8
 1 file changed, 1 insertion(+), 1 deletion(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block.c |    2 +-
9ae3a8
 1 files changed, 1 insertions(+), 1 deletions(-)
9ae3a8
9ae3a8
diff --git a/block.c b/block.c
9ae3a8
index a3bc800..bd52c13 100644
9ae3a8
--- a/block.c
9ae3a8
+++ b/block.c
9ae3a8
@@ -2567,7 +2567,7 @@ static int coroutine_fn bdrv_co_do_readv(BlockDriverState *bs,
9ae3a8
             goto out;
9ae3a8
         }
9ae3a8
 
9ae3a8
-        total_sectors = len >> BDRV_SECTOR_BITS;
9ae3a8
+        total_sectors = (len + BDRV_SECTOR_SIZE - 1) >> BDRV_SECTOR_BITS;
9ae3a8
         max_nb_sectors = MAX(0, total_sectors - sector_num);
9ae3a8
         if (max_nb_sectors > 0) {
9ae3a8
             ret = drv->bdrv_co_readv(bs, sector_num,
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8