qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 18/22] virtio-blk: tidy up iothread_vq_mapping functions
Date: Tue, 11 Mar 2025 17:00:17 +0100	[thread overview]
Message-ID: <20250311160021.349761-19-kwolf@redhat.com> (raw)
In-Reply-To: <20250311160021.349761-1-kwolf@redhat.com>

From: Stefan Hajnoczi <stefanha@redhat.com>

Use noun_verb() function naming instead of verb_noun() because the
former is the most common naming style for APIs. The next commit will
move these functions into a header file so that virtio-scsi can call
them.

Shorten iothread_vq_mapping_apply()'s iothread_vq_mapping_list argument
to just "list" like in the other functions.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20250311132616.1049687-10-stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/block/virtio-blk.c | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 21b1b768ed..6bf7b50520 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -1424,8 +1424,8 @@ static const BlockDevOps virtio_block_ops = {
 };
 
 static bool
-validate_iothread_vq_mapping_list(IOThreadVirtQueueMappingList *list,
-        uint16_t num_queues, Error **errp)
+iothread_vq_mapping_validate(IOThreadVirtQueueMappingList *list, uint16_t
+        num_queues, Error **errp)
 {
     g_autofree unsigned long *vqs = bitmap_new(num_queues);
     g_autoptr(GHashTable) iothreads =
@@ -1486,22 +1486,22 @@ validate_iothread_vq_mapping_list(IOThreadVirtQueueMappingList *list,
 }
 
 /**
- * apply_iothread_vq_mapping:
- * @iothread_vq_mapping_list: The mapping of virtqueues to IOThreads.
+ * iothread_vq_mapping_apply:
+ * @list: The mapping of virtqueues to IOThreads.
  * @vq_aio_context: The array of AioContext pointers to fill in.
  * @num_queues: The length of @vq_aio_context.
  * @errp: If an error occurs, a pointer to the area to store the error.
  *
  * Fill in the AioContext for each virtqueue in the @vq_aio_context array given
- * the iothread-vq-mapping parameter in @iothread_vq_mapping_list.
+ * the iothread-vq-mapping parameter in @list.
  *
- * cleanup_iothread_vq_mapping() must be called to free IOThread object
+ * iothread_vq_mapping_cleanup() must be called to free IOThread object
  * references after this function returns success.
  *
  * Returns: %true on success, %false on failure.
  **/
-static bool apply_iothread_vq_mapping(
-        IOThreadVirtQueueMappingList *iothread_vq_mapping_list,
+static bool iothread_vq_mapping_apply(
+        IOThreadVirtQueueMappingList *list,
         AioContext **vq_aio_context,
         uint16_t num_queues,
         Error **errp)
@@ -1510,16 +1510,15 @@ static bool apply_iothread_vq_mapping(
     size_t num_iothreads = 0;
     size_t cur_iothread = 0;
 
-    if (!validate_iothread_vq_mapping_list(iothread_vq_mapping_list,
-                                           num_queues, errp)) {
+    if (!iothread_vq_mapping_validate(list, num_queues, errp)) {
         return false;
     }
 
-    for (node = iothread_vq_mapping_list; node; node = node->next) {
+    for (node = list; node; node = node->next) {
         num_iothreads++;
     }
 
-    for (node = iothread_vq_mapping_list; node; node = node->next) {
+    for (node = list; node; node = node->next) {
         IOThread *iothread = iothread_by_id(node->value->iothread);
         AioContext *ctx = iothread_get_aio_context(iothread);
 
@@ -1549,13 +1548,13 @@ static bool apply_iothread_vq_mapping(
 }
 
 /**
- * cleanup_iothread_vq_mapping:
+ * iothread_vq_mapping_cleanup:
  * @list: The mapping of virtqueues to IOThreads.
  *
  * Release IOThread object references that were acquired by
- * apply_iothread_vq_mapping().
+ * iothread_vq_mapping_apply().
  */
-static void cleanup_iothread_vq_mapping(IOThreadVirtQueueMappingList *list)
+static void iothread_vq_mapping_cleanup(IOThreadVirtQueueMappingList *list)
 {
     IOThreadVirtQueueMappingList *node;
 
@@ -1597,7 +1596,7 @@ static bool virtio_blk_vq_aio_context_init(VirtIOBlock *s, Error **errp)
     s->vq_aio_context = g_new(AioContext *, conf->num_queues);
 
     if (conf->iothread_vq_mapping_list) {
-        if (!apply_iothread_vq_mapping(conf->iothread_vq_mapping_list,
+        if (!iothread_vq_mapping_apply(conf->iothread_vq_mapping_list,
                                        s->vq_aio_context,
                                        conf->num_queues,
                                        errp)) {
@@ -1631,7 +1630,7 @@ static void virtio_blk_vq_aio_context_cleanup(VirtIOBlock *s)
     assert(!s->ioeventfd_started);
 
     if (conf->iothread_vq_mapping_list) {
-        cleanup_iothread_vq_mapping(conf->iothread_vq_mapping_list);
+        iothread_vq_mapping_cleanup(conf->iothread_vq_mapping_list);
     }
 
     if (conf->iothread) {
-- 
2.48.1



  parent reply	other threads:[~2025-03-11 16:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-11 15:59 [PULL 00/22] Block layer patches Kevin Wolf
2025-03-11 16:00 ` [PULL 01/22] block: Remove unused blk_op_is_blocked() Kevin Wolf
2025-03-11 16:00 ` [PULL 02/22] block: Zero block driver state before reopening Kevin Wolf
2025-03-11 16:00 ` [PULL 03/22] file-posix: Support FUA writes Kevin Wolf
2025-03-11 16:00 ` [PULL 04/22] block/io: Ignore FUA with cache.no-flush=on Kevin Wolf
2025-03-11 16:00 ` [PULL 05/22] aio: Create AioPolledEvent Kevin Wolf
2025-03-11 16:00 ` [PULL 06/22] aio-posix: Factor out adjust_polling_time() Kevin Wolf
2025-03-11 16:00 ` [PULL 07/22] aio-posix: Separate AioPolledEvent per AioHandler Kevin Wolf
2025-03-11 16:00 ` [PULL 08/22] aio-posix: Adjust polling time also for new handlers Kevin Wolf
2025-03-11 16:00 ` [PULL 09/22] iotests: Limit qsd-migrate to working formats Kevin Wolf
2025-03-11 16:00 ` [PULL 10/22] scsi-disk: drop unused SCSIDiskState->bh field Kevin Wolf
2025-03-11 16:00 ` [PULL 11/22] dma: use current AioContext for dma_blk_io() Kevin Wolf
2025-03-11 16:00 ` [PULL 12/22] scsi: track per-SCSIRequest AioContext Kevin Wolf
2025-03-11 16:00 ` [PULL 13/22] scsi: introduce requests_lock Kevin Wolf
2025-03-11 16:00 ` [PULL 14/22] virtio-scsi: introduce event and ctrl virtqueue locks Kevin Wolf
2025-03-11 16:00 ` [PULL 15/22] virtio-scsi: protect events_dropped field Kevin Wolf
2025-03-11 16:00 ` [PULL 16/22] virtio-scsi: perform TMFs in appropriate AioContexts Kevin Wolf
2025-03-11 16:00 ` [PULL 17/22] virtio-blk: extract cleanup_iothread_vq_mapping() function Kevin Wolf
2025-03-11 16:00 ` Kevin Wolf [this message]
2025-03-11 16:00 ` [PULL 19/22] virtio: extract iothread-vq-mapping.h API Kevin Wolf
2025-03-11 16:00 ` [PULL 20/22] virtio-scsi: add iothread-vq-mapping parameter Kevin Wolf
2025-03-26 10:43   ` Thomas Huth
2025-04-24  9:39     ` iotest 240 is failing (was: Re: [PULL 20/22] virtio-scsi: add iothread-vq-mapping parameter) Thomas Huth
2025-05-16  7:21       ` iotest 240 is failing Thomas Huth
2025-05-20 14:00         ` Stefan Hajnoczi
2025-03-11 16:00 ` [PULL 21/22] virtio-scsi: handle ctrl virtqueue in main loop Kevin Wolf
2025-03-11 16:00 ` [PULL 22/22] virtio-scsi: only expose cmd vqs via iothread-vq-mapping Kevin Wolf
2025-03-12 13:40 ` [PULL 00/22] Block layer patches Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311160021.349761-19-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).