qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block: Formats don't need CONSISTENT_READ with NO_IO
Date: Thu, 30 Nov 2017 19:27:46 +0100	[thread overview]
Message-ID: <20171130182746.GF4039@localhost.localdomain> (raw)
In-Reply-To: <ce174622-1df0-bf86-452e-280dd3f7e068@redhat.com>

Am 30.11.2017 um 18:09 hat Eric Blake geschrieben:
> On 11/30/2017 10:44 AM, Kevin Wolf wrote:
> > Commit 1f4ad7d fixed 'qemu-img info' for raw images that are currently
> > in use as a mirror target. It is not enough for image formats, though,
> > as these still unconditionally request BLK_PERM_CONSISTENT_READ.
> > 
> > As this permission is meaningless unless you do actual I/O on the image,
> > drop the requirement and allow 'qemu-img info' even for image formats
> > under conditions where BLK_PERM_CONSISTENT_READ can't be granted.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >   block.c | 6 +++++-
> >   1 file changed, 5 insertions(+), 1 deletion(-)
> > 
> 
> > @@ -1936,7 +1938,9 @@ void bdrv_format_default_perms(BlockDriverState *bs, BdrvChild *c,
> >           /* bs->file always needs to be consistent because of the metadata. We
> >            * can never allow other users to resize or write to it. */
> > -        perm |= BLK_PERM_CONSISTENT_READ;
> > +        if (!(flags & BDRV_O_NO_IO)) {
> > +            perm |= BLK_PERM_CONSISTENT_READ;
> 
> I thought BDRV_O_NO_IO only means we aren't doing I/O on guest-visible data,
> but doesn't stop us from reading the metadata.  The comment is telling: if
> we can read metadata, then we depend on CONSISTENT_READ for the metadata to
> be stable (even if we don't care about guest data consistency).

Yes and no. The trouble is that at the file system level we have only a
single bit to describe the consistency of the whole image throughout the
whole block driver tree.

We forbid shared BLK_PERM_CONSISTENT_READ for mirror targets (which
aren't fully populated yet) and intermediate nodes for commit (which
expose corrupted data). Both scenarios are really about the data exposed
at the format layer, the metadata stays completely consistent.

The question is what we do with this as we propagate permissions down to
the protocol layer. Strictly speaking, the file at the protocol layer is
perfectly consistent, so we might not forbid BLK_PERM_CONSISTENT_READ
there. But I think it's more useful to do it anyway so that image
locking can prevent the typical case of another process that uses qcow2
over file-posix again, where the file-posix node could in theory be
considered consistent, but the qcow2 one wouldn't.

In the end, this is just a pragmatic way to let 'qemu-img info' work
while the image is a mirror target or intermediate node for commit, but
to forbid cases where corrupted data is used.

Or would you argue that either 'qemu-img info' shouldn't be working or
reading corrupted data should be allowed in other processes?

Kevin

  reply	other threads:[~2017-12-01 16:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 16:44 [Qemu-devel] [PATCH] block: Formats don't need CONSISTENT_READ with NO_IO Kevin Wolf
2017-11-30 17:09 ` Eric Blake
2017-11-30 18:27   ` Kevin Wolf [this message]
2017-11-30 19:05     ` Eric Blake
2017-12-01 12:41       ` Kevin Wolf
2017-12-01 13:42         ` Eric Blake

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=20171130182746.GF4039@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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).