[openib-general] [PATCH] ipoib_mcast_restart_task

Michael S. Tsirkin mst at mellanox.co.il
Tue Apr 4 08:52:33 PDT 2006


Roland, Eli spotted the following race that might explain part
of the crashes in sendonly complete. Please take a look.

---

ipoib_mcast_restart_task might free an mcast object while a join request (sa
query) is still outstanding, leading to an oops when the query completes.  Fix
this by waiting for query to complete, similiar to what ipoib_stop_thread is
doing.

Signed-off-by: Eli Cohen <eli at mellanox.co.il>
Signed-off-by: Michael S. Tsirkin <mst at mellanox.co.il>

Index: openib/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
===================================================================
--- openib/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	(revision 5992)
+++ openib/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	(working copy)
@@ -910,6 +910,16 @@ void ipoib_mcast_restart_task(void *dev_
 
 	/* We have to cancel outside of the spinlock */
 	list_for_each_entry_safe(mcast, tmcast, &remove_list, list) {
+		spin_lock_irq(&priv->lock);
+		if (mcast->query) {
+			ib_sa_cancel_query(mcast->query_id, mcast->query);
+			mcast->query = NULL;
+			spin_unlock_irq(&priv->lock);
+			ipoib_dbg_mcast(priv, "waiting for MGID " IPOIB_GID_FMT "\n",
+					IPOIB_GID_ARG(mcast->mcmember.mgid));
+			wait_for_completion(&mcast->done);
+		} else
+			spin_unlock_irq(&priv->lock);
 		ipoib_mcast_leave(mcast->dev, mcast);
 		ipoib_mcast_free(mcast);
 	}

-- 
Michael S. Tsirkin
Staff Engineer, Mellanox Technologies



More information about the general mailing list