block: make BdrvRequestFlags public

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block: add flags to bdrv_*_write_zeroes

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block: introduce BDRV_REQ_MAY_UNMAP request flag

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block: add logical block provisioning info to BlockDriverInfo

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block: add wrappers for logical block provisioning information

This adds 2 wrappers to read the unallocated_blocks_are_zero and
can_write_zeroes_with_unmap info from the BDI. The wrappers are
required to check for the existence of a backing_hd and
if the devices are opened with the correct flags.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block/iscsi: add .bdrv_get_info

Signed-off-by: Peter Lieven <pl@kamp.de>
block: add BlockLimits structure to BlockDriverState

this patch adds BlockLimits which introduces discard and write_zeroes
limits and alignment information to the BlockDriverState.

Signed-off-by: Peter Lieven <pl@kamp.de>
block/raw: copy BlockLimits on raw_open

Signed-off-by: Peter Lieven <pl@kamp.de>
block: honour BlockLimits in bdrv_co_do_write_zeroes

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
block: honour BlockLimits in bdrv_co_discard

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
iscsi: set limits in BlockDriverState

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
iscsi: simplify iscsi_co_discard

now that bdrv_co_discard can handle limits we do not need
the request split logic here anymore.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
iscsi: add bdrv_co_write_zeroes

Signed-off-by: Peter Lieven <pl@kamp.de>
block: introduce bdrv_make_zero

this patch adds a call to completely zero out a block device.
the operation is sped up by checking the block status and
only writing zeroes to the device if they currently do not
return zeroes. optionally the zero writing can be sped up
by setting the flag BDRV_REQ_MAY_UNMAP to emulate the zero
write by unmapping if the driver supports it.

Signed-off-by: Peter Lieven <pl@kamp.de>
block/get_block_status: fix BDRV_BLOCK_ZERO for unallocated blocks

this patch does 2 things:
a) only do additional call outs if BDRV_BLOCK_ZERO is not already set.
b) use the newly introduced bdrv_unallocated_blocks_are_zero()
   to return the zero state of an unallocated block. the used callout
   to bdrv_has_zero_init() is only valid right after bdrv_create.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
qemu-img: add support for fully allocated images

Signed-off-by: Peter Lieven <pl@kamp.de>
qemu-img: conditionally zero out target on convert

If the target has_zero_init = 0, but supports efficiently
writing zeroes by unmapping we call bdrv_make_zero to
avoid fully allocating the target. This currently works
only for iscsi.  It can be extended to raw with
BLKDISCARDZEROES for example.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
Merge branch 'write-zeroes-v7', remote-tracking branch 'origin' into vc-1.7.0
block: fix bounce buffer size in bdrv_co_do_write_zeroes

if the driver supplies alignment information, but does
not provide a bdrv_write_zeroes function it can happen
that in the first iteration num is less than nb_sectors
and in a following round num is bigger than in the first
round. fix this by allocation num bytes only if we
handle all sectors in the first round and allocate
the maximum otherwise.

Signed-off-by: Peter Lieven <pl@kamp.de>
[VC] hyperv: add refcnt hack 1.7.0

Signed-off-by: Peter Lieven <pl@kamp.de>