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=1795621495; b=CmxofKW1PXttSBPG9jzlZl8ZZVC6A42drO+6VPt73A6HthRH37N4OKIxBwrpqmMuQZCR h0ib5hjK7O7bWYCXrU42KxLtDr7STc1YiU5uIRGXaUgU9LTsZ1SDXZCFFb/a2BgJCRWuP I1LOkRZE5pdlNmdzxb8H5SWox2AxjHS6zJ727AFltdeiESAAQpVyRC1Y7pe1bGh9ZQnwA ArAqefwlz+w9fguJnA4V6e9x5EDhs1Ly1llFMJCPJ9wdYy2UMqgRNBrx5fKgf173Oj/zN bXhFuqyjCEE+/maZnjOGEsIeQDMfLlrYZkijRpi2fe/Lv1TGhgMb6cKL83GMwY6Klew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795621495; 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=n3fpRJPnLtCi71P0i416eJJaGWSVTRo6yGEoyK/a7do=; b=FeI8c2wog+zldBMHPfGH4XsOIZiqOPe9DT9khC8RFxCGhi8bY8sKauqYHYPDfN1F9bWf c2R9/jscznNRRiToOBR6Wbx+CSpYIbUsIp1yMWExY3WlEmyjhPodj8JxsonX0qpGhhnMp 86O4feZMx97MyEFy/B/TPWM/WtuMeCf0sziN8TKitkAxXGLW44znvqGFwmpZ5QloL0fH9 vlU/JhHSjbb3N/mgSqfMgNfXWjiSu1AMyc/doVNMr4/V/vXFyhAyuc6Aqgl70Ro6+VOga HLI61Tv5yFUEnz6nivsrudc3Ec5GHCEqQ5HuRLK1gA5glBRYmizvJyXcMt0OuBUEAoQ== 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=F5fDn+xd; 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 B03A7606A326; Wed, 25 Nov 2026 15:44:55 +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=F5fDn+xd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 135C81F000C6; Wed, 25 Nov 2026 15:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795621495; bh=n3fpRJPnLtCi71P0i416eJJaGWSVTRo6yGEoyK/a7do=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F5fDn+xduQ8rJoa2aZG2w1GETt7gf8wiXMsSQ6iHGJOvCaBWrYjTTyGw87naSEtJX medAephIoZa0VEsUaGP+8JW1NFczjRWux8BzSoSrC74FSnLIC3Wc29LgY7is0JGImi dd+AVavdqPYyC7sEpV6uvXFXGYVI3WokXudQTbfk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Chris Mason , Jens Axboe , Keith Busch , Sasha Levin Subject: [PATCH 6.18 242/990] nvmet-rdma: disconnect a queue on device removal Date: Wed, 25 Nov 2026 15:26:49 +0100 Message-ID: <20261125143827.758898671@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261125143822.072087159@linuxfoundation.org> References: <20261125143822.072087159@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Mason [ Upstream commit a4387799d4228866dc1746b466cd17e1c638d050 ] cma_remove_one() sends DEVICE_REMOVAL to the owner of every cm_id on the device and then waits, without timeout, until they're all destroyed. nvmet_rdma_device_removal() does nothing for a queue cm_id and leaves the queues to nvmet_rdma_remove_one(), which only works if that runs first. As a module it does, nvmet-rdma registers after rdma_cm. Built in, both register at the same initcall level and drivers/Makefile lists nvme/ ahead of infiniband/, so cma_remove_one() runs first and waits for cm_ids that only the later callback would destroy. Since the RDMA CM drops all later events for a cm_id once it has sent DEVICE_REMOVAL, a peer closing its connection doesn't help either. One connection from anyone who can reach the port hangs "rdma link delete" until something else ends the queue. Call nvmet_rdma_queue_disconnect() for the queue. It unlists the queue and queues the release work, which destroys the cm_id. Don't wait for it, rdma_destroy_id() waits for the handler to return, which was the deadlock before commit f1d4ef7d8883. Fixes: f1d4ef7d8883 ("nvmet-rdma: register ib_client to not deadlock in device removal") Cc: Christoph Hellwig Cc: Sagi Grimberg Cc: Chaitanya Kulkarni Reviewed-by: Christoph Hellwig Signed-off-by: Chris Mason Signed-off-by: Jens Axboe Signed-off-by: Keith Busch Signed-off-by: Sasha Levin --- drivers/nvme/target/rdma.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index 58fc89b22c98c..7cbba255de206 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c @@ -1779,10 +1779,13 @@ static void nvmet_rdma_queue_connect_fail(struct rdma_cm_id *cm_id, * queue cm_id and/or a device bound listener cm_id (where in this * case queue will be null). * - * We registered an ib_client to handle device removal for queues, - * so we only need to handle the listening port cm_ids. In this case - * we nullify the priv to prevent double cm_id destruction and destroying - * the cm_id implicitly by returning a non-zero rc to the callout. + * The RDMA CM waits until each cm_id of the device is destroyed, so a queue + * has to go now. Our ib_client also removes the queues, but it cannot be + * relied on here: built in, it is called after the RDMA CM's client. + * + * For a listening port cm_id we nullify the priv to prevent double cm_id + * destruction and destroying the cm_id implicitly by returning a non-zero + * rc to the callout. */ static int nvmet_rdma_device_removal(struct rdma_cm_id *cm_id, struct nvmet_rdma_queue *queue) @@ -1790,11 +1793,7 @@ static int nvmet_rdma_device_removal(struct rdma_cm_id *cm_id, struct nvmet_rdma_port *port; if (queue) { - /* - * This is a queue cm_id. we have registered - * an ib_client to handle queues removal - * so don't interfere and just return. - */ + nvmet_rdma_queue_disconnect(queue); return 0; } -- 2.53.0