From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: berto@igalia.com, vsementsov@virtuozzo.com,
qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v5 7/9] block: truncate: Don't make backing file data visible
Date: Thu, 23 Apr 2020 15:00:05 +0200 [thread overview]
Message-ID: <20200423130005.GB7687@linux.fritz.box> (raw)
In-Reply-To: <1d0c34af-7efa-9be7-669e-fe15cf89e3cb@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3214 bytes --]
Am 23.04.2020 um 13:14 hat Max Reitz geschrieben:
> On 22.04.20 17:21, Kevin Wolf wrote:
> > When extending the size of an image that has a backing file larger than
> > its old size, make sure that the backing file data doesn't become
> > visible in the guest, but the added area is properly zeroed out.
> >
> > Consider the following scenario where the overlay is shorter than its
> > backing file:
> >
> > base.qcow2: AAAAAAAA
> > overlay.qcow2: BBBB
> >
> > When resizing (extending) overlay.qcow2, the new blocks should not stay
> > unallocated and make the additional As from base.qcow2 visible like
> > before this patch, but zeros should be read.
> >
> > A similar case happens with the various variants of a commit job when an
> > intermediate file is short (- for unallocated):
> >
> > base.qcow2: A-A-AAAA
> > mid.qcow2: BB-B
> > top.qcow2: C--C--C-
> >
> > After commit top.qcow2 to mid.qcow2, the following happens:
> >
> > mid.qcow2: CB-C00C0 (correct result)
> > mid.qcow2: CB-C--C- (before this fix)
> >
> > Without the fix, blocks that previously read as zeros on top.qcow2
> > suddenly turn into A.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > Reviewed-by: Alberto Garcia <berto@igalia.com>
> > ---
> > block/io.c | 14 ++++++++++++++
> > 1 file changed, 14 insertions(+)
> >
> > diff --git a/block/io.c b/block/io.c
> > index 795075954e..8fbb607515 100644
> > --- a/block/io.c
> > +++ b/block/io.c
> > @@ -3394,6 +3394,20 @@ int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
> > goto out;
> > }
> >
> > + /*
> > + * If the image has a backing file that is large enough that it would
> > + * provide data for the new area, we cannot leave it unallocated because
> > + * then the backing file content would become visible. Instead, zero-fill
> > + * the new area.
> > + *
> > + * Note that if the image has a backing file, but was opened without the
> > + * backing file, taking care of keeping things consistent with that backing
> > + * file is the user's responsibility.
> > + */
> > + if (new_bytes && bs->backing) {
> > + flags |= BDRV_REQ_ZERO_WRITE;
> > + }
>
> This breaks growing any non-qcow2 image with any backing file. Do we
> care about that?
>
> The comment says something about “a backing file that is large enough
> that it would provide data for the new area”, but that condition doesn’t
> appear in the code. Should it? (If it did, I think the number of cases
> this change broke would be much smaller.)
>
> If it was deliberate to not have that condition here, and if we decide
> that we don’t care about non-qcow2 formats here, then I think at least
> the error message deserves some improvement over “qemu-img: Block driver
> does not support requested flags”.
This was not deliberate. v3 had the check and I'm not sure why I removed
it. Probably because the new approach felt so much simpler and I was
glad that I could throw away complicated code that I threw away more
than I should have...
Kevin
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2020-04-23 13:01 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 15:21 [PATCH v5 0/9] block: Fix resize (extending) of short overlays Kevin Wolf
2020-04-22 15:21 ` [PATCH v5 1/9] block: Add flags to BlockDriver.bdrv_co_truncate() Kevin Wolf
2020-04-23 9:41 ` Max Reitz
2020-04-23 12:42 ` Kevin Wolf
2020-04-22 15:21 ` [PATCH v5 2/9] block: Add flags to bdrv(_co)_truncate() Kevin Wolf
2020-04-23 10:04 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 3/9] block-backend: Add flags to blk_truncate() Kevin Wolf
2020-04-23 10:34 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 4/9] qcow2: Support BDRV_REQ_ZERO_WRITE for truncate Kevin Wolf
2020-04-22 15:33 ` Eric Blake
2020-04-22 15:58 ` Kevin Wolf
2020-04-22 16:14 ` Eric Blake
2020-04-23 13:23 ` Kevin Wolf
2020-04-23 13:59 ` Eric Blake
2020-04-23 10:53 ` Max Reitz
2020-04-23 13:25 ` Kevin Wolf
2020-04-23 13:56 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 5/9] raw-format: " Kevin Wolf
2020-04-22 15:34 ` Eric Blake
2020-04-23 10:54 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 6/9] file-posix: " Kevin Wolf
2020-04-23 10:57 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 7/9] block: truncate: Don't make backing file data visible Kevin Wolf
2020-04-23 11:14 ` Max Reitz
2020-04-23 13:00 ` Kevin Wolf [this message]
2020-04-22 15:21 ` [PATCH v5 8/9] iotests: Filter testfiles out in filter_img_info() Kevin Wolf
2020-04-23 11:24 ` Max Reitz
2020-04-22 15:21 ` [PATCH v5 9/9] iotests: Test committing to short backing file Kevin Wolf
2020-04-23 11:53 ` Max Reitz
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=20200423130005.GB7687@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=berto@igalia.com \
--cc=mreitz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.