cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-block-Make-zero-after-EOF-work-with-larger-alignment.patch

0a122b
From 4b6c9d80b06057886e35650b904fe332ae14d0bd Mon Sep 17 00:00:00 2001
0a122b
From: Kevin Wolf <kwolf@redhat.com>
0a122b
Date: Wed, 4 Dec 2013 12:13:10 +0100
0a122b
Subject: [PATCH 19/37] block: Make zero-after-EOF work with larger alignment
0a122b
0a122b
Message-id: <1392117622-28812-20-git-send-email-kwolf@redhat.com>
0a122b
Patchwork-id: 57184
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 19/37] block: Make zero-after-EOF work with larger alignment
0a122b
Bugzilla: 748906
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
Odd file sizes could make bdrv_aligned_preadv() shorten the request in
0a122b
non-aligned ways. Fix it by rounding to the required alignment instead
0a122b
of 512 bytes.
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
Reviewed-by: Max Reitz <mreitz@redhat.com>
0a122b
Reviewed-by: Benoit Canet <benoit@irqsave.net>
0a122b
(cherry picked from commit ec746e10cb2e6276a8d2e036454792fe0674864a)
0a122b
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
---
0a122b
 block.c | 7 ++++---
0a122b
 1 file changed, 4 insertions(+), 3 deletions(-)
0a122b
---
0a122b
 block.c |    7 ++++---
0a122b
 1 files changed, 4 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/block.c b/block.c
0a122b
index feeab4e..6317321 100644
0a122b
--- a/block.c
0a122b
+++ b/block.c
0a122b
@@ -2748,7 +2748,7 @@ err:
0a122b
  */
0a122b
 static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
0a122b
     BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
0a122b
-    QEMUIOVector *qiov, int flags)
0a122b
+    int64_t align, QEMUIOVector *qiov, int flags)
0a122b
 {
0a122b
     BlockDriver *drv = bs->drv;
0a122b
     int ret;
0a122b
@@ -2796,7 +2796,8 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
0a122b
         }
0a122b
 
0a122b
         total_sectors = DIV_ROUND_UP(len, BDRV_SECTOR_SIZE);
0a122b
-        max_nb_sectors = MAX(0, total_sectors - sector_num);
0a122b
+        max_nb_sectors = MAX(0, ROUND_UP(total_sectors - sector_num,
0a122b
+                                         align >> BDRV_SECTOR_BITS));
0a122b
         if (max_nb_sectors > 0) {
0a122b
             ret = drv->bdrv_co_readv(bs, sector_num,
0a122b
                                      MIN(nb_sectors, max_nb_sectors), qiov);
0a122b
@@ -2882,7 +2883,7 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
0a122b
     }
0a122b
 
0a122b
     tracked_request_begin(&req, bs, offset, bytes, false);
0a122b
-    ret = bdrv_aligned_preadv(bs, &req, offset, bytes,
0a122b
+    ret = bdrv_aligned_preadv(bs, &req, offset, bytes, align,
0a122b
                               use_local_qiov ? &local_qiov : qiov,
0a122b
                               flags);
0a122b
     tracked_request_end(&req;;
0a122b
-- 
0a122b
1.7.1
0a122b