[PATCH 07/17] nvme-tcp: allocate socket file

Simon Horman horms at kernel.org
Fri Aug 11 03:19:50 PDT 2023


On Thu, Aug 10, 2023 at 05:06:20PM +0200, Hannes Reinecke wrote:
> 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 at suse.de>
> Reviewed-by: Sagi Grimberg <sagi at grimberg.me>

...

> @@ -1512,6 +1514,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
>  	struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
>  	struct nvme_tcp_queue *queue = &ctrl->queues[qid];
>  	int ret, rcv_pdu_size;
> +	struct file *sock_file;
>  
>  	mutex_init(&queue->queue_lock);
>  	queue->ctrl = ctrl;
> @@ -1534,6 +1537,13 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
>  		goto err_destroy_mutex;
>  	}
>  
> +	sock_file = sock_alloc_file(queue->sock, O_CLOEXEC, NULL);
> +	if (IS_ERR(sock_file)) {
> +		sock_release(queue->sock);

Hi Hannes,

Is it correct to call sock_release() here?
sock_alloc_file() already does so on error.

Flagged by Smatch.

> +		queue->sock = NULL;
> +		ret = PTR_ERR(sock_file);
> +		goto err_destroy_mutex;
> +	}
>  	nvme_tcp_reclassify_socket(queue->sock);
>  
>  	/* Single syn retry */

...



More information about the Linux-nvme mailing list