[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <bda8a68e03830c672141f531de2e35542edc0f8f.1632156835.git.linux_oss@crudebyte.com>
Date: Mon, 20 Sep 2021 18:43:46 +0200
From: Christian Schoenebeck <linux_oss@...debyte.com>
To: v9fs-developer@...ts.sourceforge.net
Cc: netdev@...r.kernel.org,
Dominique Martinet <asmadeus@...ewreck.org>,
Eric Van Hensbergen <ericvh@...il.com>,
Latchesar Ionkov <lucho@...kov.net>,
Greg Kurz <groug@...d.org>, Vivek Goyal <vgoyal@...hat.com>
Subject: [PATCH v2 2/7] 9p/trans_virtio: separate allocation of scatter gather
list
The scatter gather list in struct virtio_chan currently
resides as compile-time constant size array directly within the
contiguous struct virtio_chan's memory space.
Separate memory space and allocation of the scatter gather list
from memory space and allocation of struct virtio_chan.
Signed-off-by: Christian Schoenebeck <linux_oss@...debyte.com>
---
net/9p/trans_virtio.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 490a4c900339..1dbe2e921bb8 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -77,7 +77,7 @@ struct virtio_chan {
*/
unsigned long p9_max_pages;
/* Scatterlist: can be too big for stack. */
- struct scatterlist sg[VIRTQUEUE_NUM];
+ struct scatterlist *sg;
/**
* @tag: name to identify a mount null terminated
*/
@@ -574,6 +574,14 @@ static int p9_virtio_probe(struct virtio_device *vdev)
goto fail;
}
+ chan->sg = kmalloc_array(VIRTQUEUE_NUM,
+ sizeof(struct scatterlist), GFP_KERNEL);
+ if (!chan->sg) {
+ pr_err("Failed to allocate virtio 9P channel\n");
+ err = -ENOMEM;
+ goto out_free_chan_shallow;
+ }
+
chan->vdev = vdev;
/* We expect one virtqueue, for requests. */
@@ -635,6 +643,8 @@ static int p9_virtio_probe(struct virtio_device *vdev)
out_free_vq:
vdev->config->del_vqs(vdev);
out_free_chan:
+ kfree(chan->sg);
+out_free_chan_shallow:
kfree(chan);
fail:
return err;
@@ -728,6 +738,7 @@ static void p9_virtio_remove(struct virtio_device *vdev)
kobject_uevent(&(vdev->dev.kobj), KOBJ_CHANGE);
kfree(chan->tag);
kfree(chan->vc_wq);
+ kfree(chan->sg);
kfree(chan);
}
--
2.20.1
Powered by blists - more mailing lists