From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E76B079ED for ; Mon, 17 Apr 2023 13:03:05 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 4351721A57; Mon, 17 Apr 2023 13:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681736584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iYef/rklckEOOoRoS9YtDsZpnqfPolj4nd30wQus9cQ=; b=BtS/LlZBNwRYMPDLx1Ptrq35kdns3VMskhAhENRiZ2yn+R5taAgrGVkrSSG0BwUbmbvG/Y NczPd31ad3324y/eSrHdHzVAuI0mkYpswEBlkgUWmuvyp1gkKM9UA1L00mQ7pzkGjRSdK1 YjfLy+j2dnNbxBbIhRk5RR75hnRj+WM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681736584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iYef/rklckEOOoRoS9YtDsZpnqfPolj4nd30wQus9cQ=; b=vnla7qf+NDolsesHg8+o4n7hTSJYKZKV3lCfItXzjAcrQpxLQGsI82L1Sw9vCrDihFn+Dp PiYj8p8hlMgSWbAA== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 338EF2C15A; Mon, 17 Apr 2023 13:03:04 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 3009151C25AE; Mon, 17 Apr 2023 15:03:04 +0200 (CEST) From: Hannes Reinecke To: Sagi Grimberg Cc: Christoph Hellwig , Keith Busch , linux-nvme@lists.infradead.org, Chuck Lever , kernel-tls-handshake@lists.linux.dev, Hannes Reinecke Subject: [PATCH 10/18] nvme/tcp: allocate socket file Date: Mon, 17 Apr 2023 15:02:54 +0200 Message-Id: <20230417130302.86274-11-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230417130302.86274-1-hare@suse.de> References: <20230417130302.86274-1-hare@suse.de> Precedence: bulk X-Mailing-List: kernel-tls-handshake@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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 732aa2296560..0a39743da4e4 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1321,7 +1321,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); @@ -1495,6 +1497,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; @@ -1517,6 +1520,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; + } nvme_tcp_reclassify_socket(queue->sock); /* Single syn retry */ @@ -1638,7 +1647,8 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nctrl, int qid) if (queue->hdr_digest || queue->data_digest) nvme_tcp_free_crypto(queue); err_sock: - sock_release(queue->sock); + /* ->sock will be released by fput() */ + fput(queue->sock->file); queue->sock = NULL; err_destroy_mutex: mutex_destroy(&queue->send_mutex); -- 2.35.3