]> xenbits.xensource.com Git - people/dstodden/blktap.git/commitdiff
dm-decrypt: always write allocated blocks, even if they're empty
authorJake Wires <Jake.Wires@citrix.com>
Wed, 1 Sep 2010 21:10:08 +0000 (14:10 -0700)
committerDaniel Stodden <daniel.stodden@citrix.com>
Tue, 30 Aug 2011 12:50:15 +0000 (13:50 +0100)
otherwise the bat will be inconsistent

vhd/lib/vhd-util-dm-decrypt.c

index c69ff5b9e240df98a1406340c57648b88d2ace1a..4ee41f3231b073a0f0f283e0e904aca5da06ea0a 100644 (file)
@@ -103,16 +103,15 @@ out:
 static int
 vhd_util_stream_copy_block(struct vhd_decrypt_context *ctx, uint32_t blk)
 {
+       int err, i;
        off64_t off;
        char *bm, *data;
-       int err, i, empty;
        vhd_context_t *src, *dst;
 
        bm    = NULL;
        data  = NULL;
        src   = ctx->src_vhd;
        dst   = ctx->dst_vhd;
-       empty = 1;
 
        if (src->bat.bat[blk] == DD_BLK_UNUSED) {
                if (dst->bat.bat[blk] == DD_BLK_UNUSED)
@@ -161,7 +160,6 @@ vhd_util_stream_copy_block(struct vhd_decrypt_context *ctx, uint32_t blk)
                        cnt++;
 
                if (copy) {
-                       empty = 0;
                        err = vhd_util_pread_data(ctx->src_raw, buf,
                                                  vhd_sectors_to_bytes(cnt),
                                                  vhd_sectors_to_bytes(pos));
@@ -174,18 +172,16 @@ vhd_util_stream_copy_block(struct vhd_decrypt_context *ctx, uint32_t blk)
                i += cnt;
        }
 
-       if (!empty) {
-               err = vhd_write_bitmap(dst, blk, bm);
-               if (err) {
-                       ERR("writing bitmap 0x%x: %d\n", blk, err);
-                       goto out;
-               }
+       err = vhd_write_bitmap(dst, blk, bm);
+       if (err) {
+               ERR("writing bitmap 0x%x: %d\n", blk, err);
+               goto out;
+       }
 
-               err = vhd_write_block(dst, blk, data);
-               if (err) {
-                       ERR("writing data 0x%x: %d\n", blk, err);
-                       goto out;
-               }
+       err = vhd_write_block(dst, blk, data);
+       if (err) {
+               ERR("writing data 0x%x: %d\n", blk, err);
+               goto out;
        }
 
 out: