block-backend: Use coroutine for flush/discard/ioctl
cover block-backend: Use coroutine for flush/discard/ioctl
Paolo, this is my attempt at implementing what you were asking for last Friday. I converted blk_(co_)flush/pdiscard/ioctl so that all interfaces (coroutine, AIO, sync) go through the same coroutine-based function already on the BlockBackend level. Where it was reasonably easy, I also removed the corresponding emulations from block/io.c IIUC, this should cover your immediate needs.
Function to remove this series leaves for another day:
* bdrv_aio_flush (used by blkdebug, blkverify, qed)
* bdrv_flush (even more users)
* bdrv_pdiscard (used by qcow2)
BlockDriver callbacks to remove left for another day:
* bdrv_aio_pdiscard (implemented by raw-posix and rbd)
* bdrv_aio_ioctl (implemented by raw-posix and iscsi)
In both cases, raw-posix is trivial to covert, but iscsi and rbd feel rather scary without a proper test setup.
Kevin Wolf (9):
block: Use blk_co_flush() for all BB level flushes
block: Use blk_co_pdiscard() for all BB level discard
block: Remove bdrv_aio_pdiscard()
block: Use blk_co_ioctl() for all BB level ioctls
raw-posix: Don't use bdrv_ioctl()
block: Remove bdrv_ioctl()
block: Introduce .bdrv_co_ioctl() driver callback
raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl block: Remove bdrv_aio_ioctl()
block/block-backend.c | 94 ++++++++++++++++++++++++---------- block/io.c | 111 ++++------------------------------------- block/raw-posix.c | 16 ++++-- block/raw_bsd.c | 9 ++-- block/trace-events | 1 - include/block/block.h | 8 +-- include/block/block_int.h | 2 + include/sysemu/block-backend.h | 1 + 8 files changed, 98 insertions(+), 144 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/9 block: Use blk_co_flush() for all BB level flushes
All read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
This patch extends this mode of operation to flushes.
--- block/block-backend.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
block/block-backend.c +17 -10
@@ -1099,14 +1099,19 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, blk_aio_write_entry, flags, cb, opaque); } +static void blk_aio_flush_entry (void *opaque) +{ +BlkAioEmAIOCB *acb = opaque; +BlkRwCo *rwco = &acb->rwco; + + rwco->ret =blk_co_flush (rwco->blk); +blk_aio_complete (acb); +} +BlockAIOCB *blk_aio_flush (BlockBackend *blk,BlockCompletionFunc *cb,void *opaque) { -if (!blk_is_available (blk)) { -return blk_abort_aio_request (blk, cb, opaque, -ENOMEDIUM ); - } - -return bdrv_aio_flush (blk_bs (blk), cb, opaque); +return blk_aio_prwv (blk,0 ,0 ,NULL , blk_aio_flush_entry,0 , cb, opaque); } BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk,
@@ -1169,13 +1174,15 @@ int blk_co_flush(BlockBackend *blk)return bdrv_co_flush (blk_bs (blk)); } -int blk_flush (BlockBackend *blk) +static void blk_flush_entry (void *opaque) { -if (!blk_is_available (blk)) { -return -ENOMEDIUM ; - } +BlkRwCo *rwco = opaque; + rwco->ret =blk_co_flush (rwco->blk); +} -return bdrv_flush (blk_bs (blk)); +int blk_flush (BlockBackend *blk) +{ +return blk_prw (blk,0 ,NULL ,0 , blk_flush_entry,0 ); }void blk_drain (BlockBackend *blk)
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 1/9] block: Use blk_co_flush() for all BB level flushes
Quoted 11 lines · Kevin Wolf
All read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
This patch extends this mode of operation to flushes.
Signed-off-by Kevin Wolf <[email protected]>--- block/block-backend.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 2/9 block: Use blk_co_pdiscard() for all BB level discard
In reply to Kevin WolfAll read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
This patch extends this mode of operation to discards.
--- block/block-backend.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
block/block-backend.c +18 -12
@@ -1114,16 +1114,21 @@ BlockAIOCB *blk_aio_flush(BlockBackend *blk,return blk_aio_prwv (blk,0 ,0 ,NULL , blk_aio_flush_entry,0 , cb, opaque); } +static void blk_aio_pdiscard_entry (void *opaque) +{ +BlkAioEmAIOCB *acb = opaque; +BlkRwCo *rwco = &acb->rwco; + + rwco->ret =blk_co_pdiscard (rwco->blk, rwco->offset, acb->bytes); +blk_aio_complete (acb); +} +BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk,int64_t offset,int count,BlockCompletionFunc *cb,void *opaque) { -int ret =blk_check_byte_request (blk, offset, count); -if (ret <0 ) { -return blk_abort_aio_request (blk, cb, opaque, ret); - } - -return bdrv_aio_pdiscard (blk_bs (blk), offset, count, cb, opaque); +return blk_aio_prwv (blk, offset, count,NULL , blk_aio_pdiscard_entry,0 , + cb, opaque); }void blk_aio_cancel (BlockAIOCB *acb)
@@ -1562,14 +1567,15 @@ int blk_truncate(BlockBackend *blk, int64_t offset)return bdrv_truncate (blk_bs (blk), offset); } -int blk_pdiscard (BlockBackend *blk,int64_t offset,int count) +static void blk_pdiscard_entry (void *opaque) { -int ret =blk_check_byte_request (blk, offset, count); -if (ret <0 ) { -return ret; - } +BlkRwCo *rwco = opaque; + rwco->ret =blk_co_pdiscard (rwco->blk, rwco->offset, rwco->qiov->size); +} -return bdrv_pdiscard (blk_bs (blk), offset, count); +int blk_pdiscard (BlockBackend *blk,int64_t offset,int count) +{ +return blk_prw (blk, offset,NULL , count, blk_pdiscard_entry,0 ); } int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf,
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 2/9] block: Use blk_co_pdiscard() for all BB level discard
Quoted 5 lines · Kevin Wolf
All read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
Quoted 7 lines
This patch extends this mode of operation to discards.
Signed-off-by Kevin Wolf <[email protected]>--- block/block-backend.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 3/9 block: Remove bdrv_aio_pdiscard()
In reply to Kevin WolfIt is unused now.
--- block/io.c | 29 ----------------------------- block/trace-events | 1 - include/block/block.h | 3 --- 3 files changed, 33 deletions(-)
block/io.c +0 -29
@@ -2196,35 +2196,6 @@ BlockAIOCB *bdrv_aio_flush(BlockDriverState *bs,return &acb->common; } -static void coroutine_fn bdrv_aio_pdiscard_co_entry(void *opaque) -{ -BlockAIOCBCoroutine *acb = opaque; -BlockDriverState *bs = acb->common.bs; - - acb->req.error =bdrv_co_pdiscard (bs, acb->req.offset, acb->req.bytes); -bdrv_co_complete (acb); -} - -BlockAIOCB *bdrv_aio_pdiscard (BlockDriverState *bs,int64_t offset,int count, -BlockCompletionFunc *cb,void *opaque) -{ -Coroutine *co; -BlockAIOCBCoroutine *acb; - -trace_bdrv_aio_pdiscard (bs, offset, count, opaque); - - acb =qemu_aio_get (&bdrv_em_co_aiocb_info, bs, cb, opaque); - acb->need_bh = true; - acb->req.error = -EINPROGRESS ; - acb->req.offset = offset; - acb->req.bytes = count; - co =qemu_coroutine_create (bdrv_aio_pdiscard_co_entry, acb); -qemu_coroutine_enter (co); - -bdrv_co_maybe_schedule_bh (acb); -return &acb->common; -} -void *qemu_aio_get (const AIOCBInfo *aiocb_info,BlockDriverState *bs,BlockCompletionFunc *cb,void *opaque) {
block/trace-events +0 -1
@@ -9,7 +9,6 @@ blk_co_preadv(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %u flags %x" # block/io.c -bdrv_aio_pdiscard(void *bs, int64_t offset, int count, void *opaque) "bs %p offset %"PRId64" count %d opaque %p" bdrv_aio_flush(void *bs, void *opaque) "bs %p opaque %p" bdrv_aio_readv(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p" bdrv_aio_writev(void *bs, int64_t sector_num, int nb_sectors, void *opaque) "bs %p sector_num %"PRId64" nb_sectors %d opaque %p"
include/block/block.h +0 -3
@@ -314,9 +314,6 @@ BlockAIOCB *bdrv_aio_writev(BdrvChild *child, int64_t sector_num, BlockCompletionFunc *cb, void *opaque);BlockAIOCB *bdrv_aio_flush (BlockDriverState *bs,BlockCompletionFunc *cb,void *opaque); -BlockAIOCB *bdrv_aio_pdiscard (BlockDriverState *bs, -int64_t offset,int count, -BlockCompletionFunc *cb,void *opaque);void bdrv_aio_cancel (BlockAIOCB *acb);void bdrv_aio_cancel_async (BlockAIOCB *acb);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 3/9] block: Remove bdrv_aio_pdiscard()
Quoted 8 lines · Kevin Wolf
It is unused now.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 29 ----------------------------- block/trace-events | 1 - include/block/block.h | 3 --- 3 files changed, 33 deletions(-)
Might be nice to research which commit id removed the last use, and mention it in the commit message as an idea for how long we've had dead code, but that's not a necessity.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 3/9] block: Remove bdrv_aio_pdiscard()
Am 20.10.2016 um 19:32 hat Eric Blake geschrieben:
Quoted 10 lines · Kevin Wolf
Quoted 8 lines
It is unused now.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 29 ----------------------------- block/trace-events | 1 - include/block/block.h | 3 --- 3 files changed, 33 deletions(-)
Quoted 3 lines
Might be nice to research which commit id removed the last use, and mention it in the commit message as an idea for how long we've had dead code, but that's not a necessity.
Patch 2 removed the last user.
Kevin
Re: [Qemu-devel] [PATCH 3/9] block: Remove bdrv_aio_pdiscard()
Quoted 11 lines · Kevin Wolf
Am 20.10.2016 um 19:32 hat Eric Blake geschrieben:
Quoted 10 lines · Kevin Wolf
Quoted 8 lines
It is unused now.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 29 ----------------------------- block/trace-events | 1 - include/block/block.h | 3 --- 3 files changed, 33 deletions(-)
Quoted 5 lines
Quoted 3 lines
Might be nice to research which commit id removed the last use, and mention it in the commit message as an idea for how long we've had dead code, but that's not a necessity.
Patch 2 removed the last user.
Aha. So maybe "removed in the previous patch" is all the more mention it needs, if at all.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 4/9 block: Use blk_co_ioctl() for all BB level ioctls
In reply to Kevin WolfAll read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
This patch exports a bdrv_co_ioctl() function and uses it to extend this mode of operation to ioctls.
--- block/block-backend.c | 39 +++++++++++++++++++++++++++++++++------ block/io.c | 8 ++++---- include/block/block.h | 1 + include/sysemu/block-backend.h | 1 + 4 files changed, 39 insertions(+), 10 deletions(-)
block/block-backend.c +33 -6
@@ -1141,23 +1141,50 @@ void blk_aio_cancel_async(BlockAIOCB *acb)bdrv_aio_cancel_async (acb); } -int blk_ioctl (BlockBackend *blk,unsigned long int req,void *buf) +int blk_co_ioctl (BlockBackend *blk,unsigned long int req,void *buf) {if (!blk_is_available (blk)) {return -ENOMEDIUM ; } -return bdrv_ioctl (blk_bs (blk), req, buf); +return bdrv_co_ioctl (blk_bs (blk), req, buf); +} + +static void blk_ioctl_entry (void *opaque) +{ +BlkRwCo *rwco = opaque; + rwco->ret =blk_co_ioctl (rwco->blk, rwco->offset, + rwco->qiov->iov[0 ].iov_base); +} + +int blk_ioctl (BlockBackend *blk,unsigned long int req,void *buf) +{ +return blk_prw (blk, req, buf,0 , blk_ioctl_entry,0 ); +} + +static void blk_aio_ioctl_entry (void *opaque) +{ +BlkAioEmAIOCB *acb = opaque; +BlkRwCo *rwco = &acb->rwco; + + rwco->ret =blk_co_ioctl (rwco->blk, rwco->offset, + rwco->qiov->iov[0 ].iov_base); +blk_aio_complete (acb); }BlockAIOCB *blk_aio_ioctl (BlockBackend *blk,unsigned long int req,void *buf,BlockCompletionFunc *cb,void *opaque) { -if (!blk_is_available (blk)) { -return blk_abort_aio_request (blk, cb, opaque, -ENOMEDIUM ); - } +QEMUIOVector qiov; +struct iovec iov; + + iov = (struct iovec ) { + .iov_base = buf, + .iov_len =0 , + }; +qemu_iovec_init_external (&qiov, &iov,1 ); -return bdrv_aio_ioctl (blk_bs (blk), req, buf, cb, opaque); +return blk_aio_prwv (blk, req,0 , &qiov, blk_aio_ioctl_entry,0 , cb, opaque); }int blk_co_pdiscard (BlockBackend *blk,int64_t offset,int count)
block/io.c +4 -4
@@ -2492,7 +2492,7 @@ int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count)return rwco.ret; } -static int bdrv_co_do_ioctl (BlockDriverState *bs,int req,void *buf) +int bdrv_co_ioctl (BlockDriverState *bs,int req,void *buf) {BlockDriver *drv = bs->drv;BdrvTrackedRequest tracked_req;
@@ -2528,7 +2528,7 @@ typedef struct { static void coroutine_fn bdrv_co_ioctl_entry(void *opaque) {BdrvIoctlCoData *data = opaque; - data->ret =bdrv_co_do_ioctl (data->bs, data->req, data->buf); + data->ret =bdrv_co_ioctl (data->bs, data->req, data->buf); }/* needed for generic scsi interface */
@@ -2558,8 +2558,8 @@ int bdrv_ioctl(BlockDriverState *bs, unsigned long int req, void *buf) static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque) {BlockAIOCBCoroutine *acb = opaque; - acb->req.error =bdrv_co_do_ioctl (acb->common.bs, - acb->req.req, acb->req.buf); + acb->req.error =bdrv_co_ioctl (acb->common.bs, + acb->req.req, acb->req.buf);bdrv_co_complete (acb); }
include/block/block.h +1 -0
@@ -318,6 +318,7 @@ void bdrv_aio_cancel(BlockAIOCB *acb);void bdrv_aio_cancel_async (BlockAIOCB *acb);/* sg packet commands */ +int bdrv_co_ioctl (BlockDriverState *bs,int req,void *buf);int bdrv_ioctl (BlockDriverState *bs,unsigned long int req,void *buf); BlockAIOCB *bdrv_aio_ioctl(BlockDriverState *bs, unsigned long int req, void *buf,
include/sysemu/block-backend.h +1 -0
@@ -146,6 +146,7 @@ BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, int64_t offset, int count, BlockCompletionFunc *cb, void *opaque);void blk_aio_cancel (BlockAIOCB *acb);void blk_aio_cancel_async (BlockAIOCB *acb); +int blk_co_ioctl (BlockBackend *blk,unsigned long int req,void *buf);int blk_ioctl (BlockBackend *blk,unsigned long int req,void *buf);BlockAIOCB *blk_aio_ioctl (BlockBackend *blk,unsigned long int req,void *buf,BlockCompletionFunc *cb,void *opaque);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 4/9] block: Use blk_co_ioctl() for all BB level ioctls
Quoted 8 lines · Kevin Wolf
All read/write functions already have a single coroutine-based function on the BlockBackend level through which all requests go (no matter what API style the external caller used) and which passes the requests down to the block node level.
This patch exports a
bdrv_co_ioctl()function and uses it to extend this mode of operation to ioctls.
Quoted 8 lines
Signed-off-by Kevin Wolf <[email protected]>--- block/block-backend.c | 39 +++++++++++++++++++++++++++++++++------ block/io.c | 8 ++++---- include/block/block.h | 1 + include/sysemu/block-backend.h | 1 + 4 files changed, 39 insertions(+), 10 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 5/9 raw-posix: Don't use bdrv_ioctl()
In reply to Kevin WolfInstead of letting raw-posix use the bdrv_ioctl() abstraction to issue an ioctl to itself, just call ioctl() directly.
--- block/raw-posix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
block/raw-posix.c +13 -3
@@ -2069,13 +2069,23 @@ static bool hdev_is_sg(BlockDriverState *bs)#if defined(__linux__) +BDRVRawState *s = bs->opaque;struct stat st;struct sg_scsi_id scsiid;int sg_version; +int ret; + +if (stat (bs->filename, &st) <0 || !S_ISCHR (st.st_mode)) { +return false; + } -if (stat (bs->filename, &st) >=0 &&S_ISCHR (st.st_mode) && - !bdrv_ioctl (bs,SG_GET_VERSION_NUM , &sg_version) && - !bdrv_ioctl (bs,SG_GET_SCSI_ID , &scsiid)) { + ret =ioctl (s->fd,SG_GET_VERSION_NUM , &sg_version); +if (ret <0 ) { +return false; + } + + ret =ioctl (s->fd,SG_GET_SCSI_ID , &scsiid); +if (ret >=0 ) {DPRINTF ("SG device found: type=%d, version=%d\n" , scsiid.scsi_type, sg_version);return true;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 5/9] raw-posix: Don't use bdrv_ioctl()
Quoted 8 lines · Kevin Wolf
Instead of letting raw-posix use the
bdrv_ioctl()abstraction to issue an ioctl to itself, just callioctl()directly.Signed-off-by Kevin Wolf <[email protected]>--- block/raw-posix.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 6/9 block: Remove bdrv_ioctl()
In reply to Kevin WolfIt is unused now.
--- block/io.c | 37 ------------------------------------- include/block/block.h | 1 - 2 files changed, 38 deletions(-)
block/io.c +0 -37
@@ -2518,43 +2518,6 @@ out:return co.ret; } -typedef struct { -BlockDriverState *bs; -int req; -void *buf; -int ret; -}BdrvIoctlCoData ; - -static void coroutine_fn bdrv_co_ioctl_entry(void *opaque) -{ -BdrvIoctlCoData *data = opaque; - data->ret =bdrv_co_ioctl (data->bs, data->req, data->buf); -} - -/* needed for generic scsi interface */ -int bdrv_ioctl (BlockDriverState *bs,unsigned long int req,void *buf) -{ -BdrvIoctlCoData data = { - .bs = bs, - .req = req, - .buf = buf, - .ret = -EINPROGRESS , - }; - -if (qemu_in_coroutine ()) { -/* Fast-path if already in coroutine context */ -bdrv_co_ioctl_entry (&data); - }else { -Coroutine *co =qemu_coroutine_create (bdrv_co_ioctl_entry, &data); - -qemu_coroutine_enter (co); -while (data.ret == -EINPROGRESS ) { -aio_poll (bdrv_get_aio_context (bs), true); - } - } -return data.ret; -} - static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque) {BlockAIOCBCoroutine *acb = opaque;
include/block/block.h +0 -1
@@ -319,7 +319,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb);/* sg packet commands */ int bdrv_co_ioctl (BlockDriverState *bs,int req,void *buf); -int bdrv_ioctl (BlockDriverState *bs,unsigned long int req,void *buf);BlockAIOCB *bdrv_aio_ioctl (BlockDriverState *bs,unsigned long int req,void *buf,BlockCompletionFunc *cb,void *opaque);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 6/9] block: Remove bdrv_ioctl()
Quoted 8 lines · Kevin Wolf
It is unused now.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 37 ------------------------------------- include/block/block.h | 1 - 2 files changed, 38 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 7/9 block: Introduce .bdrv_co_ioctl() driver callback
In reply to Kevin WolfThis allows drivers to implement ioctls in a coroutine-based way.
--- block/io.c | 16 ++++++++++------ include/block/block_int.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-)
block/io.c +10 -6
@@ -2502,17 +2502,21 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf)BlockAIOCB *acb;tracked_request_begin (&tracked_req, bs,0 ,0 ,BDRV_TRACKED_IOCTL ); -if (!drv || !drv->bdrv_aio_ioctl) { +if (!drv || (!drv->bdrv_aio_ioctl && !drv->bdrv_co_ioctl)) { co.ret = -ENOTSUP ; goto out; } - acb = drv->bdrv_aio_ioctl (bs, req, buf, bdrv_co_io_em_complete, &co); -if (!acb) { - co.ret = -ENOTSUP ; - goto out; +if (drv->bdrv_co_ioctl) { + co.ret = drv->bdrv_co_ioctl (bs, req, buf); + }else { + acb = drv->bdrv_aio_ioctl (bs, req, buf, bdrv_co_io_em_complete, &co); +if (!acb) { + co.ret = -ENOTSUP ; + goto out; + } +qemu_coroutine_yield (); } -qemu_coroutine_yield (); out:tracked_request_end (&tracked_req);return co.ret;
include/block/block_int.h +2 -0
@@ -244,6 +244,8 @@ struct BlockDriver {BlockAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,unsigned long int req,void *buf,BlockCompletionFunc *cb,void *opaque); + int coroutine_fn (*bdrv_co_ioctl)(BlockDriverState *bs, +unsigned long int req,void *buf);/* List of options for creating images, terminated by name == NULL */ QemuOptsList *create_opts;
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 7/9] block: Introduce .bdrv_co_ioctl() driver callback
Quoted 8 lines · Kevin Wolf
This allows drivers to implement ioctls in a coroutine-based way.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 16 ++++++++++------ include/block/block_int.h | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 8/9 raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl
In reply to Kevin WolfIt's the simpler interface to use for the raw format driver.
Apart from that, this removes the last user of the AIO emulation implemented by bdrv_aio_ioctl().
--- block/raw_bsd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
block/raw_bsd.c +3 -6
@@ -176,12 +176,9 @@ static void raw_lock_medium(BlockDriverState *bs, bool locked)bdrv_lock_medium (bs->file->bs, locked); } -static BlockAIOCB *raw_aio_ioctl (BlockDriverState *bs, -unsigned long int req,void *buf, -BlockCompletionFunc *cb, -void *opaque) +static int raw_co_ioctl (BlockDriverState *bs,unsigned long int req,void *buf) { -return bdrv_aio_ioctl (bs->file->bs, req, buf, cb, opaque); +return bdrv_co_ioctl (bs->file->bs, req, buf); }static int raw_has_zero_init (BlockDriverState *bs)
@@ -261,7 +258,7 @@ BlockDriver bdrv_raw = { .bdrv_media_changed = &raw_media_changed, .bdrv_eject = &raw_eject, .bdrv_lock_medium = &raw_lock_medium, - .bdrv_aio_ioctl = &raw_aio_ioctl, + .bdrv_co_ioctl = &raw_co_ioctl, .create_opts = &raw_create_opts, .bdrv_has_zero_init = &raw_has_zero_init };
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 8/9] raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl
Quoted 10 lines · Kevin Wolf
It's the simpler interface to use for the raw format driver.
Apart from that, this removes the last user of the AIO emulation implemented by
bdrv_aio_ioctl().Signed-off-by Kevin Wolf <[email protected]>--- block/raw_bsd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
PATCH 9/9 block: Remove bdrv_aio_ioctl()
In reply to Kevin WolfIt is unused now.
--- block/io.c | 27 --------------------------- include/block/block.h | 3 --- 2 files changed, 30 deletions(-)
block/io.c +0 -27
@@ -2522,33 +2522,6 @@ out:return co.ret; } -static void coroutine_fn bdrv_co_aio_ioctl_entry(void *opaque) -{ -BlockAIOCBCoroutine *acb = opaque; - acb->req.error =bdrv_co_ioctl (acb->common.bs, - acb->req.req, acb->req.buf); -bdrv_co_complete (acb); -} - -BlockAIOCB *bdrv_aio_ioctl (BlockDriverState *bs, -unsigned long int req,void *buf, -BlockCompletionFunc *cb,void *opaque) -{ -BlockAIOCBCoroutine *acb =qemu_aio_get (&bdrv_em_co_aiocb_info, - bs, cb, opaque); -Coroutine *co; - - acb->need_bh = true; - acb->req.error = -EINPROGRESS ; - acb->req.req = req; - acb->req.buf = buf; - co =qemu_coroutine_create (bdrv_co_aio_ioctl_entry, acb); -qemu_coroutine_enter (co); - -bdrv_co_maybe_schedule_bh (acb); -return &acb->common; -} -void *qemu_blockalign (BlockDriverState *bs,size_t size) {return qemu_memalign (bdrv_opt_mem_align (bs), size);
include/block/block.h +0 -3
@@ -319,9 +319,6 @@ void bdrv_aio_cancel_async(BlockAIOCB *acb);/* sg packet commands */ int bdrv_co_ioctl (BlockDriverState *bs,int req,void *buf); -BlockAIOCB *bdrv_aio_ioctl (BlockDriverState *bs, -unsigned long int req,void *buf, -BlockCompletionFunc *cb,void *opaque);/* Invalidate any cached metadata used by image formats */ void bdrv_invalidate_cache (BlockDriverState *bs,Error **errp);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH 9/9] block: Remove bdrv_aio_ioctl()
Quoted 8 lines · Kevin Wolf
It is unused now.
Signed-off-by Kevin Wolf <[email protected]>--- block/io.c | 27 --------------------------- include/block/block.h | 3 --- 2 files changed, 30 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
----- Original Message -----
Quoted 23 lines
From: "Kevin Wolf" <[email protected]>
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Sent: Thursday, October 20, 2016 3:46:00 PM
Subject: [PATCH 0/9] block-backend: Use coroutine for flush/discard/ioctlPaolo, this is my attempt at implementing what you were asking for last Friday.
I converted blk_(co_)flush/pdiscard/ioctl so that all interfaces (coroutine, AIO, sync) go through the same coroutine-based function already on the BlockBackend level. Where it was reasonably easy, I also removed the corresponding emulations fromblock/io.cIIUC, this should cover your immediate
needs.Function to remove this series leaves for another day:
*
bdrv_aio_flush(used by blkdebug, blkverify, qed)
*bdrv_flush(even more users)
*bdrv_pdiscard(used by qcow2)
Quoted 7 lines
BlockDriver callbacks to remove left for another day:
*
bdrv_aio_pdiscard(implemented by raw-posix and rbd)
*bdrv_aio_ioctl(implemented by raw-posix and iscsi)In both cases, raw-posix is trivial to covert, but iscsi and rbd feel rather scary without a proper test setup.
Thanks!
Paolo
Your series seems to have some coding style problems. See output below for more information:
Hi,
Your series seems to have some coding style problems. See output below for more information:
Subject: [Qemu-devel] [PATCH 0/9] block-backend: Use coroutine for flush/discard/ioctl
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384 Switched to a new branch 'test'
f1e92c7 block: Remove bdrv_aio_ioctl()
6f353df raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl 1e5fd07 block: Introduce .bdrv_co_ioctl() driver callback 04b823d block: Remove bdrv_ioctl()
4fed6c5 raw-posix: Don't use bdrv_ioctl()
b972aa0 block: Use blk_co_ioctl() for all BB level ioctls 53ef487 block: Remove bdrv_aio_pdiscard()
d777b24 block: Use blk_co_pdiscard() for all BB level discard 2470c9c block: Use blk_co_flush() for all BB level flushes
=== OUTPUT BEGIN ===
Checking PATCH 1/9: block: Use blk_co_flush() for all BB level flushes... Checking PATCH 2/9: block: Use blk_co_pdiscard() for all BB level discard... Checking PATCH 3/9: block: Remove bdrv_aio_pdiscard()... Checking PATCH 4/9: block: Use blk_co_ioctl() for all BB level ioctls... Checking PATCH 5/9: raw-posix: Don't use bdrv_ioctl()... Checking PATCH 6/9: block: Remove bdrv_ioctl()...
Checking PATCH 7/9: block: Introduce .bdrv_co_ioctl() driver callback...
ERROR: space prohibited between function name and open parenthesis '(' #51: FILE: include/block/block_int.h:247:
+ int coroutine_fn (*bdrv_co_ioctl)(BlockDriverState *bs,
total: 1 errors, 0 warnings, 35 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 8/9: raw: Implement .bdrv_co_ioctl instead of .bdrv_aio_ioctl... Checking PATCH 9/9: block: Remove bdrv_aio_ioctl()...
=== OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]