qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, eblake@redhat.com, mreitz@redhat.com,
	qemu-devel@nongnu.org, famz@redhat.com, stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 6/6] block: Remove bs->zero_beyond_eof
Date: Fri, 10 Jun 2016 18:05:22 +0200	[thread overview]
Message-ID: <1465574722-27656-7-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1465574722-27656-1-git-send-email-kwolf@redhat.com>

It is always true for open images now.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c                   |  2 --
 block/io.c                | 51 +++++++++++++++++++++--------------------------
 include/block/block_int.h |  3 ---
 3 files changed, 23 insertions(+), 33 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 adf2726..d504443 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1000,40 +1000,35 @@ 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;
+    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

  parent reply	other threads:[~2016-06-10 16:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-10 16:05 [Qemu-devel] [PATCH 0/6] block: bdrv_load/save_vmstate() cleanups Kevin Wolf
2016-06-10 16:05 ` [Qemu-devel] [PATCH 1/6] block: Introduce bdrv_preadv() Kevin Wolf
2016-06-10 20:50   ` Eric Blake
2016-06-10 16:05 ` [Qemu-devel] [PATCH 2/6] block: Make .bdrv_load_vmstate() vectored Kevin Wolf
2016-06-10 21:25   ` Eric Blake
2016-06-10 16:05 ` [Qemu-devel] [PATCH 3/6] block: Allow .bdrv_load/save_vmstate() to return 0/-errno Kevin Wolf
2016-06-10 21:29   ` Eric Blake
2016-06-10 16:05 ` [Qemu-devel] [PATCH 4/6] block: Make bdrv_load/save_vmstate coroutine_fns Kevin Wolf
2016-06-10 22:33   ` Eric Blake
2016-06-16  8:49   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-10 16:05 ` [Qemu-devel] [PATCH 5/6] qcow2: Let vmstate call qcow2_co_preadv/pwrite directly Kevin Wolf
2016-06-10 22:39   ` Eric Blake
2016-06-12  2:58     ` Fam Zheng
2016-06-13 12:36       ` Eric Blake
2016-06-10 16:05 ` Kevin Wolf [this message]
2016-06-10 22:41   ` [Qemu-devel] [PATCH 6/6] block: Remove bs->zero_beyond_eof Eric Blake
2016-06-12  2:59 ` [Qemu-devel] [PATCH 0/6] block: bdrv_load/save_vmstate() cleanups Fam Zheng
2016-06-16  8:54 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-06-16  9:33 ` [Qemu-devel] " Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465574722-27656-7-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).