[ofa-general] [PATCH] opensm/multicast: kill mc group to_be_deleted flag

Sasha Khapyorsky sashak at voltaire.com
Mon Sep 7 05:10:03 PDT 2009


This removes multicast group delayed deletion stuff - we don't need it
anymore because MFTs cleanup (in case of group removing) is performed
using MLID only (not mgrp content) which is requested by appropriate
osm_sm_mgrp_leave() call.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/include/opensm/osm_multicast.h  |    7 +---
 opensm/opensm/osm_mcast_mgr.c          |   13 +-----
 opensm/opensm/osm_multicast.c          |   20 ++++++----
 opensm/opensm/osm_sa_mcmember_record.c |   65 ++++---------------------------
 4 files changed, 24 insertions(+), 81 deletions(-)

diff --git a/opensm/include/opensm/osm_multicast.h b/opensm/include/opensm/osm_multicast.h
index ce3d310..181f0db 100644
--- a/opensm/include/opensm/osm_multicast.h
+++ b/opensm/include/opensm/osm_multicast.h
@@ -127,7 +127,6 @@ typedef struct osm_mgrp {
 	cl_qmap_t mcm_port_tbl;
 	ib_member_rec_t mcmember_rec;
 	boolean_t well_known;
-	boolean_t to_be_deleted;
 	unsigned full_members;
 } osm_mgrp_t;
 /*
@@ -156,11 +155,6 @@ typedef struct osm_mgrp {
 *		is created during the initialization of SM/SA and will be
 *		present even if there are no ports for this group
 *
-*	to_be_deleted
-*		Since groups are deleted only after re-route we need to
-*		track the fact the group is about to be deleted so we can
-*		track the fact a new join is actually a create request.
-*
 * SEE ALSO
 *********/
 
@@ -413,6 +407,7 @@ osm_mgrp_delete_port(IN osm_subn_t * const p_subn,
 
 int osm_mgrp_remove_port(osm_subn_t *subn, osm_log_t *log, osm_mgrp_t *mgrp,
 			 osm_mcm_port_t *mcm, uint8_t join_state);
+void osm_mgrp_cleanup(osm_subn_t *subn, osm_mgrp_t *mpgr);
 
 END_C_DECLS
 #endif				/* _OSM_MULTICAST_H_ */
diff --git a/opensm/opensm/osm_mcast_mgr.c b/opensm/opensm/osm_mcast_mgr.c
index f3ddacf..c1d1916 100644
--- a/opensm/opensm/osm_mcast_mgr.c
+++ b/opensm/opensm/osm_mcast_mgr.c
@@ -1030,21 +1030,12 @@ static ib_api_status_t mcast_mgr_process_mlid(osm_sm_t * sm, uint16_t mlid)
 	mcast_mgr_clear(sm, mlid);
 
 	mgrp = osm_get_mgrp_by_mlid(sm->p_subn, cl_hton16(mlid));
-	if (!mgrp) /* already removed */
-		return IB_SUCCESS;
-
-	if (mgrp->full_members) {
+	if (mgrp) {
 		status = mcast_mgr_build_spanning_tree(sm, mgrp);
 		if (status != IB_SUCCESS)
 			OSM_LOG(sm->p_log, OSM_LOG_ERROR, "ERR 0A17: "
 				"Unable to create spanning tree (%s) for mlid "
 				"0x%x\n", ib_get_err_str(status), mlid);
-	} else if (mgrp->to_be_deleted) {
-		OSM_LOG(sm->p_log, OSM_LOG_DEBUG,
-			"Destroying mgrp with lid:0x%x\n", mlid);
-		sm->p_subn->mgroups[mlid - IB_LID_MCAST_START_HO] = NULL;
-		cl_fmap_remove_item(&sm->p_subn->mgrp_mgid_tbl, &mgrp->map_item);
-		osm_mgrp_delete(mgrp);
 	}
 
 	OSM_LOG_EXIT(sm->p_log);
@@ -1120,7 +1111,7 @@ int osm_mcast_mgr_process(osm_sm_t * sm)
 
 	for (i = 0; i <= sm->p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO;
 	     i++)
-		if (sm->p_subn->mgroups[i])
+		if (sm->p_subn->mgroups[i] || sm->mlids_req[i])
 			mcast_mgr_process_mlid(sm, i + IB_LID_MCAST_START_HO);
 
 	memset(sm->mlids_req, 0, sm->mlids_req_max);
diff --git a/opensm/opensm/osm_multicast.c b/opensm/opensm/osm_multicast.c
index 1326161..242eae7 100644
--- a/opensm/opensm/osm_multicast.c
+++ b/opensm/opensm/osm_multicast.c
@@ -86,11 +86,19 @@ osm_mgrp_t *osm_mgrp_new(IN const ib_net16_t mlid)
 	memset(p_mgrp, 0, sizeof(*p_mgrp));
 	cl_qmap_init(&p_mgrp->mcm_port_tbl);
 	p_mgrp->mlid = mlid;
-	p_mgrp->to_be_deleted = FALSE;
 
 	return p_mgrp;
 }
 
+void osm_mgrp_cleanup(osm_subn_t *subn, osm_mgrp_t *mgrp)
+{
+	if (mgrp->full_members || mgrp->well_known)
+		return;
+	subn->mgroups[cl_ntoh16(mgrp->mlid) - IB_LID_MCAST_START_HO] = NULL;
+	cl_fmap_remove_item(&subn->mgrp_mgid_tbl, &mgrp->map_item);
+	osm_mgrp_delete(mgrp);
+}
+
 /**********************************************************************
  **********************************************************************/
 static void mgrp_send_notice(osm_subn_t * subn, osm_log_t * log,
@@ -169,10 +177,8 @@ osm_mcm_port_t *osm_mgrp_add_port(IN osm_subn_t * subn, osm_log_t * log,
 
 	if ((join_state & IB_JOIN_STATE_FULL) &&
 	    !(prev_join_state & IB_JOIN_STATE_FULL) &&
-	    (++p_mgrp->full_members == 1)) {
+	    ++p_mgrp->full_members == 1)
 		mgrp_send_notice(subn, log, p_mgrp, 66);
-		p_mgrp->to_be_deleted = 0;
-	}
 
 	return (p_mcm_port);
 }
@@ -213,11 +219,8 @@ int osm_mgrp_remove_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp,
 	   but only if it is not a well known group */
 	if ((port_join_state & IB_JOIN_STATE_FULL) &&
 	    !(new_join_state & IB_JOIN_STATE_FULL) &&
-	    (--mgrp->full_members == 0)) {
+	    --mgrp->full_members == 0)
 		mgrp_send_notice(subn, log, mgrp, 67);
-		if (!mgrp->well_known)
-			mgrp->to_be_deleted = 1;
-	}
 
 	return ret;
 }
