diff --git a/exec/ckpt.c b/exec/ckpt.c index ebc2310a..657edf24 100644 --- a/exec/ckpt.c +++ b/exec/ckpt.c @@ -45,7 +45,8 @@ #include #include "../include/ais_types.h" -#include "../include/ais_msg.h" +#include "../include/saCkpt.h" +#include "../include/ipc_ckpt.h" #include "../include/list.h" #include "../include/queue.h" #include "aispoll.h" @@ -62,13 +63,16 @@ DECLARE_LIST_INIT(checkpointListHead); DECLARE_LIST_INIT(checkpointIteratorListHead); +struct checkpoint_cleanup { + struct list_head list; + struct saCkptCheckpoint *checkpoint; +}; + //TODO static totempg_recovery_plug_handle ckpt_checkpoint_recovery_plug_handle; -static int ckpt_checkpoint_exec_init_fn (void); +static int ckpt_exec_init_fn (void); -static int ckpt_checkpoint_exit_fn (struct conn_info *conn_info); - -static int ckptSectionIteratorApiFinalize (struct conn_info *conn_info); +static int ckpt_exit_fn (struct conn_info *conn_info); static int message_handler_req_lib_activatepoll (struct conn_info *, void *message); @@ -96,19 +100,17 @@ static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_a static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message); -static int message_handler_req_lib_ckpt_checkpoint_init (struct conn_info *conn_info, void *message); - -static int message_handler_req_lib_ckpt_sectioniterator_init (struct conn_info *conn_info, void *message); - static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message); static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message); +static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message); + static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message); static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message); -static int message_handler_req_lib_ckpt_activecheckpointset (struct conn_info *conn_info, void *message); +static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message); static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message); @@ -131,7 +133,7 @@ static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_ static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_info *conn_info, void *message); static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message); -static int ckpt_checkpoint_confchg_fn ( +static int ckpt_confchg_fn ( enum totempg_configuration_type configuration_type, struct in_addr *member_list, void *member_list_private, int member_list_entries, @@ -150,36 +152,6 @@ static int ckpt_checkpoint_confchg_fn ( } struct libais_handler ckpt_libais_handlers[] = -{ - { /* 0 */ - .libais_handler_fn = message_handler_req_lib_activatepoll, - .response_size = sizeof (struct res_lib_activatepoll), - .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL, - } -}; - -/* - * TODO - */ -int (*ckpt_aisexec_handler_fns[]) (void *, struct in_addr source_addr, int endian_conversion_required) = { -}; - -/* - * exported service - */ -struct service_handler ckpt_service_handler = { - .libais_handlers = ckpt_libais_handlers, - .libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler), - .aisexec_handler_fns = ckpt_aisexec_handler_fns, - .aisexec_handler_fns_count = sizeof (ckpt_aisexec_handler_fns) / sizeof (int (*)), - .confchg_fn = 0, /* ckpt service handler is not distributed */ - .libais_init_fn = message_handler_req_lib_ckpt_init, - .libais_exit_fn = 0, - .exec_init_fn = 0, - .exec_dump_fn = 0 -}; - -struct libais_handler ckpt_checkpoint_libais_handlers[] = { { /* 0 */ .libais_handler_fn = message_handler_req_lib_activatepoll, @@ -197,69 +169,84 @@ struct libais_handler ckpt_checkpoint_libais_handlers[] = .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC, }, { /* 3 */ + .libais_handler_fn = message_handler_req_lib_ckpt_checkpointclose, + .response_size = sizeof (struct res_lib_ckpt_checkpointclose), + .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE, + }, + { /* 4 */ .libais_handler_fn = message_handler_req_lib_ckpt_checkpointunlink, .response_size = sizeof (struct res_lib_ckpt_checkpointunlink), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK, }, - { /* 4 */ + { /* 5 */ .libais_handler_fn = message_handler_req_lib_ckpt_checkpointretentiondurationset, .response_size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET, }, - { /* 5 */ - .libais_handler_fn = message_handler_req_lib_ckpt_activecheckpointset, - .response_size = sizeof (struct res_lib_ckpt_activecheckpointset), - .response_id = MESSAGE_RES_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET, - }, { /* 6 */ + .libais_handler_fn = message_handler_req_lib_ckpt_activereplicaset, + .response_size = sizeof (struct res_lib_ckpt_activereplicaset), + .response_id = MESSAGE_RES_CKPT_CHECKPOINT_ACTIVEREPLICASET, + }, + { /* 7 */ .libais_handler_fn = message_handler_req_lib_ckpt_checkpointstatusget, .response_size = sizeof (struct res_lib_ckpt_checkpointstatusget), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET, }, - { /* 7 */ + { /* 8 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectioncreate, .response_size = sizeof (struct res_lib_ckpt_sectioncreate), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE, }, - { /* 8 */ + { /* 9 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectiondelete, .response_size = sizeof (struct res_lib_ckpt_sectiondelete), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE, }, - { /* 9 */ + { /* 10 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectionexpirationtimeset, .response_size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET, }, - { /* 10 */ + { /* 11 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectionwrite, .response_size = sizeof (struct res_lib_ckpt_sectionwrite), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE, }, - { /* 11 */ + { /* 12 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectionoverwrite, .response_size = sizeof (struct res_lib_ckpt_sectionoverwrite), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE, }, - { /* 12 */ + { /* 13 */ .libais_handler_fn = message_handler_req_lib_ckpt_sectionread, .response_size = sizeof (struct res_lib_ckpt_sectionread), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD, }, - { /* 13 */ + { /* 14 */ .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronize, .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronize), .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE, }, - { /* 14 */ + { /* 15 */ .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronizeasync, .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync), // TODO RESPONSE .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC, }, + { /* 16 */ + .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratorinitialize, + .response_size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize), + .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE, + }, + { /* 17 */ + .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratornext, + .response_size = sizeof (struct res_lib_ckpt_sectioniteratornext), + .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT, + } }; -static int (*ckpt_checkpoint_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr, int endian_conversion_required) = { +static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr, int endian_conversion_required) = { message_handler_req_exec_ckpt_checkpointopen, message_handler_req_exec_ckpt_checkpointclose, message_handler_req_exec_ckpt_checkpointunlink, @@ -273,53 +260,19 @@ static int (*ckpt_checkpoint_aisexec_handler_fns[]) (void *msg, struct in_addr s message_handler_req_exec_ckpt_sectionread }; -struct service_handler ckpt_checkpoint_service_handler = { - .libais_handlers = ckpt_checkpoint_libais_handlers, - .libais_handlers_count = sizeof (ckpt_checkpoint_libais_handlers) / sizeof (struct libais_handler), - .aisexec_handler_fns = ckpt_checkpoint_aisexec_handler_fns, - .aisexec_handler_fns_count = sizeof (ckpt_checkpoint_aisexec_handler_fns) / sizeof (int (*)), - .confchg_fn = ckpt_checkpoint_confchg_fn, - .libais_init_fn = message_handler_req_lib_ckpt_checkpoint_init, - .libais_exit_fn = ckpt_checkpoint_exit_fn, - .exec_init_fn = ckpt_checkpoint_exec_init_fn, +struct service_handler ckpt_service_handler = { + .libais_handlers = ckpt_libais_handlers, + .libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler), + .aisexec_handler_fns = ckpt_aisexec_handler_fns, + .aisexec_handler_fns_count = sizeof (ckpt_aisexec_handler_fns) / sizeof (int (*)), + .confchg_fn = ckpt_confchg_fn, + .libais_init_fn = message_handler_req_lib_ckpt_init, + .libais_exit_fn = ckpt_exit_fn, + .exec_init_fn = ckpt_exec_init_fn, .exec_dump_fn = 0 }; -struct libais_handler ckpt_sectioniterator_libais_handlers[] = -{ - { /* 0 */ - .libais_handler_fn = message_handler_req_lib_activatepoll, - .response_size = sizeof (struct res_lib_activatepoll), - .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL, - }, - { /* 1 */ - .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratorinitialize, - .response_size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize), - .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE, - }, - { /* 2 */ - .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratornext, - .response_size = sizeof (struct res_lib_ckpt_sectioniteratornext), - .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT, - } -}; - -static int (*ckpt_sectioniterator_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr, int endian_conversion_required) = { -}; - -struct service_handler ckpt_sectioniterator_service_handler = { - .libais_handlers = ckpt_sectioniterator_libais_handlers, - .libais_handlers_count = sizeof (ckpt_sectioniterator_libais_handlers) / sizeof (struct libais_handler), - .aisexec_handler_fns = ckpt_sectioniterator_aisexec_handler_fns , - .aisexec_handler_fns_count = sizeof (ckpt_sectioniterator_aisexec_handler_fns) / sizeof (int (*)), - .confchg_fn = 0, /* Section Iterators are not distributed */ - .libais_init_fn = message_handler_req_lib_ckpt_sectioniterator_init, - .libais_exit_fn = ckptSectionIteratorApiFinalize, - .exec_init_fn = 0, - .exec_dump_fn = 0 -}; - -static struct saCkptCheckpoint *findCheckpoint (SaNameT *name) +static struct saCkptCheckpoint *ckpt_checkpoint_find_global (SaNameT *name) { struct list_head *checkpointList; struct saCkptCheckpoint *checkpoint; @@ -338,7 +291,28 @@ static struct saCkptCheckpoint *findCheckpoint (SaNameT *name) return (0); } -static struct saCkptCheckpointSection *findCheckpointSection ( +static void ckpt_checkpoint_remove_cleanup ( + struct conn_info *conn_info, + struct saCkptCheckpoint *checkpoint) +{ + struct list_head *list; + struct checkpoint_cleanup *checkpoint_cleanup; + + for (list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next; + list != &conn_info->ais_ci.u.libckpt_ci.checkpoint_list; + list = list->next) { + + checkpoint_cleanup = list_entry (list, + struct checkpoint_cleanup, list); + + if (checkpoint_cleanup->checkpoint == checkpoint) { + list_del (&checkpoint_cleanup->list); + free (checkpoint_cleanup); + return; + } + } +} +static struct saCkptCheckpointSection *ckpt_checkpoint_find_globalSection ( struct saCkptCheckpoint *ckptCheckpoint, char *id, int idLen) @@ -400,7 +374,7 @@ void checkpoint_release (struct saCkptCheckpoint *checkpoint) free (checkpoint); } -int sendCkptCheckpointClose (struct saCkptCheckpoint *checkpoint) { +int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) { struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose; struct iovec iovecs[2]; @@ -412,8 +386,7 @@ int sendCkptCheckpointClose (struct saCkptCheckpoint *checkpoint) { req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE; memcpy (&req_exec_ckpt_checkpointclose.checkpointName, - &checkpoint->name, - sizeof (SaNameT)); + &checkpoint->name, sizeof (SaNameT)); iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose; iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose); @@ -426,7 +399,7 @@ int sendCkptCheckpointClose (struct saCkptCheckpoint *checkpoint) { return (-1); } -static int ckpt_checkpoint_exec_init_fn (void) +static int ckpt_exec_init_fn (void) { #ifdef TODO int res; @@ -441,34 +414,41 @@ static int ckpt_checkpoint_exec_init_fn (void) return (0); } -static int ckpt_checkpoint_exit_fn (struct conn_info *conn_info) +static int ckpt_exit_fn (struct conn_info *conn_info) { - - /* - * close checkpoint opened from this fd - */ - if (conn_info->service == SOCKET_SERVICE_CKPT_CHECKPOINT && - conn_info->ais_ci.u.libckpt_ci.checkpoint) { - log_printf (LOG_LEVEL_DEBUG, "Trying to finalize %p %s\n", conn_info, - getSaNameT (&conn_info->ais_ci.u.libckpt_ci.checkpoint->name)); - - sendCkptCheckpointClose (conn_info->ais_ci.u.libckpt_ci.checkpoint); + struct checkpoint_cleanup *checkpoint_cleanup; + struct list_head *list; + + if (conn_info->service != SOCKET_SERVICE_CKPT) { + return 0; } - return (0); -} - -static int ckptSectionIteratorApiFinalize (struct conn_info *conn_info) { + /* - * If section iterator connection, unlink from list and free section iterator data + * close all checkpoints opened on this fd */ - if (conn_info->service == SOCKET_SERVICE_CKPT_SECTIONITERATOR) { - log_printf (LOG_LEVEL_DEBUG, "freeing section iterator\n"); - if (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) { - free (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries); - } - list_del (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list); + for (list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next; + list != &conn_info->ais_ci.u.libckpt_ci.checkpoint_list;) { + + checkpoint_cleanup = list_entry (list, + struct checkpoint_cleanup, list); + + ckpt_checkpoint_close (checkpoint_cleanup->checkpoint); + + list = list->next; + + free (checkpoint_cleanup); } +#ifdef TODO +/* todo close section iterators + */ +// TODO what about exit of open checkpoints + + if (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) { + free (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries); + } + list_del (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list); +#endif return (0); } @@ -478,7 +458,7 @@ static int message_handler_req_lib_activatepoll (struct conn_info *conn_info, vo res_lib_activatepoll.header.size = sizeof (struct res_lib_activatepoll); res_lib_activatepoll.header.id = MESSAGE_RES_LIB_ACTIVATEPOLL; - res_lib_activatepoll.header.error = SA_OK; + res_lib_activatepoll.header.error = SA_AIS_OK; libais_send_response (conn_info, &res_lib_activatepoll, sizeof (struct res_lib_activatepoll)); @@ -493,11 +473,12 @@ static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct i struct saCkptCheckpoint *ckptCheckpoint = 0; struct saCkptCheckpointSection *ckptCheckpointSection = 0; - SaErrorT error = SA_OK; + struct checkpoint_cleanup *checkpoint_cleanup; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen); - ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointopen->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointopen->checkpointName); /* * If checkpoint doesn't exist, create one @@ -505,14 +486,14 @@ static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct i if (ckptCheckpoint == 0) { ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint)); if (ckptCheckpoint == 0) { - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection)); if (ckptCheckpointSection == 0) { free (ckptCheckpoint); - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } @@ -553,10 +534,10 @@ static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct i * If the checkpoint has been unlinked, it is an invalid name */ if (ckptCheckpoint->unlinked) { - error = SA_ERR_INVALID_PARAM; /* Is this the correct return ? */ + error = SA_AIS_ERR_INVALID_PARAM; /* Is this the correct return ? */ goto error_exit; } - + /* * Setup connection information and mark checkpoint as referenced */ @@ -577,17 +558,25 @@ error_exit: * If this node was the source of the message, respond to this node */ if (req_exec_ckpt_checkpointopen->source.in_addr.s_addr == this_ip.sin_addr.s_addr) { - req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpoint = ckptCheckpoint; - req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags = req_lib_ckpt_checkpointopen->checkpointOpenFlags; res_lib_ckpt_checkpointopen.header.size = sizeof (struct res_lib_ckpt_checkpointopen); res_lib_ckpt_checkpointopen.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN; res_lib_ckpt_checkpointopen.header.error = error; + checkpoint_cleanup = malloc (sizeof (struct checkpoint_cleanup)); + if (checkpoint_cleanup == 0) { + free (ckptCheckpoint); + error = SA_AIS_ERR_NO_MEMORY; + } else { + checkpoint_cleanup->checkpoint = ckptCheckpoint; + list_add (&checkpoint_cleanup->list, + &req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpoint_list); + } + libais_send_response (req_exec_ckpt_checkpointopen->source.conn_info, &res_lib_ckpt_checkpointopen, sizeof (struct res_lib_ckpt_checkpointopen)); } -// return (error == SA_OK ? 0 : -1); +// return (error == SA_AIS_OK ? 0 : -1); return (0); } @@ -638,16 +627,19 @@ void timer_function_retention (void *data) extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr, int endian_conversion_required) { struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message; + struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose; struct saCkptCheckpoint *checkpoint = 0; + SaAisErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to close checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointclose->checkpointName)); - checkpoint = findCheckpoint (&req_exec_ckpt_checkpointclose->checkpointName); + checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointclose->checkpointName); if (checkpoint == 0) { - return (0); + goto error_exit; } checkpoint->referenceCount--; + assert (checkpoint->referenceCount >= 0); log_printf (LOG_LEVEL_DEBUG, "disconnect called, new CKPT ref count is %d\n", checkpoint->referenceCount); @@ -666,6 +658,17 @@ extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct &checkpoint->retention_timer); } +error_exit: + if (req_exec_ckpt_checkpointclose->source.in_addr.s_addr == this_ip.sin_addr.s_addr) { + ckpt_checkpoint_remove_cleanup (req_exec_ckpt_checkpointclose->source.conn_info, + checkpoint); + + res_lib_ckpt_checkpointclose.header.size = sizeof (struct res_lib_ckpt_checkpointclose); + res_lib_ckpt_checkpointclose.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE; + res_lib_ckpt_checkpointclose.header.error = error; + libais_send_response (req_exec_ckpt_checkpointclose->source.conn_info, + &res_lib_ckpt_checkpointclose, sizeof (struct res_lib_ckpt_checkpointclose)); + } return (0); } @@ -676,16 +679,16 @@ static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)&req_exec_ckpt_checkpointunlink->req_lib_ckpt_checkpointunlink; struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink; struct saCkptCheckpoint *ckptCheckpoint = 0; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink); - ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointunlink->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointunlink->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } if (ckptCheckpoint->unlinked) { - error = SA_ERR_INVALID_PARAM; + error = SA_AIS_ERR_INVALID_PARAM; goto error_exit; } ckptCheckpoint->unlinked = 1; @@ -720,7 +723,7 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *m struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset; struct saCkptCheckpoint *checkpoint; - checkpoint = findCheckpoint (&req_exec_ckpt_checkpointretentiondurationset->checkpointName); + checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationset->checkpointName); if (checkpoint) { log_printf (LOG_LEVEL_NOTICE, "CKPT: Setting retention duration for checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointretentiondurationset->checkpointName)); @@ -743,7 +746,7 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *m if (req_exec_ckpt_checkpointretentiondurationset->source.in_addr.s_addr == this_ip.sin_addr.s_addr) { res_lib_ckpt_checkpointretentiondurationset.header.size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset); res_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET; - res_lib_ckpt_checkpointretentiondurationset.header.error = SA_OK; + res_lib_ckpt_checkpointretentiondurationset.header.error = SA_AIS_OK; libais_send_response (req_exec_ckpt_checkpointretentiondurationset->source.conn_info, &res_lib_ckpt_checkpointretentiondurationset, @@ -759,7 +762,7 @@ static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void struct saCkptCheckpoint *checkpoint; struct iovec iovecs[2]; - checkpoint = findCheckpoint (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName); + checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName); if (checkpoint && checkpoint->expired == 0) { log_printf (LOG_LEVEL_NOTICE, "CKPT: Expiring checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName)); checkpoint->expired = 1; @@ -791,23 +794,23 @@ static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in struct saCkptCheckpointSection *ckptCheckpointSection; void *initialData; void *sectionId; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n"); - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectioncreate->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectioncreate->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_SYSTEM; // TODO find the right error for this + error = SA_AIS_ERR_LIBRARY; // TODO find the right error for this goto error_exit; } /* * Determine if user-specified checkpoint ID already exists */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate), req_lib_ckpt_sectioncreate->idLen); if (ckptCheckpointSection) { - error = SA_ERR_EXIST; + error = SA_AIS_ERR_EXIST; goto error_exit; } @@ -816,7 +819,7 @@ static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in */ ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection)); if (ckptCheckpointSection == 0) { - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } /* @@ -825,7 +828,7 @@ static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in initialData = malloc (req_lib_ckpt_sectioncreate->initialDataSize); if (initialData == 0) { free (ckptCheckpointSection); - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } /* @@ -835,7 +838,7 @@ static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in if (sectionId == 0) { free (ckptCheckpointSection); free (initialData); - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } @@ -875,7 +878,8 @@ static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in * Add checkpoint section to checkpoint */ list_init (&ckptCheckpointSection->list); - list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead); + list_add (&ckptCheckpointSection->list, + &ckptCheckpoint->checkpointSectionsListHead); error_exit: if (req_exec_ckpt_sectioncreate->source.in_addr.s_addr == this_ip.sin_addr.s_addr) { @@ -896,11 +900,11 @@ static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete; struct saCkptCheckpoint *ckptCheckpoint; struct saCkptCheckpointSection *ckptCheckpointSection; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectiondelete->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectiondelete->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -908,19 +912,18 @@ static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in * Determine if the user is trying to delete the default section */ if (req_lib_ckpt_sectiondelete->idLen == 0) { - error = SA_ERR_INVALID_PARAM; + error = SA_AIS_ERR_INVALID_PARAM; goto error_exit; } /* * Find checkpoint section to be deleted */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)(req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete)), req_lib_ckpt_sectiondelete->idLen); if (ckptCheckpointSection == 0) { -printf ("section not found\n"); - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -951,12 +954,12 @@ static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset; struct saCkptCheckpoint *ckptCheckpoint; struct saCkptCheckpointSection *ckptCheckpointSection; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiratoin time\n"); - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionexpirationtimeset->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionexpirationtimeset->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -964,20 +967,20 @@ static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message * Determine if the user is trying to set expiration time for the default section */ if (req_lib_ckpt_sectionexpirationtimeset->idLen == 0) { - error = SA_ERR_INVALID_PARAM; + error = SA_AIS_ERR_INVALID_PARAM; goto error_exit; } /* * Find checkpoint section that expiration time should be set for */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)req_lib_ckpt_sectionexpirationtimeset) + sizeof (struct req_lib_ckpt_sectionexpirationtimeset), req_lib_ckpt_sectionexpirationtimeset->idLen); if (ckptCheckpointSection == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1015,12 +1018,12 @@ static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_ struct saCkptCheckpointSection *ckptCheckpointSection; int sizeRequired; void *sectionData; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request to section write.\n"); - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionwrite->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionwrite->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1028,13 +1031,13 @@ static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_ /* * Find checkpoint section to be written */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite), req_lib_ckpt_sectionwrite->idLen); if (ckptCheckpointSection == 0) { printf ("CANT FIND SECTION '%s'\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite)); - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1045,7 +1048,7 @@ printf ("CANT FIND SECTION '%s'\n", if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) { sectionData = realloc (ckptCheckpointSection->sectionData, sizeRequired); if (sectionData == 0) { - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } @@ -1093,24 +1096,24 @@ static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct struct saCkptCheckpoint *ckptCheckpoint; struct saCkptCheckpointSection *ckptCheckpointSection; void *sectionData; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n"); - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionoverwrite->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionoverwrite->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } /* * Find checkpoint section to be overwritten */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)req_lib_ckpt_sectionoverwrite) + sizeof (struct req_lib_ckpt_sectionoverwrite), req_lib_ckpt_sectionoverwrite->idLen); if (ckptCheckpointSection == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1119,7 +1122,7 @@ static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct */ sectionData = malloc (req_lib_ckpt_sectionoverwrite->dataSize); if (sectionData == 0) { - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } @@ -1164,25 +1167,25 @@ static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_a struct saCkptCheckpoint *ckptCheckpoint; struct saCkptCheckpointSection *ckptCheckpointSection = 0; int sectionSize = 0; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n"); - ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionread->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionread->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_SYSTEM; // TODO find the right error for this + error = SA_AIS_ERR_LIBRARY; // TODO find the right error for this goto error_exit; } /* * Find checkpoint section to be read */ - ckptCheckpointSection = findCheckpointSection (ckptCheckpoint, + ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint, ((char *)req_lib_ckpt_sectionread) + sizeof (struct req_lib_ckpt_sectionread), req_lib_ckpt_sectionread->idLen); if (ckptCheckpointSection == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1205,7 +1208,7 @@ static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_a */ if (req_lib_ckpt_sectionread->dataOffset > sectionSize) { sectionSize = 0; - error = SA_ERR_INVALID_PARAM; + error = SA_AIS_ERR_INVALID_PARAM; goto error_exit; } @@ -1239,69 +1242,20 @@ error_exit: static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message) { struct res_lib_init res_lib_init; - SaErrorT error = SA_ERR_SECURITY; - - log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT.\n"); - - if (conn_info->authenticated) { - conn_info->service = SOCKET_SERVICE_CKPT; - error = SA_OK; - } - - res_lib_init.header.size = sizeof (struct res_lib_init); - res_lib_init.header.id = MESSAGE_RES_INIT; - res_lib_init.header.error = error; - - libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init)); - - if (conn_info->authenticated) { - return (0); - } - return (-1); -} - -static int message_handler_req_lib_ckpt_checkpoint_init (struct conn_info *conn_info, void *message) -{ - struct res_lib_init res_lib_init; - SaErrorT error = SA_ERR_SECURITY; + SaErrorT error = SA_AIS_ERR_ACCESS; log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT checkpoint.\n"); if (conn_info->authenticated) { - conn_info->service = SOCKET_SERVICE_CKPT_CHECKPOINT; - conn_info->ais_ci.u.libckpt_ci.checkpoint = 0; - conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags = 0; - error = SA_OK; - } - - res_lib_init.header.size = sizeof (struct res_lib_init); - res_lib_init.header.id = MESSAGE_RES_INIT; - res_lib_init.header.error = error; - - libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init)); - - if (conn_info->authenticated) { - return (0); - } - return (-1); -} - -static int message_handler_req_lib_ckpt_sectioniterator_init (struct conn_info *conn_info, void *message) -{ - struct res_lib_init res_lib_init; - SaErrorT error = SA_ERR_SECURITY; - - log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT section iterator.\n"); - - if (conn_info->authenticated) { - conn_info->service = SOCKET_SERVICE_CKPT_SECTIONITERATOR; + conn_info->service = SOCKET_SERVICE_CKPT; list_init (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list); conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries = 0; conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorCount = 0; conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorPos = 0; list_add (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list, &checkpointIteratorListHead); - error = SA_OK; + list_init (&conn_info->ais_ci.u.libckpt_ci.checkpoint_list); + error = SA_AIS_OK; } res_lib_init.header.size = sizeof (struct res_lib_init); @@ -1348,6 +1302,36 @@ static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *c } +static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message) { + struct req_lib_ckpt_checkpointclose *req_lib_ckpt_checkpointclose = (struct req_lib_ckpt_checkpointclose *)message; + struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose; + struct saCkptCheckpoint *checkpoint; + struct iovec iovecs[2]; + + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointclose->checkpointName); + if (checkpoint->expired == 1) { + return (0); + } + req_exec_ckpt_checkpointclose.header.size = + sizeof (struct req_exec_ckpt_checkpointclose); + req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE; + + req_exec_ckpt_checkpointclose.source.conn_info = conn_info; + req_exec_ckpt_checkpointclose.source.in_addr.s_addr = this_ip.sin_addr.s_addr; + + memcpy (&req_exec_ckpt_checkpointclose.checkpointName, + &checkpoint->name, sizeof (SaNameT)); + + iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose; + iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose); + + if (totempg_send_ok (sizeof (struct req_exec_ckpt_checkpointclose))) { + assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0); + } + + return (0); +} + static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message) { struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)message; @@ -1387,7 +1371,7 @@ static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct c req_exec_ckpt_checkpointretentiondurationset.source.in_addr.s_addr = this_ip.sin_addr.s_addr; memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_checkpointretentiondurationset->checkpointName, sizeof (SaNameT)); req_exec_ckpt_checkpointretentiondurationset.retentionDuration = req_lib_ckpt_checkpointretentiondurationset->retentionDuration; @@ -1399,7 +1383,7 @@ static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct c return (0); } -static int message_handler_req_lib_ckpt_activecheckpointset (struct conn_info *conn_info, void *message) +static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message) { return (0); } @@ -1414,13 +1398,13 @@ static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *c struct list_head *checkpointSectionList; struct saCkptCheckpointSection *checkpointSection; - req_lib_ckpt_checkpointstatusget = 0; /* The request info isn't used */ log_printf (LOG_LEVEL_DEBUG, "in status get\n"); /* * Count memory used by checkpoint sections */ - checkpoint = conn_info->ais_ci.u.libckpt_ci.checkpoint; + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointstatusget->checkpointName); + for (checkpointSectionList = checkpoint->checkpointSectionsListHead.next; checkpointSectionList != &checkpoint->checkpointSectionsListHead; checkpointSectionList = checkpointSectionList->next) { @@ -1437,13 +1421,13 @@ static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *c */ res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget); res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET; - res_lib_ckpt_checkpointstatusget.header.error = SA_OK; + res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_OK; - memcpy (&res_lib_ckpt_checkpointstatusget.checkpointStatus.checkpointCreationAttributes, + memcpy (&res_lib_ckpt_checkpointstatusget.checkpointDescriptor.checkpointCreationAttributes, &checkpoint->checkpointCreationAttributes, sizeof (SaCkptCheckpointCreationAttributesT)); - res_lib_ckpt_checkpointstatusget.checkpointStatus.numberOfSections = numberOfSections; - res_lib_ckpt_checkpointstatusget.checkpointStatus.memoryUsed = memoryUsed; + res_lib_ckpt_checkpointstatusget.checkpointDescriptor.numberOfSections = numberOfSections; + res_lib_ckpt_checkpointstatusget.checkpointDescriptor.memoryUsed = memoryUsed; log_printf (LOG_LEVEL_DEBUG, "before sending message\n"); libais_send_response (conn_info, &res_lib_ckpt_checkpointstatusget, @@ -1455,22 +1439,11 @@ static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_in { struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)message; struct req_exec_ckpt_sectioncreate req_exec_ckpt_sectioncreate; - struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate; struct iovec iovecs[2]; + struct saCkptCheckpoint *checkpoint; log_printf (LOG_LEVEL_DEBUG, "Section create from API fd %d\n", conn_info->fd); - /* - * Determine if checkpoint is opened in write mode If not, send error to api - */ - if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { - res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate); - res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE; - res_lib_ckpt_sectioncreate.header.error = SA_ERR_ACCESS; - - libais_send_response (conn_info, &res_lib_ckpt_sectioncreate, - sizeof (struct res_lib_ckpt_sectioncreate)); - return (0); - } + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioncreate->checkpointName); /* * checkpoint opened is writeable mode so send message to cluster @@ -1483,7 +1456,7 @@ static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_in sizeof (struct req_lib_ckpt_sectioncreate)); memcpy (&req_exec_ckpt_sectioncreate.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectioncreate->checkpointName, sizeof (SaNameT)); req_exec_ckpt_sectioncreate.source.conn_info = conn_info; @@ -1532,7 +1505,7 @@ static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_in req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete); memcpy (&req_exec_ckpt_sectiondelete.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectiondelete->checkpointName, sizeof (SaNameT)); memcpy (&req_exec_ckpt_sectiondelete.req_lib_ckpt_sectiondelete, @@ -1571,7 +1544,7 @@ static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_in req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset); memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectionexpirationtimeset->checkpointName, sizeof (SaNameT)); memcpy (&req_exec_ckpt_sectionexpirationtimeset.req_lib_ckpt_sectionexpirationtimeset, @@ -1605,23 +1578,11 @@ static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_inf { struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)message; struct req_exec_ckpt_sectionwrite req_exec_ckpt_sectionwrite; - struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite; struct iovec iovecs[2]; + struct saCkptCheckpoint *checkpoint; log_printf (LOG_LEVEL_DEBUG, "Section write from API fd %d\n", conn_info->fd); -// UNDO printf ("section write %d\n", write_inv++); - /* - * Determine if checkpoint is opened in write mode If not, send error to api - */ - if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { - res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite); - res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE; - res_lib_ckpt_sectionwrite.header.error = SA_ERR_ACCESS; - - libais_send_response (conn_info, &res_lib_ckpt_sectionwrite, - sizeof (struct res_lib_ckpt_sectionwrite)); - return (0); - } + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionwrite->checkpointName); /* * checkpoint opened is writeable mode so send message to cluster @@ -1634,7 +1595,7 @@ static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_inf sizeof (struct req_lib_ckpt_sectionwrite)); memcpy (&req_exec_ckpt_sectionwrite.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectionwrite->checkpointName, sizeof (SaNameT)); req_exec_ckpt_sectionwrite.source.conn_info = conn_info; @@ -1662,22 +1623,11 @@ static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn { struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)message; struct req_exec_ckpt_sectionoverwrite req_exec_ckpt_sectionoverwrite; - struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite; struct iovec iovecs[2]; + struct saCkptCheckpoint *checkpoint; log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info->fd); - /* - * Determine if checkpoint is opened in write mode If not, send error to api - */ - if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { - res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionoverwrite); - res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE; - res_lib_ckpt_sectionoverwrite.header.error = SA_ERR_ACCESS; - - libais_send_response (conn_info, &res_lib_ckpt_sectionoverwrite, - sizeof (struct res_lib_ckpt_sectionoverwrite)); - return (0); - } + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionoverwrite->checkpointName); /* * checkpoint opened is writeable mode so send message to cluster @@ -1690,7 +1640,7 @@ static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn sizeof (struct req_lib_ckpt_sectionoverwrite)); memcpy (&req_exec_ckpt_sectionoverwrite.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectionoverwrite->checkpointName, sizeof (SaNameT)); req_exec_ckpt_sectionoverwrite.source.conn_info = conn_info; @@ -1717,22 +1667,11 @@ static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info { struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)message; struct req_exec_ckpt_sectionread req_exec_ckpt_sectionread; - struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread; struct iovec iovecs[2]; + struct saCkptCheckpoint *checkpoint; log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info->fd); - /* - * Determine if checkpoint is opened in write mode If not, send error to api - */ - if ((conn_info->ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) { - res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread); - res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD; - res_lib_ckpt_sectionread.header.error = SA_ERR_ACCESS; - - libais_send_response (conn_info, &res_lib_ckpt_sectionread, - sizeof (struct res_lib_ckpt_sectionread)); - return (0); - } + checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionread->checkpointName); /* * checkpoint opened is writeable mode so send message to cluster @@ -1745,7 +1684,7 @@ static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info sizeof (struct req_lib_ckpt_sectionread)); memcpy (&req_exec_ckpt_sectionread.checkpointName, - &conn_info->ais_ci.u.libckpt_ci.checkpoint->name, + &req_lib_ckpt_sectionread->checkpointName, sizeof (SaNameT)); req_exec_ckpt_sectionread.source.conn_info = conn_info; @@ -1789,14 +1728,14 @@ static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_i struct list_head *checkpointSectionList; int addEntry = 0; int iteratorEntries = 0; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; log_printf (LOG_LEVEL_DEBUG, "section iterator initialize\n"); ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator; - ckptCheckpoint = findCheckpoint (&req_lib_ckpt_sectioniteratorinitialize->checkpointName); + ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioniteratorinitialize->checkpointName); if (ckptCheckpoint == 0) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } @@ -1824,7 +1763,7 @@ static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_i if (ckptSectionIterator->sectionIteratorEntries) { free (ckptSectionIterator->sectionIteratorEntries); } - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_exit; } ckptSectionIteratorEntries[iteratorEntries - 1].active = 1; @@ -1850,7 +1789,7 @@ static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *c struct req_lib_ckpt_sectioniteratornext *req_lib_ckpt_sectioniteratornext = (struct req_lib_ckpt_sectioniteratornext *)message; struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext; struct saCkptSectionIterator *ckptSectionIterator; - SaErrorT error = SA_OK; + SaErrorT error = SA_AIS_OK; int sectionIdSize = 0; int iteratorPos = 0; @@ -1867,7 +1806,7 @@ static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *c * No more sections in iterator */ if (ckptSectionIterator->iteratorPos + 1 >= ckptSectionIterator->iteratorCount) { - error = SA_ERR_NOT_EXIST; + error = SA_AIS_ERR_NOT_EXIST; goto error_exit; } diff --git a/exec/ckpt.h b/exec/ckpt.h index 3c3be642..9a49d68f 100644 --- a/exec/ckpt.h +++ b/exec/ckpt.h @@ -32,7 +32,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ #include "../include/ais_types.h" -#include "../include/ais_msg.h" +#include "../include/saCkpt.h" #include "aispoll.h" #include "parse.h" @@ -70,15 +70,10 @@ struct saCkptSectionIterator { }; struct libckpt_ci { - struct saCkptCheckpoint *checkpoint; - SaCkptCheckpointOpenFlagsT checkpointOpenFlags; + struct list_head checkpoint_list; struct saCkptSectionIterator sectionIterator; }; extern struct service_handler ckpt_service_handler; -extern struct service_handler ckpt_checkpoint_service_handler; - -extern struct service_handler ckpt_sectioniterator_service_handler; - #endif /* CKPT_H_DEFINED */ diff --git a/exec/main.c b/exec/main.c index 95f27bfc..4808393d 100644 --- a/exec/main.c +++ b/exec/main.c @@ -87,12 +87,10 @@ struct service_handler *ais_service_handlers[] = { &clm_service_handler, &amf_service_handler, &ckpt_service_handler, - &ckpt_checkpoint_service_handler, - &ckpt_sectioniterator_service_handler, &evt_service_handler }; -#define AIS_SERVICE_HANDLERS_COUNT 7 +#define AIS_SERVICE_HANDLERS_COUNT 5 #define AIS_SERVICE_HANDLER_AISEXEC_FUNCTIONS_MAX 40 static int poll_handler_libais_deliver (poll_handle handle, int fd, int revent, void *data, unsigned int *prio); diff --git a/exec/main.h b/exec/main.h index 524b58dc..334be6a5 100644 --- a/exec/main.h +++ b/exec/main.h @@ -58,8 +58,6 @@ enum socket_service_type { SOCKET_SERVICE_CLM, SOCKET_SERVICE_AMF, SOCKET_SERVICE_CKPT, - SOCKET_SERVICE_CKPT_CHECKPOINT, - SOCKET_SERVICE_CKPT_SECTIONITERATOR, SOCKET_SERVICE_EVT }; diff --git a/include/ais_msg.h b/include/ais_msg.h index a94b2f11..a885c974 100644 --- a/include/ais_msg.h +++ b/include/ais_msg.h @@ -101,60 +101,6 @@ enum res_lib_amf_types { MESSAGE_RES_AMF_RESPONSE }; -enum req_lib_ckpt_checkpoint_types { - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN = 1, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTUNLINK, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET, - MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONCREATE, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE, - MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE, - MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC -}; - -enum req_lib_ckpt_sectioniterator_types { - MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 1, - MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT -}; - -enum res_lib_ckpt_types { - MESSAGE_RES_CKPT_CHECKPOINTOPENASYNC = 1, - MESSAGE_RES_CKPT_CHECKPOINTSYNCHRONIZEASYNC -}; - -enum res_lib_ckpt_checkpoint_types { - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN = 1, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET, - MESSAGE_RES_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE, - MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE, - MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC -}; - -enum res_lib_ckpt_sectioniterator_types { - MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE = 1, - MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT -}; - -struct message_source { - struct conn_info *conn_info; - struct in_addr in_addr; -} __attribute__((packed)); - struct res_evs_deliver_callback { struct res_header header; struct in_addr source_addr; @@ -305,23 +251,6 @@ struct req_exec_amf_hastateset { SaAmfHAStateT haState; }; -struct req_exec_ckpt_checkpointclose { - struct req_header header; - SaNameT checkpointName; -}; - -struct req_exec_ckpt_checkpointretentiondurationset { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - SaTimeT retentionDuration; -}; - -struct req_exec_ckpt_checkpointretentiondurationexpire { - struct req_header header; - SaNameT checkpointName; -}; - struct res_lib_amf_componentterminatecallback { struct res_header header; SaInvocationT invocation; @@ -462,226 +391,4 @@ struct res_lib_activatepoll { struct res_header header; }; -struct req_lib_ckpt_checkpointopen { - struct req_header header; - SaNameT checkpointName; - SaCkptCheckpointCreationAttributesT checkpointCreationAttributes; - SaCkptCheckpointOpenFlagsT checkpointOpenFlags; -}; - -struct res_lib_ckpt_checkpointopen { - struct res_header header; -}; - -struct req_exec_ckpt_checkpointopen { - struct req_header header; - struct message_source source; - struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen; -}; - - -struct req_lib_ckpt_checkpointopenasync { - struct req_header header; - SaNameT checkpointName; - SaCkptCheckpointCreationAttributesT checkpointCreationAttributes; - SaCkptCheckpointOpenFlagsT checkpointOpenFlags; - SaInvocationT invocation; -}; - -struct res_lib_ckpt_checkpointopenasync { - struct res_header header; - SaCkptCheckpointHandleT checkpointHandle; - SaInvocationT invocation; -}; - -struct req_lib_ckpt_checkpointclose { - struct req_header header; -}; - -struct res_lib_ckpt_checkpointclose { - struct res_header header; - SaNameT checkpointName; -}; - -struct req_lib_ckpt_checkpointunlink { - struct req_header header; - SaNameT checkpointName; -}; - -struct res_lib_ckpt_checkpointunlink { - struct res_header header; -}; - -struct req_exec_ckpt_checkpointunlink { - struct req_header header; - struct message_source source; - struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink; -}; - -struct req_lib_ckpt_checkpointretentiondurationset { - struct req_header header; - SaTimeT retentionDuration; -}; -struct res_lib_ckpt_checkpointretentiondurationset { - struct res_header header; -}; - -struct req_lib_ckpt_activecheckpointset { - struct req_header header; -}; - -struct res_lib_ckpt_activecheckpointset { - struct res_header header; -}; - -struct req_lib_ckpt_checkpointstatusget { - struct req_header header; -}; - -struct res_lib_ckpt_checkpointstatusget { - struct res_header header; - SaCkptCheckpointStatusT checkpointStatus; -}; - -struct req_lib_ckpt_sectioncreate { - struct req_header header; - SaUint32T idLen; - SaTimeT expirationTime; - SaUint32T initialDataSize; -}; - -struct res_lib_ckpt_sectioncreate { - struct res_header header; -}; - -struct req_exec_ckpt_sectioncreate { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate; /* this must be last */ -}; - -struct req_lib_ckpt_sectiondelete { - struct req_header header; - SaUint32T idLen; -}; - -struct res_lib_ckpt_sectiondelete { - struct res_header header; -}; -struct req_exec_ckpt_sectiondelete { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete; /* this must be last */ -}; - -struct req_lib_ckpt_sectionexpirationtimeset { - struct req_header header; - SaUint32T idLen; - SaTimeT expirationTime; -}; - -struct res_lib_ckpt_sectionexpirationtimeset { - struct res_header header; -}; - -struct req_exec_ckpt_sectionexpirationtimeset { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset; -}; - -struct req_lib_ckpt_sectioniteratorinitialize { - struct req_header header; - SaNameT checkpointName; - SaCkptSectionsChosenT sectionsChosen; - SaTimeT expirationTime; -}; - -struct res_lib_ckpt_sectioniteratorinitialize { - struct res_header header; -}; - -struct req_lib_ckpt_sectioniteratornext { - struct req_header header; -}; - -struct res_lib_ckpt_sectioniteratornext { - struct res_header header; - SaCkptSectionDescriptorT sectionDescriptor; -}; - -struct req_lib_ckpt_sectionwrite { - struct req_header header; - SaUint32T idLen; - SaOffsetT dataOffset; - SaOffsetT dataSize; -}; - -struct res_lib_ckpt_sectionwrite { - struct res_header header; -}; - -struct req_exec_ckpt_sectionwrite { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite; -}; - -struct req_lib_ckpt_sectionoverwrite { - struct req_header header; - SaUint32T idLen; - SaUint32T dataSize; -}; - -struct res_lib_ckpt_sectionoverwrite { - struct res_header header; -}; - -struct req_exec_ckpt_sectionoverwrite { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite; -}; - -struct req_lib_ckpt_sectionread { - struct req_header header; - SaUint32T idLen; - SaOffsetT dataOffset; - SaOffsetT dataSize; -}; - -struct res_lib_ckpt_sectionread { - struct res_header header; - SaSizeT dataRead; -}; - -struct req_exec_ckpt_sectionread { - struct req_header header; - struct message_source source; - SaNameT checkpointName; - struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread; -}; - -struct req_lib_ckpt_checkpointsynchronize { - struct req_header header; -}; - -struct res_lib_ckpt_checkpointsynchronize { - struct res_header header; -}; - -struct req_lib_ckpt_checkpointsynchronizeasync { - struct req_header header; - SaInvocationT invocation; -}; - -struct res_lib_ckpt_checkpointsynchronizeasync { - struct res_header header; -}; - #endif /* AIS_MSG_H_DEFINED */ diff --git a/include/ais_types.h b/include/ais_types.h index 52be6c57..03226164 100644 --- a/include/ais_types.h +++ b/include/ais_types.h @@ -304,95 +304,4 @@ typedef struct { SaAmfErrorBufferT *additionalInformation; } SaAmfAdditionalDataT; -typedef SaUint64T SaCkptHandleT; - -typedef SaUint64T SaCkptCheckpointHandleT; - -typedef SaUint64T SaCkptSectionIteratorT; - -#define SA_CKPT_WR_ALL_REPLICAS 0x1 -#define SA_CKPT_WR_ACTIVE_REPLICA 0x2 -#define SA_CKPT_WR_ACTIVE_REPLICA_WEAK 0x4 - -typedef SaUint32T SaCkptCheckpointCreationFlagsT; - -typedef struct { - SaCkptCheckpointCreationFlagsT creationFlags; - SaSizeT checkpointSize; - SaTimeT retentionDuration; - SaUint32T maxSections; - SaSizeT maxSectionSize; - SaUint32T maxSectionIdSize; -} SaCkptCheckpointCreationAttributesT; - -#define SA_CKPT_CHECKPOINT_READ 0x1 -#define SA_CKPT_CHECKPOINT_WRITE 0x2 -#define SA_CKPT_CHECKPOINT_COLOCATED 0x4 -typedef SaUint32T SaCkptCheckpointOpenFlagsT; - -#define SA_CKPT_DEFAULT_SECTION_ID { 0, 0 } -#define SA_CKPT_GENERATED_SECTION_ID { 0, 0 } - -typedef struct { - SaUint8T *id; - SaUint32T idLen; -} SaCkptSectionIdT; - -typedef struct { - SaCkptSectionIdT *sectionId; - SaTimeT expirationTime; -} SaCkptSectionCreationAttributesT; - -typedef enum { - SA_CKPT_SECTION_VALID = 1, - SA_CKPT_SECTION_CORRUPTED = 2 -} SaCkptSectionStateT; - -typedef struct { - SaCkptSectionIdT sectionId; - SaTimeT expirationTime; - SaSizeT sectionSize; - SaCkptSectionStateT sectionState; - SaTimeT lastUpdate; -} SaCkptSectionDescriptorT; - -typedef enum { - SA_CKPT_SECTIONS_FOREVER = 1, - SA_CKPT_SECTIONS_LEQ_EXPIRATION_TIME = 2, - SA_CKPT_SECTIONS_GEQ_EXPIRATION_TIME = 3, - SA_CKPT_SECTIONS_CORRUPTED = 4, - SA_CKPT_SECTIONS_ANY = 5 -} SaCkptSectionsChosenT; - -typedef SaUint32T SaOffsetT; - -typedef struct { - SaCkptSectionIdT sectionId; - void *dataBuffer; - SaSizeT dataSize; - SaOffsetT dataOffset; - SaSizeT readSize; -} SaCkptIOVectorElementT; - -typedef struct { - SaCkptCheckpointCreationAttributesT checkpointCreationAttributes; - SaUint32T numberOfSections; - SaUint32T memoryUsed; -} SaCkptCheckpointStatusT; - -typedef void (*SaCkptCheckpointOpenCallbackT) ( - SaInvocationT invocation, - const SaCkptCheckpointHandleT *checkpointHandle, - SaErrorT error); - -typedef void (*SaCkptCheckpointSynchronizeCallbackT) ( - SaInvocationT invocation, - SaErrorT error); - -typedef struct { - SaCkptCheckpointOpenCallbackT saCkptCheckpointOpenCallback; - SaCkptCheckpointSynchronizeCallbackT saCkptCheckpointSynchronizeCallback; -} SaCkptCallbacksT; - - #endif /* AIS_TYPES_H_DEFINED */ diff --git a/include/ipc_gen.h b/include/ipc_gen.h index 1e9ae3f2..fcfd71c3 100644 --- a/include/ipc_gen.h +++ b/include/ipc_gen.h @@ -39,8 +39,6 @@ enum req_init_types { MESSAGE_REQ_CLM_INIT, MESSAGE_REQ_AMF_INIT, MESSAGE_REQ_CKPT_INIT, - MESSAGE_REQ_CKPT_CHECKPOINT_INIT, - MESSAGE_REQ_CKPT_SECTIONITERATOR_INIT, MESSAGE_REQ_EVT_INIT }; @@ -87,5 +85,9 @@ struct res_header { SaErrorT error; }; +struct message_source { + struct conn_info *conn_info; + struct in_addr in_addr; +} __attribute__((packed)); #endif /* IPC_GEN_H_DEFINED */ diff --git a/lib/Makefile b/lib/Makefile index 332483ae..73a95abd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -86,7 +86,7 @@ amf.o: ../include/ipc_gen.h util.h clm.o: ../include/ais_types.h ../include/saClm.h ../include/ais_types.h clm.o: ../include/ais_msg.h ../include/evs.h ../include/saClm.h clm.o: ../include/ipc_gen.h ../include/ipc_clm.h util.h -ckpt.o: ../include/list.h ../include/ais_types.h ../include/ais_ckpt.h +ckpt.o: ../include/list.h ../include/ais_types.h ../include/saCkpt.h ckpt.o: ../include/ais_types.h ../include/ais_msg.h ../include/evs.h ckpt.o: ../include/saClm.h ../include/ipc_gen.h util.h evt.o: ../include/ipc_evt.h ../include/ais_types.h ../include/saEvt.h diff --git a/lib/ckpt.c b/lib/ckpt.c index ecd11e15..f760d904 100644 --- a/lib/ckpt.c +++ b/lib/ckpt.c @@ -44,12 +44,13 @@ #include #include -#include "../include/list.h" -#include "../include/ais_types.h" -#include "../include/ais_ckpt.h" -#include "../include/ais_msg.h" #include "util.h" +#include "../include/list.h" +#include "../include/saCkpt.h" +#include "../include/ipc_gen.h" +#include "../include/ipc_ckpt.h" + struct message_overlay { struct req_header header; char data[4096]; @@ -68,13 +69,16 @@ struct ckptInstance { struct ckptCheckpointInstance { int fd; + SaCkptHandleT ckptHandle; + SaCkptCheckpointOpenFlagsT checkpointOpenFlags; SaNameT checkpointName; SaUint32T maxSectionIdSize; pthread_mutex_t mutex; }; -struct ckptSectionIteratorInstance { +struct ckptSectionIterationInstance { int fd; + SaCkptCheckpointHandleT checkpointHandle; struct list_head sectionIdListHead; SaUint32T maxSectionIdSize; pthread_mutex_t mutex; @@ -82,7 +86,7 @@ struct ckptSectionIteratorInstance { void ckptHandleInstanceDestructor (void *instance); void checkpointHandleInstanceDestructor (void *instance); -void ckptSectionIteratorHandleInstanceDestructor (void *instance); +void ckptSectionIterationHandleInstanceDestructor (void *instance); /* * All CKPT instances in this database @@ -107,19 +111,19 @@ static struct saHandleDatabase checkpointHandleDatabase = { /* * All section iterators in this database */ -static struct saHandleDatabase ckptSectionIteratorHandleDatabase = { +static struct saHandleDatabase ckptSectionIterationHandleDatabase = { .handleCount = 0, .handles = 0, .mutex = PTHREAD_MUTEX_INITIALIZER, - .handleInstanceDestructor = ckptSectionIteratorHandleInstanceDestructor + .handleInstanceDestructor = ckptSectionIterationHandleInstanceDestructor }; /* * Versions supported */ static SaVersionT ckptVersionsSupported[] = { - { 'A', 1, 1 }, - { 'a', 1, 1 } + { 'B', 1, 1 }, + { 'b', 1, 1 } }; static struct saVersionDatabase ckptVersionDatabase = { @@ -146,49 +150,43 @@ struct ckptInstance *ckptInstance = (struct ckptInstance *)instance; void checkpointHandleInstanceDestructor (void *instance) { - struct ckptCheckpointInstance *ckptCheckpointInstance = (struct ckptCheckpointInstance *)instance; - - if (ckptCheckpointInstance->fd != -1) { - shutdown (ckptCheckpointInstance->fd, 0); - - close (ckptCheckpointInstance->fd); - } + return; } -void ckptSectionIteratorHandleInstanceDestructor (void *instance) +void ckptSectionIterationHandleInstanceDestructor (void *instance) { - struct ckptSectionIteratorInstance *ckptSectionIteratorInstance = (struct ckptSectionIteratorInstance *)instance; + struct ckptSectionIterationInstance *ckptSectionIterationInstance = (struct ckptSectionIterationInstance *)instance; - if (ckptSectionIteratorInstance->fd != -1) { - shutdown (ckptSectionIteratorInstance->fd, 0); + if (ckptSectionIterationInstance->fd != -1) { + shutdown (ckptSectionIterationInstance->fd, 0); - close (ckptSectionIteratorInstance->fd); + close (ckptSectionIterationInstance->fd); } } -SaErrorT +SaAisErrorT saCkptInitialize ( SaCkptHandleT *ckptHandle, const SaCkptCallbacksT *callbacks, - const SaVersionT *version) + SaVersionT *version) { struct ckptInstance *ckptInstance; - SaErrorT error = SA_OK; + SaAisErrorT error = SA_AIS_OK; error = saVersionVerify (&ckptVersionDatabase, version); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_no_destroy; } error = saHandleCreate (&ckptHandleDatabase, sizeof (struct ckptInstance), ckptHandle); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_no_destroy; } error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle, (void *)&ckptInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_destroy; } @@ -199,12 +197,12 @@ saCkptInitialize ( * sync response */ error = saQueueInit (&ckptInstance->inq, 512, sizeof (void *)); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_put_destroy; } - error = saServiceConnect (&ckptInstance->fd, MESSAGE_REQ_CKPT_CHECKPOINT_INIT); - if (error != SA_OK) { + error = saServiceConnect (&ckptInstance->fd, MESSAGE_REQ_CKPT_INIT); + if (error != SA_AIS_OK) { goto error_put_destroy; } @@ -214,7 +212,7 @@ saCkptInitialize ( saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); - return (SA_OK); + return (SA_AIS_OK); error_put_destroy: saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); @@ -224,34 +222,34 @@ error_no_destroy: return (error); } -SaErrorT +SaAisErrorT saCkptSelectionObjectGet ( - const SaCkptHandleT *ckptHandle, + const SaCkptHandleT ckptHandle, SaSelectionObjectT *selectionObject) { struct ckptInstance *ckptInstance; - SaErrorT error; + SaAisErrorT error; - error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle, (void *)&ckptInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance); + if (error != SA_AIS_OK) { return (error); } *selectionObject = ckptInstance->fd; - saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); - return (SA_OK); + return (SA_AIS_OK); } #ifdef COMPILE_OUT -SaErrorT +SaAisErrorT saCkptDispatch ( - const SaCkptHandleT *ckptHandle, + const SaCkptHandleT ckptHandle, SaDispatchFlagsT dispatchFlags) { fd_set read_fds; - SaErrorT error; + SaAisErrorT error; int dispatch_avail; struct timeval *timeout = 0; struct ckptInstance *ckptInstance; @@ -261,8 +259,8 @@ saCkptDispatch ( int ignore_dispatch = 0; int cont = 1; /* always continue do loop except when set to 0 */ - error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle, (void *)&ckptInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance); + if (error != SA_AIS_OK) { return (error); } @@ -281,7 +279,7 @@ saCkptDispatch ( FD_SET (ckptInstance->fd, &read_fds); error = saSelectRetry (ckptInstance->fd + 1, &read_fds, 0, 0, timeout); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -308,14 +306,14 @@ saCkptDispatch ( * Queue empty, read response from socket */ error = saRecvRetry (ckptInstance->fd, &ckptInstance->message.header, sizeof (struct req_header), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } if (ckptInstance->message.header.size > sizeof (struct req_header)) { error = saRecvRetry (ckptInstance->fd, &ckptInstance->message.data, ckptInstance->message.header.size - sizeof (struct req_header), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } } @@ -419,16 +417,16 @@ error_exit: } #endif -SaErrorT +SaAisErrorT saCkptFinalize ( - const SaCkptHandleT *ckptHandle) + const SaCkptHandleT ckptHandle) { struct ckptInstance *ckptInstance; - SaErrorT error; + SaAisErrorT error; - error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle, + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } @@ -439,8 +437,8 @@ saCkptFinalize ( */ if (ckptInstance->finalize) { pthread_mutex_unlock (&ckptInstance->mutex); - saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); - return (SA_ERR_BAD_HANDLE); + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); + return (SA_AIS_ERR_BAD_HANDLE); } ckptInstance->finalize = 1; @@ -449,47 +447,53 @@ saCkptFinalize ( pthread_mutex_unlock (&ckptInstance->mutex); - saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); - saHandleDestroy (&ckptHandleDatabase, *ckptHandle); + saHandleDestroy (&ckptHandleDatabase, ckptHandle); - return (SA_OK); + return (SA_AIS_OK); } -SaErrorT +SaAisErrorT saCkptCheckpointOpen ( + SaCkptHandleT ckptHandle, const SaNameT *checkpointName, const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes, SaCkptCheckpointOpenFlagsT checkpointOpenFlags, SaTimeT timeout, SaCkptCheckpointHandleT *checkpointHandle) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; + struct ckptInstance *ckptInstance; struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen; struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen; error = saHandleCreate (&checkpointHandleDatabase, sizeof (struct ckptCheckpointInstance), checkpointHandle); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_no_destroy; } error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_destroy; } - ckptCheckpointInstance->fd = -1; + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, + (void *)&ckptInstance); + if (error != SA_AIS_OK) { + goto error_put_destroy; + } + + ckptCheckpointInstance->fd = ckptInstance->fd; ckptCheckpointInstance->maxSectionIdSize = checkpointCreationAttributes->maxSectionIdSize; - error = saServiceConnect (&ckptCheckpointInstance->fd, MESSAGE_REQ_CKPT_CHECKPOINT_INIT); - if (error != SA_OK) { - goto error_put_destroy; - } + ckptCheckpointInstance->ckptHandle = ckptHandle; + ckptCheckpointInstance->checkpointOpenFlags = checkpointOpenFlags; req_lib_ckpt_checkpointopen.header.size = sizeof (struct req_lib_ckpt_checkpointopen); req_lib_ckpt_checkpointopen.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTOPEN; @@ -502,19 +506,19 @@ saCkptCheckpointOpen ( error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_checkpointopen, sizeof (struct req_lib_ckpt_checkpointopen), MSG_NOSIGNAL); - if (error != SA_OK) { - goto error_put_destroy; + if (error != SA_AIS_OK) { + goto error_put_ckpt_destroy; } error = saRecvRetry (ckptCheckpointInstance->fd, &res_lib_ckpt_checkpointopen, sizeof (struct res_lib_ckpt_checkpointopen), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { - goto error_put_destroy; + if (error != SA_AIS_OK) { + goto error_put_ckpt_destroy; } - if (res_lib_ckpt_checkpointopen.header.error != SA_OK) { + if (res_lib_ckpt_checkpointopen.header.error != SA_AIS_OK) { error = res_lib_ckpt_checkpointopen.header.error; - goto error_put_destroy; + goto error_put_ckpt_destroy; } pthread_mutex_init (&ckptCheckpointInstance->mutex, NULL); @@ -523,28 +527,32 @@ saCkptCheckpointOpen ( return (error); +error_put_ckpt_destroy: + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); + error_put_destroy: saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + error_destroy: saHandleDestroy (&checkpointHandleDatabase, *checkpointHandle); error_no_destroy: return (error); } -SaErrorT +SaAisErrorT saCkptCheckpointOpenAsync ( - const SaCkptHandleT *ckptHandle, + const SaCkptHandleT ckptHandle, SaInvocationT invocation, const SaNameT *checkpointName, const SaCkptCheckpointCreationAttributesT *checkpointCreationAttributes, SaCkptCheckpointOpenFlagsT checkpointOpenFlags) { struct ckptInstance *ckptInstance; - SaErrorT error; + SaAisErrorT error; struct req_lib_ckpt_checkpointopenasync req_lib_ckpt_checkpointopenasync; - error = saHandleInstanceGet (&ckptHandleDatabase, *ckptHandle, (void *)&ckptInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance); + if (error != SA_AIS_OK) { return (error); } @@ -565,43 +573,64 @@ saCkptCheckpointOpenAsync ( pthread_mutex_unlock (&ckptInstance->mutex); - saHandleInstancePut (&ckptHandleDatabase, *ckptHandle); + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); return (error); } -SaErrorT +SaAisErrorT saCkptCheckpointClose ( - const SaCkptCheckpointHandleT *checkpointHandle) + SaCkptCheckpointHandleT checkpointHandle) { - SaErrorT error; + struct req_lib_ckpt_checkpointclose req_lib_ckpt_checkpointclose; + struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } - saHandleDestroy (&checkpointHandleDatabase, *checkpointHandle); + req_lib_ckpt_checkpointclose.header.size = sizeof (struct req_lib_ckpt_checkpointclose); + req_lib_ckpt_checkpointclose.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTCLOSE; + memcpy (&req_lib_ckpt_checkpointclose.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_checkpointclose, + sizeof (struct req_lib_ckpt_checkpointclose), MSG_NOSIGNAL); + if (error != SA_AIS_OK) { + goto exit_put; + } + + error = saRecvRetry (ckptCheckpointInstance->fd, &res_lib_ckpt_checkpointclose, + sizeof (struct res_lib_ckpt_checkpointclose), MSG_WAITALL | MSG_NOSIGNAL); + + + saHandleInstancePut (&ckptHandleDatabase, ckptCheckpointInstance->ckptHandle); + + saHandleDestroy (&checkpointHandleDatabase, checkpointHandle); + +exit_put: + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); error_exit: return (error); } -SaErrorT +SaAisErrorT saCkptCheckpointUnlink ( + SaCkptHandleT ckptHandle, const SaNameT *checkpointName) { - SaErrorT error; + SaAisErrorT error; + struct ckptInstance *ckptInstance; struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink; struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink; - int fd; - error = saServiceConnect (&fd, MESSAGE_REQ_CKPT_CHECKPOINT_INIT); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptHandleDatabase, ckptHandle, (void *)&ckptInstance); + if (error != SA_AIS_OK) { goto exit_noclose; } @@ -610,34 +639,37 @@ saCkptCheckpointUnlink ( memcpy (&req_lib_ckpt_checkpointunlink.checkpointName, checkpointName, sizeof (SaNameT)); - error = saSendRetry (fd, &req_lib_ckpt_checkpointunlink, sizeof (struct req_lib_ckpt_checkpointunlink), MSG_NOSIGNAL); - if (error != SA_OK) { - goto exit_close; + error = saSendRetry (ckptInstance->fd, &req_lib_ckpt_checkpointunlink, + sizeof (struct req_lib_ckpt_checkpointunlink), MSG_NOSIGNAL); + if (error != SA_AIS_OK) { + goto exit_put; } - error = saRecvRetry (fd, &res_lib_ckpt_checkpointunlink, + error = saRecvRetry (ckptInstance->fd, &res_lib_ckpt_checkpointunlink, sizeof (struct res_lib_ckpt_checkpointunlink), MSG_WAITALL | MSG_NOSIGNAL); -exit_close: - close (fd); - return (error == SA_OK ? res_lib_ckpt_checkpointunlink.header.error : error); +exit_put: + saHandleInstancePut (&ckptHandleDatabase, ckptHandle); + + return (error == SA_AIS_OK ? res_lib_ckpt_checkpointunlink.header.error : error); + exit_noclose: return (error); } -SaErrorT +SaAisErrorT saCkptCheckpointRetentionDurationSet ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, SaTimeT retentionDuration) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_checkpointretentiondurationset req_lib_ckpt_checkpointretentiondurationset; struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit_noput; } @@ -645,11 +677,13 @@ saCkptCheckpointRetentionDurationSet ( req_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET; req_lib_ckpt_checkpointretentiondurationset.retentionDuration = retentionDuration; + memcpy (&req_lib_ckpt_checkpointretentiondurationset.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); pthread_mutex_lock (&ckptCheckpointInstance->mutex); error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_checkpointretentiondurationset, sizeof (struct req_lib_ckpt_checkpointretentiondurationset), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -661,74 +695,77 @@ saCkptCheckpointRetentionDurationSet ( pthread_mutex_unlock (&ckptCheckpointInstance->mutex); error_exit: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); error_exit_noput: - return (error == SA_OK ? res_lib_ckpt_checkpointretentiondurationset.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_checkpointretentiondurationset.header.error : error); } -SaErrorT +SaAisErrorT saCkptActiveCheckpointSet ( - const SaCkptCheckpointHandleT *checkpointHandle) + SaCkptCheckpointHandleT checkpointHandle) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; - struct req_lib_ckpt_activecheckpointset req_lib_ckpt_activecheckpointset; - struct res_lib_ckpt_activecheckpointset res_lib_ckpt_activecheckpointset; + struct req_lib_ckpt_activereplicaset req_lib_ckpt_activereplicaset; + struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } - req_lib_ckpt_activecheckpointset.header.size = sizeof (struct req_lib_ckpt_activecheckpointset); - req_lib_ckpt_activecheckpointset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVECHECKPOINTSET; + req_lib_ckpt_activereplicaset.header.size = sizeof (struct req_lib_ckpt_activereplicaset); + req_lib_ckpt_activereplicaset.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_ACTIVEREPLICASET; pthread_mutex_lock (&ckptCheckpointInstance->mutex); - error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_activecheckpointset, - sizeof (struct req_lib_ckpt_activecheckpointset), MSG_NOSIGNAL); - if (error != SA_OK) { + error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_activereplicaset, + sizeof (struct req_lib_ckpt_activereplicaset), MSG_NOSIGNAL); + if (error != SA_AIS_OK) { goto error_exit; } error = saRecvRetry (ckptCheckpointInstance->fd, - &res_lib_ckpt_activecheckpointset, - sizeof (struct res_lib_ckpt_activecheckpointset), + &res_lib_ckpt_activereplicaset, + sizeof (struct res_lib_ckpt_activereplicaset), MSG_WAITALL | MSG_NOSIGNAL); pthread_mutex_unlock (&ckptCheckpointInstance->mutex); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); error_exit: - return (error == SA_OK ? res_lib_ckpt_activecheckpointset.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_activereplicaset.header.error : error); } -SaErrorT +SaAisErrorT saCkptCheckpointStatusGet ( - const SaCkptCheckpointHandleT *checkpointHandle, - SaCkptCheckpointStatusT *checkpointStatus) + SaCkptCheckpointHandleT checkpointHandle, + SaCkptCheckpointDescriptorT *checkpointStatus) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_checkpointstatusget req_lib_ckpt_checkpointstatusget; struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } req_lib_ckpt_checkpointstatusget.header.size = sizeof (struct req_lib_ckpt_checkpointstatusget); req_lib_ckpt_checkpointstatusget.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET; + memcpy (&req_lib_ckpt_checkpointstatusget.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); + pthread_mutex_lock (&ckptCheckpointInstance->mutex); error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_checkpointstatusget, sizeof (struct req_lib_ckpt_checkpointstatusget), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -736,39 +773,43 @@ saCkptCheckpointStatusGet ( &res_lib_ckpt_checkpointstatusget, sizeof (struct res_lib_ckpt_checkpointstatusget), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } pthread_mutex_unlock (&ckptCheckpointInstance->mutex); memcpy (checkpointStatus, - &res_lib_ckpt_checkpointstatusget.checkpointStatus, - sizeof (SaCkptCheckpointStatusT)); + &res_lib_ckpt_checkpointstatusget.checkpointDescriptor, + sizeof (SaCkptCheckpointDescriptorT)); error_exit: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); return (error); } -SaErrorT +SaAisErrorT saCkptSectionCreate ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, SaCkptSectionCreationAttributesT *sectionCreationAttributes, const void *initialData, SaUint32T initialDataSize) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate; struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } + if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { + error = SA_AIS_ERR_ACCESS; + goto error_exit; + } req_lib_ckpt_sectioncreate.header.size = sizeof (struct req_lib_ckpt_sectioncreate) + @@ -780,12 +821,14 @@ saCkptSectionCreate ( req_lib_ckpt_sectioncreate.expirationTime = sectionCreationAttributes->expirationTime; req_lib_ckpt_sectioncreate.initialDataSize = initialDataSize; + memcpy (&req_lib_ckpt_sectioncreate.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); pthread_mutex_lock (&ckptCheckpointInstance->mutex); error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_sectioncreate, sizeof (struct req_lib_ckpt_sectioncreate), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -794,13 +837,13 @@ saCkptSectionCreate ( */ error = saSendRetry (ckptCheckpointInstance->fd, sectionCreationAttributes->sectionId->id, sectionCreationAttributes->sectionId->idLen, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } error = saSendRetry (ckptCheckpointInstance->fd, initialData, initialDataSize, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -812,25 +855,25 @@ saCkptSectionCreate ( pthread_mutex_unlock (&ckptCheckpointInstance->mutex); error_exit: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_sectioncreate.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectioncreate.header.error : error); } -SaErrorT +SaAisErrorT saCkptSectionDelete ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, const SaCkptSectionIdT *sectionId) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete; struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } @@ -840,9 +883,12 @@ saCkptSectionDelete ( req_lib_ckpt_sectiondelete.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONDELETE; req_lib_ckpt_sectiondelete.idLen = sectionId->idLen; + memcpy (&req_lib_ckpt_sectiondelete.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); + error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_sectiondelete, sizeof (struct req_lib_ckpt_sectiondelete), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -851,7 +897,7 @@ saCkptSectionDelete ( */ error = saSendRetry (ckptCheckpointInstance->fd, sectionId->id, sectionId->idLen, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } error = saRecvRetry (ckptCheckpointInstance->fd, @@ -862,24 +908,24 @@ saCkptSectionDelete ( pthread_mutex_unlock (&ckptCheckpointInstance->mutex); error_exit: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_sectiondelete.header.error : error); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); + return (error == SA_AIS_OK ? res_lib_ckpt_sectiondelete.header.error : error); } -SaErrorT +SaAisErrorT saCkptSectionExpirationTimeSet ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, const SaCkptSectionIdT *sectionId, SaTimeT expirationTime) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset; struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit_noput; } @@ -888,11 +934,14 @@ saCkptSectionExpirationTimeSet ( req_lib_ckpt_sectionexpirationtimeset.idLen = sectionId->idLen; req_lib_ckpt_sectionexpirationtimeset.expirationTime = expirationTime; + memcpy (&req_lib_ckpt_sectionexpirationtimeset.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); + pthread_mutex_lock (&ckptCheckpointInstance->mutex); error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_sectionexpirationtimeset, sizeof (struct req_lib_ckpt_sectionexpirationtimeset), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -902,7 +951,7 @@ saCkptSectionExpirationTimeSet ( if (sectionId->idLen) { error = saSendRetry (ckptCheckpointInstance->fd, sectionId->id, sectionId->idLen, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } } @@ -915,58 +964,59 @@ saCkptSectionExpirationTimeSet ( pthread_mutex_unlock (&ckptCheckpointInstance->mutex); error_exit: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); error_exit_noput: - return (error == SA_OK ? res_lib_ckpt_sectionexpirationtimeset.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectionexpirationtimeset.header.error : error); } -SaErrorT -saCkptSectionIteratorInitialize ( - const SaCkptCheckpointHandleT *checkpointHandle, +SaAisErrorT +saCkptSectionIterationInitialize ( + SaCkptCheckpointHandleT checkpointHandle, SaCkptSectionsChosenT sectionsChosen, SaTimeT expirationTime, - SaCkptSectionIteratorT *sectionIterator) + SaCkptSectionIterationHandleT *sectionIterationHandle) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; - struct ckptSectionIteratorInstance *ckptSectionIteratorInstance; + struct ckptSectionIterationInstance *ckptSectionIterationInstance; struct req_lib_ckpt_sectioniteratorinitialize req_lib_ckpt_sectioniteratorinitialize; struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_no_destroy; } - error = saHandleCreate (&ckptSectionIteratorHandleDatabase, - sizeof (struct ckptSectionIteratorInstance), sectionIterator); - if (error != SA_OK) { + error = saHandleCreate (&ckptSectionIterationHandleDatabase, + sizeof (struct ckptSectionIterationInstance), sectionIterationHandle); + if (error != SA_AIS_OK) { goto error_put_checkpoint_db; } - error = saHandleInstanceGet (&ckptSectionIteratorHandleDatabase, - *sectionIterator, - (void *)&ckptSectionIteratorInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase, + *sectionIterationHandle, (void *)&ckptSectionIterationInstance); + if (error != SA_AIS_OK) { goto error_destroy; } - ckptSectionIteratorInstance->fd = -1; + ckptSectionIterationInstance->fd = ckptCheckpointInstance->fd; - pthread_mutex_init (&ckptSectionIteratorInstance->mutex, NULL); + ckptSectionIterationInstance->checkpointHandle = checkpointHandle; + + pthread_mutex_init (&ckptSectionIterationInstance->mutex, NULL); /* * Setup section id list for iterator next */ - list_init (&ckptSectionIteratorInstance->sectionIdListHead); + list_init (&ckptSectionIterationInstance->sectionIdListHead); - ckptSectionIteratorInstance->maxSectionIdSize = + ckptSectionIterationInstance->maxSectionIdSize = ckptCheckpointInstance->maxSectionIdSize; - error = saServiceConnect (&ckptSectionIteratorInstance->fd, - MESSAGE_REQ_CKPT_SECTIONITERATOR_INIT); - if (error != SA_OK) { + error = saServiceConnect (&ckptSectionIterationInstance->fd, + MESSAGE_REQ_CKPT_INIT); + if (error != SA_AIS_OK) { goto error_put_destroy; } @@ -977,36 +1027,34 @@ saCkptSectionIteratorInitialize ( memcpy (&req_lib_ckpt_sectioniteratorinitialize.checkpointName, &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); - pthread_mutex_lock (&ckptSectionIteratorInstance->mutex); + pthread_mutex_lock (&ckptSectionIterationInstance->mutex); - error = saSendRetry (ckptSectionIteratorInstance->fd, + error = saSendRetry (ckptSectionIterationInstance->fd, &req_lib_ckpt_sectioniteratorinitialize, sizeof (struct req_lib_ckpt_sectioniteratorinitialize), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_put_destroy; } - error = saRecvRetry (ckptSectionIteratorInstance->fd, + error = saRecvRetry (ckptSectionIterationInstance->fd, &res_lib_ckpt_sectioniteratorinitialize, sizeof (struct res_lib_ckpt_sectioniteratorinitialize), MSG_WAITALL | MSG_NOSIGNAL); - pthread_mutex_unlock (&ckptSectionIteratorInstance->mutex); + pthread_mutex_unlock (&ckptSectionIterationInstance->mutex); - saHandleInstancePut (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); - - return (error == SA_OK ? res_lib_ckpt_sectioniteratorinitialize.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratorinitialize.header.error : error); error_put_destroy: - saHandleInstancePut (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleInstancePut (&ckptSectionIterationHandleDatabase, *sectionIterationHandle); error_destroy: - saHandleDestroy (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleDestroy (&ckptSectionIterationHandleDatabase, *sectionIterationHandle); error_put_checkpoint_db: - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); error_no_destroy: return (error); } @@ -1016,48 +1064,48 @@ struct iteratorSectionIdListEntry { char data[0]; }; -SaErrorT -saCkptSectionIteratorNext ( - SaCkptSectionIteratorT *sectionIterator, +SaAisErrorT +saCkptSectionIterationNext ( + SaCkptSectionIterationHandleT sectionIterationHandle, SaCkptSectionDescriptorT *sectionDescriptor) { - SaErrorT error; - struct ckptSectionIteratorInstance *ckptSectionIteratorInstance; + SaAisErrorT error; + struct ckptSectionIterationInstance *ckptSectionIterationInstance; struct req_lib_ckpt_sectioniteratornext req_lib_ckpt_sectioniteratornext; struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext; struct iteratorSectionIdListEntry *iteratorSectionIdListEntry; - error = saHandleInstanceGet (&ckptSectionIteratorHandleDatabase, - *sectionIterator, (void *)&ckptSectionIteratorInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase, + sectionIterationHandle, (void *)&ckptSectionIterationInstance); + if (error != SA_AIS_OK) { goto error_exit; } /* * Allocate section id storage area */ iteratorSectionIdListEntry = malloc (sizeof (struct list_head) + - ckptSectionIteratorInstance->maxSectionIdSize); + ckptSectionIterationInstance->maxSectionIdSize); if (iteratorSectionIdListEntry == 0) { - error = SA_ERR_NO_MEMORY; + error = SA_AIS_ERR_NO_MEMORY; goto error_put_nounlock; } req_lib_ckpt_sectioniteratornext.header.size = sizeof (struct req_lib_ckpt_sectioniteratornext); req_lib_ckpt_sectioniteratornext.header.id = MESSAGE_REQ_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT; - pthread_mutex_lock (&ckptSectionIteratorInstance->mutex); + pthread_mutex_lock (&ckptSectionIterationInstance->mutex); - error = saSendRetry (ckptSectionIteratorInstance->fd, + error = saSendRetry (ckptSectionIterationInstance->fd, &req_lib_ckpt_sectioniteratornext, sizeof (struct req_lib_ckpt_sectioniteratornext), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_put; } - error = saRecvRetry (ckptSectionIteratorInstance->fd, &res_lib_ckpt_sectioniteratornext, + error = saRecvRetry (ckptSectionIterationInstance->fd, &res_lib_ckpt_sectioniteratornext, sizeof (struct res_lib_ckpt_sectioniteratornext), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_put; } @@ -1068,7 +1116,7 @@ saCkptSectionIteratorNext ( sectionDescriptor->sectionId.id = &iteratorSectionIdListEntry->data[0]; if ((res_lib_ckpt_sectioniteratornext.header.size - sizeof (struct res_lib_ckpt_sectioniteratornext)) > 0) { - error = saRecvRetry (ckptSectionIteratorInstance->fd, + error = saRecvRetry (ckptSectionIterationInstance->fd, sectionDescriptor->sectionId.id, res_lib_ckpt_sectioniteratornext.header.size - sizeof (struct res_lib_ckpt_sectioniteratornext), @@ -1078,32 +1126,32 @@ saCkptSectionIteratorNext ( /* * Add to persistent memory list for this sectioniterator */ - if (error == SA_OK && res_lib_ckpt_sectioniteratornext.header.error == SA_OK) { + if (error == SA_AIS_OK && res_lib_ckpt_sectioniteratornext.header.error == SA_AIS_OK) { list_init (&iteratorSectionIdListEntry->list); - list_add (&iteratorSectionIdListEntry->list, &ckptSectionIteratorInstance->sectionIdListHead); + list_add (&iteratorSectionIdListEntry->list, &ckptSectionIterationInstance->sectionIdListHead); } error_put: - pthread_mutex_unlock (&ckptSectionIteratorInstance->mutex); + pthread_mutex_unlock (&ckptSectionIterationInstance->mutex); error_put_nounlock: - saHandleInstancePut (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle); error_exit: - return (error == SA_OK ? res_lib_ckpt_sectioniteratornext.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectioniteratornext.header.error : error); } -SaErrorT -saCkptSectionIteratorFinalize ( - SaCkptSectionIteratorT *sectionIterator) +SaAisErrorT +saCkptSectionIterationFinalize ( + SaCkptSectionIterationHandleT sectionIterationHandle) { - SaErrorT error; - struct ckptSectionIteratorInstance *ckptSectionIteratorInstance; + SaAisErrorT error; + struct ckptSectionIterationInstance *ckptSectionIterationInstance; struct iteratorSectionIdListEntry *iteratorSectionIdListEntry; - struct list_head *sectionIdIteratorList; - struct list_head *sectionIdIteratorListNext; + struct list_head *sectionIdIterationList; + struct list_head *sectionIdIterationListNext; - error = saHandleInstanceGet (&ckptSectionIteratorHandleDatabase, - *sectionIterator, (void *)&ckptSectionIteratorInstance); - if (error != SA_OK) { + error = saHandleInstanceGet (&ckptSectionIterationHandleDatabase, + sectionIterationHandle, (void *)&ckptSectionIterationInstance); + if (error != SA_AIS_OK) { goto error_noput; } @@ -1111,34 +1159,37 @@ saCkptSectionIteratorFinalize ( * iterate list of section ids for this iterator to free the allocated memory * be careful to cache next pointer because free removes memory from use */ - for (sectionIdIteratorList = ckptSectionIteratorInstance->sectionIdListHead.next, - sectionIdIteratorListNext = sectionIdIteratorList->next; - sectionIdIteratorList != &ckptSectionIteratorInstance->sectionIdListHead; - sectionIdIteratorList = sectionIdIteratorListNext, - sectionIdIteratorListNext = sectionIdIteratorList->next) { + for (sectionIdIterationList = ckptSectionIterationInstance->sectionIdListHead.next, + sectionIdIterationListNext = sectionIdIterationList->next; + sectionIdIterationList != &ckptSectionIterationInstance->sectionIdListHead; + sectionIdIterationList = sectionIdIterationListNext, + sectionIdIterationListNext = sectionIdIterationList->next) { - iteratorSectionIdListEntry = list_entry (sectionIdIteratorList, + iteratorSectionIdListEntry = list_entry (sectionIdIterationList, struct iteratorSectionIdListEntry, list); free (iteratorSectionIdListEntry); } - saHandleInstancePut (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleInstancePut (&checkpointHandleDatabase, + ckptSectionIterationInstance->checkpointHandle); - saHandleDestroy (&ckptSectionIteratorHandleDatabase, *sectionIterator); + saHandleInstancePut (&ckptSectionIterationHandleDatabase, sectionIterationHandle); + + saHandleDestroy (&ckptSectionIterationHandleDatabase, sectionIterationHandle); error_noput: return (error); } -SaErrorT +SaAisErrorT saCkptCheckpointWrite ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, const SaCkptIOVectorElementT *ioVector, SaUint32T numberOfElements, SaUint32T *erroneousVectorIndex) { - SaErrorT error = SA_OK; + SaAisErrorT error = SA_AIS_OK; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite; struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite; @@ -1146,12 +1197,16 @@ saCkptCheckpointWrite ( struct iovec iov[3]; int iov_len = 0; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } + if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { + error = SA_AIS_ERR_ACCESS; + goto error_put; + } req_lib_ckpt_sectionwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONWRITE; pthread_mutex_lock (&ckptCheckpointInstance->mutex); @@ -1164,6 +1219,9 @@ saCkptCheckpointWrite ( req_lib_ckpt_sectionwrite.dataSize = ioVector[i].dataSize; req_lib_ckpt_sectionwrite.idLen = ioVector[i].sectionId.idLen; + memcpy (&req_lib_ckpt_sectionwrite.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); + iov_len = 0; /* TODO check for zero length stuff */ iov[0].iov_base = (char *)&req_lib_ckpt_sectionwrite; @@ -1176,7 +1234,7 @@ saCkptCheckpointWrite ( error = saSendMsgRetry (ckptCheckpointInstance->fd, iov, 3); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -1185,18 +1243,18 @@ saCkptCheckpointWrite ( */ error = saRecvRetry (ckptCheckpointInstance->fd, &res_lib_ckpt_sectionwrite, sizeof (struct res_lib_ckpt_sectionwrite), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } - if (res_lib_ckpt_sectionwrite.header.error == SA_ERR_TRY_AGAIN) { - error = SA_ERR_TRY_AGAIN; + if (res_lib_ckpt_sectionwrite.header.error == SA_AIS_ERR_TRY_AGAIN) { + error = SA_AIS_ERR_TRY_AGAIN; goto error_exit; } /* * If error, report back erroneous index */ - if (res_lib_ckpt_sectionwrite.header.error != SA_OK) { + if (res_lib_ckpt_sectionwrite.header.error != SA_AIS_OK) { if (erroneousVectorIndex) { *erroneousVectorIndex = i; } @@ -1205,54 +1263,60 @@ saCkptCheckpointWrite ( } error_exit: - pthread_mutex_unlock (&ckptCheckpointInstance->mutex); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); +error_put: + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_sectionwrite.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectionwrite.header.error : error); } -SaErrorT +SaAisErrorT saCkptSectionOverwrite ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, const SaCkptSectionIdT *sectionId, - SaUint8T *dataBuffer, + const void *dataBuffer, SaSizeT dataSize) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite; struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } + if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) { + return (SA_AIS_ERR_ACCESS); + } + req_lib_ckpt_sectionoverwrite.header.size = sizeof (struct req_lib_ckpt_sectionoverwrite) + sectionId->idLen + dataSize; req_lib_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONOVERWRITE; req_lib_ckpt_sectionoverwrite.idLen = sectionId->idLen; req_lib_ckpt_sectionoverwrite.dataSize = dataSize; + memcpy (&req_lib_ckpt_sectionoverwrite.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); pthread_mutex_lock (&ckptCheckpointInstance->mutex); error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_sectionoverwrite, sizeof (struct req_lib_ckpt_sectionoverwrite), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } if (sectionId->idLen) { error = saSendRetry (ckptCheckpointInstance->fd, sectionId->id, sectionId->idLen, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } } error = saSendRetry (ckptCheckpointInstance->fd, dataBuffer, dataSize, MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -1264,19 +1328,19 @@ saCkptSectionOverwrite ( error_exit: pthread_mutex_unlock (&ckptCheckpointInstance->mutex); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_sectionoverwrite.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectionoverwrite.header.error : error); } -SaErrorT +SaAisErrorT saCkptCheckpointRead ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, SaCkptIOVectorElementT *ioVector, SaUint32T numberOfElements, SaUint32T *erroneousVectorIndex) { - SaErrorT error = SA_OK; + SaAisErrorT error = SA_AIS_OK; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread; struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread; @@ -1284,12 +1348,16 @@ saCkptCheckpointRead ( int i; struct iovec iov[3]; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } + if ((ckptCheckpointInstance->checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) { + return (SA_AIS_ERR_ACCESS); + } + req_lib_ckpt_sectionread.header.id = MESSAGE_REQ_CKPT_CHECKPOINT_SECTIONREAD; pthread_mutex_lock (&ckptCheckpointInstance->mutex); @@ -1302,6 +1370,9 @@ saCkptCheckpointRead ( req_lib_ckpt_sectionread.dataOffset = ioVector[i].dataOffset; req_lib_ckpt_sectionread.dataSize = ioVector[i].dataSize; + memcpy (&req_lib_ckpt_sectionread.checkpointName, + &ckptCheckpointInstance->checkpointName, sizeof (SaNameT)); + iov[0].iov_base = (char *)&req_lib_ckpt_sectionread; iov[0].iov_len = sizeof (struct req_lib_ckpt_sectionread); iov[1].iov_base = ioVector[i].sectionId.id; @@ -1316,7 +1387,7 @@ saCkptCheckpointRead ( */ error = saRecvRetry (ckptCheckpointInstance->fd, &res_lib_ckpt_sectionread, sizeof (struct res_lib_ckpt_sectionread), MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -1328,11 +1399,11 @@ saCkptCheckpointRead ( if (dataLength > 0) { error = saRecvRetry (ckptCheckpointInstance->fd, ioVector[i].dataBuffer, dataLength, MSG_WAITALL | MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } } - if (res_lib_ckpt_sectionread.header.error != SA_OK) { + if (res_lib_ckpt_sectionread.header.error != SA_AIS_OK) { if (erroneousVectorIndex) { *erroneousVectorIndex = i; } @@ -1348,24 +1419,24 @@ saCkptCheckpointRead ( error_exit: pthread_mutex_unlock (&ckptCheckpointInstance->mutex); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_sectionread.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_sectionread.header.error : error); } -SaErrorT +SaAisErrorT saCkptCheckpointSynchronize ( - const SaCkptCheckpointHandleT *checkpointHandle, + SaCkptCheckpointHandleT checkpointHandle, SaTimeT timeout) { - SaErrorT error; + SaAisErrorT error; struct ckptCheckpointInstance *ckptCheckpointInstance; struct req_lib_ckpt_checkpointsynchronize req_lib_ckpt_checkpointsynchronize; struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } @@ -1377,7 +1448,7 @@ saCkptCheckpointSynchronize ( error = saSendRetry (ckptCheckpointInstance->fd, &req_lib_ckpt_checkpointsynchronize, sizeof (struct req_lib_ckpt_checkpointsynchronize), MSG_NOSIGNAL); - if (error != SA_OK) { + if (error != SA_AIS_OK) { goto error_exit; } @@ -1389,30 +1460,30 @@ saCkptCheckpointSynchronize ( error_exit: pthread_mutex_unlock (&ckptCheckpointInstance->mutex); - saHandleInstancePut (&checkpointHandleDatabase, *checkpointHandle); + saHandleInstancePut (&checkpointHandleDatabase, checkpointHandle); - return (error == SA_OK ? res_lib_ckpt_checkpointsynchronize.header.error : error); + return (error == SA_AIS_OK ? res_lib_ckpt_checkpointsynchronize.header.error : error); } -SaErrorT +SaAisErrorT saCkptCheckpointSynchronizeAsync ( - const SaCkptHandleT *ckptHandle, - SaInvocationT invocation, - const SaCkptCheckpointHandleT *checkpointHandle) + SaCkptHandleT ckptHandle, + SaCkptCheckpointHandleT checkpointHandle, + SaInvocationT invocation) { - return (SA_OK); + return (SA_AIS_OK); /* TODO not implemented in executive struct ckptInstance *ckptInstance; struct ckptCheckpointInstance *ckptCheckpointInstance; - SaErrorT error; + SaAisErrorT error; struct req_lib_ckpt_checkpointsynchronizeasync req_lib_ckpt_checkpointsynchronizeasync; - error = saHandleInstanceGet (&checkpointHandleDatabase, *checkpointHandle, + error = saHandleInstanceGet (&checkpointHandleDatabase, checkpointHandle, (void *)&ckptCheckpointInstance); - if (error != SA_OK) { + if (error != SA_AIS_OK) { return (error); } diff --git a/test/Makefile b/test/Makefile index d96a2fee..aac34d3a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -102,8 +102,8 @@ evsbench: evsbench.o $(LIBS) testclm: testclm.o $(LIBRARIES) $(CC) $(LDFLAGS) -o testclm testclm.o $(LIBS) -testckpt: testckpt.o $(LIBRARIES) - $(CC) $(LDFLAGS) -o testckpt testckpt.o $(LIBS) +testckpt: testckpt.o sa_error.o $(LIBRARIES) + $(CC) $(LDFLAGS) -o testckpt testckpt.o sa_error.o $(LIBS) ckptbench: ckptbench.o $(LIBRARIES) $(CC) $(LDFLAGS) -o ckptbench ckptbench.o $(LIBS) @@ -149,13 +149,13 @@ testamf5.o: ../include/ais_types.h ../include/ais_amf.h testamf6.o: ../include/ais_types.h ../include/ais_amf.h testamfth.o: ../include/ais_types.h ../include/ais_amf.h ../include/ais_msg.h testamfth.o: ../include/evs.h ../include/saClm.h ../include/ipc_gen.h -testckpt.o: ../include/ais_types.h ../include/ais_ckpt.h -ckptstress.o: ../include/ais_types.h ../include/ais_ckpt.h +testckpt.o: ../include/ais_types.h ../include/saCkpt.h +ckptstress.o: ../include/ais_types.h ../include/saCkpt.h testparse.o: ../include/ais_types.h ../exec/parse.h ../include/list.h testparse.o: ../exec/aispoll.h ../exec/totempg.h ../exec/totemsrp.h testparse.o: ../exec/print.h ../include/saClm.h ../include/ais_types.h -ckptbench.o: ../include/ais_types.h ../include/ais_ckpt.h -ckptbenchth.o: ../include/ais_types.h ../include/ais_ckpt.h +ckptbench.o: ../include/ais_types.h ../include/saCkpt.h +ckptbenchth.o: ../include/ais_types.h ../include/saCkpt.h testevt.o: ../include/ais_types.h ../include/saEvt.h testevs.o: ../include/evs.h evsbench.o: ../include/ais_types.h ../include/evs.h diff --git a/test/ckptbench.c b/test/ckptbench.c index 1937fe25..a4d72f15 100644 --- a/test/ckptbench.c +++ b/test/ckptbench.c @@ -50,7 +50,7 @@ #include #include "ais_types.h" -#include "ais_ckpt.h" +#include "saCkpt.h" int alarm_notice; @@ -63,7 +63,12 @@ void printSaNameT (SaNameT *name) } } -SaVersionT version = { 'A', 1, 1 }; +SaVersionT version = { 'B', 1, 1 }; + +SaCkptCallbacksT callbacks = { + 0, + 0 +}; SaNameT checkpointName = { 5, "abra\0" }; @@ -77,13 +82,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { }; SaCkptSectionIdT sectionId1 = { - "section ID #1", - 14 + 14, + "section ID #1" }; SaCkptSectionIdT sectionId2 = { - "section ID #2", - 14 + 14, + "section ID #2" }; SaCkptSectionCreationAttributesT sectionCreationAttributes1 = { §ionId1, @@ -102,8 +107,8 @@ char readBuffer2[1025]; SaCkptIOVectorElementT ReadVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, readBuffer1, sizeof (readBuffer1), @@ -112,8 +117,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = { }, { { - "section ID #2", - 14 + 14, + "section ID #2" }, readBuffer2, sizeof (readBuffer2), @@ -129,8 +134,8 @@ char data[500000]; SaCkptIOVectorElementT WriteVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, data, /*"written data #1, this should extend past end of old section data", */ DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */ @@ -140,8 +145,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = { #ifdef COMPILE_OUT { { - "section ID #2", - 14 + 14, + "section ID #2" }, data, /*"written data #2, this should extend past end of old section data" */ DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */ @@ -168,7 +173,7 @@ void ckpt_benchmark (SaCkptCheckpointHandleT checkpointHandle, /* * Test checkpoint write */ - error = saCkptCheckpointWrite (&checkpointHandle, + error = saCkptCheckpointWrite (checkpointHandle, WriteVectorElements, 1, &erroroneousVectorIndex); @@ -197,6 +202,7 @@ void sigalrm_handler (int num) } int main (void) { + SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; SaErrorT error; int size; @@ -204,16 +210,19 @@ int main (void) { signal (SIGALRM, sigalrm_handler); - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptInitialize (&ckptHandle, &callbacks, &version); + + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandle); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes2, "Initial Data #0", strlen ("Initial Data #0") + 1); @@ -224,5 +233,7 @@ int main (void) { ckpt_benchmark (checkpointHandle, size); size += 1000; } + + error = saCkptFinalize (ckptHandle); return (0); } diff --git a/test/ckptbenchth.c b/test/ckptbenchth.c index dd300386..5290ebbb 100644 --- a/test/ckptbenchth.c +++ b/test/ckptbenchth.c @@ -46,7 +46,7 @@ #include #include "ais_types.h" -#include "ais_ckpt.h" +#include "saCkpt.h" void printSaNameT (SaNameT *name) { @@ -57,7 +57,12 @@ void printSaNameT (SaNameT *name) } } -SaVersionT version = { 'A', 1, 1 }; +SaVersionT version = { 'B', 1, 1 }; + +SaCkptCallbacksT callbacks = { + 0, + 0 +}; SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { SA_CKPT_WR_ALL_REPLICAS, @@ -69,13 +74,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { }; SaCkptSectionIdT sectionId1 = { - "section ID #1", - 14 + 14, + "section ID #1" }; SaCkptSectionIdT sectionId2 = { - "section ID #2", - 14 + 14, + "section ID #2" }; SaCkptSectionCreationAttributesT sectionCreationAttributes1 = { §ionId1, @@ -94,8 +99,8 @@ char readBuffer2[1025]; SaCkptIOVectorElementT ReadVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, readBuffer1, sizeof (readBuffer1), @@ -104,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = { }, { { - "section ID #2", - 14 + 14, + "section ID #2" }, readBuffer2, sizeof (readBuffer2), @@ -121,8 +126,8 @@ char data[500000]; SaCkptIOVectorElementT WriteVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, data, /*"written data #1, this should extend past end of old section data", */ DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */ @@ -132,8 +137,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = { #ifdef COMPILE_OUT { { - "section ID #2", - 14 + 14, + "section ID #2" }, data, /*"written data #2, this should extend past end of old section data" */ DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */ @@ -146,6 +151,7 @@ SaCkptIOVectorElementT WriteVectorElements[] = { int runs = 0; struct threaddata { + SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; int write_count; int write_size; @@ -156,6 +162,7 @@ void *benchmark_thread (void *arg) { SaCkptCheckpointHandleT checkpointHandle; + SaCkptHandleT ckptHandle; int write_count; int write_size; SaErrorT error; @@ -164,6 +171,7 @@ void *benchmark_thread (void *arg) int ckptinv; checkpointHandle = td->checkpointHandle; + ckptHandle = td->ckptHandle; write_count = td->write_count; write_size = td->write_size; @@ -174,7 +182,7 @@ void *benchmark_thread (void *arg) * Test checkpoint write */ do { - error = saCkptCheckpointWrite (&checkpointHandle, + error = saCkptCheckpointWrite (checkpointHandle, WriteVectorElements, 1, &erroroneousVectorIndex); @@ -193,8 +201,8 @@ printf ("done writing for thread %d\n", td->thread); } -void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, int write_count, - int write_size) +void threaded_bench (SaCkptHandleT *ckptHandles, SaCkptCheckpointHandleT *checkpointHandles, + int threads, int write_count, int write_size) { struct timeval tv1, tv2, tv_elapsed; struct threaddata td[100]; @@ -206,6 +214,7 @@ void threaded_bench (SaCkptCheckpointHandleT *checkpointHandles, int threads, in gettimeofday (&tv1, NULL); for (i = 0; i < threads; i++) { + td[i].ckptHandle = ckptHandles[i]; td[i].checkpointHandle = checkpointHandles[i]; td[i].write_count = write_count; td[i].write_size = write_size; @@ -235,6 +244,7 @@ SaNameT checkpointName = { 12, "abra\0" }; #define CHECKPOINT_THREADS 50 int main (void) { + SaCkptHandleT ckptHandles[500]; SaCkptCheckpointHandleT checkpointHandles[500]; SaErrorT error; int size; @@ -246,16 +256,19 @@ int main (void) { */ for (i = 0; i < CHECKPOINT_THREADS; i++) { sprintf (checkpointName.value, "checkpoint%d \n", i); - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptInitialize (&ckptHandles[i], &callbacks, &version); + + error = saCkptCheckpointOpen (ckptHandles[i], + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandles[i]); - error = saCkptSectionCreate (&checkpointHandles[i], + error = saCkptSectionCreate (checkpointHandles[i], §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - error = saCkptSectionCreate (&checkpointHandles[i], + error = saCkptSectionCreate (checkpointHandles[i], §ionCreationAttributes2, "Initial Data #0", strlen ("Initial Data #0") + 1); @@ -266,7 +279,7 @@ int main (void) { size = 100000; /* initial size */ printf ("THREADS %d\n", i); for (j = 0; j < 5; j++) { /* number of runs with i threads */ - threaded_bench (checkpointHandles, i, count, size); + threaded_bench (ckptHandles, checkpointHandles, i, count, size); /* * Adjust count to 95% of previous count * adjust size upwards by 1500 diff --git a/test/ckptstress.c b/test/ckptstress.c index 8b42112d..74527cc1 100644 --- a/test/ckptstress.c +++ b/test/ckptstress.c @@ -43,7 +43,7 @@ #include #include "ais_types.h" -#include "ais_ckpt.h" +#include "saCkpt.h" int ckptinv; void printSaNameT (SaNameT *name) @@ -55,7 +55,12 @@ void printSaNameT (SaNameT *name) } } -SaVersionT version = { 'A', 1, 1 }; +SaVersionT version = { 'B', 1, 1 }; + +SaCkptCallbacksT callbacks = { + 0, + 0 +}; SaNameT checkpointName = { 5, "abra\0" }; @@ -69,13 +74,13 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { }; SaCkptSectionIdT sectionId1 = { - "section ID #1", - 14 + 14, + "section ID #1" }; SaCkptSectionIdT sectionId2 = { - "section ID #2", - 14 + 14, + "section ID #2" }; SaCkptSectionCreationAttributesT sectionCreationAttributes1 = { §ionId1, @@ -94,8 +99,8 @@ char readBuffer2[1025]; SaCkptIOVectorElementT ReadVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, readBuffer1, sizeof (readBuffer1), @@ -104,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = { }, { { - "section ID #2", - 14 + 14, + "section ID #2" }, readBuffer2, sizeof (readBuffer2), @@ -119,8 +124,8 @@ char data[DATASIZE]; SaCkptIOVectorElementT WriteVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, data, /*"written data #1, this should extend past end of old section data", */ DATASIZE, /*sizeof ("written data #1, this should extend past end of old section data") + 1, */ @@ -130,8 +135,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = { #ifdef COMPILE_OUT { { - "section ID #2", - 14 + 14, + "section ID #2" }, data, /*"written data #2, this should extend past end of old section data" */ DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */ @@ -144,18 +149,22 @@ SaCkptIOVectorElementT WriteVectorElements[] = { void *th_dispatch (void *arg) { int th = (int)arg; + SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT handle; SaErrorT error; int i; SaUint32T erroroneousVectorIndex = 0; - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptInitialize (&ckptHandle, &callbacks, &version); + + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &handle); for (i = 0; i < 1000; i++) { - error = saCkptCheckpointWrite (&handle, + error = saCkptCheckpointWrite (handle, WriteVectorElements, 1,/* placing two here with only one vector element causes an assertion failure !! */ &erroroneousVectorIndex); @@ -164,29 +173,36 @@ void *th_dispatch (void *arg) printf ("Thread %d: Error from write.\n", th); } } + + error = saCkptFinalize (ckptHandle); + return (0); } int main (void) { + SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; SaErrorT error; int i; pthread_t dispatch_thread; - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptInitialize (&ckptHandle, &callbacks, &version); + + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandle); printf ("first open result %d (should be 1)\n", error); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); printf ("create2 error is %d\n", error); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes2, "Initial Data #0", strlen ("Initial Data #0") + 1); @@ -196,5 +212,8 @@ printf ("create2 error is %d\n", error); pthread_create (&dispatch_thread, NULL, th_dispatch, (void *)i); } pthread_join (dispatch_thread, NULL); + + error = saCkptInitialize (&ckptHandle, &callbacks, &version); + return (0); } diff --git a/test/sa_error.c b/test/sa_error.c index 7b26489f..3183aa26 100644 --- a/test/sa_error.c +++ b/test/sa_error.c @@ -1,4 +1,6 @@ +#include #include +#include #include #include "ais_types.h" @@ -44,3 +46,20 @@ int get_sa_error(SaErrorT error, char *str, int len) strncpy(str, sa_error_list[error], len); return 0; } + +char *get_sa_error_b (SaAisErrorT error) { + return (sa_error_list[error]); +} + +char *get_test_output (SaAisErrorT result, SaAisErrorT expected) { + static *test_result[256]; + + if (result == expected) { + return ("PASSED"); + } else { + sprintf (test_result, + "FAILED expected %s got %s", + get_sa_error_b(expected), get_sa_error_b(result)); + return (test_result); + } +} diff --git a/test/testckpt.c b/test/testckpt.c index 3506a4c8..9064d892 100644 --- a/test/testckpt.c +++ b/test/testckpt.c @@ -44,7 +44,8 @@ #include #include "ais_types.h" -#include "ais_ckpt.h" +#include "saCkpt.h" +#include "sa_error.h" #define SECONDS_TO_EXPIRE 4 @@ -58,7 +59,7 @@ void printSaNameT (SaNameT *name) } } -SaVersionT version = { 'A', 1, 1 }; +SaVersionT version = { 'B', 1, 1 }; SaNameT checkpointName = { 5, "abra\0" }; @@ -72,14 +73,15 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = { }; SaCkptSectionIdT sectionId1 = { - "section ID #1", - 14 + 14, + "section ID #1" }; SaCkptSectionIdT sectionId2 = { - "section ID #2", - 14 + 14, + "section ID #2" }; + SaCkptSectionCreationAttributesT sectionCreationAttributes1 = { §ionId1, SA_TIME_END @@ -97,8 +99,8 @@ char readBuffer2[1025]; SaCkptIOVectorElementT ReadVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, readBuffer1, sizeof (readBuffer1), @@ -107,8 +109,8 @@ SaCkptIOVectorElementT ReadVectorElements[] = { }, { { - "section ID #2", - 14 + 14, + "section ID #2" }, readBuffer2, sizeof (readBuffer2), @@ -122,8 +124,8 @@ char data[DATASIZE]; SaCkptIOVectorElementT WriteVectorElements[] = { { { - "section ID #1", - 14 + 14, + "section ID #1" }, data, /*"written data #1, this should extend past end of old section data", */ DATASIZE, /*sizeof ("data #1, this should extend past end of old section data") + 1, */ @@ -133,8 +135,8 @@ SaCkptIOVectorElementT WriteVectorElements[] = { #ifdef COMPILE_OUT { { - "section ID #2", 14 + "section ID #2", }, data, /*"written data #2, this should extend past end of old section data" */ DATASIZE, /*sizeof ("written data #2, this should extend past end of old section data") + 1, */ @@ -144,12 +146,18 @@ SaCkptIOVectorElementT WriteVectorElements[] = { #endif }; +SaCkptCallbacksT callbacks = { + 0, + 0 +}; + int main (void) { + SaCkptHandleT ckptHandle; SaCkptCheckpointHandleT checkpointHandle; SaCkptCheckpointHandleT checkpointHandle2; SaCkptCheckpointHandleT checkpointHandleRead; - SaCkptCheckpointStatusT checkpointStatus; - SaCkptSectionIteratorT sectionIterator; + SaCkptCheckpointDescriptorT checkpointStatus; + SaCkptSectionIterationHandleT sectionIterator; SaCkptSectionDescriptorT sectionDescriptor; SaUint32T erroroneousVectorIndex = 0; SaErrorT error; @@ -157,30 +165,39 @@ int main (void) { struct timeval tv_end; struct timeval tv_elapsed; - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptInitialize (&ckptHandle, &callbacks, &version); + + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandle); - printf ("first open result %d (should be 1)\n", error); + printf ("%s: initial open of checkpoint\n", + get_test_output (error, SA_AIS_OK)); gettimeofday (&tv_start, 0); sectionCreationAttributes1.expirationTime = ((unsigned long long)(tv_start.tv_sec + SECONDS_TO_EXPIRE)) * ((unsigned long long)1000000000) + ((unsigned long long)(tv_start.tv_usec) * ((unsigned long long)1000)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); + + printf ("%s: checkpoint section create\n", + get_test_output (error, SA_AIS_OK)); + if (error != SA_OK) { - error = saCkptSectionExpirationTimeSet (&checkpointHandle, + error = saCkptSectionExpirationTimeSet (checkpointHandle, §ionId1, sectionCreationAttributes1.expirationTime); + printf ("%s: checkpoint section expiration set\n", + get_test_output (error, SA_AIS_OK)); } -printf ("create1 error is %d\n", error); printf ("Please wait, testing expiry of checkpoint sections.\n"); do { - error = saCkptCheckpointRead (&checkpointHandle, + error = saCkptCheckpointRead (checkpointHandle, ReadVectorElements, 1, &erroroneousVectorIndex); @@ -189,15 +206,18 @@ printf ("Please wait, testing expiry of checkpoint sections.\n"); timersub (&tv_end, &tv_start, &tv_elapsed); printf ("Elapsed Time to expiry is %ld.%ld (should be about %d seconds)\n", tv_elapsed.tv_sec, tv_elapsed.tv_usec, SECONDS_TO_EXPIRE); - error = saCkptCheckpointRetentionDurationSet (&checkpointHandle, + error = saCkptCheckpointRetentionDurationSet (checkpointHandle, 5000000000LL); - printf ("RetentionDurationSet is %d\n", error); + printf ("%s: RetentionDurationSet\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes2, "Initial Data #0", strlen ("Initial Data #0") + 1); -printf ("create2 error is %d\n", error); + + printf ("%s: Section creation\n", + get_test_output (error, SA_AIS_OK)); printf ("saCkptSectionCreate result %d (should be 1)\n", error); #ifdef cmpout for (ckptinv = 0; ckptinv < 500000; ckptinv++) { @@ -205,7 +225,7 @@ printf ("Writing checkpoint loop %d\n", ckptinv); /* * Test checkpoint write */ - error = saCkptCheckpointWrite (&checkpointHandle, + error = saCkptCheckpointWrite (checkpointHandle, WriteVectorElements, 1, &erroroneousVectorIndex); @@ -217,115 +237,131 @@ if (error != SA_OK) { exit (1); #endif - error = saCkptCheckpointUnlink (&checkpointName); - printf ("unlink result %d (should be 1)\n", error); + error = saCkptCheckpointUnlink (ckptHandle, &checkpointName); + printf ("%s: Unlinking checkpoint\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandle2); - printf ("open after unlink result %d (should be 7)\n", error); + printf ("%s: Opening unlinked checkpoint\n", + get_test_output (error, 7)); - error = saCkptCheckpointClose (&checkpointHandle); - printf ("close result %d (should be 1)\n", error); + error = saCkptCheckpointClose (checkpointHandle); + printf ("%s: Closing checkpoint\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptCheckpointOpen (&checkpointName, + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ, 0, &checkpointHandleRead); - printf ("read only open result %d (should be 1)\n", error); - error = saCkptCheckpointOpen (&checkpointName, + printf ("%s: Open checkpoint read only\n", + get_test_output (error, SA_AIS_OK)); + + + error = saCkptCheckpointOpen (ckptHandle, + &checkpointName, &checkpointCreationAttributes, SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE, 0, &checkpointHandle); - printf ("open after unlink/close result %d (should be 1)\n", error); + printf ("%s: open after unlink/close\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptCheckpointRetentionDurationSet (&checkpointHandle, + error = saCkptCheckpointRetentionDurationSet (checkpointHandle, 5000000000LL); -printf ("Retention duration set error is %d\n", error); - printf ("set checkpoint retention duration result %d (should be 1)\n", error); + printf ("%s: set checkpoint retention duration\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptCheckpointStatusGet (&checkpointHandle, + error = saCkptCheckpointStatusGet (checkpointHandle, &checkpointStatus); - printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error); + printf ("%s: Get checkpoint status\n", + get_test_output (error, SA_AIS_OK)); if (error == SA_OK) { printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed, (int)checkpointStatus.numberOfSections); } - error = saCkptSectionCreate (&checkpointHandleRead, + error = saCkptSectionCreate (checkpointHandleRead, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - printf ("saCkptSectionCreate result %d (should be 11)\n", error); + printf ("%s: Create checkpoint section on read only checkpoint\n", + get_test_output (error, SA_AIS_ERR_ACCESS)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - printf ("saCkptSectionCreate result %d (should be 1)\n", error); + printf ("%s: Create checkpoint section on writeable checkpoint\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - printf ("saCkptSectionCreate result %d (should be 14)\n", error); + printf ("%s: Create checkpoint section when one already exists\n", + get_test_output (error, 14)); -#ifdef COMPILE_OUT - error = saCkptSectionDelete (&checkpointHandle, + error = saCkptSectionDelete (checkpointHandle, §ionId1); - printf ("saCkptSectionDelete result %d (should be 1)\n", error); + printf ("%s: deleting checkpoint handle\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes1, "Initial Data #0", strlen ("Initial Data #0") + 1); - printf ("saCkptSectionCreate result %d (should be 1)\n", error); -#endif + printf ("%s: replacing deleted checkpoint section\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptSectionExpirationTimeSet (&checkpointHandle, + error = saCkptSectionExpirationTimeSet (checkpointHandle, §ionId2, SA_TIME_END); - printf ("saCkptSectionExpirationTimeSet result %d (should be 1)\n", error); + printf ("%s: Setting expiration time for section 2\n", + get_test_output (error, SA_AIS_OK)); - - error = saCkptSectionOverwrite (&checkpointHandle, + error = saCkptSectionOverwrite (checkpointHandle, §ionId1, "Overwrite Data #1", strlen ("Overwrite Data #1") + 1); - printf ("saCkptSectionOverwrite result %d (should be 1)\n", error); + printf ("%s: overwriting checkpoint section 1\n", + get_test_output (error, SA_AIS_OK)); /* * Test checkpoint read */ memset (readBuffer1, 0, sizeof (readBuffer1)); memset (readBuffer2, 0, sizeof (readBuffer2)); - error = saCkptSectionCreate (&checkpointHandle, + error = saCkptSectionCreate (checkpointHandle, §ionCreationAttributes2, "Initial Data #2", strlen ("Initial Data #2") + 1); - printf ("saCkptSectionCreate result %d (should be 1)\n", error); + printf ("%s: creating checkpoint for read test\n", + get_test_output (error, SA_AIS_OK)); - error = saCkptCheckpointRead (&checkpointHandle, + error = saCkptCheckpointRead (checkpointHandle, ReadVectorElements, 2, &erroroneousVectorIndex); - printf ("saCkptCheckpointRead result %d (should be 1)\n", error); + printf ("%s: checkpoint read operation", + get_test_output (error, SA_AIS_OK)); printf ("Buffers after checkpoint read\n"); printf (" buffer #1: '%s'\n", readBuffer1); printf (" buffer #2: '%s'\n", readBuffer2); -//sleep (20); #ifdef COMPILE_OUT for (ckptinv = 0; ckptinv < 2000; ckptinv++) { /* * Test checkpoint write */ - error = saCkptCheckpointWrite (&checkpointHandle, + error = saCkptCheckpointWrite (checkpointHandle, WriteVectorElements, 2, &erroroneousVectorIndex); @@ -337,7 +373,7 @@ exit (1); } exit (1); #endif - error = saCkptCheckpointRead (&checkpointHandle, + error = saCkptCheckpointRead (checkpointHandle, ReadVectorElements, 2, &erroroneousVectorIndex); @@ -346,26 +382,30 @@ exit (1); // printf (" buffer #1: '%s'\n", readBuffer1); // printf (" buffer #2: '%s'\n", readBuffer2); - error = saCkptCheckpointStatusGet (&checkpointHandle, + error = saCkptCheckpointStatusGet (checkpointHandle, &checkpointStatus); - printf ("saCkptCheckpointStatusGet result %d (should be 1)\n", error); + printf ("%s: get checkpoint status\n", + get_test_output (error, SA_AIS_OK)); if (error == SA_OK) { - printf ("Memory used %d in %d sections.\n", (int)checkpointStatus.memoryUsed, + printf ("Memory used %d in %d sections.\n", + (int)checkpointStatus.memoryUsed, (int)checkpointStatus.numberOfSections); } - error = saCkptSectionIteratorInitialize (&checkpointHandle, + error = saCkptSectionIterationInitialize (checkpointHandle, 0, 0, §ionIterator); - printf ("saCkptSectionIteratorInitialize result %d (should be 1)\n", error); + printf ("%s: initialize section iterator\n", + get_test_output (error, SA_AIS_OK)); /* * Iterate all sections */ do { - error = saCkptSectionIteratorNext (§ionIterator, + error = saCkptSectionIterationNext (sectionIterator, §ionDescriptor); - printf ("saCkptSectionIteratorNext result %d (should be 1)\n", error); + printf ("%s: Get next section in iteartion\n", + get_test_output (error, SA_AIS_OK)); if (error == SA_OK) { printf ("Section '%s' expires %llx size %d state %x update %llx\n", sectionDescriptor.sectionId.id, @@ -375,8 +415,10 @@ exit (1); sectionDescriptor.lastUpdate); } } while (error == SA_OK); + printf ("The last iteration should fail\n"); - error = saCkptSectionIteratorFinalize (§ionIterator); - printf ("saCkptSectionIteratorFinalize result %d (should be 1)\n", error); + error = saCkptSectionIterationFinalize (sectionIterator); + printf ("%s: Finalize iteration\n", + get_test_output (error, SA_AIS_OK)); return (0); }