All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL
@ 2016-08-29 11:45 Raju Rangoju
       [not found] ` <20160829114549.6635-1-rajur-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Raju Rangoju @ 2016-08-29 11:45 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, sagi-NQWnxTmZq1alnMjI0IkVqw,
	dledford-H+wXaHxf7aLQT0dZR+AlfA
  Cc: swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW, rajur-ut6Up61K2wZBDgjK7y7TUQ

When the low level driver exercises the hot unplug they would call
rdma_cm cma_remove_one which would fire DEVICE_REMOVAL event to all cma
consumers. Now, if consumer doesn't make sure they destroy all IB
objects created on that IB device instance prior to finalizing all
processing of DEVICE_REMOVAL callback, rdma_cm will let the lld to
de-register with IB core and destroy the IB device instance. And if the
consumer calls (say) ib_dereg_mr(), it will crash since that dev object
is NULL.

In the current implementation, iser-target just initiates the cleanup
and returns from DEVICE_REMOVAL callback. This deferred work creates a
race between iser-target cleaning IB objects(say MR) and lld destroying
IB device instance.

This patch includes the following fixes
  -> make sure that consumer frees all IB objects associated with device
     instance
  -> return non-zero from the callback to destroy the rdma_cm id

Signed-off-by: Raju Rangoju <rajur-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
Acked-by: Sagi Grimberg <sagi-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 23 ++++++++++++++++++++---
 drivers/infiniband/ulp/isert/ib_isert.h |  2 ++
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 7914c14..cae9bbc 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -403,6 +403,7 @@ isert_init_conn(struct isert_conn *isert_conn)
 	INIT_LIST_HEAD(&isert_conn->node);
 	init_completion(&isert_conn->login_comp);
 	init_completion(&isert_conn->login_req_comp);
+	init_waitqueue_head(&isert_conn->rem_wait);
 	kref_init(&isert_conn->kref);
 	mutex_init(&isert_conn->mutex);
 	INIT_WORK(&isert_conn->release_work, isert_release_work);
@@ -578,7 +579,8 @@ isert_connect_release(struct isert_conn *isert_conn)
 	BUG_ON(!device);
 
 	isert_free_rx_descriptors(isert_conn);
-	if (isert_conn->cm_id)
+	if (isert_conn->cm_id &&
+	    !isert_conn->dev_removed)
 		rdma_destroy_id(isert_conn->cm_id);
 
 	if (isert_conn->qp) {
@@ -593,7 +595,10 @@ isert_connect_release(struct isert_conn *isert_conn)
 
 	isert_device_put(device);
 
-	kfree(isert_conn);
+	if (isert_conn->dev_removed)
+		wake_up_interruptible(&isert_conn->rem_wait);
+	else
+		kfree(isert_conn);
 }
 
 static void
@@ -753,6 +758,7 @@ static int
 isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
 {
 	struct isert_np *isert_np = cma_id->context;
+	struct isert_conn *isert_conn;
 	int ret = 0;
 
 	isert_info("%s (%d): status %d id %p np %p\n",
@@ -773,10 +779,21 @@ isert_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
 		break;
 	case RDMA_CM_EVENT_ADDR_CHANGE:    /* FALLTHRU */
 	case RDMA_CM_EVENT_DISCONNECTED:   /* FALLTHRU */
-	case RDMA_CM_EVENT_DEVICE_REMOVAL: /* FALLTHRU */
 	case RDMA_CM_EVENT_TIMEWAIT_EXIT:  /* FALLTHRU */
 		ret = isert_disconnected_handler(cma_id, event->event);
 		break;
+	case RDMA_CM_EVENT_DEVICE_REMOVAL:
+		isert_conn = cma_id->qp->qp_context;
+		isert_conn->dev_removed = true;
+		isert_disconnected_handler(cma_id, event->event);
+		wait_event_interruptible(isert_conn->rem_wait,
+					 isert_conn->state == ISER_CONN_DOWN);
+		kfree(isert_conn);
+		/*
+		 * return non-zero from the callback to destroy
+		 * the rdma cm id
+		 */
+		return 1;
 	case RDMA_CM_EVENT_REJECTED:       /* FALLTHRU */
 	case RDMA_CM_EVENT_UNREACHABLE:    /* FALLTHRU */
 	case RDMA_CM_EVENT_CONNECT_ERROR:
diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h
index fc791ef..c02ada5 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.h
+++ b/drivers/infiniband/ulp/isert/ib_isert.h
@@ -158,6 +158,8 @@ struct isert_conn {
 	struct work_struct	release_work;
 	bool                    logout_posted;
 	bool                    snd_w_inv;
+	wait_queue_head_t	rem_wait;
+	bool			dev_removed;
 };
 
 #define ISERT_MAX_CQ 64
-- 
2.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL
       [not found] ` <20160829114549.6635-1-rajur-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
