From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHqtq-0005Zv-Ce for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:09:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHqtl-0008EK-9P for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:09:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHqtl-0008EG-11 for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:09:45 -0400 Date: Tue, 28 Jun 2016 13:09:41 +0200 From: Kevin Wolf Message-ID: <20160628110941.GB6800@noname.redhat.com> References: <1464686130-12265-1-git-send-email-den@openvz.org> <1464686130-12265-3-git-send-email-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1464686130-12265-3-git-send-email-den@openvz.org> Subject: Re: [Qemu-devel] [PATCH 02/11] block/io: add bdrv_co_write_compressed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Pavel Butsykin , Jeff Cody , Markus Armbruster , Eric Blake , John Snow , Stefan Hajnoczi Am 31.05.2016 um 11:15 hat Denis V. Lunev geschrieben: > From: Pavel Butsykin > > 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 > Signed-off-by: Denis V. Lunev > CC: Jeff Cody > CC: Markus Armbruster > CC: Eric Blake > CC: John Snow > CC: Stefan Hajnoczi > CC: Kevin Wolf > --- > 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