Skip to content

Commit f575f14

Browse files
dlunevkevmw
authored andcommitted
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: Denis V. Lunev <[email protected]> CC: Kevin Wolf <[email protected]> Reviewed-by: Eric Blake <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent b97511c commit f575f14

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

block/qcow2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ static bool is_zero_cluster(BlockDriverState *bs, int64_t start)
24122412
BlockDriverState *file;
24132413
int64_t res = bdrv_get_block_status_above(bs, NULL, start,
24142414
s->cluster_sectors, &nr, &file);
2415-
return res >= 0 && ((res & BDRV_BLOCK_ZERO) || !(res & BDRV_BLOCK_DATA));
2415+
return res >= 0 && (res & BDRV_BLOCK_ZERO);
24162416
}
24172417

24182418
static bool is_zero_cluster_top_locked(BlockDriverState *bs, int64_t start)

0 commit comments

Comments
 (0)