@ 2016-08-29 12:58   ` Sagi Grimberg
       [not found]     ` <ae587bf0-3dd0-6e38-c589-565c6dcbcf2b-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2016-08-29 12:58 UTC (permalink / raw)
  To: Raju Rangoju, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA
  Cc: swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW

Thanks,

Doug, can you queue this for 4.9 please?
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL
       [not found]     ` <ae587bf0-3dd0-6e38-c589-565c6dcbcf2b-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
@ 2016-08-29 13:05       ` Leon Romanovsky
       [not found]         ` <20160829130518.GE594-2ukJVAZIZ/Y@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Leon Romanovsky @ 2016-08-29 13:05 UTC (permalink / raw)
  To: Sagi Grimberg
  Cc: Raju Rangoju, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

On Mon, Aug 29, 2016 at 03:58:54PM +0300, Sagi Grimberg wrote:
> Thanks,
>
> Doug, can you queue this for 4.9 please?

Sagi,
Why 4.9? It looks like a good candidate (fix) to be in 4.8.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL
       [not found]         ` <20160829130518.GE594-2ukJVAZIZ/Y@public.gmane.org>
@ 2016-08-29 13:16           ` Sagi Grimberg
       [not found]             ` <aa94ae4d-c429-29c1-b04e-065274c17d9d-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Sagi Grimberg @ 2016-08-29 13:16 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Raju Rangoju, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	dledford-H+wXaHxf7aLQT0dZR+AlfA,
	swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW

> Sagi,
> Why 4.9? It looks like a good candidate (fix) to be in 4.8.

Next round of 4.8-rc is good too.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL
       [not found]             ` <aa94ae4d-c429-29c1-b04e-065274c17d9d-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
@ 2016-09-02 17:21               ` Doug Ledford
  0 siblings, 0 replies; 5+ messages in thread
From: Doug Ledford @ 2016-09-02 17:21 UTC (permalink / raw)
  To: Sagi Grimberg, Leon Romanovsky
  Cc: Raju Rangoju, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW


[-- Attachment #1.1: Type: text/plain, Size: 410 bytes --]

On 8/29/2016 9:16 AM, Sagi Grimberg wrote:
>> Sagi,
>> Why 4.9? It looks like a good candidate (fix) to be in 4.8.
> 
> Next round of 4.8-rc is good too.

I had been watching to see if Nick took this from the first submission
and if he didn't I had planned to.  It's now in my next -rc queue.  Thanks.

-- 
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2016-09-02 17:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-29 11:45 [PATCH 1/1] IB/isert: Properly release resources on RDMA_CM_EVENT_DEVICE_REMOVAL Raju Rangoju
     [not found] ` <20160829114549.6635-1-rajur-ut6Up61K2wZBDgjK7y7TUQ@public.gmane.org>
2016-08-29 12:58   ` Sagi Grimberg
     [not found]     ` <ae587bf0-3dd0-6e38-c589-565c6dcbcf2b-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-08-29 13:05       ` Leon Romanovsky
     [not found]         ` <20160829130518.GE594-2ukJVAZIZ/Y@public.gmane.org>
2016-08-29 13:16           ` Sagi Grimberg
     [not found]             ` <aa94ae4d-c429-29c1-b04e-065274c17d9d-NQWnxTmZq1alnMjI0IkVqw@public.gmane.org>
2016-09-02 17:21               ` Doug Ledford

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.