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=1796384431; b=rA6EnpHZxmeAZ8AO9AWom6Lcu6tGR1WlGEL9ZAf7hvvIMz1Ej8bfoDOdAiZrGF/g+a5u 0alxlyoBoUUzduBOrYJ0QcxCr8+Dp3ygfKkbn04kxv+Sp2PTy8kHjAjAPjHz2NXvjkKXC A+Ra6oMaY3CWYyfq7zeQRIFZPXnoLk+jfzZSdhx2+VEW6TqIMfeoj+GJk73pdQrNVKTD4 o5DeWugqwfrSEG4b1F1qO5RFnOcYkEibTF1uHmVHTbZpLtPQRnOgwhEf1xuNFsOGi7N7u EuRjhRtG012BQtbH3B7nsmtPNnW4s4/4fl+MdNjH0D9BMLVf+awFzhnjcc+nqXzP7Zw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384431; 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=FlOfTeG3bpT1gqBeLEZpDkpP1hqh2bUTPKJNtYveqlw=; b=TgAy88bGIhigVDg90vjiTe+Nz64zYOlCfDeHJEN54utPHQ2ljLJ/KFZ5wgPirxKrnSU6 JpzAsrSNJFyrGXzR2TEjEE9xC5N6bT/jHcx4CGhd/m6+ZKM6/sem71ieHYVA4b4u+CwZW KlOZ18eCfBZPKGcqf87sLL6p54MbiqB3ik4kLIBb7YckPlZAEFsqLT1AI78AGZ3u39/T3 FFccu8R6/KsfJHeRuvt51Q+KJ/+Djkk5etb8fjkgz/HJANXTERdf3GCsGMt9AOkctZKWv SnE5j+BxBkjn/LUuB0vpha/UehWuRlUjikk8tHmZvSwroZAD2JsiBgkyxHqwSsS9JsQ== 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=LSqlt34X; 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 9FEF3606A322; Fri, 4 Dec 2026 11:40:31 +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=LSqlt34X Received: by smtp.kernel.org (Postfix) with ESMTPSA id 177711F000C2; Fri, 4 Dec 2026 11:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384431; bh=FlOfTeG3bpT1gqBeLEZpDkpP1hqh2bUTPKJNtYveqlw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LSqlt34X54Bj84thmOIbL/jSDDie5VAI8BYiMXdjBsLoxwYNhKEyUKqGbn24Io3L+ ArRDxeeGmeMB93gJyBOdcxPI3pQC4NKv3TY7RVFPj8G++k/qwBsrIHc7zISNStaEp5 BBaxv2k5RfrLRqRyHSUvSxI5cLR2WbXLFk6xgiGE= 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.6 0145/1167] nvmet-tcp: limit the connections accepted per work run Date: Fri, 4 Dec 2026 18:52:52 +0900 Message-ID: <20261204100705.864951695@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-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 7134c54592dcd..9a7ee3f0c7073 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -70,6 +70,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, @@ -1816,9 +1817,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) @@ -1827,6 +1828,9 @@ static void nvmet_tcp_accept_work(struct work_struct *w) } nvmet_tcp_alloc_queue(port, 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