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=1796384436; b=oxqiBK2wgy4HSHr/CCUWVo6CEauRD511n2Jux+6GqsQhyJlMbhxGUWsybeSkYmdxkgDw SSQWo4G9CN9zUL+fmINW0oFDAycYXZMll8PbtTfnPRun6KoYTyXYys9PnxzYE2I4Yd0RZ bNglqmUG3bdJ0nBaTkYMQDzoBWzuimLdz5AqgNzHKihUfPOB7jH62WNZUIKv1Z7CEAX0J HfN2gBJ8xYXGF8IJdzcr15PK5Hwb2LF6xDQ7cIPsR7jB2e/z3Fo0qUGG60SQbMFi5YS5+ 5lYYd9Gay5/l4Jft1X6DkjarT+vtud96Ch0Bjb3WF3lhBDqyFhkB68P57LsZtGMzJEQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384436; 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=wC+u/wb0PWdgnIy/AqILQeW72dDoP1Tm9ztFbIZFwxA=; b=m1arG8N8ZsZ+ESZf1yI4mMlSrIrA1XA/U3e90KTn7RHUTl//wF15sXsMEAiRcQuujknK f3sqXhcmKALXAZrHS0WVdmyu+PnHVshIkrtJED3DeJtWQPqKytXaWCWUWS6UBj6uYgRCe dmQQid5WSSxeBsIVOgkCyrczZXu+PgW1fpyYgF61s8Ai05TWeT9HG1HRG0hzk+oCeRefP U7bWnnuOeX9a4i0h08P3cjCPcPKGaVC7CbpWh4ReSwoyOlQPG3zo7kxuB8GxGBO0bz2Zw oi3KMvOXPCYelk/5H36jD36+qq9n3lerMTQrNWRjZb5ZD1Wa1czmomdaKgKvrC0F2VQ== 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=Y9T73xiG; 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 1DD7F606A335; Fri, 4 Dec 2026 11:40:36 +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=Y9T73xiG Received: by smtp.kernel.org (Postfix) with ESMTPSA id 930231F00897; Fri, 4 Dec 2026 11:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384436; bh=wC+u/wb0PWdgnIy/AqILQeW72dDoP1Tm9ztFbIZFwxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y9T73xiG+Ts3WjuhqXxHdtOQELmyBBOMh+bojdFwsbYycIokLg15Tk2GW8wsIPytg DNYcToZdCXXOMcd517kWdKm92XKJ1GKlFeLFQujPJIE8wkF36WWhhKJ9xLJuwrZBoK NNa4tO/H1G3/gZ1wAxDRngz55vkuEMvhCtM5jigM= 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.6 0147/1167] nvmet-rdma: queue the release work under the mutex Date: Fri, 4 Dec 2026 18:52:54 +0900 Message-ID: <20261204100705.917198269@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: 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