Commit f575f145 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by Kevin Wolf
Browse files

qcow2: fix condition in is_zero_cluster



We should check for (res & BDRV_BLOCK_ZERO) only. The situation when we
will have !(res & BDRV_BLOCK_DATA) and will not have BDRV_BLOCK_ZERO is
not possible for images with bdi.unallocated_blocks_are_zero == true.

For those images where it's false, however, it can happen and we must
not consider the data zeroed then or we would corrupt the image.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
parent b97511c7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2412,7 +2412,7 @@ static bool is_zero_cluster(BlockDriverState *bs, int64_t start)
    BlockDriverState *file;
    int64_t res = bdrv_get_block_status_above(bs, NULL, start,
                                              s->cluster_sectors, &nr, &file);
    return res >= 0 && ((res & BDRV_BLOCK_ZERO) || !(res & BDRV_BLOCK_DATA));
    return res >= 0 && (res & BDRV_BLOCK_ZERO);
}

static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)