Re: [PATCH 06/18] nvme/tcp: allocate socket file

Sagi Grimberg
2023-03-29T15:57:18Z

> When using the TLS upcall we need to allocate a socket file such
> that the userspace daemon is able to use the socket.
>
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> ---
> drivers/nvme/host/tcp.c | 17 +++++++++++++++--
> 1 file changed, 15 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
> index 42c0598c31f2..fddf785aba74 100644
> --- a/drivers/nvme/host/tcp.c
> +++ b/drivers/nvme/host/tcp.c
> @@ -115,6 +115,7 @@ enum nvme_tcp_recv_state {
> struct nvme_tcp_ctrl;
> struct nvme_tcp_queue {
> struct socket *sock;
> + struct file *sock_file;

I think that sock->file is storing the file, no need to store it as
well.

> struct work_struct io_work;
> int io_cpu;
>
> @@ -1330,7 +1331,10 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
> }
>
> noreclaim_flag = memalloc_noreclaim_save();
> - sock_release(queue->sock);
> + /* ->sock will be released by fput() */
> + fput(queue->sock_file);
> + queue->sock_file = NULL;
> + queue->sock = NULL;

Is the queue->sock = NULL here required because we allocate a sock_file?