diff mbox

qcow2 resize with snapshot

Message ID 467DE7EB-A927-4100-96FB-736444263B06@meituan.com (mailing list archive)
State New, archived
Headers show

Commit Message

zhangzhiming June 1, 2016, 4:15 a.m. UTC
hi, thanks for the review and the format of code changed.
have a good day!

zhangzhiming
zhangzhiming02@meituan.com

Signed-off-by: zhangzhiming <zhangzhiming02@meituan.com>
---
 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 mbox

Patch

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");