[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv2 07/20] block: honour alignment and limit in bd
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCHv2 07/20] block: honour alignment and limit in bdrv_co_do_write_zeroes |
Date: |
Thu, 19 Sep 2013 14:07:24 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8 |
On 09/17/2013 07:48 AM, Peter Lieven wrote:
> Signed-off-by: Peter Lieven <address@hidden>
> ---
> block.c | 57 +++++++++++++++++++++++++++++++++++++++++----------------
> 1 file changed, 41 insertions(+), 16 deletions(-)
>
> diff --git a/block.c b/block.c
> index 177720e..74ec342 100644
> --- a/block.c
> +++ b/block.c
> @@ -2660,28 +2660,53 @@ static int coroutine_fn
> bdrv_co_do_write_zeroes(BlockDriverState *bs,
> BlockDriver *drv = bs->drv;
> QEMUIOVector qiov;
> struct iovec iov;
> - int ret;
> + int ret = 0;
>
> - /* TODO Emulate only part of misaligned requests instead of letting block
> - * drivers return -ENOTSUP and emulate everything */
> + /* if no limit is specified in the BlockDriverState use a default
> + * of 32768 512-byte sectors (16 MiB) per request.
> + */
> + int max_write_zeroes = bs->max_write_zeroes ? bs->max_write_zeroes :
> 32768;
Worth having a named constant instead of a magic number?
> + while (nb_sectors > 0 && !ret) {
> +
> + if (ret == -ENOTSUP) {
> + /* Fall back to bounce buffer if write zeroes is unsupported */
> + iov.iov_len = nb_sectors * BDRV_SECTOR_SIZE;
> + iov.iov_base = qemu_blockalign(bs, iov.iov_len);
> + memset(iov.iov_base, 0, iov.iov_len);
This allocates, clears, and frees iov.iov_len bytes of 0 every iteration
through the loop. Can you hoist that so you only allocate the bounce
buffer once, and then clean it up after the loop completes?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCHv2 10/20] iscsi: set limits in BlockDriverState, (continued)
- [Qemu-devel] [PATCHv2 09/20] iscsi: simplify iscsi_co_discard, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 05/20] block/raw: add bdrv_has_discard_zeroes and bdrv_has_discard_write_zeroes, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 11/20] iscsi: add bdrv_has_discard_zeroes and bdrv_has_discard_write_zeroes, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 12/20] iscsi: add bdrv_co_write_zeroes, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 07/20] block: honour alignment and limit in bdrv_co_do_write_zeroes, Peter Lieven, 2013/09/17
- Re: [Qemu-devel] [PATCHv2 07/20] block: honour alignment and limit in bdrv_co_do_write_zeroes,
Eric Blake <=
- [Qemu-devel] [PATCHv2 14/20] block/get_block_status: set *pnum = 0 on error, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 13/20] block: introduce bdrv_zeroize, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 15/20] block/get_block_status: avoid segfault if there is no backing_hd, Peter Lieven, 2013/09/17
- [Qemu-devel] [PATCHv2 20/20] block/raw: copy block limits and alignment information on raw_open, Peter Lieven, 2013/09/17