From patchwork Tue Apr 11 22:15:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 749633 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w2hGq4YKLz9sN5 for ; Wed, 12 Apr 2017 08:16:35 +1000 (AEST) Received: from localhost ([::1]:41281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy45R-00020E-8L for incoming@patchwork.ozlabs.org; Tue, 11 Apr 2017 18:16:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cy451-0001yj-70 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 18:16:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cy44z-0000Sg-W1 for qemu-devel@nongnu.org; Tue, 11 Apr 2017 18:16:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cy44t-0000PV-LB; Tue, 11 Apr 2017 18:15:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF9407E9DB; Tue, 11 Apr 2017 22:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BF9407E9DB Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=eblake@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BF9407E9DB Received: from red.redhat.com (ovpn-122-61.rdu2.redhat.com [10.10.122.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id 141B218238; Tue, 11 Apr 2017 22:15:57 +0000 (UTC) From: Eric Blake To: qemu-devel@nongnu.org Date: Tue, 11 Apr 2017 17:15:55 -0500 Message-Id: <20170411221555.24863-1-eblake@redhat.com> In-Reply-To: <20170411011718.9152-8-eblake@redhat.com> References: <20170411011718.9152-8-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 11 Apr 2017 22:15:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v9.5 07/13] fixup! qcow2: Discard/zero clusters by byte count X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Squash this to keep iotest 154 happy. Signed-off-by: Eric Blake --- v9.5: fixup v9: rebase to earlier changes, drop R-b v7, v8: only earlier half of series submitted for 2.9 v6: rebase due to context v5: s/count/byte/ to make the units obvious, and rework the math to ensure no 32-bit integer overflow on large clusters v4: improve function names, split assertion additions into earlier patch [no v3 or v2] v1: https://lists.gnu.org/archive/html/qemu-devel/2016-12/msg00339.html --- block/qcow2-cluster.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 595e6e3..bc59cb8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1597,18 +1597,15 @@ int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset, uint64_t bytes, int flags) { BDRVQcow2State *s = bs->opaque; - uint64_t end_offset; + uint64_t end_offset = offset + bytes; uint64_t nb_clusters; int64_t cleared; int ret; - end_offset = offset + bytes; - /* Caller must pass aligned values, except at image end */ assert(QEMU_IS_ALIGNED(offset, s->cluster_size)); assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) || end_offset == bs->total_sectors << BDRV_SECTOR_BITS); - assert(QEMU_IS_ALIGNED(bytes, s->cluster_size)); /* The zero flag is only supported by version 3 and newer; we * require the use of that flag if there is a backing file or if