qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Jeff Cody <jcody@redhat.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	stefanha@redhat.com
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present
Date: Tue, 29 Sep 2015 10:39:14 +0200	[thread overview]
Message-ID: <20150929083914.GC3930@noname.str.redhat.com> (raw)
In-Reply-To: <56097990.7040007@redhat.com>

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

Am 28.09.2015 um 19:32 hat Max Reitz geschrieben:
> On 28.09.2015 05:29, Jeff Cody wrote:
> > During mirror, if the target device does not have support zero
> > initialization, a mirror may result in a corrupt image.
> > 
> > For instance, on mirror to a host device with format = raw, whatever
> > random data is on the target device will still be there for unallocated
> > sectors.
> > 
> > This is because during the mirror, we set the dirty bitmap to copy only
> > sectors allocated above 'base'.  In the case of target devices where we
> > cannot assume unallocated sectors will be read as zeroes, we need to
> > explicitely zero out this data.
> > 
> > In order to avoid zeroing out all sectors of the target device prior to
> > mirroring, we do zeroing as part of the block job.  A second dirty
> > bitmap cache is created, to track sectors that are unallocated above
> > 'base'.  These sectors are then checked for status of BDRV_BLOCK_ZERO
> > on the target - if they are not, then zeroes are explicitly written.
> > 
> > This only occurs under two conditions:
> > 
> >     1. 'mode' != "existing"
> >     2. bdrv_has_zero_init(target) == NULL
> > 
> > We perform the mirroring through mirror_iteration() as before, except
> > in two passes.  If the above two conditions are met, the first pass
> > is using the bitmap tracking unallocated sectors, to write the needed
> > zeroes.  Then, the second pass is performed, to mirror the actual data
> > as before.
> > 
> > If the above two conditions are not met, then the first pass is skipped,
> > and only the second pass (the one with the actual data) is performed.
> > 
> > Signed-off-by: Jeff Cody <jcody@redhat.com>

> > @@ -737,6 +787,7 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
> >          return;
> >      }
> >  
> > +    s->zero_unallocated = !existing && !bdrv_has_zero_init(target);
> 
> I think this should be set only if we're doing a full mirror operation.
> For instance, I could do a none, top or incremental mirror to a new
> qcow2 file, which would give it a backing file, obviously. You're lucky
> in that qcow2 claims to always have zero initialization, when this is in
> fact not true (someone's ought to fix that...): With a backing file, an
> overlay file just cannot have zero initialization, it's impossible
> (well, unless the backing file is completely zero).

bdrv_has_zero_init() takes care of that, in theory. The "problem" here
is that the target is opened with BDRV_O_NO_BACKING, so the block layer
doesn't consider this an image with a backing file.

Is there anything better than bs->backing_hd that we could check?

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2015-09-29  8:39 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-28  3:29 [Qemu-devel] [PATCH 0/3] block: mirror - Write zeroes for unallocated sectors if no zero init Jeff Cody
2015-09-28  3:29 ` [Qemu-devel] [PATCH 1/3] block: allow creation of detached dirty bitmaps Jeff Cody
2015-09-28 14:41   ` Kevin Wolf
2015-09-28 15:13   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-09-28 16:38   ` Max Reitz
2015-09-28  3:29 ` [Qemu-devel] [PATCH 2/3] block: mirror - split out part of mirror_run() Jeff Cody
2015-09-28 14:17   ` Paolo Bonzini
2015-09-28 14:47   ` Kevin Wolf
2015-09-28 16:50   ` [Qemu-devel] [Qemu-block] " Max Reitz
2015-09-28  3:29 ` [Qemu-devel] [PATCH 3/3] block: mirror - zero unallocated target sectors when zero init not present Jeff Cody
2015-09-28 14:13   ` Paolo Bonzini
2015-09-28 20:31     ` Eric Blake
2015-09-29  8:10       ` Kevin Wolf
2015-09-29  8:42         ` Paolo Bonzini
2015-09-29  9:35           ` Kevin Wolf
2015-09-29 10:52             ` Paolo Bonzini
2015-09-30 14:43               ` Jeff Cody
2015-09-30 15:16                 ` Paolo Bonzini
2015-09-30 15:26                 ` Kevin Wolf
2015-09-30 16:02                   ` Jeff Cody
2015-09-30 16:06                     ` Paolo Bonzini
2015-10-01  8:23                       ` Kevin Wolf
2015-09-28 21:32     ` Jeff Cody
2015-09-29  2:48       ` Eric Blake
2015-09-28 15:07   ` Kevin Wolf
2015-09-28 21:57     ` Jeff Cody
2015-09-29  8:28       ` Kevin Wolf
2015-09-28 15:10   ` Kevin Wolf
2015-09-28 21:58     ` Jeff Cody
2015-09-28 15:23   ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2015-09-30 15:11     ` Jeff Cody
2015-09-30 15:28       ` Kevin Wolf
2015-09-28 17:32   ` Max Reitz
2015-09-29  8:39     ` Kevin Wolf [this message]
2015-09-29 14:47       ` [Qemu-devel] " Paolo Bonzini

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=20150929083914.GC3930@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=jcody@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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).