diff mbox

[v9.5,07/13] fixup! qcow2: Discard/zero clusters by byte count

Message ID 20170411221555.24863-1-eblake@redhat.com
State New
Headers show

Commit Message

Eric Blake April 11, 2017, 10:15 p.m. UTC
Squash this to keep iotest 154 happy.

Signed-off-by: Eric Blake <eblake@redhat.com>

---
v9.5: fixup
v9: rebase to earlier changes, drop R-b
v7, v8: only earlier half of series submitted for 2.9
v6: rebase due to context
v5: s/count/byte/ to make the units obvious, and rework the math
to ensure no 32-bit integer overflow on large clusters
v4: improve function names, split assertion additions into earlier patch
[no v3 or v2]
v1: https://lists.gnu.org/archive/html/qemu-devel/2016-12/msg00339.html
---
 block/qcow2-cluster.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
diff mbox

Patch

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 595e6e3..bc59cb8 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -1597,18 +1597,15 @@  int qcow2_cluster_zeroize(BlockDriverState *bs, uint64_t offset,
                           uint64_t bytes, int flags)
 {
     BDRVQcow2State *s = bs->opaque;
-    uint64_t end_offset;
+    uint64_t end_offset = offset + bytes;
     uint64_t nb_clusters;
     int64_t cleared;
     int ret;

-    end_offset = offset + bytes;
-
     /* Caller must pass aligned values, except at image end */
     assert(QEMU_IS_ALIGNED(offset, s->cluster_size));
     assert(QEMU_IS_ALIGNED(end_offset, s->cluster_size) ||
            end_offset == bs->total_sectors << BDRV_SECTOR_BITS);
-    assert(QEMU_IS_ALIGNED(bytes, s->cluster_size));

     /* The zero flag is only supported by version 3 and newer; we
      * require the use of that flag if there is a backing file or if