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