All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leonro@mellanox.com>,
	Doug Ledford <dledford@redhat.com>,
	linux-rdma@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Honggang LI <honli@redhat.com>,
	Laurence Oberman <loberman@redhat.com>
Subject: [PATCH 12/15] RDMA/srpt: Rework the approach for closing an RDMA channel
Date: Mon, 30 Sep 2019 16:17:04 -0700	[thread overview]
Message-ID: <20190930231707.48259-13-bvanassche@acm.org> (raw)
In-Reply-To: <20190930231707.48259-1-bvanassche@acm.org>

Instead of relying on a waitqueue, report when the identity of an RDMA
channel can be reused through a completion.

Cc: Honggang LI <honli@redhat.com>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srpt/ib_srpt.c | 30 +++++++--------------------
 drivers/infiniband/ulp/srpt/ib_srpt.h |  3 +++
 2 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index dabaea301328..88e11a250c96 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -1928,41 +1928,22 @@ static int srpt_disconnect_ch(struct srpt_rdma_ch *ch)
 	return ret;
 }
 
-static bool srpt_ch_closed(struct srpt_port *sport, struct srpt_rdma_ch *ch)
-{
-	struct srpt_nexus *nexus;
-	struct srpt_rdma_ch *ch2;
-	bool res = true;
-
-	rcu_read_lock();
-	list_for_each_entry(nexus, &sport->nexus_list, entry) {
-		list_for_each_entry(ch2, &nexus->ch_list, list) {
-			if (ch2 == ch) {
-				res = false;
-				goto done;
-			}
-		}
-	}
-done:
-	rcu_read_unlock();
-
-	return res;
-}
-
 /* Send DREQ and wait for DREP. */
 static void srpt_disconnect_ch_sync(struct srpt_rdma_ch *ch)
 {
+	DECLARE_COMPLETION_ONSTACK(closed);
 	struct srpt_port *sport = ch->sport;
 
 	pr_debug("ch %s-%d state %d\n", ch->sess_name, ch->qp->qp_num,
 		 ch->state);
 
+	ch->closed = &closed;
+
 	mutex_lock(&sport->mutex);
 	srpt_disconnect_ch(ch);
 	mutex_unlock(&sport->mutex);
 
-	while (wait_event_timeout(sport->ch_releaseQ, srpt_ch_closed(sport, ch),
-				  5 * HZ) == 0)
+	while (wait_for_completion_timeout(&closed, 5 * HZ) == 0)
 		pr_info("%s(%s-%d state %d): still waiting ...\n", __func__,
 			ch->sess_name, ch->qp->qp_num, ch->state);
 
@@ -2089,6 +2070,9 @@ static void srpt_release_channel_work(struct work_struct *w)
 	list_del_rcu(&ch->list);
 	mutex_unlock(&sport->mutex);
 
+	if (ch->closed)
+		complete(ch->closed);
+
 	srpt_destroy_ch_ib(ch);
 
 	srpt_free_ioctx_ring((struct srpt_ioctx **)ch->ioctx_ring,
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index ee9f20e9177a..d0955bc0343d 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -264,6 +264,8 @@ enum rdma_ch_state {
  * @zw_cqe:	   Zero-length write CQE.
  * @rcu:           RCU head.
  * @kref:	   kref for this channel.
+ * @closed:	   Completion object that will be signaled as soon as a new
+ *		   channel object with the same identity can be created.
  * @rq_size:       IB receive queue size.
  * @max_rsp_size:  Maximum size of an RSP response message in bytes.
  * @sq_wr_avail:   number of work requests available in the send queue.
@@ -306,6 +308,7 @@ struct srpt_rdma_ch {
 	struct ib_cqe		zw_cqe;
 	struct rcu_head		rcu;
 	struct kref		kref;
+	struct completion	*closed;
 	int			rq_size;
 	u32			max_rsp_size;
 	atomic_t		sq_wr_avail;
-- 
2.23.0.444.g18eeb5a265-goog


  parent reply	other threads:[~2019-09-30 23:17 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-30 23:16 [PATCH 00/15] RDMA patches for kernel v5.5 Bart Van Assche
2019-09-30 23:16 ` [PATCH 01/15] RDMA/ucma: Reduce the number of rdma_destroy_id() calls Bart Van Assche
2019-10-01 15:07   ` Jason Gunthorpe
2019-10-01 17:13     ` Bart Van Assche
2019-09-30 23:16 ` [PATCH 02/15] RDMA/iwcm: Fix a lock inversion issue Bart Van Assche
2019-10-01 15:17   ` Jason Gunthorpe
2019-09-30 23:16 ` [PATCH 03/15] RDMA/siw: Simplify several debug messages Bart Van Assche
2019-10-01 15:20   ` Jason Gunthorpe
2019-09-30 23:16 ` [PATCH 04/15] RDMA/siw: Fix port number endianness in a debug message Bart Van Assche
2019-10-01 15:20   ` Jason Gunthorpe
2019-09-30 23:16 ` [PATCH 05/15] RDMA/siw: Make node GUIDs valid EUI-64 identifiers Bart Van Assche
2019-09-30 23:16 ` [PATCH 06/15] RDMA/srp: Remove two casts Bart Van Assche
2019-09-30 23:16 ` [PATCH 07/15] RDMA/srp: Honor the max_send_sge device attribute Bart Van Assche
2019-09-30 23:17 ` [PATCH 08/15] RDMA/srp: Make route resolving error messages more informative Bart Van Assche
2019-09-30 23:17 ` [PATCH 09/15] RDMA/srpt: Fix handling of SR-IOV and iWARP ports Bart Van Assche
2019-10-02 14:14   ` Jason Gunthorpe
2019-10-02 15:21     ` Bart Van Assche
2019-10-02 16:51       ` Jason Gunthorpe
2019-10-02 17:24         ` Leon Romanovsky
2019-10-02 17:43           ` Bart Van Assche
2019-10-03  8:33             ` Leon Romanovsky
2019-09-30 23:17 ` [PATCH 10/15] RDMA/srpt: Fix handling of iWARP logins Bart Van Assche
2019-10-02 14:16   ` Jason Gunthorpe
2019-10-02 15:23     ` Bart Van Assche
2019-09-30 23:17 ` [PATCH 11/15] RDMA/srpt: Improve a debug message Bart Van Assche
2019-09-30 23:17 ` Bart Van Assche [this message]
2019-09-30 23:17 ` [PATCH 13/15] RDMA/srpt: Rework the code that waits until an RDMA port is no longer in use Bart Van Assche
2019-09-30 23:17 ` [PATCH 14/15] RDMA/srpt: Make the code for handling port identities more systematic Bart Van Assche
2019-09-30 23:17 ` [PATCH 15/15] RDMA/srpt: Postpone HCA removal until after configfs directory removal Bart Van Assche
2019-10-01 11:39 ` [PATCH 03/15] RDMA/siw: Simplify several debug messages Bernard Metzler
2019-10-01 11:45 ` [PATCH 04/15] RDMA/siw: Fix port number endianness in a debug message Bernard Metzler
2019-10-04 18:36 ` [PATCH 00/15] RDMA patches for kernel v5.5 Jason Gunthorpe

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=20190930231707.48259-13-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=dledford@redhat.com \
    --cc=honli@redhat.com \
    --cc=jgg@ziepe.ca \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=loberman@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.