@@ -230,6 +233,7 @@ void osm_mgrp_delete_port(osm_subn_t * subn, osm_log_t * log, osm_mgrp_t * mgrp,
 	if (item != cl_qmap_end(&mgrp->mcm_port_tbl))
 		osm_mgrp_remove_port(subn, log, mgrp, (osm_mcm_port_t *) item,
 				     0xf);
+	osm_mgrp_cleanup(subn, mgrp);
 }
 
 /**********************************************************************
diff --git a/opensm/opensm/osm_sa_mcmember_record.c b/opensm/opensm/osm_sa_mcmember_record.c
index e8aecc4..5fc1064 100644
--- a/opensm/opensm/osm_sa_mcmember_record.c
+++ b/opensm/opensm/osm_sa_mcmember_record.c
@@ -125,36 +125,14 @@ static ib_net16_t get_new_mlid(osm_sa_t * sa, ib_net16_t requested_mlid)
 		return requested_mlid;
 
 	max = p_subn->max_mcast_lid_ho - IB_LID_MCAST_START_HO + 1;
-	for (i = 0; i < max; i++) {
-		osm_mgrp_t *p_mgrp = sa->p_subn->mgroups[i];
-		if (!p_mgrp || p_mgrp->to_be_deleted)
+	for (i = 0; i < max; i++)
+		if (!sa->p_subn->mgroups[i])
 			return cl_hton16(i + IB_LID_MCAST_START_HO);
-	}
 
 	return 0;
 }
 
 /*********************************************************************
- This procedure is only invoked to cleanup an INTERMEDIATE mgrp.
- If there is only one port on the mgrp it means that the current
- request was the only member and the group is not really needed. So
- we silently drop it. Since it was an intermediate group no need to
- re-route it.
-**********************************************************************/
-static void cleanup_mgrp(IN osm_sa_t * sa, osm_mgrp_t * mgrp)
-{
-	/* Remove MGRP only if osm_mcm_port_t count is 0 and
-	   not a well known group */
-	if (cl_is_qmap_empty(&mgrp->mcm_port_tbl) && !mgrp->well_known) {
-		sa->p_subn->mgroups[cl_ntoh16(mgrp->mlid) -
-				    IB_LID_MCAST_START_HO] = NULL;
-		cl_fmap_remove_item(&sa->p_subn->mgrp_mgid_tbl,
-				    &mgrp->map_item);
-		osm_mgrp_delete(mgrp);
-	}
-}
-
-/*********************************************************************
  Add a port to the group. Calculating its PROXY_JOIN by the Port and
  requester gids.
 **********************************************************************/
@@ -812,7 +790,6 @@ ib_api_status_t osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 	unsigned zero_mgid, i;
 	uint8_t scope;
 	ib_gid_t *p_mgid;
-	osm_mgrp_t *p_prev_mgrp;
 	ib_api_status_t status = IB_SUCCESS;
 	ib_member_rec_t mcm_rec = *p_recvd_mcmember_rec;	/* copy for modifications */
 
