From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: berto@igalia.com, vsementsov@virtuozzo.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v7 04/10] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate
Date: Fri, 24 Apr 2020 16:07:35 +0200 [thread overview]
Message-ID: <ad81ea15-03a9-07c5-90c9-a3c51a07dc93@redhat.com> (raw)
In-Reply-To: <20200424125448.63318-5-kwolf@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1840 bytes --]
On 24.04.20 14:54, Kevin Wolf wrote:
> If BDRV_REQ_ZERO_WRITE is set and we're extending the image, calling
> qcow2_cluster_zeroize() with flags=0 does the right thing: It doesn't
> undo any previous preallocation, but just adds the zero flag to all
> relevant L2 entries. If an external data file is in use, a write_zeroes
> request to the data file is made instead.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2-cluster.c | 2 +-
> block/qcow2.c | 34 ++++++++++++++++++++++++++++++++++
> 2 files changed, 35 insertions(+), 1 deletion(-)
[...]
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 9cfbdfc939..98065d7808 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
[...]
> @@ -4214,6 +4215,39 @@ static int coroutine_fn qcow2_co_truncate(BlockDriverState *bs, int64_t offset,
[...]
> + /* Write explicit zeros for the unaligned head */
> + if (zero_start > old_length) {
> + uint64_t len = zero_start - old_length;
> + uint8_t *buf = qemu_blockalign0(bs, len);
I wonder whether I should raise the question of why this should be
block-aligned when we make no effort to align the offset its written to
(and we know it isn’t aligned to qcow2 clusters at least).
I probably should not.
Reviewed-by: Max Reitz <mreitz@redhat.com>
> + QEMUIOVector qiov;
> + qemu_iovec_init_buf(&qiov, buf, len);
> +
> + qemu_co_mutex_unlock(&s->lock);
> + ret = qcow2_co_pwritev_part(bs, old_length, len, &qiov, 0, 0);
> + qemu_co_mutex_lock(&s->lock);
> +
> + qemu_vfree(buf);
> + if (ret < 0) {
> + error_setg_errno(errp, -ret, "Failed to zero out the new area");
> + goto fail;
> + }
> + }
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-04-24 14:08 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 12:54 [PATCH v7 00/10] block: Fix resize (extending) of short overlays Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 01/10] block: Add flags to BlockDriver.bdrv_co_truncate() Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 02/10] block: Add flags to bdrv(_co)_truncate() Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 03/10] block-backend: Add flags to blk_truncate() Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 04/10] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate Kevin Wolf
2020-04-24 14:07 ` Max Reitz [this message]
2020-04-24 14:39 ` Eric Blake
2020-04-28 16:28 ` Eric Blake
2020-04-28 18:45 ` Kevin Wolf
2020-04-28 18:58 ` Eric Blake
2020-04-24 12:54 ` [PATCH v7 05/10] raw-format: " Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 06/10] file-posix: " Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 07/10] block: truncate: Don't make backing file data visible Kevin Wolf
2020-04-24 14:09 ` Max Reitz
2020-04-24 12:54 ` [PATCH v7 08/10] iotests: Filter testfiles out in filter_img_info() Kevin Wolf
2020-04-24 12:54 ` [PATCH v7 09/10] iotests: Test committing to short backing file Kevin Wolf
2020-04-24 14:14 ` Max Reitz
2020-04-24 14:49 ` Vladimir Sementsov-Ogievskiy
2020-04-24 14:16 ` [PATCH v7 00/10] block: Fix resize (extending) of short overlays Max Reitz
2020-04-24 14:27 ` [PATCH v7 10/10] qcow2: Forward ZERO_WRITE flag for full preallocation Kevin Wolf
2020-04-24 14:28 ` Max Reitz
2020-04-24 15:26 ` Vladimir Sementsov-Ogievskiy
2020-04-27 15:43 ` [PATCH v7 00/10] block: Fix resize (extending) of short overlays 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=ad81ea15-03a9-07c5-90c9-a3c51a07dc93@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).