Skip to content

Commit e40d4eb

Browse files
hreineckekeithbusch
authored andcommitted
nvme-tcp: allocate socket file
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 <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 037c343 commit e40d4eb

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/nvme/host/tcp.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,9 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)
13381338
}
13391339

13401340
noreclaim_flag = memalloc_noreclaim_save();
1341-
sock_release(queue->sock);
1341+
/* ->sock will be released by fput() */
1342+
fput(queue->sock->file);
1343+
queue->sock = NULL;
13421344
memalloc_noreclaim_restore(noreclaim_flag);
13431345

13441346
kfree(queue->pdu);
@@ -1512,6 +1514,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
15121514
struct nvme_tcp_ctrl *ctrl = to_tcp_ctrl(nctrl);
15131515
struct nvme_tcp_queue *queue = &ctrl->queues[qid];
15141516
int ret, rcv_pdu_size;
1517+
struct file *sock_file;
15151518

15161519
mutex_init(&queue->queue_lock);
15171520
queue->ctrl = ctrl;
@@ -1534,6 +1537,11 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
15341537
goto err_destroy_mutex;
15351538
}
15361539

1540+
sock_file = sock_alloc_file(queue->sock, O_CLOEXEC, NULL);
1541+
if (IS_ERR(sock_file)) {
1542+
ret = PTR_ERR(sock_file);
1543+
goto err_destroy_mutex;
1544+
}
15371545
nvme_tcp_reclassify_socket(queue->sock);
15381546

15391547
/* Single syn retry */
@@ -1640,7 +1648,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid)
16401648
if (queue->hdr_digest || queue->data_digest)
16411649
nvme_tcp_free_crypto(queue);
16421650
err_sock:
1643-
sock_release(queue->sock);
1651+
/* ->sock will be released by fput() */
1652+
fput(queue->sock->file);
16441653
queue->sock = NULL;
16451654
err_destroy_mutex:
16461655
mutex_destroy(&queue->send_mutex);

0 commit comments

Comments
 (0)