@@ -913,25 +890,8 @@ ib_api_status_t osm_mcmr_rcv_create_new_mgrp(IN osm_sa_t * sa,
 	(*pp_mgrp)->mcmember_rec.pkt_life |= 2 << 6;	/* exactly */
 
 	/* Insert the new group in the data base */
-
-	/* since we might have an old group by that mlid
-	   one whose deletion was delayed for an idle time
-	   we need to deallocate it first */
-	p_prev_mgrp = osm_get_mgrp_by_mlid(sa->p_subn, mlid);
-	if (p_prev_mgrp) {
-		OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
-			"Found previous group for mlid:0x%04x - "
-			"Destroying it first\n", cl_ntoh16(mlid));
-		sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO] =
-		    NULL;
-		cl_fmap_remove_item(&sa->p_subn->mgrp_mgid_tbl,
-				    &p_prev_mgrp->map_item);
-		osm_mgrp_delete(p_prev_mgrp);
-	}
-
 	cl_fmap_insert(&sa->p_subn->mgrp_mgid_tbl,
 		       &(*pp_mgrp)->mcmember_rec.mgid, &(*pp_mgrp)->map_item);
-
 	sa->p_subn->mgroups[cl_ntoh16(mlid) - IB_LID_MCAST_START_HO] = *pp_mgrp;
 
 Exit:
@@ -975,8 +935,7 @@ osm_mgrp_t *osm_get_mgrp_by_mgid(IN osm_sa_t * sa, IN ib_gid_t * p_mgid)
 	}
 
 	mg = (osm_mgrp_t *)cl_fmap_get(&sa->p_subn->mgrp_mgid_tbl, p_mgid);
-	if (mg != (osm_mgrp_t *)cl_fmap_end(&sa->p_subn->mgrp_mgid_tbl)
-	    && !mg->to_be_deleted)
+	if (mg != (osm_mgrp_t *)cl_fmap_end(&sa->p_subn->mgrp_mgid_tbl))
 		return mg;
 
 	return NULL;
@@ -1078,6 +1037,9 @@ static void mcmr_rcv_leave_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 
 	mcmr_rcv_respond(sa, p_madw, &mcmember_rec);
 
+	CL_PLOCK_EXCL_ACQUIRE(sa->p_lock);
+	osm_mgrp_cleanup(sa->p_subn, p_mgrp);
+	CL_PLOCK_RELEASE(sa->p_lock);
 Exit:
 	OSM_LOG_EXIT(sa->p_log);
 }
@@ -1151,7 +1113,7 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 
 	/* do we need to create a new group? */
 	p_mgrp = osm_get_mgrp_by_mgid(sa, &p_recvd_mcmember_rec->mgid);
-	if (!p_mgrp || p_mgrp->to_be_deleted) {
+	if (!p_mgrp) {
 		/* check for JoinState.FullMember = 1 o15.0.1.9 */
 		if ((join_state & 0x01) != 0x01) {
 			char gid_str[INET6_ADDRSTRLEN];
@@ -1235,7 +1197,7 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 	    || !validate_port_caps(sa->p_log, p_mgrp, p_physp)
 	    || !(join_state != 0)) {
 		/* since we might have created the new group we need to cleanup */
-		cleanup_mgrp(sa, p_mgrp);
+		osm_mgrp_cleanup(sa->p_subn, p_mgrp);
 		CL_PLOCK_RELEASE(sa->p_lock);
 		OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1B12: "
 			"validate_more_comp_fields, validate_port_caps, "
@@ -1268,7 +1230,7 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 				   &p_mcmr_port);
 	if (status != IB_SUCCESS) {
 		/* we fail to add the port so we might need to delete the group */
-		cleanup_mgrp(sa, p_mgrp);
+		osm_mgrp_cleanup(sa->p_subn, p_mgrp);
 		CL_PLOCK_RELEASE(sa->p_lock);
 		osm_sa_send_error(sa, p_madw, status == IB_INVALID_PARAMETER ?
 				  IB_SA_MAD_STATUS_REQ_INVALID :
@@ -1299,7 +1261,6 @@ static void mcmr_rcv_join_mgrp(IN osm_sa_t * sa, IN osm_madw_t * p_madw)
 		osm_mgrp_delete_port(sa->p_subn, sa->p_log, p_mgrp,
 				     p_recvd_mcmember_rec->port_gid.
 				     unicast.interface_id);
-		cleanup_mgrp(sa, p_mgrp);
 		CL_PLOCK_RELEASE(sa->p_lock);
 		osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_NO_RESOURCES);
 		goto Exit;
@@ -1371,14 +1332,6 @@ static void mcmr_by_comp_mask(osm_sa_t * sa, const ib_member_rec_t * p_rcvd_rec,
 	OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
 		"Checking mlid:0x%X\n", cl_ntoh16(p_mgrp->mlid));
 
-	/* the group might be marked for deletion */
-	if (p_mgrp->to_be_deleted) {
-		OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
-			"Group mlid:0x%X is marked to be deleted\n",
-			cl_ntoh16(p_mgrp->mlid));
-		goto Exit;
-	}
-
 	/* first try to eliminate the group by MGID, MLID, or P_Key */
 	if ((IB_MCR_COMPMASK_MGID & comp_mask) &&
 	    memcmp(&p_rcvd_rec->mgid, &p_mgrp->mcmember_rec.mgid,
-- 
1.6.4.2




More information about the general mailing list