From patchwork Tue Jun 12 13:47:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 164418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D1F8B6EE7 for ; Tue, 12 Jun 2012 23:47:40 +1000 (EST) Received: from localhost ([::1]:38321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeRRa-00059A-Eh for incoming@patchwork.ozlabs.org; Tue, 12 Jun 2012 09:47:38 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeRRP-00058i-Nu for qemu-devel@nongnu.org; Tue, 12 Jun 2012 09:47:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SeRRH-00084S-5z for qemu-devel@nongnu.org; Tue, 12 Jun 2012 09:47:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13261) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SeRRG-00082P-Uf for qemu-devel@nongnu.org; Tue, 12 Jun 2012 09:47:19 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q5CDlHlC030776 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 12 Jun 2012 09:47:17 -0400 Received: from dhcp-5-188.str.redhat.com (dhcp-5-175.str.redhat.com [10.32.5.175]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q5CDlGvC017840; Tue, 12 Jun 2012 09:47:16 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 12 Jun 2012 15:47:15 +0200 Message-Id: <1339508835-15108-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com Subject: [Qemu-devel] [PATCH] qcow2: Simplify calculation for COW area at the end X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); qemu_co_mutex_lock(&s->lock); if (ret < 0) goto err;