block: 64bit blk io
cover block: 64bit blk io
Hi all!
That's a new part of 64bit block-layer story, now to update blk_* io functions.
Vladimir Sementsov-Ogievskiy (12):
block-backend: blk_check_byte_request(): int64_t bytes
block-backend: make blk_co_preadv() 64bit
block-backend: convert blk_co_pwritev_part to int64_t bytes
block-backend: convert blk_co_pdiscard to int64_t bytes
block-backend: rename _do_ helper functions to _co_do_ block-coroutine-wrapper.py: support BlockBackend first argument
block-backend: drop blk_prw, use block-coroutine-wrapper
block-backend: convert blk_foo wrappers to use int64_t bytes parameter
block-backend: convert blk_co_copy_range to int64_t bytes
block-backend: convert blk_aio_ functions to int64_t bytes paramter
block-backend: blk_pread, blk_pwrite: rename count parameter to bytes
block-backend: drop INT_MAX restriction from blk_check_byte_request()
block/coroutines.h | 33 ++++ include/sysemu/block-backend.h | 23 +-- block/block-backend.c | 247 +++++++++++++---------------- block/trace-events | 4 +- scripts/block-coroutine-wrapper.py | 12 +- 5 files changed, 165 insertions(+), 154 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/12 block-backend: blk_check_byte_request(): int64_t bytes
Rename size and make it int64_t to correspond to modern block layer, which always uses int64_t for offset and bytes (not in blk layer yet, which is a task for following commits).
All callers pass int or unsigned int.
So, for bytes in [0, INT_MAX] nothing is changed, for negative bytes we now fail on "bytes < 0" check instead of "bytes > INT_MAX" check.
Note, that blk_check_byte_request() still doesn't allow requests exceeding INT_MAX.
--- block/block-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
block/block-backend.c +3 -3
@@ -1161,11 +1161,11 @@ void blk_set_disable_request_queuing(BlockBackend *blk, bool disable) }static int blk_check_byte_request (BlockBackend *blk,int64_t offset, -size_t size) +int64_t bytes) {int64_t len; -if (size >INT_MAX ) { +if (bytes <0 || bytes >INT_MAX ) {return -EIO ; }
@@ -1183,7 +1183,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset,return len; } -if (offset > len || len - offset < size) { +if (offset > len || len - offset < bytes) {return -EIO ; } }
Signature · 1 line
2.31.1
Re: [PATCH 01/12] block-backend: blk_check_byte_request(): int64_t bytes
Quoted 9 lines · Vladimir Sementsov-Ogievskiy
Rename size and make it
int64_tto correspond to modern block layer, which always usesint64_tfor offset and bytes (not in blk layer yet, which is a task for following commits).All callers pass int or unsigned int.
So, for bytes in [0,
INT_MAX] nothing is changed, for negative bytes we now fail on "bytes < 0" check instead of "bytes >INT_MAX" check.
Quoted 7 lines
Note, that
blk_check_byte_request()still doesn't allow requests exceedingINT_MAX.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/block-backend.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 2/12 block-backend: make blk_co_preadv() 64bit
In reply to Vladimir Sementsov-OgievskiyFor both updated functions type of bytes becomes wider, so all callers should be OK with it.
blk_co_preadv() only pass its arguments to blk_do_preadv().
blk_do_preadv() pass bytes to:
- trace_blk_co_preadv, which is updated too
- blk_check_byte_request, throttle_group_co_io_limits_intercept, bdrv_co_preadv, which are already int64_t.
Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request().
--- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 4 ++-- block/trace-events | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
include/sysemu/block-backend.h +1 -1
@@ -126,7 +126,7 @@ BlockBackend *blk_by_dev(void *dev);BlockBackend *blk_by_qdev_id (const char *id,Error **errp);void blk_set_dev_ops (BlockBackend *blk,const BlockDevOps *ops,void *opaque); int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, -unsigned int bytes,QEMUIOVector *qiov, +int64_t bytes,QEMUIOVector *qiov,BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, unsigned int bytes,
block/block-backend.c +2 -2
@@ -1205,7 +1205,7 @@ static void coroutine_fn blk_wait_while_drained(BlockBackend *blk)/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_preadv (BlockBackend *blk,int64_t offset,unsigned int bytes, +blk_do_preadv (BlockBackend *blk,int64_t offset,int64_t bytes,QEMUIOVector *qiov,BdrvRequestFlags flags) {int ret;
@@ -1236,7 +1236,7 @@ blk_do_preadv(BlockBackend *blk, int64_t offset, unsigned int bytes, } int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, -unsigned int bytes,QEMUIOVector *qiov, +int64_t bytes,QEMUIOVector *qiov,BdrvRequestFlags flags) {int ret;
block/trace-events +1 -1
@@ -5,7 +5,7 @@ bdrv_open_common(void *bs, const char *filename, int flags, const char *format_n bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" # block-backend.c -blk_co_preadv(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %u flags 0x%x" +blk_co_preadv(void *blk, void *bs, int64_t offset, int64_t bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %" PRId64 " flags 0x%x" blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %u flags 0x%x" blk_root_attach(void *child, void *blk, void *bs) "child %p blk %p bs %p" blk_root_detach(void *child, void *blk, void *bs) "child %p blk %p bs %p"
Signature · 1 line
2.31.1
Re: [PATCH 02/12] block-backend: make blk_co_preadv() 64bit
Quoted 14 lines · Vladimir Sementsov-Ogievskiy
For both updated functions type of bytes becomes wider, so all callers should be OK with it.
blk_co_preadv()only pass its arguments toblk_do_preadv().
blk_do_preadv()pass bytes to:-
trace_blk_co_preadv, which is updated too
-blk_check_byte_request,throttle_group_co_io_limits_intercept,bdrv_co_preadv, which are alreadyint64_t.Note that requests exceeding
INT_MAXare still restricted byblk_check_byte_request().
Quoted 7 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 4 ++-- block/trace-events | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 3/12 block-backend: convert blk_co_pwritev_part to int64_t bytes
In reply to Vladimir Sementsov-OgievskiyWe convert blk_do_pwritev_part() and some wrappers:blk_co_pwritev_part(), blk_co_pwritev(), blk_co_pwrite_zeroes().
All functions are converted so that parameter type becomes wider, so all callers should be OK with it.
Look at blk_do_pwritev_part() body:
bytes is passed to:
- trace_blk_co_pwritev (we update it here)
- blk_check_byte_request, throttle_group_co_io_limits_intercept, bdrv_co_pwritev_part - all already has int64_t argument.
Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request().
--- include/sysemu/block-backend.h | 6 +++--- block/block-backend.c | 8 ++++---- block/trace-events | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
include/sysemu/block-backend.h +3 -3
@@ -129,11 +129,11 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset, int64_t bytes, QEMUIOVector *qiov, BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, -unsigned int bytes, +int64_t bytes,QEMUIOVector *qiov,size_t qiov_offset,BdrvRequestFlags flags); int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, -unsigned int bytes,QEMUIOVector *qiov, +int64_t bytes,QEMUIOVector *qiov,BdrvRequestFlags flags); static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset,
@@ -242,7 +242,7 @@ int blk_get_open_flags_from_root_state(BlockBackend *blk);void *blk_aio_get (const AIOCBInfo *aiocb_info,BlockBackend *blk,BlockCompletionFunc *cb,void *opaque); int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, -int bytes,BdrvRequestFlags flags); +int64_t bytes,BdrvRequestFlags flags);int blk_pwrite_compressed (BlockBackend *blk,int64_t offset,const void *buf,int bytes); int blk_truncate(BlockBackend *blk, int64_t offset, bool exact,
block/block-backend.c +4 -4
@@ -1250,7 +1250,7 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pwritev_part (BlockBackend *blk,int64_t offset,unsigned int bytes, +blk_do_pwritev_part (BlockBackend *blk,int64_t offset,int64_t bytes,QEMUIOVector *qiov,size_t qiov_offset,BdrvRequestFlags flags) {
@@ -1286,7 +1286,7 @@ blk_do_pwritev_part(BlockBackend *blk, int64_t offset, unsigned int bytes, } int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, -unsigned int bytes, +int64_t bytes,QEMUIOVector *qiov,size_t qiov_offset,BdrvRequestFlags flags) {
@@ -1300,7 +1300,7 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset, } int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, -unsigned int bytes,QEMUIOVector *qiov, +int64_t bytes,QEMUIOVector *qiov,BdrvRequestFlags flags) {return blk_co_pwritev_part (blk, offset, bytes, qiov,0 , flags);
@@ -2208,7 +2208,7 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, } int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, -int bytes,BdrvRequestFlags flags) +int64_t bytes,BdrvRequestFlags flags) {return blk_co_pwritev (blk, offset, bytes,NULL , flags |BDRV_REQ_ZERO_WRITE );
block/trace-events +1 -1
@@ -6,7 +6,7 @@ bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d" # block-backend.c blk_co_preadv(void *blk, void *bs, int64_t offset, int64_t bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %" PRId64 " flags 0x%x" -blk_co_pwritev(void *blk, void *bs, int64_t offset, unsigned int bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %u flags 0x%x" +blk_co_pwritev(void *blk, void *bs, int64_t offset, int64_t bytes, int flags) "blk %p bs %p offset %"PRId64" bytes %" PRId64 " flags 0x%x" blk_root_attach(void *child, void *blk, void *bs) "child %p blk %p bs %p" blk_root_detach(void *child, void *blk, void *bs) "child %p blk %p bs %p"
Signature · 1 line
2.31.1
Re: [PATCH 03/12] block-backend: convert blk_co_pwritev_part to int64_t bytes
Quoted 16 lines · Vladimir Sementsov-Ogievskiy
We convert
blk_do_pwritev_part()and some wrappers:blk_co_pwritev_part(),blk_co_pwritev(),blk_co_pwrite_zeroes().All functions are converted so that parameter type becomes wider, so all callers should be OK with it.
Look at
blk_do_pwritev_part()body:
bytes is passed to:-
trace_blk_co_pwritev(we update it here)
-blk_check_byte_request,throttle_group_co_io_limits_intercept,bdrv_co_pwritev_part- all already hasint64_targument.Note that requests exceeding
INT_MAXare still restricted byblk_check_byte_request().
Quoted 7 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 6 +++--- block/block-backend.c | 8 ++++---- block/trace-events | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 4/12 block-backend: convert blk_co_pdiscard to int64_t bytes
In reply to Vladimir Sementsov-OgievskiyWe updated blk_do_pdiscard() and its wrapper blk_co_pdiscard(). Both functions are updated so that parameter type becomes wider, so all callers should be OK with it.
Look at blk_do_pdiscard(): bytes passed only to blk_check_byte_request() and bdrv_co_pdiscard(), which already has int64_t bytes parameter, so we are OK.
Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request().
--- include/sysemu/block-backend.h | 3 ++- block/block-backend.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
include/sysemu/block-backend.h +2 -1
@@ -181,7 +181,8 @@ void blk_aio_cancel_async(BlockAIOCB *acb);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); -int blk_co_pdiscard (BlockBackend *blk,int64_t offset,int bytes); +int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, +int64_t bytes);int blk_co_flush (BlockBackend *blk);int blk_flush (BlockBackend *blk);int blk_commit_all (void );
block/block-backend.c +3 -2
@@ -1626,7 +1626,7 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pdiscard (BlockBackend *blk,int64_t offset,int bytes) +blk_do_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes) {int ret;
@@ -1657,7 +1657,8 @@ BlockAIOCB *blk_aio_pdiscard(BlockBackend *blk, cb, opaque); } -int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, int bytes) +int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, +int64_t bytes) {int ret;
Signature · 1 line
2.31.1
Re: [PATCH 04/12] block-backend: convert blk_co_pdiscard to int64_t bytes
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
We updated
blk_do_pdiscard()and its wrapperblk_co_pdiscard(). Both functions are updated so that parameter type becomes wider, so all callers should be OK with it.Look at
blk_do_pdiscard(): bytes passed only toblk_check_byte_request()andbdrv_co_pdiscard(), which already hasint64_tbytes parameter, so we are OK.
Quoted 8 lines
Note that requests exceeding
INT_MAXare still restricted byblk_check_byte_request().Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 3 ++- block/block-backend.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-)
include/sysemu/block-backend.h void blk_aio_cancel_async(BlockAIOCB *acb); · line 185
Quoted 12 lines
include/sysemu/block-backend.h +2
-1@@ -181,7 +181,8 @@ void blk_aio_cancel_async(BlockAIOCB *acb);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); -int blk_co_pdiscard (BlockBackend *blk,int64_t offset,int bytes); +int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset, +int64_t bytes);
Commit message didn't mention the addition of this label, but it looks correct.
include/sysemu/block-backend.h void blk_aio_cancel_async(BlockAIOCB *acb); · line 186
Quoted 1 line
include/sysemu/block-backend.h +0
-0int blk_co_flush (BlockBackend *blk);
I guess fixing blk_co_flush to have the coroutine_fn label would be a separate patch. Or, you could rearrange the patches to add the label on multiple functions independently from type changes.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 5/12 block-backend: rename _do_ helper functions to _co_do_
In reply to Vladimir Sementsov-OgievskiyThis is a preparation to the following commit, to use automatic coroutine wrapper generation.
--- block/block-backend.c | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
block/block-backend.c +26 -26
@@ -1205,8 +1205,8 @@ static void coroutine_fn blk_wait_while_drained(BlockBackend *blk)/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_preadv (BlockBackend *blk,int64_t offset,int64_t bytes, -QEMUIOVector *qiov,BdrvRequestFlags flags) +blk_co_do_preadv (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,BdrvRequestFlags flags) {int ret;BlockDriverState *bs;
@@ -1242,7 +1242,7 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,int ret;blk_inc_in_flight (blk); - ret =blk_do_preadv (blk, offset, bytes, qiov, flags); + ret =blk_co_do_preadv (blk, offset, bytes, qiov, flags);blk_dec_in_flight (blk);return ret;
@@ -1250,9 +1250,9 @@ int coroutine_fn blk_co_preadv(BlockBackend *blk, int64_t offset,/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pwritev_part (BlockBackend *blk,int64_t offset,int64_t bytes, -QEMUIOVector *qiov,size_t qiov_offset, -BdrvRequestFlags flags) +blk_co_do_pwritev_part (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,size_t qiov_offset, +BdrvRequestFlags flags) {int ret;BlockDriverState *bs;
@@ -1293,7 +1293,7 @@ int coroutine_fn blk_co_pwritev_part(BlockBackend *blk, int64_t offset,int ret;blk_inc_in_flight (blk); - ret =blk_do_pwritev_part (blk, offset, bytes, qiov, qiov_offset, flags); + ret =blk_co_do_pwritev_part (blk, offset, bytes, qiov, qiov_offset, flags);blk_dec_in_flight (blk);return ret;
@@ -1319,8 +1319,8 @@ static void blk_read_entry(void *opaque)BlkRwCo *rwco = opaque;QEMUIOVector *qiov = rwco->iobuf; - rwco->ret =blk_do_preadv (rwco->blk, rwco->offset, qiov->size, - qiov, rwco->flags); + rwco->ret =blk_co_do_preadv (rwco->blk, rwco->offset, qiov->size, + qiov, rwco->flags);aio_wait_kick (); }
@@ -1329,8 +1329,8 @@ static void blk_write_entry(void *opaque)BlkRwCo *rwco = opaque;QEMUIOVector *qiov = rwco->iobuf; - rwco->ret =blk_do_pwritev_part (rwco->blk, rwco->offset, qiov->size, - qiov,0 , rwco->flags); + rwco->ret =blk_co_do_pwritev_part (rwco->blk, rwco->offset, qiov->size, + qiov,0 , rwco->flags);aio_wait_kick (); }
@@ -1483,8 +1483,8 @@ static void blk_aio_read_entry(void *opaque)QEMUIOVector *qiov = rwco->iobuf;assert (qiov->size == acb->bytes); - rwco->ret =blk_do_preadv (rwco->blk, rwco->offset, acb->bytes, - qiov, rwco->flags); + rwco->ret =blk_co_do_preadv (rwco->blk, rwco->offset, acb->bytes, + qiov, rwco->flags);blk_aio_complete (acb); }
@@ -1495,8 +1495,8 @@ static void blk_aio_write_entry(void *opaque)QEMUIOVector *qiov = rwco->iobuf;assert (!qiov || qiov->size == acb->bytes); - rwco->ret =blk_do_pwritev_part (rwco->blk, rwco->offset, acb->bytes, - qiov,0 , rwco->flags); + rwco->ret =blk_co_do_pwritev_part (rwco->blk, rwco->offset, acb->bytes, + qiov,0 , rwco->flags);blk_aio_complete (acb); }
@@ -1583,7 +1583,7 @@ void blk_aio_cancel_async(BlockAIOCB *acb)/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_ioctl (BlockBackend *blk,unsigned long int req,void *buf) +blk_co_do_ioctl (BlockBackend *blk,unsigned long int req,void *buf) {blk_wait_while_drained (blk);
@@ -1599,7 +1599,7 @@ static void blk_ioctl_entry(void *opaque)BlkRwCo *rwco = opaque;QEMUIOVector *qiov = rwco->iobuf; - rwco->ret =blk_do_ioctl (rwco->blk, rwco->offset, qiov->iov[0 ].iov_base); + rwco->ret =blk_co_do_ioctl (rwco->blk, rwco->offset, qiov->iov[0 ].iov_base);aio_wait_kick (); }
@@ -1613,7 +1613,7 @@ static void blk_aio_ioctl_entry(void *opaque)BlkAioEmAIOCB *acb = opaque;BlkRwCo *rwco = &acb->rwco; - rwco->ret =blk_do_ioctl (rwco->blk, rwco->offset, rwco->iobuf); + rwco->ret =blk_co_do_ioctl (rwco->blk, rwco->offset, rwco->iobuf);blk_aio_complete (acb); }
@@ -1626,7 +1626,7 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf,/* To be called between exactly one pair of blk_inc/dec_in_flight() */ static int coroutine_fn -blk_do_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes) +blk_co_do_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes) {int ret;
@@ -1645,7 +1645,7 @@ static void blk_aio_pdiscard_entry(void *opaque)BlkAioEmAIOCB *acb = opaque;BlkRwCo *rwco = &acb->rwco; - rwco->ret =blk_do_pdiscard (rwco->blk, rwco->offset, acb->bytes); + rwco->ret =blk_co_do_pdiscard (rwco->blk, rwco->offset, acb->bytes);blk_aio_complete (acb); }
@@ -1663,7 +1663,7 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,int ret;blk_inc_in_flight (blk); - ret =blk_do_pdiscard (blk, offset, bytes); + ret =blk_co_do_pdiscard (blk, offset, bytes);blk_dec_in_flight (blk);return ret;
@@ -1674,7 +1674,7 @@ static void blk_pdiscard_entry(void *opaque)BlkRwCo *rwco = opaque;QEMUIOVector *qiov = rwco->iobuf; - rwco->ret =blk_do_pdiscard (rwco->blk, rwco->offset, qiov->size); + rwco->ret =blk_co_do_pdiscard (rwco->blk, rwco->offset, qiov->size);aio_wait_kick (); }
@@ -1684,7 +1684,7 @@ int blk_pdiscard(BlockBackend *blk, int64_t offset, int bytes) }/* To be called between exactly one pair of blk_inc/dec_in_flight() */ -static int coroutine_fn blk_do_flush(BlockBackend *blk) +static int coroutine_fn blk_co_do_flush(BlockBackend *blk) {blk_wait_while_drained (blk);
@@ -1700,7 +1700,7 @@ static void blk_aio_flush_entry(void *opaque)BlkAioEmAIOCB *acb = opaque;BlkRwCo *rwco = &acb->rwco; - rwco->ret =blk_do_flush (rwco->blk); + rwco->ret =blk_co_do_flush (rwco->blk);blk_aio_complete (acb); }
@@ -1715,7 +1715,7 @@ int coroutine_fn blk_co_flush(BlockBackend *blk)int ret;blk_inc_in_flight (blk); - ret =blk_do_flush (blk); + ret =blk_co_do_flush (blk);blk_dec_in_flight (blk);return ret;
@@ -1724,7 +1724,7 @@ int coroutine_fn blk_co_flush(BlockBackend *blk)static void blk_flush_entry (void *opaque) {BlkRwCo *rwco = opaque; - rwco->ret =blk_do_flush (rwco->blk); + rwco->ret =blk_co_do_flush (rwco->blk);aio_wait_kick (); }
Signature · 1 line
2.31.1
Re: [PATCH 05/12] block-backend: rename _do_ helper functions to _co_do_
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
This is a preparation to the following commit, to use automatic coroutine wrapper generation.
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/block-backend.c | 52 +++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 6/12 block-coroutine-wrapper.py: support BlockBackend first argument
In reply to Vladimir Sementsov-Ogievskiy--- block/coroutines.h | 3 +++ scripts/block-coroutine-wrapper.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
block/coroutines.h +3 -0
@@ -27,6 +27,9 @@#include "block/block_int.h" +/* For blk_bs() in generated block/block-gen.c */ +#include "sysemu/block-backend.h" + int coroutine_fn bdrv_co_check(BlockDriverState *bs,BdrvCheckResult *res,BdrvCheckMode fix); int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp);
scripts/block-coroutine-wrapper.py +10 -2
@@ -100,12 +100,20 @@ def snake_to_camel(func_name: str) -> str: def gen_wrapper(func: FuncDecl) -> str: assert not '_co_' in func.name assert func.return_type == 'int' - assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *'] + assert func.args[0].type in ['BlockDriverState *', 'BdrvChild *', + 'BlockBackend *'] subsystem, subname = func.name.split('_', 1) name = f'{subsystem}_co_{subname}' - bs = 'bs' if func.args[0].type == 'BlockDriverState *' else 'child->bs' + + t = func.args[0].type + if t == 'BlockDriverState *': + bs = 'bs' + elif t == 'BdrvChild *': + bs = 'child->bs' + else: + bs = 'blk_bs(blk)' struct_name = snake_to_camel(name) return f"""\
Signature · 1 line
2.31.1
Re: [PATCH 06/12] block-coroutine-wrapper.py: support BlockBackend first argument
Quoted 6 lines · Vladimir Sementsov-Ogievskiy
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/coroutines.h | 3 +++ scripts/block-coroutine-wrapper.py | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 7/12 block-backend: drop blk_prw, use block-coroutine-wrapper
In reply to Vladimir Sementsov-OgievskiyLet's drop hand maid coroutine wrappers and use coroutine wrapper generation like in block/io.c.
Now, blk_foo() functions are written in same way as blk_co_foo() ones, but wrap blk_do_foo() instead of blk_co_do_foo().
--- block/coroutines.h | 30 ++++++++ block/block-backend.c | 155 ++++++++++++++++-------------------------- 2 files changed, 90 insertions(+), 95 deletions(-)
block/coroutines.h +30 -0
@@ -75,4 +75,34 @@ int coroutine_fnnbd_co_do_establish_connection (BlockDriverState *bs, Error **errp); +int generated_co_wrapper +blk_do_preadv (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,BdrvRequestFlags flags); +int coroutine_fn +blk_co_do_preadv (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,BdrvRequestFlags flags); + + +int generated_co_wrapper +blk_do_pwritev_part (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,size_t qiov_offset, +BdrvRequestFlags flags); +int coroutine_fn +blk_co_do_pwritev_part (BlockBackend *blk,int64_t offset,int64_t bytes, +QEMUIOVector *qiov,size_t qiov_offset, +BdrvRequestFlags flags); + +int generated_co_wrapper +blk_do_ioctl (BlockBackend *blk,unsigned long int req,void *buf); +int coroutine_fn +blk_co_do_ioctl (BlockBackend *blk,unsigned long int req,void *buf); + +int generated_co_wrapper +blk_do_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes); +int coroutine_fn +blk_co_do_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes); + +int generated_co_wrapper blk_do_flush(BlockBackend *blk); +int coroutine_fn blk_co_do_flush(BlockBackend *blk); +#endif /* BLOCK_COROUTINES_INT_H */
block/block-backend.c +60 -95
244 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH 07/12] block-backend: drop blk_prw, use block-coroutine-wrapper
Quoted 1 line · Vladimir Sementsov-Ogievskiy
Let's drop hand maid coroutine wrappers and use coroutine wrapper
s/maid/made/
Quoted 11 lines
generation like in
block/io.c.Now,
blk_foo()functions are written in same way asblk_co_foo()ones, but wrapblk_do_foo()instead ofblk_co_do_foo().Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/coroutines.h | 30 ++++++++ block/block-backend.c | 155 ++++++++++++++++-------------------------- 2 files changed, 90 insertions(+), 95 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 8/12 block-backend: convert blk_foo wrappers to use int64_t bytes parameter
In reply to Vladimir Sementsov-OgievskiyConvert blk_pdiscard, blk_pwrite_compressed, blk_pwrite_zeroes. These are just wrappers for functions with int64_t argument, so allow passing int64_t as well. Parameter type becomes wider so all callers should be OK with it.
Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request().
Note also that we don't (and are not going to) convert blk_pwrite andblk_pread: these functions returns number of bytes on success, so to update them, we should change return type to int64_t as well, which will lead to investigating and updating all callers which is too much.
So, blk_pread and blk_pwrite remain unchanged.
--- include/sysemu/block-backend.h | 6 +++--- block/block-backend.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-)
include/sysemu/block-backend.h +3 -3
@@ -155,7 +155,7 @@ static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, }int blk_pwrite_zeroes (BlockBackend *blk,int64_t offset, -int bytes,BdrvRequestFlags flags); +int64_t bytes,BdrvRequestFlags flags);BlockAIOCB *blk_aio_pwrite_zeroes (BlockBackend *blk,int64_t offset,int bytes,BdrvRequestFlags flags,BlockCompletionFunc *cb,void *opaque);
@@ -245,10 +245,10 @@ void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk, int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset,int64_t bytes,BdrvRequestFlags flags);int blk_pwrite_compressed (BlockBackend *blk,int64_t offset,const void *buf, -int bytes); +int64_t bytes);int blk_truncate (BlockBackend *blk,int64_t offset,bool exact,PreallocMode prealloc,BdrvRequestFlags flags,Error **errp); -int blk_pdiscard (BlockBackend *blk,int64_t offset,int bytes); +int blk_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes);int blk_save_vmstate (BlockBackend *blk,const uint8_t *buf,int64_t pos,int size);int blk_load_vmstate (BlockBackend *blk,uint8_t *buf,int64_t pos,int size);
block/block-backend.c +5 -5
@@ -1330,7 +1330,7 @@ typedef struct BlkRwCo { } BlkRwCo;int blk_pwrite_zeroes (BlockBackend *blk,int64_t offset, -int bytes,BdrvRequestFlags flags) +int64_t bytes,BdrvRequestFlags flags) {return blk_pwritev_part (blk, offset, bytes,NULL ,0 , flags |BDRV_REQ_ZERO_WRITE );
@@ -1637,7 +1637,7 @@ int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,return ret; } -int blk_pdiscard (BlockBackend *blk,int64_t offset,int bytes) +int blk_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes) {int ret;
@@ -2180,10 +2180,10 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, }int blk_pwrite_compressed (BlockBackend *blk,int64_t offset,const void *buf, -int count) +int64_t bytes) { -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, count); -return blk_pwritev_part (blk, offset, count, &qiov,0 , +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); +return blk_pwritev_part (blk, offset, bytes, &qiov,0 ,BDRV_REQ_WRITE_COMPRESSED ); }
Signature · 1 line
2.31.1
Re: [PATCH 08/12] block-backend: convert blk_foo wrappers to use int64_t bytes parameter
Quoted 13 lines · Vladimir Sementsov-Ogievskiy
Convert
blk_pdiscard,blk_pwrite_compressed,blk_pwrite_zeroes. These are just wrappers for functions withint64_targument, so allow passingint64_tas well. Parameter type becomes wider so all callers should be OK with it.Note that requests exceeding
INT_MAXare still restricted byblk_check_byte_request().Note also that we don't (and are not going to) convert
blk_pwriteandblk_pread: these functions returns number of bytes on success, so to update them, we should change return type toint64_tas well, which will lead to investigating and updating all callers which is too much.
Quoted 8 lines
So,
blk_preadandblk_pwriteremain unchanged.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 6 +++--- block/block-backend.c | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 9/12 block-backend: convert blk_co_copy_range to int64_t bytes
In reply to Vladimir Sementsov-OgievskiyFunction is updated so that parameter type becomes wider, so all callers should be OK with it.
Look at blk_co_copy_range() itself: bytes passed only to blk_check_byte_request() and bdrv_co_copy_range(), which already has int64_t bytes parameter, so we are OK.
Note that requests exceeding INT_MAX are still restricted by blk_check_byte_request().
--- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/sysemu/block-backend.h +1 -1
@@ -269,7 +269,7 @@ void blk_unregister_buf(BlockBackend *blk, void *host); int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,BlockBackend *blk_out,int64_t off_out, -int bytes,BdrvRequestFlags read_flags, +int64_t bytes,BdrvRequestFlags read_flags,BdrvRequestFlags write_flags);const BdrvChild *blk_root (BlockBackend *blk);
block/block-backend.c +1 -1
@@ -2412,7 +2412,7 @@ void blk_unregister_buf(BlockBackend *blk, void *host) int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,BlockBackend *blk_out,int64_t off_out, -int bytes,BdrvRequestFlags read_flags, +int64_t bytes,BdrvRequestFlags read_flags,BdrvRequestFlags write_flags) {int r;
Signature · 1 line
2.31.1
Re: [PATCH 09/12] block-backend: convert blk_co_copy_range to int64_t bytes
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
Function is updated so that parameter type becomes wider, so all callers should be OK with it.
Look at
blk_co_copy_range()itself: bytes passed only toblk_check_byte_request()andbdrv_co_copy_range(), which already hasint64_tbytes parameter, so we are OK.
Quoted 9 lines
Note that requests exceeding
INT_MAXare still restricted byblk_check_byte_request().Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 2 +- block/block-backend.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 10/12 block-backend: convert blk_aio_ functions to int64_t bytes paramter
In reply to Vladimir Sementsov-Ogievskiy1. Convert bytes in BlkAioEmAIOCB:
aio->bytes is only passed to already int64_t interfaces, and set in blk_aio_prwv, which is updated here.
2. For all updated functions parameter type becomes wider so callers are safe.
3. In blk_aio_prwv we only store bytes to BlkAioEmAIOCB, which is updated here.
4. Other updated functions are wrappers on blk_aio_prwv.
Note that blk_aio_preadv and blk_aio_pwritev become safer: before this commit, it's theoretically possible to pass qiov with size exceeding INT_MAX, which than converted to int argument of blk_aio_prwv. Now it's converted to int64_t which is a lot better. Still add assertions.
--- include/sysemu/block-backend.h | 4 ++-- block/block-backend.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-)
include/sysemu/block-backend.h +2 -2
@@ -157,7 +157,7 @@ static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset,int blk_pwrite_zeroes (BlockBackend *blk,int64_t offset,int64_t bytes,BdrvRequestFlags flags);BlockAIOCB *blk_aio_pwrite_zeroes (BlockBackend *blk,int64_t offset, -int bytes,BdrvRequestFlags flags, +int64_t bytes,BdrvRequestFlags flags,BlockCompletionFunc *cb,void *opaque);int blk_make_zero (BlockBackend *blk,BdrvRequestFlags flags);int blk_pread (BlockBackend *blk,int64_t offset,void *buf,int bytes);
@@ -174,7 +174,7 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, BlockCompletionFunc *cb, void *opaque);BlockAIOCB *blk_aio_flush (BlockBackend *blk,BlockCompletionFunc *cb,void *opaque); -BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk,int64_t offset,int bytes, +BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk,int64_t offset,int64_t bytes,BlockCompletionFunc *cb,void *opaque);void blk_aio_cancel (BlockAIOCB *acb);void blk_aio_cancel_async (BlockAIOCB *acb);
block/block-backend.c +8 -5
@@ -1380,7 +1380,7 @@ BlockAIOCB *blk_abort_aio_request(BlockBackend *blk,typedef struct BlkAioEmAIOCB {BlockAIOCB common;BlkRwCo rwco; -int bytes; +int64_t bytes;bool has_returned; }BlkAioEmAIOCB ;
@@ -1412,7 +1412,8 @@ static void blk_aio_complete_bh(void *opaque)blk_aio_complete (acb); } -static BlockAIOCB *blk_aio_prwv (BlockBackend *blk,int64_t offset,int bytes, +static BlockAIOCB *blk_aio_prwv (BlockBackend *blk,int64_t offset, +int64_t bytes,void *iobuf,CoroutineEntry co_entry,BdrvRequestFlags flags,BlockCompletionFunc *cb,void *opaque)
@@ -1469,10 +1470,10 @@ static void blk_aio_write_entry(void *opaque) }BlockAIOCB *blk_aio_pwrite_zeroes (BlockBackend *blk,int64_t offset, -int count,BdrvRequestFlags flags, +int64_t bytes,BdrvRequestFlags flags,BlockCompletionFunc *cb,void *opaque) { -return blk_aio_prwv (blk, offset, count,NULL , blk_aio_write_entry, +return blk_aio_prwv (blk, offset, bytes,NULL , blk_aio_write_entry, flags |BDRV_REQ_ZERO_WRITE , cb, opaque); }
@@ -1530,6 +1531,7 @@ BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);return blk_aio_prwv (blk, offset, qiov->size, qiov, blk_aio_read_entry, flags, cb, opaque); }
@@ -1538,6 +1540,7 @@ BlockAIOCB *blk_aio_pwritev(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);return blk_aio_prwv (blk, offset, qiov->size, qiov, blk_aio_write_entry, flags, cb, opaque); }
@@ -1618,7 +1621,7 @@ static void blk_aio_pdiscard_entry(void *opaque) }BlockAIOCB *blk_aio_pdiscard (BlockBackend *blk, -int64_t offset,int bytes, +int64_t offset,int64_t bytes,BlockCompletionFunc *cb,void *opaque) { return blk_aio_prwv(blk, offset, bytes, NULL, blk_aio_pdiscard_entry, 0,
Signature · 1 line
2.31.1
Re: [PATCH 10/12] block-backend: convert blk_aio_ functions to int64_t bytes paramter
Quoted 24 lines · Vladimir Sementsov-Ogievskiy
1. Convert bytes in BlkAioEmAIOCB:
aio->bytesis only passed to alreadyint64_tinterfaces, and set inblk_aio_prwv, which is updated here.2. For all updated functions parameter type becomes wider so callers are safe.
3. In
blk_aio_prwvwe only store bytes to BlkAioEmAIOCB, which is updated here.4. Other updated functions are wrappers on
blk_aio_prwv.Note that
blk_aio_preadvandblk_aio_pwritevbecome safer: before this commit, it's theoretically possible to pass qiov with size exceedingINT_MAX, which than converted to int argument ofblk_aio_prwv. Now it's converted toint64_twhich is a lot better. Still add assertions.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 4 ++-- block/block-backend.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-)
block/block-backend.c BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, · line 1534
Quoted 4 lines
block/block-backend.c +1
-0@@ -1530,6 +1531,7 @@ BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);
I hope this doesn't cause 32-bit compilers to warn about an always-true expression; but if it does, we'll figure something out. That's not enough for me to ask for you to respin this, though, so:
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 10/12] block-backend: convert blk_aio_ functions to int64_t bytes paramter
Quoted 34 lines · Eric Blake
Quoted 24 lines · Vladimir Sementsov-Ogievskiy
1. Convert bytes in BlkAioEmAIOCB:
aio->bytesis only passed to alreadyint64_tinterfaces, and set inblk_aio_prwv, which is updated here.2. For all updated functions parameter type becomes wider so callers are safe.
3. In
blk_aio_prwvwe only store bytes to BlkAioEmAIOCB, which is updated here.4. Other updated functions are wrappers on
blk_aio_prwv.Note that
blk_aio_preadvandblk_aio_pwritevbecome safer: before this commit, it's theoretically possible to pass qiov with size exceedingINT_MAX, which than converted to int argument ofblk_aio_prwv. Now it's converted toint64_twhich is a lot better. Still add assertions.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 4 ++-- block/block-backend.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-)block/block-backend.c BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, · line 1534
Quoted 4 lines
block/block-backend.c +1
-0@@ -1530,6 +1531,7 @@ BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);I hope this doesn't cause 32-bit compilers to warn about an always-true expression; but if it does, we'll figure something out. That's not enough for me to ask for you to respin this, though, so:
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>
So, here we need
assert((uint64_t)qiov->size <= INT64_MAX);
as in recent fix by Hanna.
Eric, will you stage this as continuation of 64bit series, or do we wait for Kevin or Hanna, or for me resending it with this small fix and your wording fixes?
Signature · 2 lines
Best regards, Vladimir
Re: [PATCH 10/12] block-backend: convert blk_aio_ functions to int64_t bytes paramter
Quoted 10 lines · Vladimir Sementsov-Ogievskiy
Quoted 10 lines
block/block-backend.c BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, · line 1534
Quoted 5 lines
block/block-backend.c +1
-0@@ -1530,6 +1531,7 @@ BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);I hope this doesn't cause 32-bit compilers to warn about an always-true expression; but if it does, we'll figure something out. That's not enough for me to ask for you to respin this, though, so:
Quoted 9 lines
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>So, here we need
assert((uint64_t)qiov->size <= INT64_MAX);as in recent fix by Hanna.
Indeed.
Quoted 1 line
Eric, will you stage this as continuation of 64bit series, or do we wait for Kevin or Hanna, or for me resending it with this small fix and your wording fixes?
At this point, I think I'm fine touching up the series and staging it through my tree.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Re: [PATCH 10/12] block-backend: convert blk_aio_ functions to int64_t bytes paramter
Quoted 21 lines · Eric Blake
Quoted 10 lines · Vladimir Sementsov-Ogievskiy
Quoted 10 lines
block/block-backend.c BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, · line 1534
Quoted 5 lines
block/block-backend.c +1
-0@@ -1530,6 +1531,7 @@ BlockAIOCB *blk_aio_preadv(BlockBackend *blk, int64_t offset, QEMUIOVector *qiov, BdrvRequestFlags flags, BlockCompletionFunc *cb, void *opaque) { + assert(qiov->size <= INT64_MAX);I hope this doesn't cause 32-bit compilers to warn about an always-true expression; but if it does, we'll figure something out. That's not enough for me to ask for you to respin this, though, so:
Quoted 9 lines
Quoted 2 lines
Reviewed-by Eric Blake <[email protected]>So, here we need
assert((uint64_t)qiov->size <= INT64_MAX);as in recent fix by Hanna.
Quoted 7 lines
Indeed.
Quoted 1 line
Eric, will you stage this as continuation of 64bit series, or do we wait for Kevin or Hanna, or for me resending it with this small fix and your wording fixes?
At this point, I think I'm fine touching up the series and staging it through my tree.
Great, thanks!
Signature · 2 lines
Best regards, Vladimir
PATCH 11/12 block-backend: blk_pread, blk_pwrite: rename count parameter to bytes
In reply to Vladimir Sementsov-OgievskiyTo be consistent with declarations in include/sysemu/block-backend.h.
--- block/block-backend.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
block/block-backend.c +8 -8
@@ -1477,27 +1477,27 @@ BlockAIOCB *blk_aio_pwrite_zeroes(BlockBackend *blk, int64_t offset, flags | BDRV_REQ_ZERO_WRITE, cb, opaque); } -int blk_pread (BlockBackend *blk,int64_t offset,void *buf,int count) +int blk_pread (BlockBackend *blk,int64_t offset,void *buf,int bytes) {int ret; -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, count); +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes);blk_inc_in_flight (blk); - ret =blk_do_preadv (blk, offset, count, &qiov,0 ); + ret =blk_do_preadv (blk, offset, bytes, &qiov,0 );blk_dec_in_flight (blk); -return ret <0 ? ret : count; +return ret <0 ? ret : bytes; } -int blk_pwrite (BlockBackend *blk,int64_t offset,const void *buf,int count, +int blk_pwrite (BlockBackend *blk,int64_t offset,const void *buf,int bytes,BdrvRequestFlags flags) {int ret; -QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, count); +QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); - ret =blk_pwritev_part (blk, offset, count, &qiov,0 , flags); + ret =blk_pwritev_part (blk, offset, bytes, &qiov,0 , flags); -return ret <0 ? ret : count; +return ret <0 ? ret : bytes; }int64_t blk_getlength (BlockBackend *blk)
Signature · 1 line
2.31.1
Re: [PATCH 11/12] block-backend: blk_pread, blk_pwrite: rename count parameter to bytes
Quoted 7 lines · Vladimir Sementsov-Ogievskiy
To be consistent with declarations in
include/sysemu/block-backend.h.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/block-backend.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
PATCH 12/12 block-backend: drop INT_MAX restriction from blk_check_byte_request()
In reply to Vladimir Sementsov-Ogievskiyblk_check_bytes_request is called from blk_co_do_preadv, blk_co_do_pwritev_part, blk_co_do_pdiscard and blk_co_copy_range before (maybe) calling throttle_group_co_io_limits_intercept() (which has int64_t argument) and then calling corresponding bdrv_co_ function. bdrv_co_ functions are OK with int64_t bytes as well.
So dropping the check for INT_MAX we just get same restrictions as in bdrv_ layer: discard and write-zeroes goes through bdrv_check_qiov_request() and are allowed to be 64bit. Other requests go through bdrv_check_request32() and still restricted by INT_MAX boundary.
--- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/block-backend.c +1 -1
@@ -1166,7 +1166,7 @@ static int blk_check_byte_request(BlockBackend *blk, int64_t offset, {int64_t len; -if (bytes <0 || bytes >INT_MAX ) { +if (bytes <0 ) {return -EIO ; }
Signature · 1 line
2.31.1
Re: [PATCH 12/12] block-backend: drop INT_MAX restriction from blk_check_byte_request()
Quoted 12 lines · Vladimir Sementsov-Ogievskiy
blk_check_bytes_requestis called fromblk_co_do_preadv,blk_co_do_pwritev_part,blk_co_do_pdiscardandblk_co_copy_rangebefore (maybe) callingthrottle_group_co_io_limits_intercept()(which hasint64_targument) and then calling correspondingbdrv_co_function.bdrv_co_functions are OK withint64_tbytes as well.So dropping the check for
INT_MAXwe just get same restrictions as inbdrv_layer: discard and write-zeroes goes throughbdrv_check_qiov_request()and are allowed to be 64bit. Other requests go throughbdrv_check_request32()and still restricted byINT_MAXboundary.
Quoted 4 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- block/block-backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Deceptively short, but this is the one where a mistake would hurt.
Thankfully, I agree with your analysis that the call stack is still checking 32-bit limits on read/write, and that discard/zero requests can now go up to 63-bit sizing if everything else in the call stack is ready; plus the fact that we are careful both in our drivers to document actual limits (whether 32-bit or even smaller), and in the block code to honor those limits (breaking larger requests into chunks before reaching this far).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
[PATCH 13/12] block-backend: fix blk_co_flush prototype to mention coroutine_fn
In reply to Vladimir Sementsov-OgievskiyWe do have this marker for blk_co_flush function declaration in block/block-backend.c. Add it in header too.
--- include/sysemu/block-backend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/sysemu/block-backend.h +1 -1
@@ -183,7 +183,7 @@ BlockAIOCB *blk_aio_ioctl(BlockBackend *blk, unsigned long int req, void *buf, BlockCompletionFunc *cb, void *opaque); int coroutine_fn blk_co_pdiscard(BlockBackend *blk, int64_t offset,int64_t bytes); -int blk_co_flush (BlockBackend *blk); +int coroutine_fn blk_co_flush(BlockBackend *blk);int blk_flush (BlockBackend *blk);int blk_commit_all (void );void blk_inc_in_flight (BlockBackend *blk);
Signature · 1 line
2.31.1
Eric Blake
Reviewed-byRe: [PATCH 13/12] block-backend: fix blk_co_flush prototype to mention coroutine_fn
Quoted 2 lines · Vladimir Sementsov-Ogievskiy
We do have this marker for
blk_co_flushfunction declaration inblock/block-backend.c. Add it in header too.
Maybe:
We alreaddy have this marker for the blk_co_flush function declaration in block/block-backend.c. Add it in the header, too.
Quoted 5 lines
Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
[PATCH 14/12] block-backend: update blk_co_pwrite() and blk_co_pread() wrappers
In reply to Vladimir Sementsov-OgievskiyMake bytes argument int64_t to be consistent with modern block-layer. Callers should be OK with it as type becomes wider.
What is inside functions?
- Conversion from int64_t to size_t. Still, we
can't have a buffer larger than SIZE_MAX, therefore bytes should not be larger than SIZE_MAX as well. Add and assertion.
- Passing to blk_co_pwritev() / blk_co_preadv() which already has int64_t bytes argument.
--- include/sysemu/block-backend.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
include/sysemu/block-backend.h +6 -2
@@ -137,20 +137,24 @@ int coroutine_fn blk_co_pwritev(BlockBackend *blk, int64_t offset, BdrvRequestFlags flags); static inline int coroutine_fn blk_co_pread(BlockBackend *blk, int64_t offset, -unsigned int bytes,void *buf, +int64_t bytes,void *buf,BdrvRequestFlags flags) {QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); +assert (bytes <=SIZE_MAX ); +return blk_co_preadv (blk, offset, bytes, &qiov, flags); } static inline int coroutine_fn blk_co_pwrite(BlockBackend *blk, int64_t offset, -unsigned int bytes,void *buf, +int64_t bytes,void *buf,BdrvRequestFlags flags) {QEMUIOVector qiov =QEMU_IOVEC_INIT_BUF (qiov, buf, bytes); +assert (bytes <=SIZE_MAX ); +return blk_co_pwritev (blk, offset, bytes, &qiov, flags); }
Signature · 1 line
2.31.1
Eric Blake
Reviewed-byRe: [PATCH 14/12] block-backend: update blk_co_pwrite() and blk_co_pread() wrappers
Quoted 8 lines · Vladimir Sementsov-Ogievskiy
Make bytes argument
int64_tto be consistent with modern block-layer. Callers should be OK with it as type becomes wider.What is inside functions?
- Conversion from
int64_ttosize_t. Still, we
can't have a buffer larger thanSIZE_MAX, therefore bytes should not be larger thanSIZE_MAXas well. Add and assertion.
s/and/an/
Quoted 9 lines
- Passing to
blk_co_pwritev()/blk_co_preadv()which already hasint64_tbytes argument.Signed-off-by Vladimir Sementsov-Ogievskiy <[email protected]>--- include/sysemu/block-backend.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org