osaf/services/saf/ntfsv/ntfs/ntfs.h          |   7 ++-
 osaf/services/saf/ntfsv/ntfs/ntfs_amf.c      |  21 ++++-----
 osaf/services/saf/ntfsv/ntfs/ntfs_cb.h       |   2 +-
 osaf/services/saf/ntfsv/ntfs/ntfs_evt.c      |  26 ++++++++---
 osaf/services/saf/ntfsv/ntfs/ntfs_imcnutil.c |  20 +++++----
 osaf/services/saf/ntfsv/ntfs/ntfs_main.c     |  60 +++++++++++++++++----------
 osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c    |   8 +-
 osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.h    |   5 +-
 osaf/services/saf/ntfsv/ntfs/ntfs_mds.c      |   6 +-
 9 files changed, 92 insertions(+), 63 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/services/saf/ntfsv/ntfs/ntfs.h 
b/osaf/services/saf/ntfsv/ntfs/ntfs.h
--- a/osaf/services/saf/ntfsv/ntfs/ntfs.h
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs.h
@@ -26,6 +26,8 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdint.h>
+#include "saAmf.h"
 
 #include <ncsgl_defs.h>
 #include <ncs_lib.h>
@@ -60,7 +62,7 @@
  */
 extern ntfs_cb_t *ntfs_cb;
 extern SaAisErrorT ntfs_amf_init();
