[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 02/11] block/io: add bdrv_co_write_compressed
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH 02/11] block/io: add bdrv_co_write_compressed |
Date: |
Tue, 28 Jun 2016 13:09:41 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 31.05.2016 um 11:15 hat Denis V. Lunev geschrieben:
> From: Pavel Butsykin <address@hidden>
>
> This patch just adds the interface to the bdrv_co_pwritev_compressed,
> which is currently not used but will be useful for safe implementation of the
> bdrv_co_write_compressed callback in format drivers.
>
> Signed-off-by: Pavel Butsykin <address@hidden>
> Signed-off-by: Denis V. Lunev <address@hidden>
> CC: Jeff Cody <address@hidden>
> CC: Markus Armbruster <address@hidden>
> CC: Eric Blake <address@hidden>
> CC: John Snow <address@hidden>
> CC: Stefan Hajnoczi <address@hidden>
> CC: Kevin Wolf <address@hidden>
> ---
> block/io.c | 78
> +++++++++++++++++++++++++++++++++++++++++++----
> include/block/block_int.h | 5 +++
> qemu-img.c | 2 +-
> 3 files changed, 78 insertions(+), 7 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index c5bb6ae..54cd9a4 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -1779,8 +1779,8 @@ int bdrv_is_allocated_above(BlockDriverState *top,
> return 0;
> }
>
> -int bdrv_pwrite_compressed(BlockDriverState *bs, int64_t offset,
> - const void *buf, int count)
> +int coroutine_fn bdrv_co_pwritev_compressed(BlockDriverState *bs,
> + int64_t offset, unsigned int bytes, QEMUIOVector *qiov)
> {
> BlockDriver *drv = bs->drv;
> int ret;
> @@ -1788,18 +1788,84 @@ int bdrv_pwrite_compressed(BlockDriverState *bs,
> int64_t offset,
> if (!drv) {
> return -ENOMEDIUM;
> }
> - if (!drv->bdrv_write_compressed) {
> +
> + if (!drv->bdrv_co_write_compressed) {
> return -ENOTSUP;
> }
> - ret = bdrv_check_byte_request(bs, offset, count);
> +
> + ret = bdrv_check_byte_request(bs, offset, bytes);
> if (ret < 0) {
> return ret;
> }
>
> assert(QLIST_EMPTY(&bs->dirty_bitmaps));
> + assert(qemu_in_coroutine());
> +
> + return drv->bdrv_co_write_compressed(bs, offset >> BDRV_SECTOR_BITS,
> + bytes >> BDRV_SECTOR_BITS, qiov);
> +}
> +
> +typedef struct BdrvWriteCompressedCo {
> + BlockDriverState *bs;
> + int64_t offset;
> + QEMUIOVector *qiov;
> + int ret;
> +} BdrvWriteCompressedCo;
I think you could just reuse RwCo here.
And in fact, this made we wonder whether we can reuse more from the
normal I/O path. If compressed writes could be made just another REQ_*
flag and we went through bdrv_co_pwritev(), we would automatically get
the alignment code if we don't want to convert drivers to byte-based.
And also the existing coroutine wrapper code would be reused instead
implementing it once more.
I'm not completely sure how special compressed writes really are, so
reusing the normal I/O path may or may not work. It might be worth
investigating, though.
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -207,6 +207,9 @@ struct BlockDriver {
> int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
> const uint8_t *buf, int nb_sectors);
>
> + int coroutine_fn (*bdrv_co_write_compressed)(BlockDriverState *bs,
> + int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
This should be called bdrv_co_writev_compressed because it's a vectored
interface.
Kevin