From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>, Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>,
Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [PATCH 1/2] nvmet-rdma: avoid circular locking dependency on install_queue()
Date: Thu, 2 Nov 2023 15:19:02 +0100 [thread overview]
Message-ID: <20231102141903.66515-2-hare@suse.de> (raw)
In-Reply-To: <20231102141903.66515-1-hare@suse.de>
nvmet_rdma_install_queue() is driven from the ->io_work workqueue
function, but will call flush_workqueue() which might trigger
->release_work() which in itself calls flush_work on ->io_work.
To avoid that move the check for any pending queue disconnects
to the 'install_queue()' callback. This replicates what the tcp
code is already doing, and also allows us to return a
'controller busy' connect response until all disconnects
are completed.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Tested-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
drivers/nvme/target/rdma.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c
index 4597bca43a6d..8e011bdec3b0 100644
--- a/drivers/nvme/target/rdma.c
+++ b/drivers/nvme/target/rdma.c
@@ -1582,11 +1582,6 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,
goto put_device;
}
- if (queue->host_qid == 0) {
- /* Let inflight controller teardown complete */
- flush_workqueue(nvmet_wq);
- }
-
ret = nvmet_rdma_cm_accept(cm_id, queue, &event->param.conn);
if (ret) {
/*
@@ -1975,6 +1970,24 @@ static void nvmet_rdma_remove_port(struct nvmet_port *nport)
kfree(port);
}
+static u16 nvmet_rdma_install_queue(struct nvmet_sq *sq)
+{
+ if (sq->qid == 0) {
+ struct nvmet_rdma_queue *q;
+
+ mutex_lock(&nvmet_rdma_queue_mutex);
+ list_for_each_entry(q, &nvmet_rdma_queue_list, queue_list) {
+ if (q->state == NVMET_RDMA_Q_DISCONNECTING) {
+ mutex_unlock(&nvmet_rdma_queue_mutex);
+ /* Retry for pending controller teardown */
+ return NVME_SC_CONNECT_CTRL_BUSY;
+ }
+ }
+ mutex_unlock(&nvmet_rdma_queue_mutex);
+ }
+ return 0;
+}
+
static void nvmet_rdma_disc_port_addr(struct nvmet_req *req,
struct nvmet_port *nport, char *traddr)
{
@@ -2014,6 +2027,7 @@ static const struct nvmet_fabrics_ops nvmet_rdma_ops = {
.remove_port = nvmet_rdma_remove_port,
.queue_response = nvmet_rdma_queue_response,
.delete_ctrl = nvmet_rdma_delete_ctrl,
+ .install_queue = nvmet_rdma_install_queue,
.disc_traddr = nvmet_rdma_disc_port_addr,
.get_mdts = nvmet_rdma_get_mdts,
.get_max_queue_size = nvmet_rdma_get_max_queue_size,
--
2.35.3
next prev parent reply other threads:[~2023-11-02 14:19 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 14:19 [PATCHv2 0/2] nvmet: avoid circular locking warning Hannes Reinecke
2023-11-02 14:19 ` Hannes Reinecke [this message]
2023-11-03 8:23 ` [PATCH 1/2] nvmet-rdma: avoid circular locking dependency on install_queue() Christoph Hellwig
2023-11-03 8:53 ` Hannes Reinecke
2023-11-03 9:19 ` Christoph Hellwig
2023-11-03 11:58 ` Hannes Reinecke
2023-11-03 14:05 ` Christoph Hellwig
2023-11-20 13:48 ` Sagi Grimberg
2023-12-04 10:19 ` Sagi Grimberg
2023-12-04 11:49 ` Hannes Reinecke
2023-12-04 11:57 ` Sagi Grimberg
2023-12-04 12:31 ` Hannes Reinecke
2023-12-04 12:46 ` Sagi Grimberg
2023-12-07 5:54 ` Shinichiro Kawasaki
2023-12-07 12:17 ` Sagi Grimberg
2023-11-02 14:19 ` [PATCH 2/2] nvmet-tcp: " Hannes Reinecke
-- strict thread matches above, loose matches on Subject: below --
2023-11-01 10:32 [PATCH 0/2] nvmet: avoid circular locking warning Hannes Reinecke
2023-11-01 10:32 ` [PATCH 1/2] nvmet-rdma: avoid circular locking dependency on install_queue() Hannes Reinecke
2023-11-01 16:21 ` Jens Axboe
2023-11-01 17:28 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231102141903.66515-2-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox