From patchwork Tue Aug 9 07:46:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 109164 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 613E0B6F84 for ; Tue, 9 Aug 2011 18:26:19 +1000 (EST) Received: from localhost ([::1]:53181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qqh2g-0006iG-0y for incoming@patchwork.ozlabs.org; Tue, 09 Aug 2011 03:48:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]:40291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qqh2E-00063U-04 for qemu-devel@nongnu.org; Tue, 09 Aug 2011 03:47:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qqh2B-00071X-NI for qemu-devel@nongnu.org; Tue, 09 Aug 2011 03:47:33 -0400 Received: from mail-ey0-f171.google.com ([209.85.215.171]:43960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qqh2B-0006nW-BN for qemu-devel@nongnu.org; Tue, 09 Aug 2011 03:47:31 -0400 Received: by mail-ey0-f171.google.com with SMTP id 24so3371321eyg.16 for ; Tue, 09 Aug 2011 00:47:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=AwEY8mkHLb4RALn75wMSmnRUIlEennAK1Lvrsvp0v5U=; b=JeD5/XXRi/oL0lzB0KdUDl3Zad6Lvz3zqnl7tL4mVxXIfprzCZESLuRqJKgZiyaBV8 JSnMGMnfi8lPWdi0WhE800MgmVBqM5YpUK8IgxZQUEllme4/fqCijCH9YCnJMUas8K7V IhsehnNtY+de/hbECxUVE9dx3OWmP5kF+Xdrs= Received: by 10.14.15.7 with SMTP id e7mr1854844eee.44.1312876050882; Tue, 09 Aug 2011 00:47:30 -0700 (PDT) Received: from obol602.omnitel.it ([206.217.137.183]) by mx.google.com with ESMTPS id p49sm2857459eef.58.2011.08.09.00.47.27 (version=SSLv3 cipher=OTHER); Tue, 09 Aug 2011 00:47:30 -0700 (PDT) From: Frediano Ziglio To: kwolf@redhat.com Date: Tue, 9 Aug 2011 09:46:50 +0200 Message-Id: <1312876010-15361-16-git-send-email-freddy77@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1312876010-15361-1-git-send-email-freddy77@gmail.com> References: <1312876010-15361-1-git-send-email-freddy77@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.215.171 Cc: qemu-devel@nongnu.org, Frediano Ziglio Subject: [Qemu-devel] [PATCH v2 15/15] qcow2: small optimization 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 Signed-off-by: Frediano Ziglio --- block/qcow2-refcount.c | 11 +++++------ 1 files changed, 5 insertions(+), 6 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 0e31868..318d66d 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -681,14 +681,13 @@ void qcow2_create_refcount_update(QCowCreateState *s, int64_t offset, int64_t size) { int refcount; - int64_t start, last, cluster_offset; + int64_t start, last, cluster; uint16_t *p; - start = offset & ~(s->cluster_size - 1); - last = (offset + size - 1) & ~(s->cluster_size - 1); - for(cluster_offset = start; cluster_offset <= last; - cluster_offset += s->cluster_size) { - p = &s->refcount_block[cluster_offset >> s->cluster_bits]; + start = offset >> s->cluster_bits; + last = (offset + size - 1) >> s->cluster_bits; + for (cluster = start; cluster <= last; ++cluster) { + p = &s->refcount_block[cluster]; refcount = be16_to_cpu(*p); refcount++; *p = cpu_to_be16(refcount);