From patchwork Wed Jun 1 04:15:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhangzhiming X-Patchwork-Id: 9145979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A092760757 for ; Wed, 1 Jun 2016 04:16:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 975141FFBD for ; Wed, 1 Jun 2016 04:16:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BD9C20499; Wed, 1 Jun 2016 04:16:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64C271FFBD for ; Wed, 1 Jun 2016 04:16:35 +0000 (UTC) Received: from localhost ([::1]:39512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7xa6-0000PC-DW for patchwork-qemu-devel@patchwork.kernel.org; Wed, 01 Jun 2016 00:16:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60016) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7xZm-0000Oe-TJ for qemu-devel@nongnu.org; Wed, 01 Jun 2016 00:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b7xZk-0005LW-Ef for qemu-devel@nongnu.org; Wed, 01 Jun 2016 00:16:14 -0400 Received: from mx-fe5-210.meituan.com ([103.37.138.210]:56176 helo=mx02.meituan.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b7xZb-0005K4-Tt; Wed, 01 Jun 2016 00:16:05 -0400 Received: from localhost (localhost [127.0.0.1]) by it-mx02.lf.sankuai.com (Postfix) with ESMTP id C905F2975C40; Wed, 1 Jun 2016 12:15:50 +0800 (CST) Authentication-Results: it-mx02.lf.sankuai.com (amavisd-new); dkim=pass (1024-bit key) header.d=meituan.com Received: from mx02.meituan.com ([127.0.0.1]) by localhost (it-mx02.lf.sankuai.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ehYB0JmcV8nj; Wed, 1 Jun 2016 12:15:50 +0800 (CST) Received: from localhost (localhost [127.0.0.1]) by it-mx02.lf.sankuai.com (Postfix) with ESMTP id 934652975C4E; Wed, 1 Jun 2016 12:15:50 +0800 (CST) DKIM-Filter: OpenDKIM Filter v2.9.2 it-mx02.lf.sankuai.com 934652975C4E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meituan.com; s=20130113; t=1464754550; bh=V166YUF0lBUAckTQ2iMGVMlohRiXoT4DNNK4aJL8zJ8=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To; b=KAHzPUbjutVgpaLgvZsIr9OMtsJawIhXTkfC2/epY1en5Fk3+oD5L8b8EiNFn6cXD fc7eKm0nwY1CLu67IsvQIG0H7wA0TiTRAk/rTMNt0A2Xny21xHNR85yVV5PLoWItH4 QKpLVkGlKypAceaLRKccK93dWvaQl7yY83AO5dmQ= X-Virus-Scanned: amavisd-new at it-mx02.lf.sankuai.com Received: from mx02.meituan.com ([127.0.0.1]) by localhost (it-mx02.lf.sankuai.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id rbTmbe5ybRwo; Wed, 1 Jun 2016 12:15:50 +0800 (CST) Received: from [172.18.178.40] (unknown [103.37.140.15]) by it-mx02.lf.sankuai.com (Postfix) with ESMTPSA id 476372975C50; Wed, 1 Jun 2016 12:15:44 +0800 (CST) Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2070.6\)) From: zhangzhiming In-Reply-To: <574DC0CB.7020707@redhat.com> Date: Wed, 1 Jun 2016 12:15:44 +0800 Message-Id: <467DE7EB-A927-4100-96FB-736444263B06@meituan.com> References: <8E87729A-E996-4D12-B940-87B77C1D22EC@meituan.com> <574DC0CB.7020707@redhat.com> To: Eric Blake X-Mailer: Apple Mail (2.2070.6) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 103.37.138.210 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [Qemu-devel] [PATCH] qcow2 resize with snapshot 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: Kevin Wolf , lihuiba , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP hi, thanks for the review and the format of code changed. have a good day! zhangzhiming zhangzhiming02@meituan.com Signed-off-by: zhangzhiming --- block.c | 4 ++-- block/qcow2-cluster.c | 4 ++-- block/qcow2-snapshot.c | 5 ++--- block/qcow2.c | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/block.c b/block.c index 729f820..b6f2004 100644 --- a/block.c +++ b/block.c @@ -2643,9 +2643,9 @@ int bdrv_apply_snapshot(BlockDriverState *bs, const char *snapshot_id, if (ret < 0) { return ret; } - bdrv_dirty_bitmap_truncate(bs); /* void return */ + bdrv_dirty_bitmap_truncate(bs); if (bs->blk) { - blk_dev_resize_cb(bs->blk); /* void return too */ + blk_dev_resize_cb(bs->blk); } return ret; } diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index e4c5c05..f921fd8 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -37,14 +37,14 @@ int shrink_l1_table(BlockDriverState *bs, int64_t new_l1_size) int64_t old_l1_size = s->l1_size; s->l1_size = new_l1_size; int ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, - s->l1_size, 1); + s->l1_size, 1); if (ret < 0) { return ret; } s->l1_size = old_l1_size; ret = qcow2_update_snapshot_refcount(bs, s->l1_table_offset, - s->l1_size, -1); + s->l1_size, -1); if (ret < 0) { return ret; } diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 9c77096..1ed0e18 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -562,12 +562,11 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) * Now update the in-memory L1 table to be in sync with the on-disk one. We * need to do this even if updating refcounts failed. */ - memset(s->l1_table, 0, s->l1_size*sizeof(uint64_t)); - for(i = 0;i < sn->l1_size; i++) { + memset(s->l1_table, 0, s->l1_size * sizeof(uint64_t)); + for (i = 0; i < sn->l1_size; i++) { s->l1_table[i] = be64_to_cpu(sn_l1_table[i]); } - if (ret < 0) { goto fail; } diff --git a/block/qcow2.c b/block/qcow2.c index 70ec890..58b53e1 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2503,14 +2503,14 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset) bool v3_truncate = (s->qcow_version == 3); - /* cannot proceed if image has snapshots and qcow_version is not 3*/ + /* cannot proceed if image has snapshots and qcow_version is not 3 */ if (!v3_truncate && s->nb_snapshots) { error_report("Can't resize an image which has snapshots and " "qcow_version is not 3"); return -ENOTSUP; } - /* shrinking is supported from version 3*/ + /* shrinking is supported from version 3 */ if (!v3_truncate && offset < bs->total_sectors * 512) { error_report("qcow2 doesn't support shrinking images yet while" " qcow_version is not 3");