From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeRee-00033W-24 for qemu-devel@nongnu.org; Tue, 12 Jun 2012 10:01:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeReU-00078C-5F for qemu-devel@nongnu.org; Tue, 12 Jun 2012 10:01:07 -0400 Received: from mail-pz0-f45.google.com ([209.85.210.45]:49165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeReT-00076e-SL for qemu-devel@nongnu.org; Tue, 12 Jun 2012 10:00:58 -0400 Received: by dadv2 with SMTP id v2so7577871dad.4 for ; Tue, 12 Jun 2012 07:00:55 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4FD74B8D.9090800@redhat.com> Date: Tue, 12 Jun 2012 16:00:45 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1339508835-15108-1-git-send-email-kwolf@redhat.com> In-Reply-To: <1339508835-15108-1-git-send-email-kwolf@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qcow2: Simplify calculation for COW area at the end List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-devel@nongnu.org Il 12/06/2012 15:47, Kevin Wolf ha scritto: > copy_sectors() always uses the sum (cluster_offset + n_start) or > (start_sect + n_start), so if some value is added to both cluster_offset > and start_sect, and subtracted from n_start, it's cancelled out anyway. > > Signed-off-by: Kevin Wolf > --- > block/qcow2-cluster.c | 5 ++--- > 1 files changed, 2 insertions(+), 3 deletions(-) > > diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c > index 9aee9fc..763b724 100644 > --- a/block/qcow2-cluster.c > +++ b/block/qcow2-cluster.c > @@ -640,11 +640,10 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) > } > > if (m->nb_available & (s->cluster_sectors - 1)) { > - uint64_t end = m->nb_available & ~(uint64_t)(s->cluster_sectors - 1); > cow = true; > qemu_co_mutex_unlock(&s->lock); > - ret = copy_sectors(bs, start_sect + end, cluster_offset + (end << 9), > - m->nb_available - end, s->cluster_sectors); > + ret = copy_sectors(bs, start_sect, cluster_offset, > + m->nb_available, s->cluster_sectors); Do you need to add end to s->cluster_sectors too, so that "start_sect + n_end" and "n_end - n_start" remain the same? Paolo