diff options
author | Emanuele Giuseppe Esposito | 2022-10-25 10:49:45 +0200 |
---|---|---|
committer | Kevin Wolf | 2022-10-27 20:14:11 +0200 |
commit | e08cc001d502958040565636e19a42c06e1ae8b7 (patch) | |
tree | d775af529b1d7d598993d80c95ad1a30907d6a47 /include | |
parent | block: use transactions as a replacement of ->{can_}set_aio_context() (diff) | |
download | qemu-e08cc001d502958040565636e19a42c06e1ae8b7.tar.gz qemu-e08cc001d502958040565636e19a42c06e1ae8b7.tar.xz qemu-e08cc001d502958040565636e19a42c06e1ae8b7.zip |
bdrv_change_aio_context: use hash table instead of list of visited nodes
Minor performance improvement, but given that we have hash tables
available, avoid iterating in the visited nodes list every time just
to check if a node has been already visited.
The data structure is not actually a proper hash map, but an hash set,
as we are just adding nodes and not key,value pairs.
Suggested-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221025084952.2139888-4-eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/block/block-global-state.h | 2 | ||||
-rw-r--r-- | include/block/block_int-common.h | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h index 7b0095b419..e7372ec541 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -233,7 +233,7 @@ bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx, AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c); bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx, - GSList **visited, Transaction *tran, + GHashTable *visited, Transaction *tran, Error **errp); int bdrv_child_try_change_aio_context(BlockDriverState *bs, AioContext *ctx, BdrvChild *ignore_child, Error **errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 9067a99249..7ccbbdae05 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -911,7 +911,8 @@ struct BdrvChildClass { void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore); bool (*change_aio_ctx)(BdrvChild *child, AioContext *ctx, - GSList **visited, Transaction *tran, Error **errp); + GHashTable *visited, Transaction *tran, + Error **errp); AioContext *(*get_parent_aio_context)(BdrvChild *child); |