Patchwork [24/26] FVD: add impl of interface bdrv_has_zero_init()

login
register
mail settings
Submitter Chunqiang Tang
Date Feb. 25, 2011, 10:38 p.m.
Message ID <1298673486-3573-24-git-send-email-ctang@us.ibm.com>
Download mbox | patch
Permalink /patch/84579/
State New
Headers show

Comments

Chunqiang Tang - Feb. 25, 2011, 10:38 p.m.
This patch is part of the Fast Virtual Disk (FVD) proposal.
See http://wiki.qemu.org/Features/FVD.

This patch adds FVD's implementation of the bdrv_has_zero_init() interface.

Signed-off-by: Chunqiang Tang <ctang@us.ibm.com>
---
 block/fvd-misc.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

Patch

diff --git a/block/fvd-misc.c b/block/fvd-misc.c
index 766b62b..61e39bb 100644
--- a/block/fvd-misc.c
+++ b/block/fvd-misc.c
@@ -341,5 +341,12 @@  static int fvd_get_info(BlockDriverState * bs, BlockDriverInfo * bdi)
 
 static int fvd_has_zero_init(BlockDriverState * bs)
 {
-    return 0;
+    BDRVFvdState *s = bs->opaque;
+
+    /* For a non-compact image, chunks_relocated is always false. For a
+     * compact image with chunks_relocated=true, it can no longer guarantee
+     * zero init even if the file system does that. This is because a partialy
+     * written chunk X may be relocated to a location previously used by
+     * another chunk Y and some garbage data are left there by Y. */
+    return s->chunks_relocated ? 0 : bdrv_has_zero_init(s->fvd_data);
 }