qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [RFC V6 13/33] qcow2: make the deduplication forget a cluster hash when a cluster is to dedupe
Date: Mon, 11 Mar 2013 13:59:56 +0100	[thread overview]
Message-ID: <20130311125956.GB3824@irqsave.net> (raw)
In-Reply-To: <20130207094814.GH1081@stefanha-thinkpad.redhat.com>

Le Thursday 07 Feb 2013 à 10:48:14 (+0100), Stefan Hajnoczi a écrit :
> On Wed, Feb 06, 2013 at 01:31:46PM +0100, Benoît Canet wrote:
> > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> > index ef91216..5b1d20d 100644
> > --- a/block/qcow2-cluster.c
> > +++ b/block/qcow2-cluster.c
> > @@ -710,6 +710,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
> >  
> >      for (i = 0; i < m->nb_clusters; i++) {
> >          uint64_t flags = 0;
> > +        uint64_t offset = cluster_offset + (i << s->cluster_bits);
> >          /* if two concurrent writes happen to the same unallocated cluster
> >  	 * each write allocates separate cluster and writes data concurrently.
> >  	 * The first one to complete updates l2 table with pointer to its
> > @@ -722,8 +723,14 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m)
> >          flags = m->oflag_copied ? QCOW_OFLAG_COPIED : 0;
> >          flags |= m->to_deduplicate ? QCOW_OFLAG_TO_DEDUP : 0;
> >  
> > -        l2_table[l2_index + i] = cpu_to_be64((cluster_offset +
> > -                    (i << s->cluster_bits)) | flags);
> > +        l2_table[l2_index + i] = cpu_to_be64(offset | flags);
> > +
> > +        /* make the deduplication forget the cluster to avoid making
> > +         * the dedup pointing to a cluster that has changed on it's back.
> > +         */
> > +        if (m->to_deduplicate) {
> > +            qcow2_dedup_forget_cluster_by_sector(bs, offset >> 9);
> > +        }
> 
> This does not play well with internal snapshots.  Imagine that an
> internal snapshot was taken, so refcount == 2.
> 
> Now the cluster is overwritten by the guest but we still need to hang on
> to the original data since the snapshot refers to it.
> 
> If dedup forgets about the cluster then dedup is only effective for the
> current disk image, but it ignores snapshots.  Ideally dedup would take
> snapshots into account since they share the same data clusters as the
> current image.
> 
> Stefan

Is checking the refcount with a qcow2_get_refcounts(index) a solution ? 

Benoît

  parent reply	other threads:[~2013-03-11 12:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1360153926-9492-1-git-send-email-benoit@irqsave.net>
     [not found] ` <1360153926-9492-28-git-send-email-benoit@irqsave.net>
     [not found]   ` <20130208105746.GD7835@stefanha-thinkpad.redhat.com>
     [not found]     ` <20130227150028.GC4010@irqsave.net>
     [not found]       ` <20130228094139.GB12748@stefanha-thinkpad.redhat.com>
     [not found]         ` <20130228101434.GD2429@dhcp-200-207.str.redhat.com>
     [not found]           ` <20130228161418.GA4214@irqsave.net>
2013-03-01  8:59             ` [Qemu-devel] [RFC V6 27/33] qcow2: Adapt checking of QCOW_OFLAG_COPIED for dedup Kevin Wolf
2013-03-01  9:34               ` Stefan Hajnoczi
     [not found] ` <1360153926-9492-14-git-send-email-benoit@irqsave.net>
     [not found]   ` <20130207094814.GH1081@stefanha-thinkpad.redhat.com>
2013-03-11 12:59     ` Benoît Canet [this message]
     [not found] ` <1360153926-9492-20-git-send-email-benoit@irqsave.net>
     [not found]   ` <20130207101621.GM1081@stefanha-thinkpad.redhat.com>
2013-03-11 15:20     ` [Qemu-devel] [RFC V6 19/33] block: Add qcow2_dedup format and image creation code Benoît Canet
2013-03-12  9:33       ` Stefan Hajnoczi

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=20130311125956.GB3824@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --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).