218e99
From 7bae8147abc5661103da3316f09306939ec03708 Mon Sep 17 00:00:00 2001
218e99
From: Fam Zheng <famz@redhat.com>
218e99
Date: Thu, 5 Sep 2013 08:45:39 +0200
218e99
Subject: [PATCH 11/29] vmdk: fix comment for vmdk_co_write_zeroes
218e99
218e99
RH-Author: Fam Zheng <famz@redhat.com>
218e99
Message-id: <1378370739-22259-1-git-send-email-famz@redhat.com>
218e99
Patchwork-id: 54100
218e99
O-Subject: [RHEL-7 qemu-kvm PATCH] vmdk: fix comment for vmdk_co_write_zeroes
218e99
Bugzilla: 995866
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
218e99
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=995866
218e99
Brew:     http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6246791
218e99
Upstream: merged
218e99
218e99
The comment was truncated. Add the missing parts, especially explain why
218e99
we need zero_dry_run.
218e99
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
218e99
(cherry picked from commit 8e50724313895a87057cc243ad805f2eb21feb9f)
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
---
218e99
 block/vmdk.c | 8 ++++++--
218e99
 1 file changed, 6 insertions(+), 2 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/vmdk.c |    8 ++++++--
218e99
 1 files changed, 6 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/block/vmdk.c b/block/vmdk.c
218e99
index a28fb5e..f0c1f93 100644
218e99
--- a/block/vmdk.c
218e99
+++ b/block/vmdk.c
218e99
@@ -1200,8 +1200,10 @@ static coroutine_fn int vmdk_co_read(BlockDriverState *bs, int64_t sector_num,
218e99
 /**
218e99
  * vmdk_write:
218e99
  * @zeroed:       buf is ignored (data is zero), use zeroed_grain GTE feature
218e99
- * if possible, otherwise return -ENOTSUP.
218e99
- * @zero_dry_run: used for zeroed == true only, don't update L2 table, just
218e99
+ *                if possible, otherwise return -ENOTSUP.
218e99
+ * @zero_dry_run: used for zeroed == true only, don't update L2 table, just try
218e99
+ *                with each cluster. By dry run we can find if the zero write
218e99
+ *                is possible without modifying image data.
218e99
  *
218e99
  * Returns: error code with 0 for success.
218e99
  */
218e99
@@ -1328,6 +1330,8 @@ static int coroutine_fn vmdk_co_write_zeroes(BlockDriverState *bs,
218e99
     int ret;
218e99
     BDRVVmdkState *s = bs->opaque;
218e99
     qemu_co_mutex_lock(&s->lock);
218e99
+    /* write zeroes could fail if sectors not aligned to cluster, test it with
218e99
+     * dry_run == true before really updating image */
218e99
     ret = vmdk_write(bs, sector_num, NULL, nb_sectors, true, true);
218e99
     if (!ret) {
218e99
         ret = vmdk_write(bs, sector_num, NULL, nb_sectors, true, false);
218e99
-- 
218e99
1.7.1
218e99