Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmet-rdma: recheck queue state is LIVE in state lock in recv done
@ 2025-02-11  3:45 Ruozhu Li
  2025-02-13  6:20 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Ruozhu Li @ 2025-02-11  3:45 UTC (permalink / raw)
  To: linux-nvme; +Cc: hch, sagi

The queue state checking in nvmet_rdma_recv_done is not in queue state
lock.Queue state can transfer to LIVE in cm establish handler between
state checking and state lock here, cause a silent drop of nvme connect
cmd.
Recheck queue state whether in LIVE state in state lock to prevent this
issue.

Signed-off-by: Ruozhu Li <david.li@jaguarmicro.com>
---
 drivers/nvme/target/rdma.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 1afd93026f9b..9f9e51fbfe49 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -1042,12 +1042,16 @@ static void nvmet_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc)
 		unsigned long flags;
 
 		spin_lock_irqsave(&queue->state_lock, flags);
-		if (queue->state == NVMET_RDMA_Q_CONNECTING)
-			list_add_tail(&rsp->wait_list, &queue->rsp_wait_list);
-		else
-			nvmet_rdma_put_rsp(rsp);
+		if (queue->state != NVMET_RDMA_Q_LIVE) {
+			if (queue->state == NVMET_RDMA_Q_CONNECTING)
+				list_add_tail(&rsp->wait_list, &queue->rsp_wait_list);
+			else
+				nvmet_rdma_put_rsp(rsp);
+
+			spin_unlock_irqrestore(&queue->state_lock, flags);
+			return;
+		}
 		spin_unlock_irqrestore(&queue->state_lock, flags);
-		return;
 	}
 
 	nvmet_rdma_handle_command(queue, rsp);
-- 
2.43.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-02-13 10:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-11  3:45 [PATCH] nvmet-rdma: recheck queue state is LIVE in state lock in recv done Ruozhu Li
2025-02-13  6:20 ` Christoph Hellwig
2025-02-13 10:06   ` Ruozhu Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox