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=1796387208; b=La4D/ysoBZQ9JH4RllbvXOWqTMwG5/FTDa/C1ffe2O85/29mNFbVx0PGfwVLwsUW2L/v c/d+LnloMfNq9OYrRAu65BJigZZHnTgwme9aHpzT7LZ7AzuAmrVLvPONYN8urHsCrS9El F6h8OsWPbmEm3RtnBuAb7YsCf/AeGexjDW9/xLamCxHf4aUXtNEQCtOZebgn/tm3AHbMC BcW9LN8RycFIvWupM+24dfyXX9lYqHiKfM4RhkGQh3ZvJBlykeZHGFQMGYScIZFo3a6gE nxNgKf+uHX2wA68gwxcFUDYTNCPqcPCu9Ix/egXMtYmMSKl+TTo0YenymOEBoppjp7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387208; 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=PHR2CMqaxvhiiFZ2MFmXH6y4x/kKlvW6mpV+g8jjNYk=; b=Pz5vtQLVjOk34tNs0U7Poq9pJlr9KK2kvF9v2yJBGZAGyevE8r1/6ORNIpzZiAN2wsgr F8fVwOHl57yv6h0rJfOyKB+aWmFZZyLWCp/bCI1k1ZoZQA4gA1nA9EHYnqGfJd3HxczDy b0Cre2b41qniRsQZ3+2Fs9i+vQnAScAQ/ekhTgzQtRkt1GMcmqg9wj09G8L1pVY0AaKuJ MBW449ak79cx5JtCYm/9feOsTRc6L+D5v2zjOgEub5VomebppN7V8tuk+JDZsTxQVVPpc BBdpPbFPIraPsewzcXL1uMJFw1yYtFIAKozaBjYZ5l84zBHPlweuZ/vIfdHBNjKAJJQ== 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=DW+PpE0B; 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 75455606A32C; Fri, 4 Dec 2026 12:26:48 +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=DW+PpE0B Received: by smtp.kernel.org (Postfix) with ESMTPSA id E68341F000C2; Fri, 4 Dec 2026 12:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387208; bh=PHR2CMqaxvhiiFZ2MFmXH6y4x/kKlvW6mpV+g8jjNYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DW+PpE0BR7EAGngmB9JzOtBZ8b0cvoMfbD9G5Y8wLhDrFtNisTWptxvpQ269jq4vS 8B9zXrD0BJ0J5LLxp79JNNr20O78ZiDak8xE3uNo9bnnIvjfc9MVisI20qeFFkgKd2 P6PsEhdf5y7r/CvZIDnPiMYRCOYBUumIoPoti/dU= 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.1 0108/1059] nvmet-rdma: queue the release work under the mutex Date: Fri, 4 Dec 2026 18:53:59 +0900 Message-ID: <20261204100646.997269823@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: Chris Mason [ Upstream commit 80095787f776967361cca76357f19e5445e0cd75 ] nvmet_rdma_remove_one() takes the queue mutex, unlists each queue of the device and queues its release work, then flushes nvmet-wq. So a queue that still holds objects on the device must either be on the list or have its release work queued. nvmet_rdma_queue_disconnect() breaks that: it unlists the queue under the mutex, drops it, and only then calls __nvmet_rdma_queue_disconnect() to queue the work. A device removal in that window finds nothing to wait for, and the release work then destroys the QP and CQ share on a freed device. Queue the work before dropping the mutex, as nvmet_rdma_remove_one() itself does. That's safe now that rdma_disconnect() no longer sleeps on an iWARP event that needs the same mutex. 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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index 53214a092c62f..d99d76a327559 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c @@ -1742,17 +1742,17 @@ static void __nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue) static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue) { - bool disconnect = false; - + /* + * Queue the release work with &nvmet_rdma_queue_mutex held, so that + * nvmet_rdma_remove_one() either finds the queue on the list or the + * work has already been queued. + */ mutex_lock(&nvmet_rdma_queue_mutex); if (!list_empty(&queue->queue_list)) { list_del_init(&queue->queue_list); - disconnect = true; + __nvmet_rdma_queue_disconnect(queue); } mutex_unlock(&nvmet_rdma_queue_mutex); - - if (disconnect) - __nvmet_rdma_queue_disconnect(queue); } static void nvmet_rdma_queue_connect_fail(struct rdma_cm_id *cm_id, -- 2.53.0