| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638 |
- /*
- * Copyright (c) 2003-2004 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * This software licensed under BSD license, the text of which follows:
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * - Neither the name of the MontaVista Software, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include <sys/poll.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <sys/sysinfo.h>
- #include <netinet/in.h>
- #include <linux/if.h>
- #include <linux/sockios.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <errno.h>
- #include <signal.h>
- #include "../include/ais_types.h"
- #include "../include/ais_msg.h"
- #include "../include/list.h"
- #include "../include/queue.h"
- #include "poll.h"
- #include "mempool.h"
- #include "parse.h"
- #include "main.h"
- #include "print.h"
- #include "gmi.h"
- DECLARE_LIST_INIT(checkpointListHead);
- DECLARE_LIST_INIT(checkpointIteratorListHead);
- static int ckptCheckpointApiFinalize (int fd);
- static int ckptSectionIteratorApiFinalize (int fd);
- static int message_handler_req_exec_ckpt_checkpointopen (int fd, void *message);
- static int message_handler_req_exec_ckpt_checkpointclose (int fd, void *message);
- static int message_handler_req_exec_ckpt_checkpointunlink (int fd, void *message);
- static int message_handler_req_exec_ckpt_checkpointretentiondurationset (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectioncreate (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectiondelete (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectionexpirationtimeset (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectionwrite (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectionoverwrite (int fd, void *message);
- static int message_handler_req_exec_ckpt_sectionread (int fd, void *message);
- static int message_handler_req_lib_ckpt_init (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpoint_init (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectioniterator_init (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointopen (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointopenasync (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointunlink (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointretentiondurationset (int fd, void *message);
- static int message_handler_req_lib_ckpt_activecheckpointset (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointstatusget (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectioncreate (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectiondelete (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectionexpirationtimeset (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectionwrite (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectionoverwrite (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectionread (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointsynchronize (int fd, void *message);
- static int message_handler_req_lib_ckpt_checkpointsyncronizeasync (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectioniteratorinitialize (int fd, void *message);
- static int message_handler_req_lib_ckpt_sectioniteratornext (int fd, void *message);
- static int ckptConfChg (
- struct sockaddr_in *member_list, int member_list_entries,
- struct sockaddr_in *left_list, int left_list_entries,
- struct sockaddr_in *joined_list, int joined_list_entries) {
- return (0);
- }
- int (*ckpt_libais_handler_fns[]) (int fd, void *) = {
- };
- /*
- * TODO multinode not yet implemented
- */
- int (*ckpt_aisexec_handler_fns[]) (int fd, void *) = {
- };
- /*
- * exported service
- */
- struct service_handler ckpt_service_handler = {
- libais_handler_fns: ckpt_libais_handler_fns,
- libais_handler_fns_count: sizeof (ckpt_libais_handler_fns) / sizeof (int (*)),
- 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,
- aisexec_init_fn: 0
- };
- static int (*ckpt_checkpoint_libais_handler_fns[]) (int fd, void *) = {
- message_handler_req_lib_ckpt_checkpointopen,
- message_handler_req_lib_ckpt_checkpointopenasync,
- message_handler_req_lib_ckpt_checkpointunlink,
- message_handler_req_lib_ckpt_checkpointretentiondurationset,
- message_handler_req_lib_ckpt_activecheckpointset,
- message_handler_req_lib_ckpt_checkpointstatusget,
- message_handler_req_lib_ckpt_sectioncreate,
- message_handler_req_lib_ckpt_sectiondelete,
- message_handler_req_lib_ckpt_sectionexpirationtimeset,
- message_handler_req_lib_ckpt_sectionwrite,
- message_handler_req_lib_ckpt_sectionoverwrite,
- message_handler_req_lib_ckpt_sectionread,
- message_handler_req_lib_ckpt_checkpointsynchronize,
- message_handler_req_lib_ckpt_checkpointsyncronizeasync
- };
-
- static int (*ckpt_checkpoint_aisexec_handler_fns[]) (int fd, void *) = {
- message_handler_req_exec_ckpt_checkpointopen,
- message_handler_req_exec_ckpt_checkpointclose,
- message_handler_req_exec_ckpt_checkpointunlink,
- message_handler_req_exec_ckpt_checkpointretentiondurationset,
- message_handler_req_exec_ckpt_sectioncreate,
- message_handler_req_exec_ckpt_sectiondelete,
- message_handler_req_exec_ckpt_sectionexpirationtimeset,
- message_handler_req_exec_ckpt_sectionwrite,
- message_handler_req_exec_ckpt_sectionoverwrite,
- message_handler_req_exec_ckpt_sectionread
- };
- struct service_handler ckpt_checkpoint_service_handler = {
- libais_handler_fns: ckpt_checkpoint_libais_handler_fns,
- libais_handler_fns_count: sizeof (ckpt_checkpoint_libais_handler_fns) / sizeof (int (*)),
- aisexec_handler_fns: ckpt_checkpoint_aisexec_handler_fns ,
- aisexec_handler_fns_count: sizeof (ckpt_checkpoint_aisexec_handler_fns) / sizeof (int (*)),
- confchg_fn: ckptConfChg,
- libais_init_fn: message_handler_req_lib_ckpt_checkpoint_init,
- libais_exit_fn: ckptCheckpointApiFinalize,
- aisexec_init_fn: 0
- };
- static int (*ckpt_sectioniterator_libais_handler_fns[]) (int fd, void *) = {
- message_handler_req_lib_ckpt_sectioniteratorinitialize,
- message_handler_req_lib_ckpt_sectioniteratornext
- };
- static int (*ckpt_sectioniterator_aisexec_handler_fns[]) (int fd, void *) = {
- };
- struct service_handler ckpt_sectioniterator_service_handler = {
- libais_handler_fns: ckpt_sectioniterator_libais_handler_fns,
- libais_handler_fns_count: sizeof (ckpt_sectioniterator_libais_handler_fns) / sizeof (int (*)),
- 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,
- aisexec_init_fn: 0
- };
- static struct saCkptCheckpoint *findCheckpoint (SaNameT *name)
- {
- struct list_head *checkpointList;
- struct saCkptCheckpoint *checkpoint;
- for (checkpointList = checkpointListHead.next;
- checkpointList != &checkpointListHead;
- checkpointList = checkpointList->next) {
- checkpoint = list_entry (checkpointList,
- struct saCkptCheckpoint, list);
- if (SaNameTisNameT (name, &checkpoint->name)) {
- return (checkpoint);
- }
- }
- return (0);
- }
- static struct saCkptCheckpointSection *findCheckpointSection (
- struct saCkptCheckpoint *ckptCheckpoint,
- char *id,
- int idLen)
- {
- struct list_head *checkpointSectionList;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- log_printf (LOG_LEVEL_DEBUG, "Finding checkpoint section id %s %d\n", id, idLen);
- for (checkpointSectionList = ckptCheckpoint->checkpointSectionsListHead.next;
- checkpointSectionList != &ckptCheckpoint->checkpointSectionsListHead;
- checkpointSectionList = checkpointSectionList->next) {
- ckptCheckpointSection = list_entry (checkpointSectionList,
- struct saCkptCheckpointSection, list);
-
- log_printf (LOG_LEVEL_DEBUG, "Checking section id %s %d\n",
- ckptCheckpointSection->sectionDescriptor.sectionId.id,
- ckptCheckpointSection->sectionDescriptor.sectionId.idLen);
- if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen == idLen &&
- (memcmp (ckptCheckpointSection->sectionDescriptor.sectionId.id,
- id, idLen) == 0)) {
- return (ckptCheckpointSection);
- }
- }
- return 0;
- }
- void sendCkptCheckpointClose (struct saCkptCheckpoint *checkpoint) {
- struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
- struct iovec iovecs[2];
- int result;
- req_exec_ckpt_checkpointclose.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_checkpointclose.header.size =
- sizeof (struct req_exec_ckpt_checkpointclose);
- req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
- memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
- &checkpoint->name,
- sizeof (SaNameT));
- iovecs[0].iov_base = &req_exec_ckpt_checkpointclose;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- static int ckptCheckpointApiFinalize (int fd)
- {
- /*
- * close checkpoint opened from this fd
- */
- if (connections[fd].service == SOCKET_SERVICE_CKPT_CHECKPOINT &&
- connections[fd].ais_ci.u.libckpt_ci.checkpoint) {
- log_printf (LOG_LEVEL_DEBUG, "APIFinalize fd is %d %s\n", fd, getSaNameT (&connections[fd].ais_ci.u.libckpt_ci.checkpoint->name));
- sendCkptCheckpointClose (connections[fd].ais_ci.u.libckpt_ci.checkpoint);
- }
- return (0);
- }
- static int ckptSectionIteratorApiFinalize (int fd) {
- /*
- * If section iterator connection, unlink from list and free section iterator data
- */
- if (connections[fd].service == SOCKET_SERVICE_CKPT_SECTIONITERATOR) {
- log_printf (LOG_LEVEL_DEBUG, "freeing section iterator\n");
- if (connections[fd].ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) {
- free (connections[fd].ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries);
- }
- list_del (&connections[fd].ais_ci.u.libckpt_ci.sectionIterator.list);
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_checkpointopen (int fd, void *message)
- {
- struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message;
- struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)&req_exec_ckpt_checkpointopen->req_lib_ckpt_checkpointopen;
- struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
- struct saCkptCheckpoint *ckptCheckpoint = 0;
- struct saCkptCheckpointSection *ckptCheckpointSection = 0;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen);
-
- ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointopen->checkpointName);
- /*
- * If checkpoint doesn't exist, create one
- */
- if (ckptCheckpoint == 0) {
- ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
- if (ckptCheckpoint == 0) {
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
- if (ckptCheckpointSection == 0) {
- free (ckptCheckpoint);
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- memcpy (&ckptCheckpoint->name,
- &req_lib_ckpt_checkpointopen->checkpointName,
- sizeof (SaNameT));
- memcpy (&ckptCheckpoint->checkpointCreationAttributes,
- &req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
- sizeof (SaCkptCheckpointCreationAttributesT));
- ckptCheckpoint->unlinked = 0;
- list_init (&ckptCheckpoint->list);
- list_init (&ckptCheckpoint->checkpointSectionsListHead);
- list_add (&ckptCheckpoint->list, &checkpointListHead);
- ckptCheckpoint->referenceCount = 0;
- /*
- * Add in default checkpoint section
- */
- list_init (&ckptCheckpointSection->list);
- list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
- ckptCheckpointSection->sectionDescriptor.expirationTime = 0xFFFFFFFF; //SA_END_TIME;
-
- /*
- * Default section id
- */
- ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
- ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
- ckptCheckpointSection->sectionDescriptor.sectionSize = 0;
- ckptCheckpointSection->sectionDescriptor.expirationTime = 0xffffffff; /* SA_END_TIME */
- ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
- ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // current time
- ckptCheckpointSection->sectionData = 0;
- }
- /*
- * If the checkpoint has been unlinked, it is an invalid name
- */
- if (ckptCheckpoint->unlinked) {
- error = SA_ERR_INVALID_PARAM; /* Is this the correct return ? */
- goto error_exit;
- }
- /*
- * Setup connection information and mark checkpoint as referenced
- */
- log_printf (LOG_LEVEL_DEBUG, "CHECKPOINT opened fd %d is %p\n", fd, ckptCheckpoint);
- ckptCheckpoint->referenceCount += 1;
- /*
- * Send error result to CKPT library
- */
- 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) {
- connections[req_exec_ckpt_checkpointopen->source.fd].ais_ci.u.libckpt_ci.checkpoint = ckptCheckpoint;
- connections[req_exec_ckpt_checkpointopen->source.fd].ais_ci.u.libckpt_ci.checkpointOpenFlags = req_lib_ckpt_checkpointopen->checkpointOpenFlags;
- res_lib_ckpt_checkpointopen.header.magic = MESSAGE_MAGIC;
- 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.error = error;
- libais_send_response (req_exec_ckpt_checkpointopen->source.fd, &res_lib_ckpt_checkpointopen,
- sizeof (struct res_lib_ckpt_checkpointopen));
- }
- // return (error == SA_OK ? 0 : -1);
- return (0);
- }
- extern int message_handler_req_exec_ckpt_checkpointclose (int fd, void *message)
- {
- struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message;
- struct saCkptCheckpoint *checkpoint = 0;
- 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);
- if (checkpoint == 0) {
- return (0);
- }
- checkpoint->referenceCount--;
- log_printf (LOG_LEVEL_DEBUG, "disconnect called, new CKPT ref count is %d\n",
- checkpoint->referenceCount);
- /*
- * If checkpoint has been unlinked and this is the last reference, delete it
- */
- if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
- log_printf (LOG_LEVEL_DEBUG, "Unlinking checkpoint.\n");
- list_del (&checkpoint->list);
- free (checkpoint);
- } else
- if (checkpoint->referenceCount == 0) {
- // TODO Start retention duration timer if reference count is 0
- // and checkpoint has not been unlinked
- }
-
- return (0);
- }
- static int message_handler_req_exec_ckpt_checkpointunlink (int fd, void *message)
- {
- struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message;
- 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;
-
- log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink);
- ckptCheckpoint = findCheckpoint (&req_lib_ckpt_checkpointunlink->checkpointName);
- if (ckptCheckpoint == 0) {
- printf ("invalid checkpoint name\n");
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (ckptCheckpoint->unlinked) {
- error = SA_ERR_INVALID_PARAM;
- goto error_exit;
- }
- ckptCheckpoint->unlinked = 1;
- /*
- * Immediately delete entry if reference count is zero
- */
- if (ckptCheckpoint->referenceCount == 0) {
- list_del (&ckptCheckpoint->list);
- free (ckptCheckpoint);
- }
- error_exit:
- /*
- * If this node was the source of the message, respond to this node
- */
- if (req_exec_ckpt_checkpointunlink->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_checkpointunlink.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_checkpointunlink.header.size = sizeof (struct res_lib_ckpt_checkpointunlink);
- res_lib_ckpt_checkpointunlink.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
- res_lib_ckpt_checkpointunlink.error = error;
- libais_send_response (req_exec_ckpt_checkpointunlink->source.fd, &res_lib_ckpt_checkpointunlink,
- sizeof (struct res_lib_ckpt_checkpointunlink));
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_checkpointretentiondurationset (int fd, void *message)
- {
- struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message;
- struct saCkptCheckpoint *checkpoint;
- log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to set retention duratione checkpoint %p\n", req_exec_ckpt_checkpointretentiondurationset);
- checkpoint = findCheckpoint (&req_exec_ckpt_checkpointretentiondurationset->checkpointName);
- if (checkpoint) {
- log_printf (LOG_LEVEL_DEBUG, "setting retention duration\n");
- checkpoint->checkpointCreationAttributes.retentionDuration = req_exec_ckpt_checkpointretentiondurationset->retentionDuration;
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_sectioncreate (int fd, void *message) {
- struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message;
- struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)&req_exec_ckpt_sectioncreate->req_lib_ckpt_sectioncreate;
- struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- void *initialData;
- void *sectionId;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n");
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectioncreate->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_SYSTEM; // TODO find the right error for this
- goto error_exit;
- }
- /*
- * Determine if user-specified checkpoint ID already exists
- */
- ckptCheckpointSection = findCheckpointSection (ckptCheckpoint,
- ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
- req_lib_ckpt_sectioncreate->idLen);
- if (ckptCheckpointSection) {
- error = SA_ERR_EXIST;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section
- */
- ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
- if (ckptCheckpointSection == 0) {
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section data
- */
- initialData = malloc (req_lib_ckpt_sectioncreate->initialDataSize);
- if (initialData == 0) {
- free (ckptCheckpointSection);
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section id
- */
- sectionId = malloc (req_lib_ckpt_sectioncreate->idLen);
- if (sectionId == 0) {
- free (ckptCheckpointSection);
- free (initialData);
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
-
- /*
- * Copy checkpoint section and section ID
- */
- memcpy (sectionId, ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
- req_lib_ckpt_sectioncreate->idLen);
-
- memcpy (initialData,
- ((char *)req_lib_ckpt_sectioncreate) +
- sizeof (struct req_lib_ckpt_sectioncreate) +
- req_lib_ckpt_sectioncreate->idLen,
- req_lib_ckpt_sectioncreate->initialDataSize);
- /*
- * Configure checkpoint section
- */
- ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectioncreate->expirationTime;
- ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
- ckptCheckpointSection->sectionDescriptor.sectionId.idLen = req_lib_ckpt_sectioncreate->idLen;
- ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectioncreate->initialDataSize;
- ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
- ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // TODO current time
- ckptCheckpointSection->sectionData = initialData;
- /*
- * Add checkpoint section to checkpoint
- */
- list_init (&ckptCheckpointSection->list);
- list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
- error_exit:
- if (req_exec_ckpt_sectioncreate->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectioncreate.header.magic = MESSAGE_MAGIC;
- 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.error = error;
- libais_send_response (req_exec_ckpt_sectioncreate->source.fd,
- &res_lib_ckpt_sectioncreate,
- sizeof (struct res_lib_ckpt_sectioncreate));
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_sectiondelete (int fd, void *message) {
- struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message;
- struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)&req_exec_ckpt_sectiondelete->req_lib_ckpt_sectiondelete;
- struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- SaErrorT error = SA_OK;
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectiondelete->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Determine if the user is trying to delete the default section
- */
- if (req_lib_ckpt_sectiondelete->idLen == 0) {
- error = SA_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Find checkpoint section to be deleted
- */
- ckptCheckpointSection = findCheckpointSection (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;
- goto error_exit;
- }
- /*
- * Delete checkpoint section
- */
- list_del (&ckptCheckpointSection->list);
- free (ckptCheckpointSection->sectionDescriptor.sectionId.id);
- free (ckptCheckpointSection->sectionData);
- free (ckptCheckpointSection);
- /*
- * return result to CKPT library
- */
- error_exit:
- if (req_exec_ckpt_sectiondelete->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectiondelete.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_sectiondelete.header.size = sizeof (struct res_lib_ckpt_sectiondelete);
- res_lib_ckpt_sectiondelete.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE;
- res_lib_ckpt_sectiondelete.error = error;
- libais_send_response (req_exec_ckpt_sectiondelete->source.fd,
- &res_lib_ckpt_sectiondelete,
- sizeof (struct res_lib_ckpt_sectiondelete));
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_sectionexpirationtimeset (int fd, void *message) {
- struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message;
- struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)&req_exec_ckpt_sectionexpirationtimeset->req_lib_ckpt_sectionexpirationtimeset;
- struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiratoin time\n");
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionexpirationtimeset->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * 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;
- goto error_exit;
- }
- /*
- * Find checkpoint section that expiration time should be set for
- */
- ckptCheckpointSection = findCheckpointSection (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;
- goto error_exit;
- }
- ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectionexpirationtimeset->expirationTime;
- error_exit:
- if (req_exec_ckpt_sectionexpirationtimeset->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectionexpirationtimeset.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset);
- res_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
- res_lib_ckpt_sectionexpirationtimeset.error = error;
- libais_send_response (req_exec_ckpt_sectionexpirationtimeset->source.fd,
- &res_lib_ckpt_sectionexpirationtimeset,
- sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
- }
- return (0);
- }
- int exec_section_write = 0;
- static int message_handler_req_exec_ckpt_sectionwrite (int fd, void *message) {
- struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message;
- struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)&req_exec_ckpt_sectionwrite->req_lib_ckpt_sectionwrite;
- struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- int sizeRequired;
- void *sectionData;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to section write. %d\n", exec_section_write++);
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionwrite->checkpointName);
- if (ckptCheckpoint == 0) {
- printf ("can't find checkpoint\n"); // TODO
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- //printf ("writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
- /*
- * Find checkpoint section to be written
- */
- ckptCheckpointSection = findCheckpointSection (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;
- goto error_exit;
- }
- /*
- * If write would extend past end of section data, enlarge section
- */
- sizeRequired = req_lib_ckpt_sectionwrite->dataOffset + req_lib_ckpt_sectionwrite->dataSize;
- if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
- printf ("reallocating data\n");
- sectionData = realloc (ckptCheckpointSection->sectionData, sizeRequired);
- if (sectionData == 0) {
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Install new section data
- */
- ckptCheckpointSection->sectionData = sectionData;
- ckptCheckpointSection->sectionDescriptor.sectionSize = sizeRequired;
- }
- /*
- * Write checkpoint section to section data
- */
- if (req_lib_ckpt_sectionwrite->dataSize > 0) {
- char *sd;
- int *val;
- val = ckptCheckpointSection->sectionData;
- sd = (char *)ckptCheckpointSection->sectionData;
- memcpy (&sd[req_lib_ckpt_sectionwrite->dataOffset],
- ((char *)req_exec_ckpt_sectionwrite) + sizeof (struct req_exec_ckpt_sectionwrite) +
- req_lib_ckpt_sectionwrite->idLen,
- req_lib_ckpt_sectionwrite->dataSize);
- }
- /*
- * Write write response to CKPT library
- */
- error_exit:
- if (req_exec_ckpt_sectionwrite->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectionwrite.header.magic = MESSAGE_MAGIC;
- 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.error = error;
- libais_send_response (req_exec_ckpt_sectionwrite->source.fd,
- &res_lib_ckpt_sectionwrite,
- sizeof (struct res_lib_ckpt_sectionwrite));
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_sectionoverwrite (int fd, void *message) {
- struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message;
- struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)&req_exec_ckpt_sectionoverwrite->req_lib_ckpt_sectionoverwrite;
- struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- void *sectionData;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n");
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionoverwrite->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Find checkpoint section to be overwritten
- */
- ckptCheckpointSection = findCheckpointSection (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;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section data
- */
- sectionData = malloc (req_lib_ckpt_sectionoverwrite->dataSize);
- if (sectionData == 0) {
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- memcpy (sectionData,
- ((char *)req_lib_ckpt_sectionoverwrite) +
- sizeof (struct req_lib_ckpt_sectionoverwrite) +
- req_lib_ckpt_sectionoverwrite->idLen,
- req_lib_ckpt_sectionoverwrite->dataSize);
- /*
- * release old checkpoint section data
- */
- free (ckptCheckpointSection->sectionData);
- /*
- * Install overwritten checkpoint section data
- */
- ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectionoverwrite->dataSize;
- ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
- ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; // TODO current time
- ckptCheckpointSection->sectionData = sectionData;
- /*
- * return result to CKPT library
- */
- error_exit:
- if (req_exec_ckpt_sectionoverwrite->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectionoverwrite.header.magic = MESSAGE_MAGIC;
- 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.error = error;
- libais_send_response (req_exec_ckpt_sectionoverwrite->source.fd,
- &res_lib_ckpt_sectionoverwrite,
- sizeof (struct res_lib_ckpt_sectionoverwrite));
- }
- return (0);
- }
- static int message_handler_req_exec_ckpt_sectionread (int fd, void *message) {
- struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message;
- struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)&req_exec_ckpt_sectionread->req_lib_ckpt_sectionread;
- struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection = 0;
- int sectionSize = 0;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n");
- ckptCheckpoint = findCheckpoint (&req_exec_ckpt_sectionread->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_SYSTEM; // TODO find the right error for this
- goto error_exit;
- }
- /*
- * Find checkpoint section to be read
- */
- ckptCheckpointSection = findCheckpointSection (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;
- goto error_exit;
- }
- /*
- * Determine the section size
- */
- sectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize -
- req_lib_ckpt_sectionread->dataOffset;
- /*
- * If the library has less space available then can be sent from the
- * section, reduce bytes sent to library to max requested
- */
- if (sectionSize > req_lib_ckpt_sectionread->dataSize) {
- sectionSize = req_lib_ckpt_sectionread->dataSize;
- }
- /*
- * If dataOffset is past end of data, return INVALID PARAM
- */
- if (req_lib_ckpt_sectionread->dataOffset > sectionSize) {
- sectionSize = 0;
- error = SA_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Write read response to CKPT library
- */
- error_exit:
- if (req_exec_ckpt_sectionread->source.in_addr.s_addr == this_ip.sin_addr.s_addr) {
- res_lib_ckpt_sectionread.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread) + sectionSize;
- res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
- res_lib_ckpt_sectionread.error = error;
-
- libais_send_response (req_exec_ckpt_sectionread->source.fd,
- &res_lib_ckpt_sectionread,
- sizeof (struct res_lib_ckpt_sectionread));
- /*
- * Write checkpoint to CKPT library section if section has data
- */
- if (sectionSize) {
- char *sd;
- sd = (char *)ckptCheckpointSection->sectionData;
- libais_send_response (req_exec_ckpt_sectionread->source.fd,
- &sd[req_lib_ckpt_sectionread->dataOffset],
- sectionSize);
- }
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_init (int fd, 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 (connections[fd].authenticated) {
- connections[fd].service = SOCKET_SERVICE_CKPT;
- error = SA_OK;
- }
- res_lib_init.header.magic = MESSAGE_MAGIC;
- res_lib_init.header.size = sizeof (struct res_lib_init);
- res_lib_init.header.id = MESSAGE_RES_INIT;
- res_lib_init.error = error;
- libais_send_response (fd, &res_lib_init, sizeof (res_lib_init));
- if (connections[fd].authenticated) {
- return (0);
- }
- return (-1);
- }
- static int message_handler_req_lib_ckpt_checkpoint_init (int fd, void *message)
- {
- struct res_lib_init res_lib_init;
- SaErrorT error = SA_ERR_SECURITY;
- log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT checkpoint.\n");
- if (connections[fd].authenticated) {
- connections[fd].service = SOCKET_SERVICE_CKPT_CHECKPOINT;
- connections[fd].ais_ci.u.libckpt_ci.checkpoint = 0;
- connections[fd].ais_ci.u.libckpt_ci.checkpointOpenFlags = 0;
- error = SA_OK;
- }
- res_lib_init.header.magic = MESSAGE_MAGIC;
- res_lib_init.header.size = sizeof (struct res_lib_init);
- res_lib_init.header.id = MESSAGE_RES_INIT;
- res_lib_init.error = error;
- libais_send_response (fd, &res_lib_init, sizeof (res_lib_init));
- if (connections[fd].authenticated) {
- return (0);
- }
- return (-1);
- }
- static int message_handler_req_lib_ckpt_sectioniterator_init (int fd, 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 (connections[fd].authenticated) {
- connections[fd].service = SOCKET_SERVICE_CKPT_SECTIONITERATOR;
- list_init (&connections[fd].ais_ci.u.libckpt_ci.sectionIterator.list);
- connections[fd].ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries = 0;
- connections[fd].ais_ci.u.libckpt_ci.sectionIterator.iteratorCount = 0;
- connections[fd].ais_ci.u.libckpt_ci.sectionIterator.iteratorPos = 0;
- list_add (&connections[fd].ais_ci.u.libckpt_ci.sectionIterator.list,
- &checkpointIteratorListHead);
- error = SA_OK;
- }
- res_lib_init.header.magic = MESSAGE_MAGIC;
- res_lib_init.header.size = sizeof (struct res_lib_init);
- res_lib_init.header.id = MESSAGE_RES_INIT;
- res_lib_init.error = error;
- libais_send_response (fd, &res_lib_init, sizeof (res_lib_init));
- if (connections[fd].authenticated) {
- return (0);
- }
- return (-1);
- }
- static int message_handler_req_lib_ckpt_checkpointopen (int fd, void *message)
- {
- struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)message;
- struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
- struct iovec iovecs[2];
- int result;
- log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
- req_exec_ckpt_checkpointopen.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_checkpointopen.header.size =
- sizeof (struct req_exec_ckpt_checkpointopen);
- req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
- req_exec_ckpt_checkpointopen.source.fd = fd;
- req_exec_ckpt_checkpointopen.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_ckpt_checkpointopen.req_lib_ckpt_checkpointopen,
- req_lib_ckpt_checkpointopen,
- sizeof (struct req_lib_ckpt_checkpointopen));
- iovecs[0].iov_base = &req_exec_ckpt_checkpointopen;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointopen);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointopenasync (int fd, void *message)
- {
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointunlink (int fd, void *message)
- {
- struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)message;
- struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
- struct iovec iovecs[2];
- int result;
- req_exec_ckpt_checkpointunlink.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_checkpointunlink.header.size =
- sizeof (struct req_exec_ckpt_checkpointunlink);
- req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
- req_exec_ckpt_checkpointunlink.source.fd = fd;
- req_exec_ckpt_checkpointunlink.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink,
- req_lib_ckpt_checkpointunlink,
- sizeof (struct req_lib_ckpt_checkpointunlink));
- iovecs[0].iov_base = &req_exec_ckpt_checkpointunlink;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
- result = gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointretentiondurationset (int fd, void *message)
- {
- struct req_lib_ckpt_checkpointretentiondurationset *req_lib_ckpt_checkpointretentiondurationset = (struct req_lib_ckpt_checkpointretentiondurationset *)message;
- struct req_exec_ckpt_checkpointretentiondurationset req_exec_ckpt_checkpointretentiondurationset;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API fd %d\n", fd);
- req_exec_ckpt_checkpointretentiondurationset.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET;
- req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
- memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- req_exec_ckpt_checkpointretentiondurationset.retentionDuration = req_lib_ckpt_checkpointretentiondurationset->retentionDuration;
- iovecs[0].iov_base = &req_exec_ckpt_checkpointretentiondurationset;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationset);
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- return (0);
- }
- static int message_handler_req_lib_ckpt_activecheckpointset (int fd, void *message)
- {
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointstatusget (int fd, void *message)
- {
- struct req_lib_ckpt_checkpointstatusget *req_lib_ckpt_checkpointstatusget = (struct req_lib_ckpt_checkpointstatusget *)message;
- struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
- struct saCkptCheckpoint *checkpoint;
- int memoryUsed = 0;
- int numberOfSections = 0;
- 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 = connections[fd].ais_ci.u.libckpt_ci.checkpoint;
- for (checkpointSectionList = checkpoint->checkpointSectionsListHead.next;
- checkpointSectionList != &checkpoint->checkpointSectionsListHead;
- checkpointSectionList = checkpointSectionList->next) {
- checkpointSection = list_entry (checkpointSectionList,
- struct saCkptCheckpointSection, list);
- memoryUsed += checkpointSection->sectionDescriptor.sectionSize;
- numberOfSections += 1;
- }
- /*
- * Build checkpoint status get response
- */
- res_lib_ckpt_checkpointstatusget.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
- res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
- memcpy (&res_lib_ckpt_checkpointstatusget.checkpointStatus.checkpointCreationAttributes,
- &checkpoint->checkpointCreationAttributes,
- sizeof (SaCkptCheckpointCreationAttributesT));
- res_lib_ckpt_checkpointstatusget.checkpointStatus.numberOfSections = numberOfSections;
- res_lib_ckpt_checkpointstatusget.checkpointStatus.memoryUsed = memoryUsed;
- log_printf (LOG_LEVEL_DEBUG, "before sending message\n");
- libais_send_response (fd, &res_lib_ckpt_checkpointstatusget,
- sizeof (struct res_lib_ckpt_checkpointstatusget));
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectioncreate (int fd, void *message)
- {
- 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];
- log_printf (LOG_LEVEL_DEBUG, "Section create from API fd %d\n", fd);
- /*
- * Determine if checkpoint is opened in write mode If not, send error to api
- */
- if ((connections[fd].ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
- res_lib_ckpt_sectioncreate.header.magic = MESSAGE_MAGIC;
- 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.error = SA_ERR_ACCESS;
- libais_send_response (fd, &res_lib_ckpt_sectioncreate,
- sizeof (struct res_lib_ckpt_sectioncreate));
- return (0);
- }
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectioncreate.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectioncreate.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE;
- req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
- memcpy (&req_exec_ckpt_sectioncreate.req_lib_ckpt_sectioncreate,
- req_lib_ckpt_sectioncreate,
- sizeof (struct req_lib_ckpt_sectioncreate));
- memcpy (&req_exec_ckpt_sectioncreate.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- req_exec_ckpt_sectioncreate.source.fd = fd;
- req_exec_ckpt_sectioncreate.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectioncreate;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectioncreate);
- /*
- * Send section name and initial data in message
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate);
- iovecs[1].iov_len = req_lib_ckpt_sectioncreate->header.size - sizeof (struct req_lib_ckpt_sectioncreate);
- #ifdef DEBUG
- printf ("LIBRARY SECTIONCREATE string is %s len is %d\n", iovecs[1].iov_base, iovecs[1].iov_len);
- printf ("|\n");
- { int i;
- char *suck = iovecs[1].iov_base;
- for (i = 0; i < 14;i++) {
- printf ("%c ", suck[i]);
- }
- }
- printf ("|\n");
- #endif
- if (iovecs[1].iov_len > 0) {
- log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectiondelete (int fd, void *message)
- {
- struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)message;
- struct req_exec_ckpt_sectiondelete req_exec_ckpt_sectiondelete;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "section delete from API fd %d\n", fd);
- req_exec_ckpt_sectiondelete.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectiondelete.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE;
- req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
- memcpy (&req_exec_ckpt_sectiondelete.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- memcpy (&req_exec_ckpt_sectiondelete.req_lib_ckpt_sectiondelete,
- req_lib_ckpt_sectiondelete,
- sizeof (struct req_lib_ckpt_sectiondelete));
- req_exec_ckpt_sectiondelete.source.fd = fd;
- req_exec_ckpt_sectiondelete.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectiondelete;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectiondelete);
- /*
- * Send section name
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete);
- iovecs[1].iov_len = req_lib_ckpt_sectiondelete->header.size - sizeof (struct req_lib_ckpt_sectiondelete);
- if (iovecs[1].iov_len > 0) {
- log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectionexpirationtimeset (int fd, void *message)
- {
- struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)message;
- struct req_exec_ckpt_sectionexpirationtimeset req_exec_ckpt_sectionexpirationtimeset;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "section expiration time set fd=%d\n", fd);
- req_exec_ckpt_sectionexpirationtimeset.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET;
- req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
- memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- memcpy (&req_exec_ckpt_sectionexpirationtimeset.req_lib_ckpt_sectionexpirationtimeset,
- req_lib_ckpt_sectionexpirationtimeset,
- sizeof (struct req_lib_ckpt_sectionexpirationtimeset));
- req_exec_ckpt_sectionexpirationtimeset.source.fd = fd;
- req_exec_ckpt_sectionexpirationtimeset.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectionexpirationtimeset;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionexpirationtimeset);
- /*
- * Send section name
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionexpirationtimeset) + sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
- iovecs[1].iov_len = req_lib_ckpt_sectionexpirationtimeset->header.size - sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
- if (iovecs[1].iov_len > 0) {
- log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %s\n", iovecs[1].iov_base);
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- int write_inv = 0;
- static int message_handler_req_lib_ckpt_sectionwrite (int fd, void *message)
- {
- 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];
- log_printf (LOG_LEVEL_DEBUG, "Section write from API fd %d\n", fd);
- // UNDO printf ("section write %d\n", write_inv++);
- /*
- * Determine if checkpoint is opened in write mode If not, send error to api
- */
- if ((connections[fd].ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
- res_lib_ckpt_sectionwrite.header.magic = MESSAGE_MAGIC;
- 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.error = SA_ERR_ACCESS;
- libais_send_response (fd, &res_lib_ckpt_sectionwrite,
- sizeof (struct res_lib_ckpt_sectionwrite));
- return (0);
- }
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectionwrite.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectionwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE;
- req_exec_ckpt_sectionwrite.header.size = sizeof (struct req_exec_ckpt_sectionwrite);
- memcpy (&req_exec_ckpt_sectionwrite.req_lib_ckpt_sectionwrite,
- req_lib_ckpt_sectionwrite,
- sizeof (struct req_lib_ckpt_sectionwrite));
- memcpy (&req_exec_ckpt_sectionwrite.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- req_exec_ckpt_sectionwrite.source.fd = fd;
- req_exec_ckpt_sectionwrite.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectionwrite;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionwrite);
- /*
- * Send section name and data to write in message
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite);
- iovecs[1].iov_len = req_lib_ckpt_sectionwrite->header.size - sizeof (struct req_lib_ckpt_sectionwrite);
- //printf ("LIB writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
- if (iovecs[1].iov_len > 0) {
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectionoverwrite (int fd, void *message)
- {
- 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];
- log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", fd);
- /*
- * Determine if checkpoint is opened in write mode If not, send error to api
- */
- if ((connections[fd].ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_WRITE) == 0) {
- res_lib_ckpt_sectionoverwrite.header.magic = MESSAGE_MAGIC;
- 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.error = SA_ERR_ACCESS;
- libais_send_response (fd, &res_lib_ckpt_sectionoverwrite,
- sizeof (struct res_lib_ckpt_sectionoverwrite));
- return (0);
- }
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectionoverwrite.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE;
- req_exec_ckpt_sectionoverwrite.header.size = sizeof (struct req_exec_ckpt_sectionoverwrite);
- memcpy (&req_exec_ckpt_sectionoverwrite.req_lib_ckpt_sectionoverwrite,
- req_lib_ckpt_sectionoverwrite,
- sizeof (struct req_lib_ckpt_sectionoverwrite));
- memcpy (&req_exec_ckpt_sectionoverwrite.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- req_exec_ckpt_sectionoverwrite.source.fd = fd;
- req_exec_ckpt_sectionoverwrite.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectionoverwrite;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionoverwrite);
- /*
- * Send section name and data to overwrite in message
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionoverwrite) + sizeof (struct req_lib_ckpt_sectionoverwrite);
- iovecs[1].iov_len = req_lib_ckpt_sectionoverwrite->header.size - sizeof (struct req_lib_ckpt_sectionoverwrite);
- if (iovecs[1].iov_len > 0) {
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectionread (int fd, void *message)
- {
- 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];
- log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", fd);
- /*
- * Determine if checkpoint is opened in write mode If not, send error to api
- */
- if ((connections[fd].ais_ci.u.libckpt_ci.checkpointOpenFlags & SA_CKPT_CHECKPOINT_READ) == 0) {
- res_lib_ckpt_sectionread.header.magic = MESSAGE_MAGIC;
- 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.error = SA_ERR_ACCESS;
- libais_send_response (fd, &res_lib_ckpt_sectionread,
- sizeof (struct res_lib_ckpt_sectionread));
- return (0);
- }
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectionread.header.magic = MESSAGE_MAGIC;
- req_exec_ckpt_sectionread.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONREAD;
- req_exec_ckpt_sectionread.header.size = sizeof (struct req_exec_ckpt_sectionread);
- memcpy (&req_exec_ckpt_sectionread.req_lib_ckpt_sectionread,
- req_lib_ckpt_sectionread,
- sizeof (struct req_lib_ckpt_sectionread));
- memcpy (&req_exec_ckpt_sectionread.checkpointName,
- &connections[fd].ais_ci.u.libckpt_ci.checkpoint->name,
- sizeof (SaNameT));
- req_exec_ckpt_sectionread.source.fd = fd;
- req_exec_ckpt_sectionread.source.in_addr.s_addr = this_ip.sin_addr.s_addr;
- iovecs[0].iov_base = &req_exec_ckpt_sectionread;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionread);
- /*
- * Send section name and data to overwrite in message
- */
- iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionread) + sizeof (struct req_lib_ckpt_sectionread);
- iovecs[1].iov_len = req_lib_ckpt_sectionread->header.size - sizeof (struct req_lib_ckpt_sectionread);
- if (iovecs[1].iov_len > 0) {
- gmi_mcast (&aisexec_groupname, iovecs, 2, GMI_PRIO_MED);
- } else {
- gmi_mcast (&aisexec_groupname, iovecs, 1, GMI_PRIO_MED);
- }
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointsynchronize (int fd, void *message)
- {
- return (0);
- }
- static int message_handler_req_lib_ckpt_checkpointsyncronizeasync (int fd, void *message)
- {
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectioniteratorinitialize (int fd, void *message)
- {
- struct req_lib_ckpt_sectioniteratorinitialize *req_lib_ckpt_sectioniteratorinitialize = (struct req_lib_ckpt_sectioniteratorinitialize *)message;
- struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize;
- struct saCkptCheckpoint *ckptCheckpoint;
- struct saCkptCheckpointSection *ckptCheckpointSection;
- struct saCkptSectionIteratorEntry *ckptSectionIteratorEntries;
- struct saCkptSectionIterator *ckptSectionIterator;
- struct list_head *checkpointSectionList;
- int addEntry = 0;
- int iteratorEntries = 0;
- SaErrorT error = SA_OK;
- log_printf (LOG_LEVEL_DEBUG, "section iterator initialize\n");
- ckptSectionIterator = &connections[fd].ais_ci.u.libckpt_ci.sectionIterator;
- ckptCheckpoint = findCheckpoint (&req_lib_ckpt_sectioniteratorinitialize->checkpointName);
- if (ckptCheckpoint == 0) {
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Iterate list of checkpoint sections
- */
- for (checkpointSectionList = ckptCheckpoint->checkpointSectionsListHead.next;
- checkpointSectionList != &ckptCheckpoint->checkpointSectionsListHead;
- checkpointSectionList = checkpointSectionList->next) {
- ckptCheckpointSection = list_entry (checkpointSectionList,
- struct saCkptCheckpointSection, list);
- addEntry = 1;
- /*
- * Item should be added to iterator list
- */
- if (addEntry) {
- iteratorEntries += 1;
- ckptSectionIteratorEntries =
- realloc (ckptSectionIterator->sectionIteratorEntries,
- sizeof (struct saCkptSectionIteratorEntry) * iteratorEntries);
- if (ckptSectionIteratorEntries == 0) {
- if (ckptSectionIterator->sectionIteratorEntries) {
- free (ckptSectionIterator->sectionIteratorEntries);
- }
- error = SA_ERR_NO_MEMORY;
- goto error_exit;
- }
- ckptSectionIteratorEntries[iteratorEntries - 1].active = 1;
- ckptSectionIteratorEntries[iteratorEntries - 1].checkpointSection = ckptCheckpointSection;
- ckptSectionIterator->sectionIteratorEntries = ckptSectionIteratorEntries;
- }
- }
- ckptSectionIterator->iteratorCount = iteratorEntries;
- error_exit:
- res_lib_ckpt_sectioniteratorinitialize.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_sectioniteratorinitialize.header.size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize);
- res_lib_ckpt_sectioniteratorinitialize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
- res_lib_ckpt_sectioniteratorinitialize.error = error;
- libais_send_response (fd, &res_lib_ckpt_sectioniteratorinitialize,
- sizeof (struct res_lib_ckpt_sectioniteratorinitialize));
- return (0);
- }
- static int message_handler_req_lib_ckpt_sectioniteratornext (int fd, void *message)
- {
- 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;
- int sectionIdSize = 0;
- int iteratorPos = 0;
- req_lib_ckpt_sectioniteratornext = 0; /* this variable not used */
- log_printf (LOG_LEVEL_DEBUG, "section iterator next\n");
- ckptSectionIterator = &connections[fd].ais_ci.u.libckpt_ci.sectionIterator;
- /*
- * Find active iterator entry
- */
- for (;;) {
- /*
- * No more sections in iterator
- */
- if (ckptSectionIterator->iteratorPos + 1 >= ckptSectionIterator->iteratorCount) {
- error = SA_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * active iterator entry
- */
- if (ckptSectionIterator->sectionIteratorEntries[ckptSectionIterator->iteratorPos].active == 1) {
- break;
- }
- ckptSectionIterator->iteratorPos += 1;
- }
- /*
- * Prepare response to API
- */
- iteratorPos = ckptSectionIterator->iteratorPos;
- sectionIdSize = ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.idLen;
- memcpy (&res_lib_ckpt_sectioniteratornext.sectionDescriptor,
- &ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor,
- sizeof (SaCkptSectionDescriptorT));
- /*
- * Get to next iterator entry
- */
- ckptSectionIterator->iteratorPos += 1;
- error_exit:
- res_lib_ckpt_sectioniteratornext.header.magic = MESSAGE_MAGIC;
- res_lib_ckpt_sectioniteratornext.header.size = sizeof (struct res_lib_ckpt_sectioniteratornext) + sectionIdSize;
- res_lib_ckpt_sectioniteratornext.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
- res_lib_ckpt_sectioniteratornext.error = error;
- libais_send_response (fd, &res_lib_ckpt_sectioniteratornext,
- sizeof (struct res_lib_ckpt_sectioniteratornext));
- libais_send_response (fd,
- ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.id,
- sectionIdSize);
- return (0);
- }
|