qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: qemu-devel@nongnu.org
Cc: den@openvz.org, Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 2/6] block: split write_zeroes always
Date: Sat, 14 May 2016 15:01:09 +0300	[thread overview]
Message-ID: <1463227273-27523-3-git-send-email-den@openvz.org> (raw)
In-Reply-To: <1463227273-27523-1-git-send-email-den@openvz.org>

We should split requests even if they are less than write_zeroes_alignment.
For example we can have the following request:
  offset 62k
  size   4k
  write_zeroes_alignment 64k
Original code will send 1 request covering 2 qcow2 clusters. One cluster
could be zeroed as a whole, another could not be. In this case we will have
both 2 clusters allocated.

After the patch 2 requests to qcow2 layer will be sent and thus only one
cluster will be allocated.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
---
 block/io.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/block/io.c b/block/io.c
index cd6d71a..2d6f48f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -1172,13 +1172,13 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
         /* Align request.  Block drivers can expect the "bulk" of the request
          * to be aligned.
          */
-        if (bs->bl.write_zeroes_alignment
-            && num > bs->bl.write_zeroes_alignment) {
+        if (bs->bl.write_zeroes_alignment) {
             if (sector_num % bs->bl.write_zeroes_alignment != 0) {
                 /* Make a small request up to the first aligned sector.  */
                 num = bs->bl.write_zeroes_alignment;
                 num -= sector_num % bs->bl.write_zeroes_alignment;
-            } else if ((sector_num + num) % bs->bl.write_zeroes_alignment != 0) {
+            } else if (num > bs->bl.write_zeroes_alignment &&
+                    (sector_num + num) % bs->bl.write_zeroes_alignment != 0) {
                 /* Shorten the request to the last aligned sector.  num cannot
                  * underflow because num > bs->bl.write_zeroes_alignment.
                  */
-- 
2.5.0

  parent reply	other threads:[~2016-05-14 12:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-14 12:01 [Qemu-devel] [PATCH 0/6] qcow2_co_write_zeroes and related improvements Denis V. Lunev
2016-05-14 12:01 ` [Qemu-devel] [PATCH 1/6] qemu-io: enable tracing in qemu-io Denis V. Lunev
2016-05-16 13:09   ` Paolo Bonzini
2016-05-16 13:21     ` Denis V. Lunev
2016-05-16 16:07   ` Eric Blake
2016-05-14 12:01 ` Denis V. Lunev [this message]
2016-05-16 16:13   ` [Qemu-devel] [PATCH 2/6] block: split write_zeroes always Eric Blake
2016-05-14 12:01 ` [Qemu-devel] [PATCH 3/6] qcow2: simplify logic in qcow2_co_write_zeroes Denis V. Lunev
2016-05-16 16:28   ` Eric Blake
2016-05-14 12:01 ` [Qemu-devel] [PATCH 4/6] qcow2: add tracepoints for qcow2_co_write_zeroes Denis V. Lunev
2016-05-16 16:32   ` Eric Blake
2016-05-16 16:48     ` Denis V. Lunev
2016-05-14 12:01 ` [Qemu-devel] [PATCH 5/6] qcow2: fix condition in is_zero_cluster Denis V. Lunev
2016-05-14 12:01 ` [Qemu-devel] [PATCH 6/6] qcow2: merge is_zero_cluster helpers into qcow2_co_write_zeroes Denis V. Lunev

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=1463227273-27523-3-git-send-email-den@openvz.org \
    --to=den@openvz.org \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).