Message ID | 1463476543-3087-5-git-send-email-den@openvz.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Am 17.05.2016 um 11:15 hat Denis V. Lunev geschrieben: > 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. The patch is okay, but I'm correcting this paragraph into: 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. Kevin
diff --git a/block/qcow2.c b/block/qcow2.c index 97bf870..05beb64 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -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)
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. Signed-off-by: Denis V. Lunev <den@openvz.org> CC: Kevin Wolf <kwolf@redhat.com> --- block/qcow2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)