virtio-blk: tidy up iothread_vq_mapping functions

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>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2025-03-11 21:26:12 +08:00 committed by Kevin Wolf
parent 366b5811d6
commit 2fa67a7b1d

View File

@ -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) {