From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 1F6B623CD for ; Wed, 19 Apr 2023 06:57:21 +0000 (UTC) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 4459C1FD87; Wed, 19 Apr 2023 06:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681887438; 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=+CSZpfqW3pvsHdj/giiXOazZVwbGUB3k6ooMf+//vEA=; b=N1q/411EDkmqAV36YVa16F6AzJijc+U2V/TRbjIQfxQmG0gdkQrEINEe5COfWpPYj2IoTr hjgmeASKadkURW+tWkxOFP9omv9zF/izV8pqzSj7nnp67Am2UPLI0Dqtp9EIoWTlWAcpin xg36M/JPm/F2+v169p63ybqWmpWtBrI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681887438; 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=+CSZpfqW3pvsHdj/giiXOazZVwbGUB3k6ooMf+//vEA=; b=p2iww5GoPHOBZMJHKK90SIXD1JxOlUN6J1B7EUNcxovQI7+QPmIb7xl1jhT0Nj2T7a5XQi 5brk4XOnEAP2WADQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 2E72A2C152; Wed, 19 Apr 2023 06:57:18 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 1DC8651C26DB; Wed, 19 Apr 2023 08:57:18 +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/17] nvme/tcp: allocate socket file Date: Wed, 19 Apr 2023 08:57:07 +0200 Message-Id: <20230419065714.52076-11-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230419065714.52076-1-hare@suse.de> References: <20230419065714.52076-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 9ecd7db2cd98..9deba481ae6a 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -1331,7 +1331,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); @@ -1505,6 +1507,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; @@ -1527,6 +1530,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 */ @@ -1648,7 +1657,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