From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4D444C00528 for ; Thu, 3 Aug 2023 10:53:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NccFubh2TaATVxU8i8TvzFH/BZl87WpBWeAni0Hg+2Y=; b=A4wau6WWMV/GXIo3YTqsZigEXK 9eaYJcUR36XEBnl1Z0fRQj3C8PkrLTZ/3dXRZtbVhA8zHe7MBRiF62fqfApqaDUB7D5DN3kpNr9UV nB6hmhUMdsp8kFn9ZtYha6r3L3C4IRb1JianXMIy4sqIJOJOGKuLB/NoUolfVIeiniwmiucPXNFie p/YjM351AZZqxkax6UFuajaaRexaLWBefa82Bxo21FmCGjsZPZNoU0c+tbnIq0W+cZ7vgrd3LCn+7 vo9C2X19piJtWOw+VSn+nuJF01DO0LKy2XEESIDpy754l1N0KMZq8AY9Zm2nnU4f2gVeQpejUnRXB 9Kmu6U4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRVxF-007XD2-0c; Thu, 03 Aug 2023 10:53:17 +0000 Received: from smtp-out2.suse.de ([195.135.220.29]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRVx8-007X7u-2p for linux-nvme@lists.infradead.org; Thu, 03 Aug 2023 10:53:14 +0000 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 8D3991F891; Thu, 3 Aug 2023 10:53:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691059989; 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=NccFubh2TaATVxU8i8TvzFH/BZl87WpBWeAni0Hg+2Y=; b=lpvFHoSHKq4RW/2nBR96CrEUIPII1l0+6Tvw1teviHrlmknhzKe+4UNi4Ml15B0McYzyRq ichlCfsKf+k3jurKhn+Az3iyps2KgmhuQSj3uS0k9WqR3Eoh80yMj9oN4JrFezNtzt6UTJ ii0pjm4Ife6MmqUjGLGMhOIFYdxOdSE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691059989; 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=NccFubh2TaATVxU8i8TvzFH/BZl87WpBWeAni0Hg+2Y=; b=oi6WadRH4bG5asrS/kTCQ3A3Tq1OgXheB+OQfFtcfOmsYtl297etS5Kqxi0WXYVg9K3muP lJ4P1t9UJNxG+dBQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id 80DFD2C15C; Thu, 3 Aug 2023 10:53:09 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 16045) id 7DAA351CA7D7; Thu, 3 Aug 2023 12:53:09 +0200 (CEST) From: Hannes Reinecke To: Christoph Hellwig Cc: Sagi Grimberg , Keith Busch , linux-nvme@lists.infradead.org, Hannes Reinecke Subject: [PATCH 12/14] nvmet-tcp: allocate socket file Date: Thu, 3 Aug 2023 12:51:00 +0200 Message-Id: <20230803105102.30949-13-hare@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230803105102.30949-1-hare@suse.de> References: <20230803105102.30949-1-hare@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230803_035311_138599_A762623D X-CRM114-Status: GOOD ( 15.21 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org For 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/target/tcp.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 868aa4de2e4c..fdc351f591a4 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -1493,12 +1493,12 @@ static void nvmet_tcp_release_queue_work(struct work_struct *w) nvmet_sq_destroy(&queue->nvme_sq); cancel_work_sync(&queue->io_work); nvmet_tcp_free_cmd_data_in_buffers(queue); - sock_release(queue->sock); + /* ->sock will be released by fput() */ + fput(queue->sock->file); nvmet_tcp_free_cmds(queue); if (queue->hdr_digest || queue->data_digest) nvmet_tcp_free_crypto(queue); ida_free(&nvmet_tcp_queue_ida, queue->idx); - page = virt_to_head_page(queue->pf_cache.va); __page_frag_cache_drain(page, queue->pf_cache.pagecnt_bias); kfree(queue); @@ -1621,15 +1621,16 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue) return ret; } -static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, +static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, struct socket *newsock) { struct nvmet_tcp_queue *queue; + struct file *sock_file; int ret; queue = kzalloc(sizeof(*queue), GFP_KERNEL); if (!queue) - return -ENOMEM; + return; INIT_WORK(&queue->release_work, nvmet_tcp_release_queue_work); INIT_WORK(&queue->io_work, nvmet_tcp_io_work); @@ -1642,10 +1643,16 @@ static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, init_llist_head(&queue->resp_list); INIT_LIST_HEAD(&queue->resp_send_list); + sock_file = sock_alloc_file(queue->sock, O_CLOEXEC, NULL); + if (IS_ERR(sock_file)) { + ret = PTR_ERR(sock_file); + goto out_free_queue; + } + queue->idx = ida_alloc(&nvmet_tcp_queue_ida, GFP_KERNEL); if (queue->idx < 0) { ret = queue->idx; - goto out_free_queue; + goto out_sock; } ret = nvmet_tcp_alloc_cmd(queue, &queue->connect); @@ -1666,7 +1673,7 @@ static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, if (ret) goto out_destroy_sq; - return 0; + return; out_destroy_sq: mutex_lock(&nvmet_tcp_queue_mutex); list_del_init(&queue->queue_list); @@ -1676,9 +1683,11 @@ static int nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, nvmet_tcp_free_cmd(&queue->connect); out_ida_remove: ida_free(&nvmet_tcp_queue_ida, queue->idx); +out_sock: + fput(queue->sock->file); out_free_queue: kfree(queue); - return ret; + pr_err("failed to allocate queue"); } static void nvmet_tcp_accept_work(struct work_struct *w) @@ -1695,11 +1704,7 @@ static void nvmet_tcp_accept_work(struct work_struct *w) pr_warn("failed to accept err=%d\n", ret); return; } - ret = nvmet_tcp_alloc_queue(port, newsock); - if (ret) { - pr_err("failed to allocate queue\n"); - sock_release(newsock); - } + nvmet_tcp_alloc_queue(port, newsock); } } -- 2.35.3