On Tue, Nov 19, 2013 at 06:07:29PM +0100, Paolo Bonzini wrote: > @@ -2761,14 +2761,19 @@ static int coroutine_fn > bdrv_co_do_write_zeroes(BlockDriverState *bs, > while (nb_sectors > 0 && !ret) { > int num = nb_sectors; > > - /* align request */ > - if (bs->bl.write_zeroes_alignment && > - num >= bs->bl.write_zeroes_alignment && > - sector_num % bs->bl.write_zeroes_alignment) { > - if (num > bs->bl.write_zeroes_alignment) { > + /* Align request. Block drivers can expect the "bulk" of the request > + * to be aligned. > + */ > + if (bs->bl.write_zeroes_alignment > + && num > bs->bl.write_zeroes_alignment) {
Here '>' is used... > + if (sector_num % bs->bl.write_zeroes_alignment != 0) { > + /* Make a small request up to the first aligned sector. */ > num = bs->bl.write_zeroes_alignment; > + num -= sector_num % bs->bl.write_zeroes_alignment; > + } else if (num >= bs->bl.write_zeroes_alignment) { ...but here '>=' is used. The == case here cannot happen. Did you mean '>=' in both places?