Ack,
Mathi.

>-----Original Message-----
>From: Anders Widell [mailto:[email protected]]
>Sent: Monday, February 29, 2016 8:51 PM
>To: Mathivanan Naickan Palanivelu
>Cc: [email protected]
>Subject: [PATCH 1 of 2] fm: Support AMF configurations containing more than
>two OpenSAF 2N SUs [#79]
>
> osaf/libs/core/include/rda_papi.h             |    3 +-
> osaf/services/infrastructure/fm/fms/fm.h      |    4 +
> osaf/services/infrastructure/fm/fms/fm_amf.c  |   19 +++-
> osaf/services/infrastructure/fm/fms/fm_cb.h   |   11 ++-
> osaf/services/infrastructure/fm/fms/fm_evt.h  |    2 -
> osaf/services/infrastructure/fm/fms/fm_main.c |   58 +++++++++++---
> osaf/services/infrastructure/fm/fms/fm_rda.c  |  101 ++++++-------------------
> 7 files changed, 98 insertions(+), 100 deletions(-)
>
>
>Add support for configuring the system with more than two OpenSAF 2N SUs.
>In particular, this means that all OpenSAF directors must support starting up
>and running without (initially) getting any assignment from AMF. Locking of an
>OpenSAF 2N SU is currently not supported on a system configured with more
>than two OpenSAF 2N SUs.
>
>diff --git a/osaf/libs/core/include/rda_papi.h
>b/osaf/libs/core/include/rda_papi.h
>--- a/osaf/libs/core/include/rda_papi.h
>+++ b/osaf/libs/core/include/rda_papi.h
>@@ -80,8 +80,7 @@ typedef enum {
>       PCS_RDA_ACTIVE,
>       PCS_RDA_STANDBY,
>       PCS_RDA_QUIESCED,
>-      PCS_RDA_ASSERTING,
>-      PCS_RDA_YIELDING
>+      PCS_RDA_QUIESCING
> } PCS_RDA_ROLE;
>
> typedef enum {
>diff --git a/osaf/services/infrastructure/fm/fms/fm.h
>b/osaf/services/infrastructure/fm/fms/fm.h
>--- a/osaf/services/infrastructure/fm/fms/fm.h
>+++ b/osaf/services/infrastructure/fm/fms/fm.h
>@@ -19,6 +19,7 @@
> #define FM_H
>
> #include <stdio.h>
>+#include <stdint.h>
> #include <poll.h>
> #include <sys/types.h>
> #include <string.h>
>@@ -32,6 +33,7 @@
> #include <sys/socket.h>
> #include <sys/un.h>
> #include <sys/time.h>
>+#include "saAmf.h"
>
> #include "ncs_main_papi.h"
> #include "ncsgl_defs.h"
>@@ -73,4 +75,6 @@
>
> extern void amfnd_down_callback(void);
> extern void ava_install_amf_down_cb(void (*cb) (void));
>+extern uint32_t initialize_for_assignment(FM_CB *cb,
>+
>+SaAmfHAStateT ha_state);
> #endif
>diff --git a/osaf/services/infrastructure/fm/fms/fm_amf.c
>b/osaf/services/infrastructure/fm/fms/fm_amf.c
>--- a/osaf/services/infrastructure/fm/fms/fm_amf.c
>+++ b/osaf/services/infrastructure/fm/fms/fm_amf.c
>@@ -128,17 +128,26 @@ void fm_amf_give_hdl(void)
>  * Notes         : None.
>
>***********************************************************
>******************/
> void fm_saf_CSI_set_callback(SaInvocationT invocation,
>-                           const SaNameT *compName, SaAmfHAStateT
>haState, SaAmfCSIDescriptorT csiDescriptor)
>+                           const SaNameT *compName, SaAmfHAStateT
>new_haState,
>+SaAmfCSIDescriptorT csiDescriptor)
> {
>       FM_AMF_CB *fm_amf_cb;
>       SaAisErrorT error = SA_AIS_OK;
>-      TRACE_ENTER();
>-      syslog(LOG_INFO, "fm_saf_CSI_set_callback: Comp %s, state %s",
>compName->value, ha_role_string[haState - 1]);
>+      uint32_t rc;
>+      TRACE_ENTER2("ha_state %d", (int) new_haState);
>+      syslog(LOG_INFO, "fm_saf_CSI_set_callback: Comp %s, state %s",
>+              compName->value, ha_role_string[new_haState - 1]);
>       fm_amf_cb = fm_amf_take_hdl();
>       if (fm_amf_cb != NULL) {
>-              fm_cb->amf_state = haState;
>+              if ((rc = initialize_for_assignment(fm_cb, new_haState)) !=
>+                      NCSCC_RC_SUCCESS) {
>+                      LOG_ER("initialize_for_assignment FAILED %u",
>+                              (unsigned) rc);
>+                      error = SA_AIS_ERR_FAILED_OPERATION;
>+              } else {
>+                      fm_cb->amf_state = new_haState;
>+                      fm_cb->csi_assigned = true;
>+              }
>               error = saAmfResponse(fm_amf_cb->amf_hdl, invocation,
>error);
>-              fm_cb->csi_assigned = true;
>       }
>       fm_amf_give_hdl();
>       TRACE_LEAVE();
>diff --git a/osaf/services/infrastructure/fm/fms/fm_cb.h
>b/osaf/services/infrastructure/fm/fms/fm_cb.h
>--- a/osaf/services/infrastructure/fm/fms/fm_cb.h
>+++ b/osaf/services/infrastructure/fm/fms/fm_cb.h
>@@ -18,6 +18,15 @@
> #ifndef FM_CB_H
> #define FM_CB_H
>
>+#include <stdbool.h>
>+#include <stdint.h>
>+#include "saAmf.h"
>+#include "ncssysf_tmr.h"
>+#include "ncssysf_ipc.h"
>+#include "mds_papi.h"
>+#include "rda_papi.h"
>+#include "fm_amf.h"
>+
> uint32_t gl_fm_hdl;
>
> typedef enum {
>@@ -70,6 +79,7 @@ typedef struct fm_cb {
>
> /* Time in terms of one hundredth of seconds (500 for 5 secs.) */
>       uint32_t active_promote_tmr_val;
>+      bool fully_initialized;
>       bool csi_assigned;
> /* Variable to indicate OpenSAF control of TIPC transport */
>       bool control_tipc;
>@@ -88,7 +98,6 @@ extern FM_CB *fm_cb;
> *         Prototypes for extern functions                       *
>
>***********************************************************
>******/
> uint32_t fm_rda_init(FM_CB *);
>-uint32_t fm_rda_finalize(FM_CB *);
> uint32_t fm_rda_set_role(FM_CB *, PCS_RDA_ROLE);
>
> #endif
>diff --git a/osaf/services/infrastructure/fm/fms/fm_evt.h
>b/osaf/services/infrastructure/fm/fms/fm_evt.h
>--- a/osaf/services/infrastructure/fm/fms/fm_evt.h
>+++ b/osaf/services/infrastructure/fm/fms/fm_evt.h
>@@ -67,6 +67,4 @@ typedef struct fm_evt {
>       } info;
> } FM_EVT;
>
>-void fm_mbx_evt_handler(FM_CB *fm_cb, FM_EVT *fm_evt);
>-
> #endif
>diff --git a/osaf/services/infrastructure/fm/fms/fm_main.c
>b/osaf/services/infrastructure/fm/fms/fm_main.c
>--- a/osaf/services/infrastructure/fm/fms/fm_main.c
>+++ b/osaf/services/infrastructure/fm/fms/fm_main.c
>@@ -39,8 +39,8 @@ enum {
> };
>
> FM_CB *fm_cb = NULL;
>-char *role_string[] = { "Undefined", "ACTIVE", "STANDBY", "QUIESCED",
>-      "ASSERTING", "YIELDING", "UNDEFINED"
>+char *role_string[] = { "UNDEFINED", "ACTIVE", "STANDBY", "QUIESCED",
>+      "QUIESCING"
> };
>
>
>/**********************************************************
>*******
>@@ -55,6 +55,7 @@ static uint32_t fms_fms_exchange_node_in  static
>uint32_t fm_nid_notify(uint32_t);  static uint32_t fm_tmr_start(FM_TMR *,
>SaTimeT);  static void fm_mbx_msg_handler(FM_CB *, FM_EVT *);
>+static void fm_evt_proc_rda_callback(FM_CB*, FM_EVT*);
> static void fm_tmr_exp(void *);
> void handle_mbx_event(void);
> extern uint32_t fm_amf_init(FM_AMF_CB *fm_amf_cb); @@ -148,6 +149,9
>@@ int main(int argc, char *argv[])
>
>       memset(fm_cb, 0, sizeof(FM_CB));
>       fm_cb->fm_amf_cb.nid_started = nid_started;
>+      fm_cb->fm_amf_cb.amf_fd = -1;
>+      fm_cb->fully_initialized = false;
>+      fm_cb->csi_assigned = false;
>
>       /* Variable to control whether FM will trigger failover immediately
>        * upon recieving down event of critical services or will wait @@ -
>186,16 +190,9 @@ int main(int argc, char *argv[])
>               goto fm_init_failed;
>       }
>
>-/* MDS initialization */
>-      if (fm_mds_init(fm_cb) != NCSCC_RC_SUCCESS) {
>-              goto fm_init_failed;
>-      }
>-
>-/* RDA initialization */
>       if (fm_rda_init(fm_cb) != NCSCC_RC_SUCCESS) {
>               goto fm_init_failed;
>       }
>-
>       if ((control_tipc = getenv("OPENSAF_MANAGE_TIPC")) == NULL)
>               fm_cb->control_tipc = false;
>       else if (strncmp(control_tipc, "yes", 3) == 0) @@ -223,9 +220,13 @@
>int main(int argc, char *argv[])
>
>       if (!nid_started &&
>               fm_amf_init(&fm_cb->fm_amf_cb) != NCSCC_RC_SUCCESS)
>-              goto done;
>+              goto fm_init_failed;
>
>-      fm_cb->csi_assigned = false;
>+      if ((rc = initialize_for_assignment(fm_cb,
>+              (SaAmfHAStateT) fm_cb->role)) != NCSCC_RC_SUCCESS) {
>+              LOG_ER("initialize_for_assignment FAILED %u", (unsigned)
>rc);
>+              goto fm_init_failed;
>+      }
>
>       /* Get mailbox selection object */
>       mbx_sel_obj = m_NCS_IPC_GET_SEL_OBJ(&fm_cb->mbx);
>@@ -295,6 +296,21 @@ int main(int argc, char *argv[])
>       exit(1);
> }
>
>+uint32_t initialize_for_assignment(FM_CB *cb, SaAmfHAStateT ha_state) {
>+      TRACE_ENTER2("ha_state = %d", (int) ha_state);
>+      uint32_t rc = NCSCC_RC_SUCCESS;
>+      if (cb->fully_initialized || ha_state == SA_AMF_HA_QUIESCED) goto
>done;
>+      cb->role = (PCS_RDA_ROLE) ha_state;
>+      if ((rc = fm_mds_init(cb)) != NCSCC_RC_SUCCESS) {
>+              LOG_ER("immd_mds_register FAILED %d", rc);
>+              goto done;
>+      }
>+      cb->fully_initialized = true;
>+done:
>+      TRACE_LEAVE2("rc = %u", rc);
>+      return rc;
>+}
>
>
>/**********************************************************
>******************
> * Name          : handle_mbx_event
>@@ -508,9 +524,7 @@ static void fm_mbx_msg_handler(FM_CB *fm
>               }
>               break;
>       case FM_EVT_RDA_ROLE:
>-              /* RDA role assignment for this controller node */
>-              fm_cb->role = fm_mbx_evt->info.rda_info.role;
>-              syslog(LOG_INFO, "RDA role for this controller node: %s",
>role_string[fm_cb->role]);
>+              fm_evt_proc_rda_callback(fm_cb, fm_mbx_evt);
>               break;
>       default:
>               break;
>@@ -525,6 +539,22 @@ static void fm_mbx_msg_handler(FM_CB *fm
>       return;
> }
>
>+static void fm_evt_proc_rda_callback(FM_CB *cb, FM_EVT *evt) {
>+      uint32_t rc = NCSCC_RC_SUCCESS;
>+
>+      TRACE_ENTER2("%d", (int) evt->info.rda_info.role);
>+      if ((rc = initialize_for_assignment(cb,
>+              (SaAmfHAStateT) evt->info.rda_info.role)) !=
>NCSCC_RC_SUCCESS) {
>+              LOG_ER("initialize_for_assignment FAILED %u", (unsigned)
>rc);
>+              opensaf_reboot(0, NULL, "FM service initialization failed");
>+      }
>+      cb->role = evt->info.rda_info.role;
>+      syslog(LOG_INFO, "RDA role for this controller node: %s",
>+              role_string[cb->role]);
>+      TRACE_LEAVE();
>+}
>+
>
>/**********************************************************
>******************
> * Name          : fm_tmr_start
> *
>diff --git a/osaf/services/infrastructure/fm/fms/fm_rda.c
>b/osaf/services/infrastructure/fm/fms/fm_rda.c
>--- a/osaf/services/infrastructure/fm/fms/fm_rda.c
>+++ b/osaf/services/infrastructure/fm/fms/fm_rda.c
>@@ -15,7 +15,11 @@
>  *
>  */
>
>-#include "fm.h"
>+#include "fm_cb.h"
>+#include <string.h>
>+#include <syslog.h>
>+#include "rda_papi.h"
>+#include "logtrace.h"
>
>
>/**********************************************************
>******************
>  * Name          : fm_rda_init
>@@ -31,84 +35,29 @@
> uint32_t fm_rda_init(FM_CB *fm_cb)
> {
>       uint32_t rc;
>-      uint32_t status = NCSCC_RC_SUCCESS;
>-      PCS_RDA_REQ rda_req;
>+      SaAmfHAStateT ha_state;
>       TRACE_ENTER();
>-
>-      /* initialize the RDA Library */
>-      memset(&rda_req, 0, sizeof(PCS_RDA_REQ));
>-      rda_req.req_type = PCS_RDA_LIB_INIT;
>-      rc = pcs_rda_request(&rda_req);
>-      if (rc != PCSRDA_RC_SUCCESS) {
>-              syslog(LOG_ERR, "RDA lib init failed");
>-              return NCSCC_RC_FAILURE;
>+      if ((rc = rda_get_role(&ha_state)) != NCSCC_RC_SUCCESS) {
>+              LOG_ER("rda_get_role FAILED");
>+              goto done;
>+      }
>+      switch (ha_state) {
>+      case SA_AMF_HA_ACTIVE:
>+              fm_cb->role = PCS_RDA_ACTIVE;
>+              break;
>+      case SA_AMF_HA_STANDBY:
>+              fm_cb->role = PCS_RDA_STANDBY;
>+              break;
>+      case SA_AMF_HA_QUIESCED:
>+              fm_cb->role = PCS_RDA_QUIESCED;
>+              break;
>+      case SA_AMF_HA_QUIESCING:
>+              fm_cb->role = PCS_RDA_QUIESCING;
>+              break;
>       }
>-
>-      /* get the role */
>-      memset(&rda_req, 0, sizeof(PCS_RDA_REQ));
>-      rda_req.req_type = PCS_RDA_GET_ROLE;
>-      rc = pcs_rda_request(&rda_req);
>-      if (rc != PCSRDA_RC_SUCCESS) {
>-              /* set the error code to be returned */
>-              status = NCSCC_RC_FAILURE;
>-              /* finalize */
>-              syslog(LOG_ERR, "RDA get role failed");
>-              goto rda_lib_destroy;
>-      }
>-
>-      /* update role in fm_cb */
>-      if ((rda_req.info.io_role == PCS_RDA_ACTIVE) ||
>(rda_req.info.io_role == PCS_RDA_STANDBY)) {
>-              fm_cb->role = rda_req.info.io_role;
>-      } else {
>-              /* set the error code to be returned */
>-              status = NCSCC_RC_FAILURE;
>-              syslog(LOG_ERR, "RDA role is neither Active nor Standby");
>-              goto rda_lib_destroy;
>-      }
>-
>-      return status;
>-
>-      /* finalize the library */
>- rda_lib_destroy:
>-      syslog(LOG_INFO, "RDA lib destroy called");
>-      memset(&rda_req, 0, sizeof(PCS_RDA_REQ));
>-      rda_req.req_type = PCS_RDA_LIB_DESTROY;
>-      rc = pcs_rda_request(&rda_req);
>-      if (rc != PCSRDA_RC_SUCCESS) {
>-              syslog(LOG_ERR, "RDA lib destroy failed in fm_rda_init");
>-              return NCSCC_RC_FAILURE;
>-      }
>+done:
>       TRACE_LEAVE();
>-      /* return the final status */
>-      return status;
>-}
>-
>-
>/**********************************************************
>******************
>- * Name          : fm_rda_finalize
>- *
>- * Description   : Finalizes RDA interfaces.
>- *
>- * Arguments     : Pointer to Control Block.
>- *
>- * Return Values : NCSCC_RC_SUCCESS/NCSCC_RC_FAILURE.
>- *
>- * Notes         : None.
>-
>***********************************************************
>******************/
>-uint32_t fm_rda_finalize(FM_CB *fm_cb)
>-{
>-      uint32_t rc;
>-      uint32_t status = NCSCC_RC_SUCCESS;
>-      PCS_RDA_REQ rda_req;
>-      TRACE_ENTER();
>-      memset(&rda_req, 0, sizeof(PCS_RDA_REQ));
>-      rda_req.req_type = PCS_RDA_LIB_DESTROY;
>-      rc = pcs_rda_request(&rda_req);
>-      if (rc != PCSRDA_RC_SUCCESS) {
>-              syslog(LOG_INFO, "RDA lib destroy failed in fm_rda_finalize
>");
>-              status = NCSCC_RC_FAILURE;
>-      }
>-      TRACE_LEAVE();
>-      return status;
>+      return rc;
> }
>
>
>/**********************************************************
>******************

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785471&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to