block drivers: expose requirement for write same alignment from formats

This will let misaligned but large requests use zero clusters.  This
is important because the cluster size is not guest visible.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Paolo Bonzini 2013-11-22 13:39:51 +01:00 committed by Stefan Hajnoczi
parent 95de6d7078
commit cffb1ec600
3 changed files with 6 additions and 0 deletions

View file

@ -718,6 +718,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
} }
qemu_opts_del(opts); qemu_opts_del(opts);
bs->bl.write_zeroes_alignment = s->cluster_sectors;
if (s->use_lazy_refcounts && s->qcow_version < 3) { if (s->use_lazy_refcounts && s->qcow_version < 3) {
error_setg(errp, "Lazy refcounts require a qcow2 image with at least " error_setg(errp, "Lazy refcounts require a qcow2 image with at least "

View file

@ -495,6 +495,7 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict *options, int flags,
} }
} }
bs->bl.write_zeroes_alignment = s->header.cluster_size >> BDRV_SECTOR_BITS;
s->need_check_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, s->need_check_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
qed_need_check_timer_cb, s); qed_need_check_timer_cb, s);

View file

@ -428,6 +428,10 @@ static int vmdk_add_extent(BlockDriverState *bs,
extent->l2_size = l2_size; extent->l2_size = l2_size;
extent->cluster_sectors = flat ? sectors : cluster_sectors; extent->cluster_sectors = flat ? sectors : cluster_sectors;
if (!flat) {
bs->bl.write_zeroes_alignment =
MAX(bs->bl.write_zeroes_alignment, cluster_sectors);
}
if (s->num_extents > 1) { if (s->num_extents > 1) {
extent->end_sector = (*(extent - 1)).end_sector + extent->sectors; extent->end_sector = (*(extent - 1)).end_sector + extent->sectors;
} else { } else {