From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387204; b=gz1EAX/4f9QdSSDAh3VgB+7eHTbv+krizxeLl2odHPAgEBrcrt3T1NjFLRfIHRzCq4HX iF0BmrWl5Fv7J/COJd2BGkaAUdaUvPsh+IJLGo/ZGB5HEoKMfNSqX1hXVARrRKDp6WDSA 3YBqxYLW5JyfOkE6xPRv8tVnJqeXuRFMCznMl7fCNnkB0RVi1xsMF72QQd3y0NFoQc6fM BA2mNbzNFvw7sPhDnBdqZhGzoTQg+0o9MrClObA11t0yA2gt26DTxIxzRI7KPZuXgv1F8 Sjl3sIzTi9WmHk+5zosj2ht7VoAE+8506G1jO0jXeRfSmZ88kHHq3PyffOdCobI42uA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387204; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=J9bdc28c3YkUqmTmQsV2GYvtm6qYQhidAbNcCQepKqg=; b=w6jFIwctDbUm6muyoATliQE16l0yoEFaXgZNsIhZAXmSV5r2Ygmcj6QRd0WvFAuRf+TZ Sogl1TM3qIZIryRGPKCex3swDVPd6quHLATheA/OFlmAlWafzNUek/bC32xkus7Qq2Ir6 J+JyjySrXsiZZ4WAPNyqSqhZrwC8yL+m4ov9LqUqoFSb0z+huZ3JHadVCQ9ALjD4XWCIA +GZepRV2vssGJ+qa6i2fLs/gCb9YRexR47BVXDoIP4HOfC/9T3fpOCH4DK6aYK1sXE4iM sDjGBQRm5fjbHY+X/3Dx1KJ7hGPWXowApTMGcr8kbjH5reMXzIYfF7sC0sMGosXKPxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oIcKa5fZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFD92606A322; Fri, 4 Dec 2026 12:26:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=oIcKa5fZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E2B81F000C2; Fri, 4 Dec 2026 12:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387203; bh=J9bdc28c3YkUqmTmQsV2GYvtm6qYQhidAbNcCQepKqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oIcKa5fZGyt7rCJV55+inMFRdwi8GUgA7jXJVbrN6D0nD3WAM7LYcVwgfSlrjg1/I sauINzjzgD1m2XcGnFfbavEevy5Z8REGd305OuLqWA2WAGRpECVhmUHa7FI1Dd8z1Y kS/bI+5jb2zIHqgPTYUal9CtX8/5epKolP7EB/0I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Hannes Reinecke , Josef Bacik , Jens Axboe , Keith Busch , Sasha Levin Subject: [PATCH 6.1 0106/1059] nvmet-tcp: limit the connections accepted per work run Date: Fri, 4 Dec 2026 18:53:57 +0900 Message-ID: <20261204100646.946812015@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Josef Bacik [ Upstream commit a029f1b2fb13e6ac6e1c2f27fba1d80b6e7cac51 ] nvmet_tcp_accept_work() loops until there's nothing left to accept, and anyone opening and closing connections fast enough keeps it running indefinitely, since tearing down a dead connection takes long enough for more to arrive. Whoever flushes nvmet_wq waits for it: removing any other port of the target does in nvmet_port_release(), and so does unloading the rdma and fc modules. Accept a bounded number of connections per run and requeue the work. A flush doesn't wait for work queued behind it. Fixes: 872d26a391da ("nvmet-tcp: add NVMe over TCP target driver") Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Chaitanya Kulkarni Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Josef Bacik Signed-off-by: Jens Axboe Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/tcp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 608464d2f308b..e01eb43c7fbab 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -43,6 +43,7 @@ MODULE_PARM_DESC(idle_poll_period_usecs, #define NVMET_TCP_RECV_BUDGET 8 #define NVMET_TCP_SEND_BUDGET 8 #define NVMET_TCP_IO_WORK_BUDGET 64 +#define NVMET_TCP_ACCEPT_BUDGET 16 enum nvmet_tcp_send_state { NVMET_TCP_SEND_DATA_PDU, @@ -1765,9 +1766,9 @@ static void nvmet_tcp_accept_work(struct work_struct *w) struct nvmet_tcp_port *port = container_of(w, struct nvmet_tcp_port, accept_work); struct socket *newsock; - int ret; + int ret, i; - while (true) { + for (i = 0; i < NVMET_TCP_ACCEPT_BUDGET; i++) { ret = kernel_accept(port->sock, &newsock, O_NONBLOCK); if (ret < 0) { if (ret != -EAGAIN) @@ -1780,6 +1781,9 @@ static void nvmet_tcp_accept_work(struct work_struct *w) sock_release(newsock); } } + + /* There may be more. Come to an end for those who flush nvmet_wq. */ + queue_work(nvmet_wq, &port->accept_work); } static void nvmet_tcp_listen_data_ready(struct sock *sk) -- 2.53.0