[openib-general] [PATCH] [REVOKE] If addr_handler() got error, do not set state as OK

Krishna Kumar krkumar2 at in.ibm.com
Wed Oct 18 22:05:33 PDT 2006


This was originally sent with the intention :
	If addr_handler() got invoked with an error status,
	do not set id_priv->state to success followed by
	resettting it to the old value (redundant code).
	Also encapsulate some common code.

But when I followed Sean's suggestion to avoid using extra
flags, the result is not very appealing (see below). The
code is too complicated (multiple overwrites of 'status')
to do this neatly.

I suggest we drop this patch, as it is not easy to achieve
the above intention cleanly by either re-write method :)

diff -ruNp org/drivers/infiniband/core/cma.c new/drivers/infiniband/core/cma.c
--- org/drivers/infiniband/core/cma.c	2006-10-10 15:45:27.000000000 +0530
+++ new/drivers/infiniband/core/cma.c	2006-10-10 15:59:53.000000000 +0530
@@ -1520,6 +1518,13 @@ static void addr_handler(int status, str
 
 	atomic_inc(&id_priv->dev_remove);
 
+	if (status) { /* We got called with an error */
+		if (!cma_comp(id_priv, CMA_ADDR_QUERY))	/* Invalid state */
+			goto out;
+		event = RDMA_CM_EVENT_ADDR_ERROR;
+		goto notify:
+	}
+
 	/*
 	 * Grab mutex to block rdma_destroy_id() from removing the device while
 	 * we're trying to acquire it.
@@ -1529,9 +1534,8 @@ static void addr_handler(int status, str
 		mutex_unlock(&lock);
 		goto out;
 	}
-
-	if (!status && !id_priv->cma_dev)
-		status = cma_acquire_dev(id_priv);
+	if (!id_priv->cma_dev)
+		status = cma_acquire_dev(id_priv); 
 	mutex_unlock(&lock);
 
 	if (status) {
@@ -1544,16 +1548,15 @@ static void addr_handler(int status, str
 		event = RDMA_CM_EVENT_ADDR_RESOLVED;
 	}
 
-	if (cma_notify_user(id_priv, event, status, NULL, 0)) {
+notify:
+	if (cma_notify_user(id_priv, event, status, NULL, 0))
 		cma_exch(id_priv, CMA_DESTROYING);
-		cma_release_remove(id_priv);
-		cma_deref_id(id_priv);
-		rdma_destroy_id(&id_priv->id);
-		return;
-	}
+
 out:
 	cma_release_remove(id_priv);
 	cma_deref_id(id_priv);
+	if (cma_comp(id_priv, CMA_DESTROYING))
+		rdma_destroy_id(&id_priv->id);
 }
 
 static int cma_resolve_loopback(struct rdma_id_private *id_priv)




More information about the general mailing list