From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrY5-0001Ji-8T for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHrY0-0001Ea-5R for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:51:25 -0400 Received: from mail-db3on0119.outbound.protection.outlook.com ([157.55.234.119]:23808 helo=emea01-db3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHrXz-0001EE-AH for qemu-devel@nongnu.org; Tue, 28 Jun 2016 07:51:20 -0400 References: <1464686130-12265-1-git-send-email-den@openvz.org> <1464686130-12265-3-git-send-email-den@openvz.org> <20160628110941.GB6800@noname.redhat.com> From: Pavel Butsykin Message-ID: <5772611B.4060800@virtuozzo.com> Date: Tue, 28 Jun 2016 14:35:55 +0300 MIME-Version: 1.0 In-Reply-To: <20160628110941.GB6800@noname.redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit 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: Kevin Wolf , "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Jeff Cody , Markus Armbruster , Eric Blake , John Snow , Stefan Hajnoczi On 28.06.2016 14:09, Kevin Wolf wrote: > 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. > I reused BlkRwCo, and it's only a temporary change. > 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. > agree > Kevin >