From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXbAR-00078y-TC for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:20 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXbAL-000715-89 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:17 -0500 Received: from [199.232.76.173] (port=43303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXbAK-00070f-Gu for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52355) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXbAJ-0003MJ-Sj for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:12 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0KE4BGf009296 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Jan 2010 09:04:11 -0500 From: Kevin Wolf Date: Wed, 20 Jan 2010 15:03:05 +0100 Message-Id: <1263996186-6623-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1263996186-6623-1-git-send-email-kwolf@redhat.com> References: <1263996186-6623-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 08/10] qcow2: Allow updating no refcounts List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf There's absolutely no problem with updating the refcounts of 0 clusters. At least snapshot code is doing this and would fail once the result of update_refcount isn't ignored any more. Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index a84620f..da7d3f2 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -284,8 +284,12 @@ static int update_refcount(BlockDriverState *bs, printf("update_refcount: offset=%" PRId64 " size=%" PRId64 " addend=%d\n", offset, length, addend); #endif - if (length <= 0) + if (length < 0) { return -EINVAL; + } else if (length == 0) { + return 0; + } + start = offset & ~(s->cluster_size - 1); last = (offset + length - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last; -- 1.6.5.2