[PATCH 09/12] block-backend: convert blk_co_copy_range to int64_t bytes

Vladimir Sementsov-Ogievskiy posted 12 patches 4 years, 4 months ago
Maintainers: Cleber Rosa <crosa@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
[PATCH 09/12] block-backend: convert blk_co_copy_range to int64_t bytes
Posted by Vladimir Sementsov-Ogievskiy 4 years, 4 months ago
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 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().

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 include/sysemu/block-backend.h | 2 +-
 block/block-backend.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 69f5cfb1c5..134c442754 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -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);
diff --git a/block/block-backend.c b/block/block-backend.c
index 018684a203..f051ea00e9 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -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;
-- 
2.31.1


Re: [PATCH 09/12] block-backend: convert blk_co_copy_range to int64_t bytes
Posted by Eric Blake 4 years, 4 months ago
On Wed, Oct 06, 2021 at 03:17:15PM +0200, Vladimir Sementsov-Ogievskiy wrote:
> 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 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().
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  include/sysemu/block-backend.h | 2 +-
>  block/block-backend.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org