[1/2] block/block-backend: add converter from BlockAcctStats to BlockBackend
diff mbox series

Message ID 20200710172711.8059-2-den@openvz.org
State New
Headers show
Series
  • block: add logging facility for long standing IO requests
Related show

Commit Message

Denis V. Lunev July 10, 2020, 5:27 p.m. UTC
Right now BlockAcctStats is always reside on BlockBackend. This structure
is not used in any other place. Thus we are able to create a converter
from one pointer to another.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
---
 block/block-backend.c          | 5 +++++
 include/sysemu/block-backend.h | 1 +
 2 files changed, 6 insertions(+)

Comments

Vladimir Sementsov-Ogievskiy July 11, 2020, 10:05 a.m. UTC | #1
10.07.2020 20:27, Denis V. Lunev wrote:
> Right now BlockAcctStats is always reside on BlockBackend. This structure
> is not used in any other place. Thus we are able to create a converter
> from one pointer to another.
> 
> Signed-off-by: Denis V. Lunev <den@openvz.org>
> CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> CC: Kevin Wolf <kwolf@redhat.com>
> CC: Max Reitz <mreitz@redhat.com>
> ---
>   block/block-backend.c          | 5 +++++
>   include/sysemu/block-backend.h | 1 +
>   2 files changed, 6 insertions(+)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 6936b25c83..e77a7e468e 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -2143,6 +2143,11 @@ BlockAcctStats *blk_get_stats(BlockBackend *blk)
>       return &blk->stats;
>   }
>   
> +BlockBackend *blk_stats2blk(BlockAcctStats *s)
> +{
> +    return container_of(s, BlockBackend, stats);
> +}
> +
>   void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
>                     BlockCompletionFunc *cb, void *opaque)
>   {
> diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
> index 8203d7f6f9..bd4694e7bc 100644
> --- a/include/sysemu/block-backend.h
> +++ b/include/sysemu/block-backend.h
> @@ -227,6 +227,7 @@ void blk_add_insert_bs_notifier(BlockBackend *blk, Notifier *notify);
>   void blk_io_plug(BlockBackend *blk);
>   void blk_io_unplug(BlockBackend *blk);
>   BlockAcctStats *blk_get_stats(BlockBackend *blk);
> +BlockBackend *blk_stats2blk(BlockAcctStats *stats);
>   BlockBackendRootState *blk_get_root_state(BlockBackend *blk);
>   void blk_update_root_state(BlockBackend *blk);
>   bool blk_get_detect_zeroes_from_root_state(BlockBackend *blk);
> 

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Patch
diff mbox series

diff --git a/block/block-backend.c b/block/block-backend.c
index 6936b25c83..e77a7e468e 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2143,6 +2143,11 @@  BlockAcctStats *blk_get_stats(BlockBackend *blk)
     return &blk->stats;
 }
 
+BlockBackend *blk_stats2blk(BlockAcctStats *s)
+{
+    return container_of(s, BlockBackend, stats);
+}
+
 void *blk_aio_get(const AIOCBInfo *aiocb_info, BlockBackend *blk,
                   BlockCompletionFunc *cb, void *opaque)
 {
diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h
index 8203d7f6f9..bd4694e7bc 100644
--- a/include/sysemu/block-backend.h
+++ b/include/sysemu/block-backend.h
@@ -227,6 +227,7 @@  void blk_add_insert_bs_notifier(BlockBackend *blk, Notifier *notify);
 void blk_io_plug(BlockBackend *blk);
 void blk_io_unplug(BlockBackend *blk);
 BlockAcctStats *blk_get_stats(BlockBackend *blk);
+BlockBackend *blk_stats2blk(BlockAcctStats *stats);
 BlockBackendRootState *blk_get_root_state(BlockBackend *blk);
 void blk_update_root_state(BlockBackend *blk);
 bool blk_get_detect_zeroes_from_root_state(BlockBackend *blk);