[PATCH 07/14] nvme/tcp: allocate socket file

Hannes Reinecke hare at suse.de
Mon Aug 7 00:23:35 PDT 2023


On 8/7/23 09:15, Sagi Grimberg wrote:
> 
> 
> On 8/3/23 13:50, 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>
>> ---
>>   drivers/nvme/host/tcp.c | 14 ++++++++++++--
>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c
>> index 9ce417cd32a7..c3b3b938c0f9 100644
>> --- a/drivers/nvme/host/tcp.c
>> +++ b/drivers/nvme/host/tcp.c
>> @@ -1338,7 +1338,9 @@ 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 = NULL;
>>       memalloc_noreclaim_restore(noreclaim_flag);
>>       kfree(queue->pdu);
>> @@ -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,12 @@ 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);
>> +        ret = PTR_ERR(sock_file);
>> +        goto err_sock;
> 
> Is it safe to fput() an error sock file?
> 
Probably not. I'll fix it up.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman




More information about the Linux-nvme mailing list