mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
virtiofs: convert to use virtio_find_vqs_info()
Instead of passing separate names and callbacks arrays to virtio_find_vqs(), allocate one of virtual_queue_info structs and pass it to virtio_find_vqs_info(). Suggested-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com> Message-Id: <20240708074814.1739223-16-jiri@resnulli.us> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a6da214b7c
commit
fc496dcd93
@ -789,14 +789,13 @@ static void virtio_fs_init_vq(struct virtio_fs_vq *fsvq, char *name,
|
||||
static int virtio_fs_setup_vqs(struct virtio_device *vdev,
|
||||
struct virtio_fs *fs)
|
||||
{
|
||||
struct virtqueue_info *vqs_info;
|
||||
struct virtqueue **vqs;
|
||||
vq_callback_t **callbacks;
|
||||
/* Specify pre_vectors to ensure that the queues before the
|
||||
* request queues (e.g. hiprio) don't claim any of the CPUs in
|
||||
* the multi-queue mapping and interrupt affinities
|
||||
*/
|
||||
struct irq_affinity desc = { .pre_vectors = VQ_REQUEST };
|
||||
const char **names;
|
||||
unsigned int i;
|
||||
int ret = 0;
|
||||
|
||||
@ -814,20 +813,18 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
|
||||
return -ENOMEM;
|
||||
|
||||
vqs = kmalloc_array(fs->nvqs, sizeof(vqs[VQ_HIPRIO]), GFP_KERNEL);
|
||||
callbacks = kmalloc_array(fs->nvqs, sizeof(callbacks[VQ_HIPRIO]),
|
||||
GFP_KERNEL);
|
||||
names = kmalloc_array(fs->nvqs, sizeof(names[VQ_HIPRIO]), GFP_KERNEL);
|
||||
fs->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*fs->mq_map), GFP_KERNEL,
|
||||
dev_to_node(&vdev->dev));
|
||||
if (!vqs || !callbacks || !names || !fs->mq_map) {
|
||||
vqs_info = kcalloc(fs->nvqs, sizeof(*vqs_info), GFP_KERNEL);
|
||||
if (!vqs || !vqs_info || !fs->mq_map) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Initialize the hiprio/forget request virtqueue */
|
||||
callbacks[VQ_HIPRIO] = virtio_fs_vq_done;
|
||||
vqs_info[VQ_HIPRIO].callback = virtio_fs_vq_done;
|
||||
virtio_fs_init_vq(&fs->vqs[VQ_HIPRIO], "hiprio", VQ_HIPRIO);
|
||||
names[VQ_HIPRIO] = fs->vqs[VQ_HIPRIO].name;
|
||||
vqs_info[VQ_HIPRIO].name = fs->vqs[VQ_HIPRIO].name;
|
||||
|
||||
/* Initialize the requests virtqueues */
|
||||
for (i = VQ_REQUEST; i < fs->nvqs; i++) {
|
||||
@ -835,11 +832,11 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
|
||||
|
||||
snprintf(vq_name, VQ_NAME_LEN, "requests.%u", i - VQ_REQUEST);
|
||||
virtio_fs_init_vq(&fs->vqs[i], vq_name, VQ_REQUEST);
|
||||
callbacks[i] = virtio_fs_vq_done;
|
||||
names[i] = fs->vqs[i].name;
|
||||
vqs_info[i].callback = virtio_fs_vq_done;
|
||||
vqs_info[i].name = fs->vqs[i].name;
|
||||
}
|
||||
|
||||
ret = virtio_find_vqs(vdev, fs->nvqs, vqs, callbacks, names, &desc);
|
||||
ret = virtio_find_vqs_info(vdev, fs->nvqs, vqs, vqs_info, &desc);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
@ -848,8 +845,7 @@ static int virtio_fs_setup_vqs(struct virtio_device *vdev,
|
||||
|
||||
virtio_fs_start_all_queues(fs);
|
||||
out:
|
||||
kfree(names);
|
||||
kfree(callbacks);
|
||||
kfree(vqs_info);
|
||||
kfree(vqs);
|
||||
if (ret) {
|
||||
kfree(fs->vqs);
|
||||
|
Loading…
Reference in New Issue
Block a user