qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, "Denis V. Lunev" <den@openvz.org>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/5] block: split write_zeroes always
Date: Wed, 25 May 2016 12:36:14 -0600	[thread overview]
Message-ID: <5745F09E.8050505@redhat.com> (raw)
In-Reply-To: <20160517163431.GG9802@noname.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2317 bytes --]

On 05/17/2016 10:34 AM, Kevin Wolf wrote:
> Am 17.05.2016 um 11:15 hat Denis V. Lunev geschrieben:
>> 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
>> The original code sent 1 request covering 2 qcow2 clusters, and resulted
>> in both clusters being allocated. But by splitting the request, we can
>> cater to the case where one of the two clusters can be zeroed as a
>> whole, for only 1 cluster allocated after the operation.
>>
>> Signed-off-by: Denis V. Lunev <den@openvz.org>
>> CC: Eric Blake <eblake@redhat.com>
>> 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..6a24ea8 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;
> 
> Turns out this doesn't work. If this is a small request that zeros
> something in the middle of a single cluster (i.e. we have untouched data
> both before and after the request in the same cluster), then num can now
> become greater than nb_sectors, so that we end up zeroing too much.

I'm planning on folding in a working version of this patch in my
byte-based write_zeroes conversion series.  As part of the patch, I'm
also hoisting the division out of the loop (no guarantees that the
compiler can spot that bs->bl.write_zeroes_alignment will be a power of
two, to optimize it to a shift).



-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-05-25 18:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17  9:15 [Qemu-devel] [PATCH v2 0/5] qcow2_co_write_zeroes and related improvements Denis V. Lunev
2016-05-17  9:15 ` [Qemu-devel] [PATCH 1/5] block: split write_zeroes always Denis V. Lunev
2016-05-17 16:34   ` Kevin Wolf
2016-05-25 18:36     ` Eric Blake [this message]
2016-05-17  9:15 ` [Qemu-devel] [PATCH 2/5] qcow2: simplify logic in qcow2_co_write_zeroes Denis V. Lunev
2016-05-17  9:15 ` [Qemu-devel] [PATCH 3/5] qcow2: add tracepoints for qcow2_co_write_zeroes Denis V. Lunev
2016-05-17 15:37   ` Eric Blake
2016-05-17  9:15 ` [Qemu-devel] [PATCH 4/5] qcow2: fix condition in is_zero_cluster Denis V. Lunev
2016-05-17 15:11   ` Kevin Wolf
2016-05-17  9:15 ` [Qemu-devel] [PATCH 5/5] qcow2: merge is_zero_cluster helpers into qcow2_co_write_zeroes Denis V. Lunev
2016-05-24 18:14   ` Eric Blake
2016-05-17 15:11 ` [Qemu-devel] [PATCH v2 0/5] qcow2_co_write_zeroes and related improvements 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=5745F09E.8050505@redhat.com \
    --to=eblake@redhat.com \
    --cc=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).