-extern uint32_t ntfs_mds_init(ntfs_cb_t *cb);
+extern uint32_t ntfs_mds_init(ntfs_cb_t *cb, SaAmfHAStateT ha_state);
 extern uint32_t ntfs_mds_finalize(ntfs_cb_t *cb);
 extern uint32_t ntfs_mds_change_role();
 extern uint32_t ntfs_mds_msg_send(ntfs_cb_t *cb,
@@ -69,5 +71,6 @@ extern uint32_t ntfs_mds_msg_send(ntfs_c
 extern void ntfs_evt_destroy(ntfsv_ntfs_evt_t *evt);
 
 const char *ha_state_str(SaAmfHAStateT state);
-
+extern uint32_t initialize_for_assignment(ntfs_cb_t *cb,
+       SaAmfHAStateT ha_state);
 #endif   /* ifndef __NTFS_H */
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_amf.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_amf.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_amf.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_amf.c
@@ -22,6 +22,7 @@
 #include "ntfs.h"
 #include "ntfs_com.h"
 #include "ntfs_imcnutil.h"
+#include "saflog.h"
 
 /****************************************************************************
  * Name          : amf_active_state_handler
@@ -186,6 +187,13 @@ static void amf_csi_set_callback(SaInvoc
                goto response;
        }
 
+       if ((rc = initialize_for_assignment(ntfs_cb,
+               new_haState)) != NCSCC_RC_SUCCESS) {
+               LOG_ER("initialize_for_assignment FAILED %u", (unsigned) rc);
+               error = SA_AIS_ERR_FAILED_OPERATION;
+               goto response;
+       }
+
        /* Invoke the appropriate state handler routine */
        switch (new_haState) {
        case SA_AMF_HA_ACTIVE:
@@ -214,16 +222,6 @@ static void amf_csi_set_callback(SaInvoc
 
        /* Update control block */
        ntfs_cb->ha_state = new_haState;
-       
-       if (ntfs_cb->csi_assigned == false) {
-               ntfs_cb->csi_assigned = true;
-               /* We shall open checkpoint only once in our life time. 
currently doing at lib init  */
-       } else if ((new_haState == SA_AMF_HA_ACTIVE) || (new_haState == 
SA_AMF_HA_STANDBY)) {   /* It is a switch over */
-               /* NOTE: This behaviour has to be checked later, when scxb 
redundancy is available 
-                * Also, change role of mds, mbcsv during quiesced has to be 
done after mds
-                * supports the same.  TBD
-                */
-       }
 
        /* Handle active to active role change. */
        if ((prev_haState == SA_AMF_HA_ACTIVE) && (new_haState == 
SA_AMF_HA_ACTIVE))
@@ -240,7 +238,8 @@ static void amf_csi_set_callback(SaInvoc
                }
 
                /* Inform MBCSV of HA state change */
-               if (NCSCC_RC_SUCCESS != (error = 
ntfs_mbcsv_change_HA_state(ntfs_cb)))
+               if (NCSCC_RC_SUCCESS != (error = ntfs_mbcsv_change_HA_state(
+                       ntfs_cb, new_haState)))
                        error = SA_AIS_ERR_FAILED_OPERATION;
                
                TRACE("%s NTFS changing HA role from %s to %s",
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_cb.h 
b/osaf/services/saf/ntfsv/ntfs/ntfs_cb.h
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_cb.h
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_cb.h
@@ -56,7 +56,7 @@ typedef struct ntfs_cb {
        SaSelectionObjectT mbcsv_sel_obj;       /* Selection object to wait for 
MBCSv events */
        NCS_MBCSV_CKPT_HDL mbcsv_ckpt_hdl;      /* MBCSv handle obtained during 
checkpoint open */
        EDU_HDL edu_hdl;        /* Handle from EDU for encode/decode operations 
*/
-       bool csi_assigned;
+       bool fully_initialized;
        unsigned int cache_size; /* size of the reader cache */
        bool nid_started;       /**< true if started by NID */
 } ntfs_cb_t;
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_evt.c
@@ -15,6 +15,7 @@
  *
  */
 #include "ntfs_com.h"
+#include <stdlib.h>
 #include <alloca.h>
 #include <time.h>
 #include <limits.h>
@@ -22,6 +23,7 @@
 #include "ntfsv_enc_dec.h"
 #include "osaf_extended_name.h"
 #include "ntfs_imcnutil.h"
+#include "saflog.h"
 
 
 #define m_NTFSV_FILL_ASYNC_UPDATE_FINALIZE(ckpt,client_id){ \
@@ -132,7 +134,7 @@ static uint32_t proc_mds_quiesced_ack_ms
        if (ntfs_cb->is_quisced_set == true) {
                ntfs_cb->ha_state = SA_AMF_HA_QUIESCED;
                /* Inform MBCSV of HA state change */
-               if (ntfs_mbcsv_change_HA_state(ntfs_cb) != NCSCC_RC_SUCCESS)
+               if (ntfs_mbcsv_change_HA_state(ntfs_cb, ntfs_cb->ha_state) != 
NCSCC_RC_SUCCESS)
                        TRACE("ntfs_mbcsv_change_HA_state FAILED");
 
                /* Update control block */
@@ -159,9 +161,16 @@ static uint32_t proc_rda_cb_msg(ntfsv_nt
 {
        uint32_t rc;
 
-       TRACE_ENTER();
+       TRACE_ENTER2("%d", (int) evt->info.rda_info.io_role);
+       if ((rc = initialize_for_assignment(ntfs_cb,
+               (SaAmfHAStateT) evt->info.rda_info.io_role)) !=
+               NCSCC_RC_SUCCESS) {
+               LOG_ER("initialize_for_assignment FAILED %u", (unsigned) rc);
+               exit(EXIT_FAILURE);
+       }
 
-       if (evt->info.rda_info.io_role == PCS_RDA_ACTIVE) {
+       if (evt->info.rda_info.io_role == PCS_RDA_ACTIVE &&
+               ntfs_cb->ha_state != SA_AMF_HA_ACTIVE) {
                SaAmfHAStateT old_ha_state = ntfs_cb->ha_state;
                LOG_NO("ACTIVE request");
 
@@ -172,7 +181,7 @@ static uint32_t proc_rda_cb_msg(ntfsv_nt
                }
 
                ntfs_cb->ha_state = SA_AMF_HA_ACTIVE;
-               if ((rc = ntfs_mbcsv_change_HA_state(ntfs_cb)) != 
NCSCC_RC_SUCCESS) {
+               if ((rc = ntfs_mbcsv_change_HA_state(ntfs_cb, 
ntfs_cb->ha_state)) != NCSCC_RC_SUCCESS) {
                        LOG_ER("ntfs_mbcsv_change_HA_state FAILED %u", rc);
                        goto done;
                }
@@ -207,13 +216,14 @@ uint32_t ntfs_cb_init(ntfs_cb_t *ntfs_cb
 {
        char *tmp;
        TRACE_ENTER();
-       /* Assign Initial HA state */
-       ntfs_cb->ha_state = NTFS_HA_INIT_STATE;
-       ntfs_cb->csi_assigned = false;
-       /* Assign Version. Currently, hardcoded, This will change later */
        ntfs_cb->ntf_version.releaseCode = NTF_RELEASE_CODE;
        ntfs_cb->ntf_version.majorVersion = NTF_MAJOR_VERSION;
        ntfs_cb->ntf_version.minorVersion = NTF_MINOR_VERSION;
+       ntfs_cb->amfSelectionObject = -1;
+       ntfs_cb->logSelectionObject = -1;
+       ntfs_cb->ha_state = NTFS_HA_INIT_STATE;
+       ntfs_cb->mbcsv_sel_obj = -1;
+       ntfs_cb->fully_initialized = false;
 
        tmp = (char *)getenv("NTFSV_ENV_CACHE_SIZE");
        if (tmp) {
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_imcnutil.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_imcnutil.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_imcnutil.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_imcnutil.c
@@ -337,16 +337,18 @@ int stop_ntfimcn(void)
        int rc = 0;
        TRACE_ENTER();
 
-       TRACE("%s: Cancel the imcn surveillance thread", __FUNCTION__);
-       rc = pthread_cancel(ipar.thread);
-       if (rc != 0) osaf_abort(rc);
-       rc = pthread_join(ipar.thread,&join_ret);
-       if (rc != 0) osaf_abort(rc);
-       rc = pthread_mutex_destroy(&ntfimcn_mutex);
-       if (rc != 0) osaf_abort(rc);
+       if (ipar.ha_state != 0) {
+               TRACE("%s: Cancel the imcn surveillance thread", __FUNCTION__);
+               rc = pthread_cancel(ipar.thread);
+               if (rc != 0) osaf_abort(rc);
+               rc = pthread_join(ipar.thread,&join_ret);
+               if (rc != 0) osaf_abort(rc);
+               rc = pthread_mutex_destroy(&ntfimcn_mutex);
+               if (rc != 0) osaf_abort(rc);
        
-       TRACE("%s: Terminating osafntfimcnd process",__FUNCTION__);
-       timedwait_imcn_exit();
+               TRACE("%s: Terminating osafntfimcnd process",__FUNCTION__);
+               timedwait_imcn_exit();
+       }
        
        TRACE_LEAVE();
        return rc;
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_main.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_main.c
@@ -22,6 +22,7 @@
  */
 
 #define _GNU_SOURCE
+#include <stdbool.h>
 #include <libgen.h>
 #include <string.h>
 #include <stdio.h>
@@ -75,7 +76,6 @@ extern void initAdmin(void);
 extern void printAdminInfo();
 extern void logEvent();
 
-
 const char *ha_state_str(SaAmfHAStateT state)
 {
        switch (state) {
@@ -226,16 +226,6 @@ static uint32_t initialize()
                goto done;
        }
 
-       if ((rc = ntfs_mds_init(ntfs_cb)) != NCSCC_RC_SUCCESS) {
-               TRACE("ntfs_mds_init FAILED %d", rc);
-               return rc;
-       }
-
-       if ((rc = ntfs_mbcsv_init(ntfs_cb)) != NCSCC_RC_SUCCESS) {
-               TRACE("ntfs_mbcsv_init FAILED");
-               return rc;
-       }
-
        if (ntfs_cb->nid_started &&
                (rc = ncs_sel_obj_create(&usr1_sel_obj)) != NCSCC_RC_SUCCESS)
        {
@@ -250,16 +240,16 @@ static uint32_t initialize()
                goto done;
        }
        
-       initAdmin();
 
        if (!ntfs_cb->nid_started && ntfs_amf_init() != SA_AIS_OK) {
                goto done;
        }
 
-       /* Initialize with saflog. This is necessary to avoid
-        *  getting blocked by LOG during role change (switchover/failover)
-        */
-       saflog_init();
+       if ((rc = initialize_for_assignment(ntfs_cb, ntfs_cb->ha_state)) !=
+               NCSCC_RC_SUCCESS) {
+               LOG_ER("initialize_for_assignment FAILED %u", (unsigned) rc);
+               goto done;
+       }
 
 done:
        if (ntfs_cb->nid_started &&
@@ -271,6 +261,33 @@ done:
        return (rc);
 }
 
+uint32_t initialize_for_assignment(ntfs_cb_t *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->ha_state = ha_state;
+       init_ntfimcn(ha_state);
+       if ((rc = ntfs_mds_init(cb, ha_state)) != NCSCC_RC_SUCCESS) {
+               LOG_ER("ntfs_mds_init FAILED %d", rc);
+               goto done;
+       }
+       if ((rc = ntfs_mbcsv_init(cb, ha_state)) != NCSCC_RC_SUCCESS) {
+               LOG_ER("ntfs_mbcsv_init FAILED");
+               ntfs_mds_finalize(cb);
+               goto done;
+       }
+       initAdmin();
+       saflog_init();
+
+       cb->fully_initialized = true;
+done:
+       TRACE_LEAVE2("rc = %u", rc);
+       return rc;
+}
+
 /**
  * Forever wait on events on AMF, MBCSV & NTFS Mailbox file descriptors
  * and process them.
@@ -292,9 +309,6 @@ int main(int argc, char *argv[])
                goto done;
        }
 
-       /* Start the imcn subprocess */
-       init_ntfimcn(ntfs_cb->ha_state);
-
        mbx_fd = ncs_ipc_get_sel_obj(&ntfs_cb->mbx);
        daemon_sigterm_install(&term_fd);
 
@@ -304,17 +318,17 @@ int main(int argc, char *argv[])
        fds[FD_AMF].fd = ntfs_cb->nid_started ?
                usr1_sel_obj.rmv_obj : ntfs_cb->amfSelectionObject;
        fds[FD_AMF].events = POLLIN;
-       fds[FD_MBCSV].fd = ntfs_cb->mbcsv_sel_obj;
-       fds[FD_MBCSV].events = POLLIN;
        fds[FD_MBX].fd = mbx_fd.rmv_obj;
        fds[FD_MBX].events = POLLIN;
-       fds[FD_LOG].fd = ntfs_cb->logSelectionObject;
-       fds[FD_LOG].events = POLLIN;
        
        TRACE("Started. HA state is %s",ha_state_str(ntfs_cb->ha_state));
 
        /* NTFS main processing loop. */
        while (1) {
+               fds[FD_MBCSV].fd = ntfs_cb->mbcsv_sel_obj;
+               fds[FD_MBCSV].events = POLLIN;
+               fds[FD_LOG].fd = ntfs_cb->logSelectionObject;
+               fds[FD_LOG].events = POLLIN;
                int ret = poll(fds, SIZE_FDS, -1);
 
                if (ret == -1) {
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.c
@@ -96,7 +96,7 @@ static NTFS_CKPT_HDLR ckpt_data_handler[
  *
  * Notes         : None.
  *****************************************************************************/
-uint32_t ntfs_mbcsv_init(ntfs_cb_t *cb)
+uint32_t ntfs_mbcsv_init(ntfs_cb_t *cb, SaAmfHAStateT ha_state)
 {
        uint32_t rc;
        NCS_MBCSV_ARG arg;
@@ -151,7 +151,7 @@ uint32_t ntfs_mbcsv_init(ntfs_cb_t *cb)
                goto done;
        }
 
-       rc = ntfs_mbcsv_change_HA_state(ntfs_cb);
+       rc = ntfs_mbcsv_change_HA_state(ntfs_cb, ha_state);
 
  done:
        TRACE_LEAVE();
@@ -173,7 +173,7 @@ uint32_t ntfs_mbcsv_init(ntfs_cb_t *cb)
  *                 during the first CSI assignment from AVSv  .
  *****************************************************************************/
 
-uint32_t ntfs_mbcsv_change_HA_state(ntfs_cb_t *cb)
+uint32_t ntfs_mbcsv_change_HA_state(ntfs_cb_t *cb, SaAmfHAStateT ha_state)
 {
        NCS_MBCSV_ARG mbcsv_arg;
        uint32_t rc = SA_AIS_OK;
@@ -184,7 +184,7 @@ uint32_t ntfs_mbcsv_change_HA_state(ntfs
        mbcsv_arg.i_op = NCS_MBCSV_OP_CHG_ROLE;
        mbcsv_arg.i_mbcsv_hdl = cb->mbcsv_hdl;
        mbcsv_arg.info.chg_role.i_ckpt_hdl = cb->mbcsv_ckpt_hdl;
-       mbcsv_arg.info.chg_role.i_ha_state = cb->ha_state;
+       mbcsv_arg.info.chg_role.i_ha_state = ha_state;
 
        if (SA_AIS_OK != (rc = ncs_mbcsv_svc(&mbcsv_arg))) {
                LOG_ER("ncs_mbcsv_svc NCS_MBCSV_OP_CHG_ROLE FAILED");
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.h 
b/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.h
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.h
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_mbcsv.h
@@ -18,6 +18,7 @@
 #ifndef NTFS_CKPT_H
 #define NTFS_CKPT_H
 
+#include "saAmf.h"
 
 #define NTFS_MBCSV_VERSION 1
 #define NTFS_MBCSV_VERSION_MIN 1
@@ -108,8 +109,8 @@ typedef struct {
 } ntfsv_ckpt_msg_t;
 
 typedef uint32_t (*NTFS_CKPT_HDLR) (ntfs_cb_t *cb, ntfsv_ckpt_msg_t *data);
-uint32_t ntfs_mbcsv_init(ntfs_cb_t *ntfs_cb);
-uint32_t ntfs_mbcsv_change_HA_state(ntfs_cb_t *cb);
+uint32_t ntfs_mbcsv_init(ntfs_cb_t *ntfs_cb, SaAmfHAStateT ha_state);
+uint32_t ntfs_mbcsv_change_HA_state(ntfs_cb_t *cb, SaAmfHAStateT ha_state);
 uint32_t ntfs_mbcsv_dispatch(NCS_MBCSV_HDL mbcsv_hdl);
 uint32_t ntfs_send_async_update(ntfs_cb_t *cb, ntfsv_ckpt_msg_t *ckpt_rec, 
uint32_t action);
 void update_standby(ntfsv_ckpt_msg_t *ckpt, uint32_t action);
diff --git a/osaf/services/saf/ntfsv/ntfs/ntfs_mds.c 
b/osaf/services/saf/ntfsv/ntfs/ntfs_mds.c
--- a/osaf/services/saf/ntfsv/ntfs/ntfs_mds.c
+++ b/osaf/services/saf/ntfsv/ntfs/ntfs_mds.c
@@ -1028,7 +1028,7 @@ static uint32_t mds_vdest_create(ntfs_cb
  *
  * Notes         : None.
  *****************************************************************************/
-uint32_t ntfs_mds_init(ntfs_cb_t *cb)
+uint32_t ntfs_mds_init(ntfs_cb_t *cb, SaAmfHAStateT ha_state)
 {
        NCSMDS_INFO mds_info;
        uint32_t rc;
@@ -1043,10 +1043,10 @@ uint32_t ntfs_mds_init(ntfs_cb_t *cb)
        }
 
        /* Set the role of MDS */
-       if (cb->ha_state == SA_AMF_HA_ACTIVE)
+       if (ha_state == SA_AMF_HA_ACTIVE)
                cb->mds_role = V_DEST_RL_ACTIVE;
 
-       if (cb->ha_state == SA_AMF_HA_STANDBY)
+       if (ha_state == SA_AMF_HA_STANDBY)
                cb->mds_role = V_DEST_RL_STANDBY;
 
        if (NCSCC_RC_SUCCESS != (rc = ntfs_mds_change_role())) {

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to