[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 6/8] block-backend: inline bdrv_co_get_geometry
From: |
Eric Blake |
Subject: |
Re: [PATCH 6/8] block-backend: inline bdrv_co_get_geometry |
Date: |
Fri, 7 Apr 2023 14:58:25 -0500 |
User-agent: |
NeoMutt/20230322 |
On Fri, Apr 07, 2023 at 05:33:01PM +0200, Paolo Bonzini wrote:
> bdrv_co_get_geometry is only used in blk_co_get_geometry. Inline it in
> there, to reduce the number of wrappers for bs->total_sectors.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> block.c | 10 ----------
> block/block-backend.c | 8 ++++++--
> include/block/block-io.h | 3 ---
> 3 files changed, 6 insertions(+), 15 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
>
> diff --git a/block.c b/block.c
> index 9de50ac7c811..dbbc8de30c24 100644
> --- a/block.c
> +++ b/block.c
> @@ -5879,16 +5879,6 @@ int64_t coroutine_fn
> bdrv_co_getlength(BlockDriverState *bs)
> return ret * BDRV_SECTOR_SIZE;
> }
>
> -/* return 0 as number of sectors if no device present or error */
> -void coroutine_fn bdrv_co_get_geometry(BlockDriverState *bs,
> - uint64_t *nb_sectors_ptr)
> -{
> - int64_t nb_sectors = bdrv_co_nb_sectors(bs);
> - IO_CODE();
Pre-patch, we called bdrv_co_nb_sectors() before the IO_CODE guard...
> +/* return 0 as number of sectors if no device present or error */
> void coroutine_fn blk_co_get_geometry(BlockBackend *blk,
> uint64_t *nb_sectors_ptr)
> {
> + BlockDriverState *bs = blk_bs(blk);
> +
> IO_CODE();
> GRAPH_RDLOCK_GUARD();
>
> - if (!blk_bs(blk)) {
> + if (!bs) {
> *nb_sectors_ptr = 0;
> } else {
> - bdrv_co_get_geometry(blk_bs(blk), nb_sectors_ptr);
> + int64_t nb_sectors = bdrv_co_nb_sectors(bs);
...post-patch the order swaps. That actually feels better to me, (the
guard is supposed to do sanity checks to detect coding bugs at the
soonest possible moment; if we have a bug, doing the work and only
later failing the check is not as safe as failing fast) - but probably
no impact to correctly written code.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
- Re: [PATCH 1/8] block: move has_variable_length to BlockLimits, (continued)
- [PATCH 2/8] block: remove has_variable_length from filters, Paolo Bonzini, 2023/04/07
- [PATCH 3/8] block: refresh bs->total_sectors on reopen, Paolo Bonzini, 2023/04/07
- [PATCH 5/8] migration/block: replace uses of blk_nb_sectors that do not check result, Paolo Bonzini, 2023/04/07
- [PATCH 4/8] block: remove has_variable_length from BlockDriver, Paolo Bonzini, 2023/04/07
- [PATCH 6/8] block-backend: inline bdrv_co_get_geometry, Paolo Bonzini, 2023/04/07
- Re: [PATCH 6/8] block-backend: inline bdrv_co_get_geometry,
Eric Blake <=
- [PATCH 8/8] block, block-backend: write some hot coroutine wrappers by hand, Paolo Bonzini, 2023/04/07
- [PATCH 7/8] block-backend: ignore inserted state in blk_co_nb_sectors, Paolo Bonzini, 2023/04/07
- Re: [PATCH 8.0 regression 0/8] block: remove bdrv_co_get_geometry coroutines from I/O hot path, Kevin Wolf, 2023/04/11