[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 26/39] block: Remove bs->zero_beyond_eof
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 26/39] block: Remove bs->zero_beyond_eof |
Date: |
Thu, 16 Jun 2016 16:08:15 +0200 |
It is always true for open images now.
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
block.c | 2 --
block/io.c | 52 +++++++++++++++++++++--------------------------
include/block/block_int.h | 3 ---
3 files changed, 23 insertions(+), 34 deletions(-)
diff --git a/block.c b/block.c
index 3d850a2..b350794 100644
--- a/block.c
+++ b/block.c
@@ -938,7 +938,6 @@ static int bdrv_open_common(BlockDriverState *bs, BdrvChild
*file,
}
bs->request_alignment = drv->bdrv_co_preadv ? 1 : 512;
- bs->zero_beyond_eof = true;
bs->read_only = !(bs->open_flags & BDRV_O_RDWR);
if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
@@ -2192,7 +2191,6 @@ static void bdrv_close(BlockDriverState *bs)
bs->encrypted = 0;
bs->valid_key = 0;
bs->sg = 0;
- bs->zero_beyond_eof = false;
QDECREF(bs->options);
QDECREF(bs->explicit_options);
bs->options = NULL;
diff --git a/block/io.c b/block/io.c
index e1e8948..f5ce5f1 100644
--- a/block/io.c
+++ b/block/io.c
@@ -967,6 +967,7 @@ static int coroutine_fn
bdrv_aligned_preadv(BlockDriverState *bs,
BdrvTrackedRequest *req, int64_t offset, unsigned int bytes,
int64_t align, QEMUIOVector *qiov, int flags)
{
+ int64_t total_bytes, max_bytes;
int ret;
assert(is_power_of_2(align));
@@ -1008,40 +1009,33 @@ static int coroutine_fn
bdrv_aligned_preadv(BlockDriverState *bs,
}
/* Forward the request to the BlockDriver */
- if (!bs->zero_beyond_eof) {
- ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0);
- } else {
- /* Read zeros after EOF */
- int64_t total_bytes, max_bytes;
-
- total_bytes = bdrv_getlength(bs);
- if (total_bytes < 0) {
- ret = total_bytes;
- goto out;
- }
+ total_bytes = bdrv_getlength(bs);
+ if (total_bytes < 0) {
+ ret = total_bytes;
+ goto out;
+ }
- max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
- if (bytes < max_bytes) {
- ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0);
- } else if (max_bytes > 0) {
- QEMUIOVector local_qiov;
+ max_bytes = ROUND_UP(MAX(0, total_bytes - offset), align);
+ if (bytes < max_bytes) {
+ ret = bdrv_driver_preadv(bs, offset, bytes, qiov, 0);
+ } else if (max_bytes > 0) {
+ QEMUIOVector local_qiov;
- qemu_iovec_init(&local_qiov, qiov->niov);
- qemu_iovec_concat(&local_qiov, qiov, 0, max_bytes);
+ qemu_iovec_init(&local_qiov, qiov->niov);
+ qemu_iovec_concat(&local_qiov, qiov, 0, max_bytes);
- ret = bdrv_driver_preadv(bs, offset, max_bytes, &local_qiov, 0);
+ ret = bdrv_driver_preadv(bs, offset, max_bytes, &local_qiov, 0);
- qemu_iovec_destroy(&local_qiov);
- } else {
- ret = 0;
- }
+ qemu_iovec_destroy(&local_qiov);
+ } else {
+ ret = 0;
+ }
- /* Reading beyond end of file is supposed to produce zeroes */
- if (ret == 0 && total_bytes < offset + bytes) {
- uint64_t zero_offset = MAX(0, total_bytes - offset);
- uint64_t zero_bytes = offset + bytes - zero_offset;
- qemu_iovec_memset(qiov, zero_offset, 0, zero_bytes);
- }
+ /* Reading beyond end of file is supposed to produce zeroes */
+ if (ret == 0 && total_bytes < offset + bytes) {
+ uint64_t zero_offset = MAX(0, total_bytes - offset);
+ uint64_t zero_bytes = offset + bytes - zero_offset;
+ qemu_iovec_memset(qiov, zero_offset, 0, zero_bytes);
}
out:
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 1fe0811..16c43e2 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -451,9 +451,6 @@ struct BlockDriverState {
/* I/O Limits */
BlockLimits bl;
- /* Whether produces zeros when read beyond eof */
- bool zero_beyond_eof;
-
/* Alignment requirement for offset/length of I/O requests */
unsigned int request_alignment;
/* Flags honored during pwrite (so far: BDRV_REQ_FUA) */
--
1.8.3.1
- [Qemu-devel] [PULL 21/39] block: Introduce bdrv_preadv(), (continued)
- [Qemu-devel] [PULL 21/39] block: Introduce bdrv_preadv(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 24/39] block: Make bdrv_load/save_vmstate coroutine_fns, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 17/39] raw-posix: Implement .bdrv_co_preadv/pwritev, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 23/39] block: Allow .bdrv_load/save_vmstate() to return 0/-errno, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 30/39] block: Prevent sleeping jobs from resuming if they have been paused, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 22/39] block: Make .bdrv_load_vmstate() vectored, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 29/39] block: use the block job list in qmp_query_block_jobs(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 25/39] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 27/39] block: Fix snapshot=on with aio=native, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 28/39] block: use the block job list in bdrv_drain_all(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 26/39] block: Remove bs->zero_beyond_eof,
Kevin Wolf <=
- [Qemu-devel] [PULL 31/39] block: Create the commit block job before reopening any image, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 34/39] block: Allow replacement of a BDS by its overlay, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 37/39] iotests: Add test for post-mirror backing chains, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 36/39] block/null: Implement bdrv_refresh_filename(), Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 32/39] iotests: 095: Clean up QEMU before showing image info, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 35/39] block/mirror: Fix target backing BDS, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 38/39] iotests: Add test for oVirt-like storage migration, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 39/39] hbitmap: add 'pos < size' asserts, Kevin Wolf, 2016/06/16
- [Qemu-devel] [PULL 33/39] rbd:change error_setg() to error_setg_errno(), Kevin Wolf, 2016/06/16
- Re: [Qemu-devel] [PULL 00/39] Block layer patches, Peter Maydell, 2016/06/16