[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 12/53] Revert "block: Fix unaligned zero write"
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 12/53] Revert "block: Fix unaligned zero write" |
Date: |
Thu, 30 Jul 2015 06:32:27 -0500 |
This reverts commit fc3959e4669a1c2149b91ccb05101cfc7ae1fc05.
>From upstream commit d01c07f:
This reverts commit fc3959e4669a1c2149b91ccb05101cfc7ae1fc05.
The core write code already handles the case, so remove this
duplication.
Because commit 61007b316 moved the touched code from block.c to
block/io.c, the change is manually reverted.
Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
v2.3.0 does not contain 61007b316 so we can revert the change
directly.
Signed-off-by: Michael Roth <address@hidden>
---
block.c | 45 ++++++---------------------------------------
1 file changed, 6 insertions(+), 39 deletions(-)
diff --git a/block.c b/block.c
index f2f8ae7..0fe97de 100644
--- a/block.c
+++ b/block.c
@@ -3118,19 +3118,6 @@ out:
return ret;
}
-static inline uint64_t bdrv_get_align(BlockDriverState *bs)
-{
- /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */
- return MAX(BDRV_SECTOR_SIZE, bs->request_alignment);
-}
-
-static inline bool bdrv_req_is_aligned(BlockDriverState *bs,
- int64_t offset, size_t bytes)
-{
- int64_t align = bdrv_get_align(bs);
- return !(offset & (align - 1) || (bytes & (align - 1)));
-}
-
/*
* Handle a read request in coroutine context
*/
@@ -3141,7 +3128,8 @@ static int coroutine_fn
bdrv_co_do_preadv(BlockDriverState *bs,
BlockDriver *drv = bs->drv;
BdrvTrackedRequest req;
- uint64_t align = bdrv_get_align(bs);
+ /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */
+ uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment);
uint8_t *head_buf = NULL;
uint8_t *tail_buf = NULL;
QEMUIOVector local_qiov;
@@ -3383,7 +3371,8 @@ static int coroutine_fn
bdrv_co_do_pwritev(BlockDriverState *bs,
BdrvRequestFlags flags)
{
BdrvTrackedRequest req;
- uint64_t align = bdrv_get_align(bs);
+ /* TODO Lift BDRV_SECTOR_SIZE restriction in BlockDriver interface */
+ uint64_t align = MAX(BDRV_SECTOR_SIZE, bs->request_alignment);
uint8_t *head_buf = NULL;
uint8_t *tail_buf = NULL;
QEMUIOVector local_qiov;
@@ -3482,10 +3471,6 @@ static int coroutine_fn
bdrv_co_do_pwritev(BlockDriverState *bs,
bytes = ROUND_UP(bytes, align);
}
- if (use_local_qiov) {
- /* Local buffer may have non-zero data. */
- flags &= ~BDRV_REQ_ZERO_WRITE;
- }
ret = bdrv_aligned_pwritev(bs, &req, offset, bytes,
use_local_qiov ? &local_qiov : qiov,
flags);
@@ -3526,32 +3511,14 @@ int coroutine_fn bdrv_co_write_zeroes(BlockDriverState
*bs,
int64_t sector_num, int nb_sectors,
BdrvRequestFlags flags)
{
- int ret;
-
trace_bdrv_co_write_zeroes(bs, sector_num, nb_sectors, flags);
if (!(bs->open_flags & BDRV_O_UNMAP)) {
flags &= ~BDRV_REQ_MAY_UNMAP;
}
- if (bdrv_req_is_aligned(bs, sector_num << BDRV_SECTOR_BITS,
- nb_sectors << BDRV_SECTOR_BITS)) {
- ret = bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL,
- BDRV_REQ_ZERO_WRITE | flags);
- } else {
- uint8_t *buf;
- QEMUIOVector local_qiov;
- size_t bytes = nb_sectors << BDRV_SECTOR_BITS;
-
- buf = qemu_memalign(bdrv_opt_mem_align(bs), bytes);
- memset(buf, 0, bytes);
- qemu_iovec_init(&local_qiov, 1);
- qemu_iovec_add(&local_qiov, buf, bytes);
- ret = bdrv_co_do_writev(bs, sector_num, nb_sectors, &local_qiov,
- BDRV_REQ_ZERO_WRITE | flags);
- qemu_vfree(buf);
- }
- return ret;
+ return bdrv_co_do_writev(bs, sector_num, nb_sectors, NULL,
+ BDRV_REQ_ZERO_WRITE | flags);
}
/**
--
1.9.1
- [Qemu-stable] Patch Round-up for stable 2.3.1, freeze on 2015-08-06, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 09/53] virtio-net: fix the upper bound when trying to delete queues, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 10/53] target-arm: Avoid buffer overrun on UNPREDICTABLE ldrd/strd, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 11/53] fdc: force the fifo access to be in bounds of the allocated buffer, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 12/53] Revert "block: Fix unaligned zero write",
Michael Roth <=
- [Qemu-stable] [PATCH 13/53] block: Fix NULL deference for unaligned write if qiov is NULL, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 14/53] qemu-iotests: Test unaligned sub-block zero write, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 15/53] hw/acpi/aml-build: Fix memory leak, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 18/53] kbd: add brazil kbd keys to x11 evdev map, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 20/53] iotests: qcow2 COW with minimal L2 cache size, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 16/53] qga/commands-posix: Fix bug in guest-fstrim, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 01/53] bt-sdp: fix broken uuids power-of-2 calculation, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 17/53] kbd: add brazil kbd keys to qemu, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 21/53] vmdk: Fix index_in_cluster calculation in vmdk_co_get_block_status, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 19/53] qcow2: Set MIN_L2_CACHE_SIZE to 2, Michael Roth, 2015/07/30