Ack, code review only. /Thanks HansN
-----Original Message----- From: praveen.malv...@oracle.com [mailto:praveen.malv...@oracle.com] Sent: den 29 januari 2015 12:26 To: Hans Nordebäck; nagendr...@oracle.com Cc: opensaf-devel@lists.sourceforge.net Subject: [PATCH 1 of 1] amfd: do not assign dependent csi if any sponsor csi is unassigned [#687] osaf/services/saf/amf/amfd/csi.cc | 31 ++++++++++++++++++++++++ osaf/services/saf/amf/amfd/include/csi.h | 1 + osaf/services/saf/amf/amfd/sgproc.cc | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 0 deletions(-) A CSI is configured with CSI dependency on multiple sponsor CSIs. When user UNLOCKs SUs, AMF is assigning the dependent CSI in the case when only some sponsors are assigned. Even if one sponsor is unassigned, AMF should not assign dependent CSI. In this particular issue, one sponsor remained unassigned because compcsType was not configured for the csType of unassigned sponsor. At present, AMF does not have mechanism to strictly check the configuration from assignment perspective. AMF will not assign dependent CSI if any sponsor CSI is unassigned. diff --git a/osaf/services/saf/amf/amfd/csi.cc b/osaf/services/saf/amf/amfd/csi.cc --- a/osaf/services/saf/amf/amfd/csi.cc +++ b/osaf/services/saf/amf/amfd/csi.cc @@ -1383,3 +1383,34 @@ bool csi_assignment_validate(AVD_SG *sg) return true; return false; } + + +/** + * @brief Checks if sponsor CSIs of any CSI are assigned to any comp in this SU. + * + * @param[in] ptr to CSI. + * @param[in] ptr to SU. + * + * @return true/false. + */ +bool are_sponsor_csis_assigned_in_su(AVD_CSI *csi, AVD_SU *su) { + for (AVD_CSI_DEPS *spons_csi = csi->saAmfCSIDependencies; spons_csi != NULL; + spons_csi = spons_csi->csi_dep_next) { + bool is_sponsor_assigned = false; + + AVD_CSI *tmp_csi = + csi_db->find(Amf::to_string(&spons_csi->csi_dep_name_value)); + + //Check if this sponsor csi is assigned to any comp in this su. + for (AVD_COMP_CSI_REL *compcsi = tmp_csi->list_compcsi; compcsi; + compcsi = compcsi->csi_csicomp_next) { + if (compcsi->comp->su == su) + is_sponsor_assigned = true; + } + //Return false if this sponsor is not assigned to this SU. + if (is_sponsor_assigned == false) + return false; + } + return true; +} + diff --git a/osaf/services/saf/amf/amfd/include/csi.h b/osaf/services/saf/amf/amfd/include/csi.h --- a/osaf/services/saf/amf/amfd/include/csi.h +++ b/osaf/services/saf/amf/amfd/include/csi.h @@ -162,5 +162,6 @@ extern void csi_cmplt_delete(struct avd_ extern AVD_CSI *csi_create(const SaNameT *csi_name); extern bool csi_assignment_validate(AVD_SG *sg); extern SaAisErrorT csi_assign_hdlr(AVD_CSI *csi); +extern bool are_sponsor_csis_assigned_in_su(AVD_CSI *dep_csi, AVD_SU +*su); #endif diff --git a/osaf/services/saf/amf/amfd/sgproc.cc b/osaf/services/saf/amf/amfd/sgproc.cc --- a/osaf/services/saf/amf/amfd/sgproc.cc +++ b/osaf/services/saf/amf/amfd/sgproc.cc @@ -36,6 +36,39 @@ #include <clm.h> #include <si_dep.h> + +/** + * @brief While creating compcsi relationship in SUSI, AMF may assign + * a dependent csi to a component in the SU when its one or more + * sponsor csi remains unassigned in the same SU. This function + * deletes compcsi which belongs to such a dependent csi. + * This function should be used before sending assignment list to AMFND. + * + * @param[in] ptr to AVD_SU_SI_REL. + * + */ + +static void verify_csi_deps_and_delete_invalid_compcsi(AVD_SU_SI_REL *susi) +{ + for (AVD_CSI *csi = susi->si->list_of_csi; csi; csi = csi->si_list_of_csi_next) + { + if (are_sponsor_csis_assigned_in_su(csi,susi->su) == false) { + for (AVD_COMP_CSI_REL *compcsi = susi->list_of_csicomp; compcsi; + compcsi = compcsi->susi_csicomp_next) { + if (compcsi->csi == csi) { + TRACE("sponsor csi unassigned: delete compcsi " + "between '%s' and '%s'", + compcsi->comp->comp_info.name.value, + compcsi->csi->name.value); + compcsi->csi->assign_flag = false; + compcsi->comp->assign_flag = false; + avd_compcsi_from_csi_and_susi_delete(susi, compcsi, true); + break; + } + } + } + } +} /***************************************************************************** * Function: avd_new_assgn_susi * @@ -170,6 +203,13 @@ uint32_t avd_new_assgn_susi(AVD_CL_CB *c }/* while (l_csi != NULL) */ npisu_done: + + /* Check from csi deps perspective, dependent csi should be assigned only if all the sponsors + are assigned. Delete all those compcsi in which dependent csi is getting assigned even if + anyone of the sponsors is unassigned. + */ + verify_csi_deps_and_delete_invalid_compcsi(susi); + l_csi = si->list_of_csi; while (l_csi != NULL) { if (l_csi->assign_flag == false) { ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel