| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923 |
- /*
- * Copyright (c) 2003-2006 MontaVista Software, Inc.
- * Copyright (c) 2006-2007 Red Hat, Inc.
- *
- * All rights reserved.
- *
- * Authors: Steven Dake (sdake@mvista.com)
- * Muni Bajpai (muni.osdl@gmail.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/types.h>
- #include <sys/uio.h>
- #include <sys/socket.h>
- #include <sys/un.h>
- #include <sys/time.h>
- #include <netinet/in.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <errno.h>
- #include <signal.h>
- #include <arpa/inet.h>
- #include "../include/saAis.h"
- #include "../include/saCkpt.h"
- #include "../include/mar_ckpt.h"
- #include "../include/ipc_ckpt.h"
- #include "../include/list.h"
- #include "../include/queue.h"
- #include "../include/hdb.h"
- #include "../lcr/lcr_comp.h"
- #include "objdb.h"
- #include "totem.h"
- #include "service.h"
- #include "mempool.h"
- #include "tlist.h"
- #include "timer.h"
- #include "util.h"
- #include "main.h"
- #include "flow.h"
- #include "ipc.h"
- #include "totempg.h"
- #include "logsys.h"
- LOGSYS_DECLARE_SUBSYS ("CKPT", LOG_INFO);
- #define CKPT_MAX_SECTION_DATA_SEND (1024*400)
- enum ckpt_message_req_types {
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN = 0,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE = 1,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK = 2,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET = 3,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE = 4,
- MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE = 5,
- MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE = 6,
- MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET = 7,
- MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE = 8,
- MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE = 9,
- MESSAGE_REQ_EXEC_CKPT_SECTIONREAD = 10,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINT = 11,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINTSECTION = 12,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINTREFCOUNT = 13
- };
- struct checkpoint_section {
- struct list_head list;
- mar_ckpt_section_descriptor_t section_descriptor;
- void *section_data;
- timer_handle expiration_timer;
- };
- enum sync_state {
- SYNC_STATE_CHECKPOINT,
- SYNC_STATE_REFCOUNT
- };
- enum iteration_state {
- ITERATION_STATE_CHECKPOINT,
- ITERATION_STATE_SECTION
- };
- struct refcount_set {
- unsigned int refcount;
- unsigned int nodeid;
- };
- typedef struct {
- unsigned int refcount __attribute__((aligned(8)));
- unsigned int nodeid __attribute__((aligned(8)));
- } mar_refcount_set_t;
- static inline void marshall_to_mar_refcount_set_t (
- mar_refcount_set_t *dest,
- struct refcount_set *src)
- {
- dest->refcount = src->refcount;
- dest->nodeid = src->nodeid;
- }
- static inline void marshall_to_mar_refcount_set_t_all (
- mar_refcount_set_t *dest,
- struct refcount_set *src)
- {
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- marshall_to_mar_refcount_set_t (&dest[i], &src[i]);
- }
- }
- static inline void marshall_from_mar_refcount_set_t (
- struct refcount_set *dest,
- mar_refcount_set_t *src)
- {
- dest->refcount = src->refcount;
- dest->nodeid = src->nodeid;
- }
- static inline void marshall_from_mar_refcount_set_t_all (
- struct refcount_set *dest,
- mar_refcount_set_t *src)
- {
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- marshall_from_mar_refcount_set_t (&dest[i], &src[i]);
- }
- }
- static inline void swab_mar_refcount_set_t (mar_refcount_set_t *to_swab)
- {
- swab_mar_uint32_t (&to_swab->refcount);
- swab_mar_uint32_t (&to_swab->nodeid);
- }
- struct checkpoint {
- struct list_head list;
- mar_name_t name;
- mar_uint32_t ckpt_id;
- mar_ckpt_checkpoint_creation_attributes_t checkpoint_creation_attributes;
- struct list_head sections_list_head;
- int reference_count;
- int unlinked;
- timer_handle retention_timer;
- int active_replica_set;
- int section_count;
- struct refcount_set refcount_set[PROCESSOR_COUNT_MAX];
- };
- struct iteration_entry {
- char *section_id;
- unsigned int section_id_len;
- };
- struct iteration_instance {
- struct iteration_entry *iteration_entries;
- mar_name_t checkpoint_name;
- mar_uint32_t ckpt_id;
- int iteration_entries_count;
- unsigned int iteration_pos;
- };
- struct ckpt_pd {
- struct list_head checkpoint_list;
- struct hdb_handle_database iteration_hdb;
- unsigned int iteration_pos;
- };
- struct ckpt_identifier {
- mar_name_t ckpt_name;
- mar_uint32_t ckpt_id;
- mar_ckpt_section_id_t ckpt_section_id;
- };
- static int ckpt_exec_init_fn (struct objdb_iface_ver0 *);
- static int ckpt_lib_exit_fn (void *conn);
- static int ckpt_lib_init_fn (void *conn);
- static void ckpt_dump_fn (void);
- static void message_handler_req_lib_ckpt_checkpointopen (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointclose (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointunlink (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointretentiondurationset (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_activereplicaset (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointstatusget (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectioncreate (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectiondelete (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectionexpirationtimeset (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectionwrite (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectionoverwrite (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectionread (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointsynchronize (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_checkpointsynchronizeasync (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectioniterationinitialize (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectioniterationfinalize (
- void *conn,
- void *msg);
- static void message_handler_req_lib_ckpt_sectioniterationnext (
- void *conn,
- void *msg);
- static void message_handler_req_exec_ckpt_checkpointopen (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sync_checkpoint (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sync_checkpoint_section (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sync_checkpoint_refcount (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_checkpointclose (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_checkpointunlink (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_checkpointretentiondurationset (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_checkpointretentiondurationexpire (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectioncreate (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectiondelete (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectionexpirationtimeset (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectionwrite (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectionoverwrite (
- void *message,
- unsigned int nodeid);
- static void message_handler_req_exec_ckpt_sectionread (
- void *message,
- unsigned int nodeid);
- static void exec_ckpt_checkpointopen_endian_convert (void *msg);
- static void exec_ckpt_checkpointclose_endian_convert (void *msg);
- static void exec_ckpt_checkpointunlink_endian_convert (void *msg);
- static void exec_ckpt_checkpointretentiondurationset_endian_convert (void *msg);
- static void exec_ckpt_checkpointretentiondurationexpire_endian_convert (void *msg);
- static void exec_ckpt_sectioncreate_endian_convert (void *msg);
- static void exec_ckpt_sectiondelete_endian_convert (void *msg);
- static void exec_ckpt_sectrionexpirationtimeset_endian_convert (void *msg);
- static void exec_ckpt_sectionwrite_endian_convert (void *msg);
- static void exec_ckpt_sectionoverwrite_endian_convert (void *msg);
- static void exec_ckpt_sectionread_endian_convert (void *msg);
- static void exec_ckpt_sync_checkpoint_endian_convert (void *msg);
- static void exec_ckpt_sync_checkpoint_section_endian_convert (void *msg);
- static void exec_ckpt_sync_checkpoint_refcount_endian_convert (void *msg);
- static void ckpt_sync_init (void);
- static void ckpt_sync_activate (void);
- static int ckpt_sync_process (void);
- static void ckpt_sync_abort(void);
- static void sync_refcount_increment (
- struct checkpoint *checkpoint, unsigned int nodeid);
- static void sync_refcount_decrement (
- struct checkpoint *checkpoint, unsigned int nodeid);
- static void sync_refcount_calculate (
- struct checkpoint *checkpoint);
- void checkpoint_release (struct checkpoint *checkpoint);
- void timer_function_retention (void *data);
- unsigned int abstime_to_msec (mar_time_t time);
- void timer_function_section_expire (void *data);
- void clean_checkpoint_list(struct list_head* head);
- DECLARE_LIST_INIT(checkpoint_list_head);
- DECLARE_LIST_INIT(sync_checkpoint_list_head);
- DECLARE_LIST_INIT(checkpoint_iteration_list_head);
- DECLARE_LIST_INIT(checkpoint_recovery_list_head);
- static mar_uint32_t global_ckpt_id = 0;
- static enum sync_state my_sync_state;
- static enum iteration_state my_iteration_state;
- static struct list_head *my_iteration_state_checkpoint;
- static struct list_head *my_iteration_state_section;
- static unsigned int my_member_list[PROCESSOR_COUNT_MAX];
- static unsigned int my_member_list_entries = 0;
- static unsigned int my_lowest_nodeid = 0;
- struct checkpoint_cleanup {
- struct list_head list;
- mar_name_t checkpoint_name;
- mar_uint32_t ckpt_id;
- };
- static struct memb_ring_id my_saved_ring_id;
- static void ckpt_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id);
- /*
- * Executive Handler Definition
- */
- static struct openais_lib_handler ckpt_lib_service[] =
- {
- { /* 0 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointopen,
- .response_size = sizeof (struct res_lib_ckpt_checkpointopen),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 1 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointclose,
- .response_size = sizeof (struct res_lib_ckpt_checkpointclose),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 2 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointunlink,
- .response_size = sizeof (struct res_lib_ckpt_checkpointunlink),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 3 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointretentiondurationset,
- .response_size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 4 */
- .lib_handler_fn = message_handler_req_lib_ckpt_activereplicaset,
- .response_size = sizeof (struct res_lib_ckpt_activereplicaset),
- .response_id = MESSAGE_RES_CKPT_ACTIVEREPLICASET,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 5 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointstatusget,
- .response_size = sizeof (struct res_lib_ckpt_checkpointstatusget),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 6 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectioncreate,
- .response_size = sizeof (struct res_lib_ckpt_sectioncreate),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 7 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectiondelete,
- .response_size = sizeof (struct res_lib_ckpt_sectiondelete),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 8 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectionexpirationtimeset,
- .response_size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 9 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectionwrite,
- .response_size = sizeof (struct res_lib_ckpt_sectionwrite),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 10 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectionoverwrite,
- .response_size = sizeof (struct res_lib_ckpt_sectionoverwrite),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 11 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectionread,
- .response_size = sizeof (struct res_lib_ckpt_sectionread),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD,
- .flow_control = OPENAIS_FLOW_CONTROL_REQUIRED
- },
- { /* 12 */
- .lib_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronize,
- .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronize),
- .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 13 */
- .lib_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,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 14 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectioniterationinitialize,
- .response_size = sizeof (struct res_lib_ckpt_sectioniterationinitialize),
- .response_id = MESSAGE_RES_CKPT_SECTIONITERATIONINITIALIZE,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 15 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectioniterationfinalize,
- .response_size = sizeof (struct res_lib_ckpt_sectioniterationfinalize),
- .response_id = MESSAGE_RES_CKPT_SECTIONITERATIONFINALIZE,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- },
- { /* 16 */
- .lib_handler_fn = message_handler_req_lib_ckpt_sectioniterationnext,
- .response_size = sizeof (struct res_lib_ckpt_sectioniterationnext),
- .response_id = MESSAGE_RES_CKPT_SECTIONITERATIONNEXT,
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED
- }
- };
- static struct openais_exec_handler ckpt_exec_service[] = {
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_checkpointopen,
- .exec_endian_convert_fn = exec_ckpt_checkpointopen_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_checkpointclose,
- .exec_endian_convert_fn = exec_ckpt_checkpointclose_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_checkpointunlink,
- .exec_endian_convert_fn = exec_ckpt_checkpointunlink_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_checkpointretentiondurationset,
- .exec_endian_convert_fn = exec_ckpt_checkpointretentiondurationset_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_checkpointretentiondurationexpire,
- .exec_endian_convert_fn = exec_ckpt_checkpointretentiondurationexpire_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectioncreate,
- .exec_endian_convert_fn = exec_ckpt_sectioncreate_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectiondelete,
- .exec_endian_convert_fn = exec_ckpt_sectiondelete_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectionexpirationtimeset,
- .exec_endian_convert_fn = exec_ckpt_sectrionexpirationtimeset_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectionwrite,
- .exec_endian_convert_fn = exec_ckpt_sectionwrite_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectionoverwrite,
- .exec_endian_convert_fn = exec_ckpt_sectionoverwrite_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sectionread,
- .exec_endian_convert_fn = exec_ckpt_sectionread_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sync_checkpoint,
- .exec_endian_convert_fn = exec_ckpt_sync_checkpoint_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sync_checkpoint_section,
- .exec_endian_convert_fn = exec_ckpt_sync_checkpoint_section_endian_convert
- },
- {
- .exec_handler_fn = message_handler_req_exec_ckpt_sync_checkpoint_refcount,
- .exec_endian_convert_fn = exec_ckpt_sync_checkpoint_refcount_endian_convert
- }
- };
- struct openais_service_handler ckpt_service_handler = {
- .name = "openais checkpoint service B.01.01",
- .id = CKPT_SERVICE,
- .private_data_size = sizeof (struct ckpt_pd),
- .flow_control = OPENAIS_FLOW_CONTROL_NOT_REQUIRED,
- .lib_init_fn = ckpt_lib_init_fn,
- .lib_exit_fn = ckpt_lib_exit_fn,
- .lib_service = ckpt_lib_service,
- .lib_service_count = sizeof (ckpt_lib_service) / sizeof (struct openais_lib_handler),
- .exec_init_fn = ckpt_exec_init_fn,
- .exec_dump_fn = ckpt_dump_fn,
- .exec_service = ckpt_exec_service,
- .exec_service_count = sizeof (ckpt_exec_service) / sizeof (struct openais_exec_handler),
- .confchg_fn = ckpt_confchg_fn,
- .sync_init = ckpt_sync_init,
- .sync_process = ckpt_sync_process,
- .sync_activate = ckpt_sync_activate,
- .sync_abort = ckpt_sync_abort,
- };
- /*
- * Dynamic loader definition
- */
- static struct openais_service_handler *ckpt_get_handler_ver0 (void);
- static struct openais_service_handler_iface_ver0 ckpt_service_handler_iface = {
- .openais_get_service_handler_ver0 = ckpt_get_handler_ver0
- };
- static struct lcr_iface openais_ckpt_ver0[1] = {
- {
- .name = "openais_ckpt",
- .version = 0,
- .versions_replace = 0,
- .versions_replace_count = 0,
- .dependencies = 0,
- .dependency_count = 0,
- .constructor = NULL,
- .destructor = NULL,
- .interfaces = NULL
- }
- };
- static struct lcr_comp ckpt_comp_ver0 = {
- .iface_count = 1,
- .ifaces = openais_ckpt_ver0
- };
- static struct openais_service_handler *ckpt_get_handler_ver0 (void)
- {
- return (&ckpt_service_handler);
- }
- __attribute__ ((constructor)) static void register_this_component (void) {
- lcr_interfaces_set (&openais_ckpt_ver0[0], &ckpt_service_handler_iface);
- lcr_component_register (&ckpt_comp_ver0);
- }
- /*
- * All data types used for executive messages
- */
- struct req_exec_ckpt_checkpointopen {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_ckpt_checkpoint_creation_attributes_t checkpoint_creation_attributes __attribute__((aligned(8)));
- mar_uint32_t checkpoint_creation_attributes_set __attribute__((aligned(8)));
- mar_ckpt_checkpoint_open_flags_t checkpoint_open_flags __attribute__((aligned(8)));
- mar_ckpt_checkpoint_handle_t checkpoint_handle __attribute__((aligned(8)));
- mar_invocation_t invocation __attribute__((aligned(8)));
- mar_uint32_t async_call __attribute__((aligned(8)));
- mar_uint32_t fail_with_error __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_checkpointclose {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_checkpointretentiondurationset {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_time_t retention_duration __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_checkpointretentiondurationexpire {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_checkpointunlink {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectioncreate {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_time_t expiration_time __attribute__((aligned(8)));
- mar_uint32_t initial_data_size __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectiondelete {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectionexpirationtimeset {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_time_t expiration_time __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectionwrite {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_offset_t data_offset __attribute__((aligned(8)));
- mar_offset_t data_size __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectionoverwrite {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_offset_t data_size __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sectionread {
- mar_req_header_t header __attribute__((aligned(8)));
- mar_message_source_t source __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_offset_t data_offset __attribute__((aligned(8)));
- mar_offset_t data_size __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sync_checkpoint {
- mar_req_header_t header __attribute__((aligned(8)));
- struct memb_ring_id ring_id __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_ckpt_checkpoint_creation_attributes_t checkpoint_creation_attributes __attribute__((aligned(8)));
- mar_uint32_t checkpoint_creation_attributes_set __attribute__((aligned(8)));
- mar_uint32_t active_replica_set __attribute__((aligned(8)));
- mar_uint32_t unlinked __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sync_checkpoint_section {
- mar_req_header_t header __attribute__((aligned(8)));
- struct memb_ring_id ring_id __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_uint32_t id_len __attribute__((aligned(8)));
- mar_time_t expiration_time __attribute__((aligned(8)));
- mar_uint32_t section_size __attribute__((aligned(8)));
- };
- struct req_exec_ckpt_sync_checkpoint_refcount {
- mar_req_header_t header __attribute__((aligned(8)));
- struct memb_ring_id ring_id __attribute__((aligned(8)));
- mar_name_t checkpoint_name __attribute__((aligned(8)));
- mar_uint32_t ckpt_id __attribute__((aligned(8)));
- mar_refcount_set_t refcount_set[PROCESSOR_COUNT_MAX] __attribute__((aligned(8)));
- };
- /*
- * Implementation
- */
- void clean_checkpoint_list(struct list_head *head)
- {
- struct list_head *checkpoint_list;
- struct checkpoint *checkpoint;
- if (list_empty(head)) {
- log_printf (LOG_LEVEL_DEBUG, "clean_checkpoint_list: List is empty \n");
- return;
- }
- checkpoint_list = head->next;
- while (checkpoint_list != head) {
- checkpoint = list_entry (checkpoint_list,
- struct checkpoint, list);
- assert (checkpoint > 0);
- /*
- * If checkpoint has been unlinked and this is the last reference, delete it
- */
- if (checkpoint->unlinked && checkpoint->reference_count == 0) {
- log_printf (LOG_LEVEL_DEBUG,"clean_checkpoint_list: deallocating checkpoint %s.\n",
- checkpoint->name.value);
- checkpoint_list = checkpoint_list->next;
- checkpoint_release (checkpoint);
- continue;
- }
- else if (checkpoint->reference_count == 0) {
- log_printf (LOG_LEVEL_DEBUG, "clean_checkpoint_list: Starting timer to release checkpoint %s.\n",
- checkpoint->name.value);
- openais_timer_delete (checkpoint->retention_timer);
- openais_timer_add_duration (
- checkpoint->checkpoint_creation_attributes.retention_duration,
- checkpoint,
- timer_function_retention,
- &checkpoint->retention_timer);
- }
- checkpoint_list = checkpoint_list->next;
- }
- }
- static void ckpt_confchg_fn (
- enum totem_configuration_type configuration_type,
- unsigned int *member_list, int member_list_entries,
- unsigned int *left_list, int left_list_entries,
- unsigned int *joined_list, int joined_list_entries,
- struct memb_ring_id *ring_id)
- {
- unsigned int i, j;
- /*
- * Determine lowest nodeid in old regular configuration for the
- * purpose of executing the synchronization algorithm
- */
- if (configuration_type == TOTEM_CONFIGURATION_TRANSITIONAL) {
- for (i = 0; i < left_list_entries; i++) {
- for (j = 0; j < my_member_list_entries; j++) {
- if (left_list[i] == my_member_list[j]) {
- my_member_list[j] = 0;
- }
- }
- }
- }
-
- my_lowest_nodeid = 0xffffffff;
- /*
- * Handle regular configuration
- */
- if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
- memcpy (my_member_list, member_list,
- sizeof (unsigned int) * member_list_entries);
- my_member_list_entries = member_list_entries;
- memcpy (&my_saved_ring_id, ring_id,
- sizeof (struct memb_ring_id));
- for (i = 0; i < my_member_list_entries; i++) {
- if ((my_member_list[i] != 0) &&
- (my_member_list[i] < my_lowest_nodeid)) {
- my_lowest_nodeid = my_member_list[i];
- }
- }
- }
- }
- static struct checkpoint *checkpoint_find (
- struct list_head *ckpt_list_head,
- mar_name_t *name,
- mar_uint32_t ckpt_id)
- {
- struct list_head *list;
- struct checkpoint *checkpoint;
- for (list = ckpt_list_head->next;
- list != ckpt_list_head;
- list = list->next) {
- checkpoint = list_entry (list,
- struct checkpoint, list);
- if (mar_name_match (name, &checkpoint->name) &&
- ckpt_id == checkpoint->ckpt_id) {
- return (checkpoint);
- }
- }
- return (0);
- }
- static struct checkpoint *checkpoint_find_linked (
- struct list_head *ckpt_list_head,
- mar_name_t *name)
- {
- struct list_head *list;
- struct checkpoint *checkpoint;
- for (list = ckpt_list_head->next;
- list != ckpt_list_head;
- list = list->next) {
- checkpoint = list_entry (list, struct checkpoint, list);
- if (mar_name_match (name, &checkpoint->name) &&
- checkpoint->unlinked == 0) {
- return (checkpoint);
- }
- }
- return (0);
- }
- static struct checkpoint *checkpoint_find_specific (
- struct list_head *ckpt_list_head,
- mar_name_t *name,
- mar_uint32_t ckpt_id)
- {
- struct list_head *list;
- struct checkpoint *checkpoint;
- for (list = ckpt_list_head->next;
- list != ckpt_list_head;
- list = list->next) {
- checkpoint = list_entry (list, struct checkpoint, list);
- if (mar_name_match (name, &checkpoint->name) &&
- (ckpt_id == checkpoint->ckpt_id)) {
- return (checkpoint);
- }
- }
- return (0);
- }
- static void ckpt_checkpoint_remove_cleanup (
- void *conn,
- mar_name_t checkpoint_name,
- mar_uint32_t ckpt_id)
- {
- struct list_head *list;
- struct checkpoint_cleanup *checkpoint_cleanup;
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- for (list = ckpt_pd->checkpoint_list.next;
- list != &ckpt_pd->checkpoint_list;
- list = list->next) {
- checkpoint_cleanup = list_entry (list, struct checkpoint_cleanup, list);
- if (mar_name_match (&checkpoint_cleanup->checkpoint_name,
- &checkpoint_name) &&
- (checkpoint_cleanup->ckpt_id == ckpt_id)) {
- list_del (&checkpoint_cleanup->list);
- free (checkpoint_cleanup);
- return;
- }
- }
- }
- static struct checkpoint_section *checkpoint_section_find (
- struct checkpoint *checkpoint,
- char *id,
- int id_len)
- {
- struct list_head *checkpoint_section_list;
- struct checkpoint_section *checkpoint_section;
- if (id_len != 0) {
- log_printf (LOG_LEVEL_DEBUG, "Finding checkpoint section id %s %d\n", (char*)id, id_len);
- }
- else {
- log_printf (LOG_LEVEL_DEBUG, "Finding default checkpoint section\n");
- }
- for (checkpoint_section_list = checkpoint->sections_list_head.next;
- checkpoint_section_list != &checkpoint->sections_list_head;
- checkpoint_section_list = checkpoint_section_list->next) {
- checkpoint_section = list_entry (checkpoint_section_list,
- struct checkpoint_section, list);
- if (checkpoint_section->section_descriptor.section_id.id_len) {
- log_printf (LOG_LEVEL_DEBUG, "Checking section id %d %*s\n",
- checkpoint_section->section_descriptor.section_id.id_len,
- checkpoint_section->section_descriptor.section_id.id_len,
- checkpoint_section->section_descriptor.section_id.id);
- }
- else {
- log_printf (LOG_LEVEL_DEBUG, "Checking default section id\n");
- }
- /*
- All 3 of these values being checked MUST be = 0 to return
- The default section. If even one of them is NON zero follow
- the normal route
- */
- if ((id_len ||
- checkpoint_section->section_descriptor.section_id.id ||
- checkpoint_section->section_descriptor.section_id.id_len) == 0) {
- log_printf (LOG_LEVEL_DEBUG, "Returning default section\n");
- return (checkpoint_section);
- }
- if (checkpoint_section->section_descriptor.section_id.id_len == id_len &&
- (checkpoint_section->section_descriptor.section_id.id)&&
- (id)&&
- (memcmp (checkpoint_section->section_descriptor.section_id.id,
- id, id_len) == 0)) {
- log_printf (LOG_LEVEL_DEBUG, "Returning section %s(0x%p)\n", checkpoint_section->section_descriptor.section_id.id,
- checkpoint_section);
- return (checkpoint_section);
- }
- }
- return 0;
- }
- void checkpoint_section_release (struct checkpoint_section *section)
- {
- log_printf (LOG_LEVEL_DEBUG, "checkpoint_section_release expiration timer = 0x%p\n", section->expiration_timer);
- list_del (§ion->list);
- openais_timer_delete (section->expiration_timer);
- if (section->section_descriptor.section_id.id) {
- free (section->section_descriptor.section_id.id);
- }
- if (section->section_data) {
- free (section->section_data);
- }
- free (section);
- }
- void checkpoint_release (struct checkpoint *checkpoint)
- {
- struct list_head *list;
- struct checkpoint_section *section;
- openais_timer_delete (checkpoint->retention_timer);
- /*
- * Release all checkpoint sections for this checkpoint
- */
- for (list = checkpoint->sections_list_head.next;
- list != &checkpoint->sections_list_head;) {
- section = list_entry (list,
- struct checkpoint_section, list);
- list = list->next;
- checkpoint->section_count -= 1;
- openais_timer_delete (section->expiration_timer);
- checkpoint_section_release (section);
- }
- list_del (&checkpoint->list);
- free (checkpoint);
- }
- int ckpt_checkpoint_close (
- mar_name_t *checkpoint_name,
- mar_uint32_t ckpt_id)
- {
- struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
- struct iovec iovec;
- req_exec_ckpt_checkpointclose.header.size =
- sizeof (struct req_exec_ckpt_checkpointclose);
- req_exec_ckpt_checkpointclose.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE);
- memcpy (&req_exec_ckpt_checkpointclose.checkpoint_name,
- checkpoint_name, sizeof (mar_name_t));
- req_exec_ckpt_checkpointclose.ckpt_id = ckpt_id;
- memset (&req_exec_ckpt_checkpointclose.source, 0,
- sizeof (mar_message_source_t));
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointclose;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointclose);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
- return (-1);
- }
- static int ckpt_exec_init_fn (struct objdb_iface_ver0 *objdb)
- {
- return (0);
- }
- /*
- * Endian conversion routines for executive message handlers
- */
- static void exec_ckpt_checkpointopen_endian_convert (void *msg)
- {
- struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_checkpointopen->header);
- swab_mar_message_source_t (&req_exec_ckpt_checkpointopen->source);
- swab_mar_name_t (&req_exec_ckpt_checkpointopen->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointopen->ckpt_id);
- swab_mar_ckpt_checkpoint_creation_attributes_t (&req_exec_ckpt_checkpointopen->checkpoint_creation_attributes);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointopen->checkpoint_creation_attributes_set);
- swab_mar_ckpt_checkpoint_open_flags_t (&req_exec_ckpt_checkpointopen->checkpoint_open_flags);
- swab_mar_ckpt_checkpoint_handle_t (&req_exec_ckpt_checkpointopen->checkpoint_handle);
- swab_mar_invocation_t (&req_exec_ckpt_checkpointopen->invocation);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointopen->async_call);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointopen->fail_with_error);
- }
- static void exec_ckpt_checkpointclose_endian_convert (void *msg)
- {
- struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_checkpointclose->header);
- swab_mar_message_source_t (&req_exec_ckpt_checkpointclose->source);
- swab_mar_name_t (&req_exec_ckpt_checkpointclose->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointclose->ckpt_id);
- }
- static void exec_ckpt_checkpointunlink_endian_convert (void *msg)
- {
- struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_checkpointunlink->header);
- swab_mar_message_source_t (&req_exec_ckpt_checkpointunlink->source);
- swab_mar_name_t (&req_exec_ckpt_checkpointunlink->checkpoint_name);
- }
- static void exec_ckpt_checkpointretentiondurationset_endian_convert (void *msg)
- {
- struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_checkpointretentiondurationset->header);
- swab_mar_message_source_t (&req_exec_ckpt_checkpointretentiondurationset->source);
- swab_mar_name_t (&req_exec_ckpt_checkpointretentiondurationset->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointretentiondurationset->ckpt_id);
- swab_mar_time_t (&req_exec_ckpt_checkpointretentiondurationset->retention_duration);
- }
- static void exec_ckpt_checkpointretentiondurationexpire_endian_convert (void *msg)
- {
- struct req_exec_ckpt_checkpointretentiondurationexpire *req_exec_ckpt_checkpointretentiondurationexpire = (struct req_exec_ckpt_checkpointretentiondurationexpire *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_checkpointretentiondurationexpire->header);
- swab_mar_name_t (&req_exec_ckpt_checkpointretentiondurationexpire->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_checkpointretentiondurationexpire->ckpt_id);
- }
- static void exec_ckpt_sectioncreate_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectioncreate->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectioncreate->source);
- swab_mar_name_t (&req_exec_ckpt_sectioncreate->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectioncreate->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectioncreate->id_len);
- swab_mar_time_t (&req_exec_ckpt_sectioncreate->expiration_time);
- swab_mar_uint32_t (&req_exec_ckpt_sectioncreate->initial_data_size);
- }
- static void exec_ckpt_sectiondelete_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectiondelete->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectiondelete->source);
- swab_mar_name_t (&req_exec_ckpt_sectiondelete->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectiondelete->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectiondelete->id_len);
- }
- static void exec_ckpt_sectrionexpirationtimeset_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectionexpirationtimeset->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectionexpirationtimeset->source);
- swab_mar_name_t (&req_exec_ckpt_sectionexpirationtimeset->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectionexpirationtimeset->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectionexpirationtimeset->id_len);
- swab_mar_time_t (&req_exec_ckpt_sectionexpirationtimeset->expiration_time);
- }
- static void exec_ckpt_sectionwrite_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectionwrite->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectionwrite->source);
- swab_mar_name_t (&req_exec_ckpt_sectionwrite->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectionwrite->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectionwrite->id_len);
- swab_mar_offset_t (&req_exec_ckpt_sectionwrite->data_size);
- }
- static void exec_ckpt_sectionoverwrite_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectionoverwrite->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectionoverwrite->source);
- swab_mar_name_t (&req_exec_ckpt_sectionoverwrite->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectionoverwrite->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectionoverwrite->id_len);
- swab_mar_offset_t (&req_exec_ckpt_sectionoverwrite->data_size);
- }
- static void exec_ckpt_sectionread_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sectionread->header);
- swab_mar_message_source_t (&req_exec_ckpt_sectionread->source);
- swab_mar_name_t (&req_exec_ckpt_sectionread->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sectionread->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sectionread->id_len);
- swab_mar_offset_t (&req_exec_ckpt_sectionread->data_offset);
- swab_mar_offset_t (&req_exec_ckpt_sectionread->data_size);
- }
- static void exec_ckpt_sync_checkpoint_endian_convert (void *msg)
- {
- }
- static void exec_ckpt_sync_checkpoint_section_endian_convert (void *msg)
- {
- }
- static void exec_ckpt_sync_checkpoint_refcount_endian_convert (void *msg)
- {
- }
- #ifdef ABC
- static void exec_ckpt_sync_state_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sync_state *req_exec_ckpt_sync_state = (struct req_exec_ckpt_sync_state *)msg;
- unsigned int i;
- swab_mar_req_header_t (&req_exec_ckpt_sync_state->header);
- // swab_mar_memb_ring_id_t (&req_exec_ckpt_sync_state->memb_ring_id);
- swab_mar_name_t (&req_exec_ckpt_sync_state->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sync_state->ckpt_id);
- swab_mar_ckpt_checkpoint_creation_attributes_t (&req_exec_ckpt_sync_state->checkpoint_creation_attributes);
- // swab_mar_ckpt_section_descriptor_t (&req_exec_ckpt_sync_state->section_descriptor);
- swab_mar_uint32_t (&req_exec_ckpt_sync_state->nodeid);
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- swab_mar_refcount_set_t (&req_exec_ckpt_sync_state->refcount_set[i]);
- }
- }
- static void exec_ckpt_sync_section_endian_convert (void *msg)
- {
- struct req_exec_ckpt_sync_section *req_exec_ckpt_sync_section = (struct req_exec_ckpt_sync_section *)msg;
- swab_mar_req_header_t (&req_exec_ckpt_sync_section->header);
- // swab_mar_memb_ring_id_t (&req_exec_ckpt_sync_section->memb_ring_id);
- swab_mar_name_t (&req_exec_ckpt_sync_section->checkpoint_name);
- swab_mar_uint32_t (&req_exec_ckpt_sync_section->ckpt_id);
- swab_mar_uint32_t (&req_exec_ckpt_sync_section->id_len);
- swab_mar_offset_t (&req_exec_ckpt_sync_section->data_offset);
- swab_mar_offset_t (&req_exec_ckpt_sync_section->data_size);
- }
- #endif
- /*
- * Executive message handlers
- */
- static void message_handler_req_exec_ckpt_checkpointopen (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message;
- struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
- struct res_lib_ckpt_checkpointopenasync res_lib_ckpt_checkpointopenasync;
- struct checkpoint *checkpoint = 0;
- struct checkpoint_section *checkpoint_section = 0;
- struct checkpoint_cleanup *checkpoint_cleanup = 0;
- struct ckpt_pd *ckpt_pd;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen);
- if (req_exec_ckpt_checkpointopen->fail_with_error != SA_AIS_OK) {
- error = req_exec_ckpt_checkpointopen->fail_with_error;
- goto error_exit;
- }
- if (message_source_is_local(&req_exec_ckpt_checkpointopen->source)) {
- checkpoint_cleanup = malloc (sizeof (struct checkpoint_cleanup));
- if (checkpoint_cleanup == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- }
- checkpoint = checkpoint_find_linked (
- &checkpoint_list_head,
- &req_exec_ckpt_checkpointopen->checkpoint_name);
- /*
- * If checkpoint doesn't exist, create one
- */
- if (checkpoint == 0) {
- if ((req_exec_ckpt_checkpointopen->checkpoint_open_flags & SA_CKPT_CHECKPOINT_CREATE) == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- checkpoint = malloc (sizeof (struct checkpoint));
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memcpy (&checkpoint->name,
- &req_exec_ckpt_checkpointopen->checkpoint_name,
- sizeof (mar_name_t));
- memcpy (&checkpoint->checkpoint_creation_attributes,
- &req_exec_ckpt_checkpointopen->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t));
- checkpoint->unlinked = 0;
- list_init (&checkpoint->list);
- list_init (&checkpoint->sections_list_head);
- list_add (&checkpoint->list, &checkpoint_list_head);
- checkpoint->reference_count = 1;
- checkpoint->retention_timer = 0;
- checkpoint->section_count = 0;
- checkpoint->ckpt_id = global_ckpt_id++;
- if ((checkpoint->checkpoint_creation_attributes.creation_flags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) &&
- (checkpoint->checkpoint_creation_attributes.creation_flags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) {
- checkpoint->active_replica_set = 1;
- } else
- if ((checkpoint->checkpoint_creation_attributes.creation_flags & SA_CKPT_WR_ALL_REPLICAS) == 1) {
- checkpoint->active_replica_set = 1;
- } else {
- checkpoint->active_replica_set = 0;
- }
- memset (&checkpoint->refcount_set, 0,
- sizeof (struct refcount_set) * PROCESSOR_COUNT_MAX);
- /*
- * Create default section id if max_sections is 1
- */
- if (checkpoint->checkpoint_creation_attributes.max_sections == 1) {
- /*
- * Add in default checkpoint section
- */
- checkpoint_section = malloc (sizeof (struct checkpoint_section));
- if (checkpoint_section == 0) {
- free (checkpoint);
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- list_init (&checkpoint_section->list);
- list_add (&checkpoint_section->list, &checkpoint->sections_list_head);
- checkpoint_section->section_descriptor.section_id.id = 0;
- checkpoint_section->section_descriptor.section_id.id_len = 0;
- checkpoint_section->section_descriptor.expiration_time = SA_TIME_END;
- checkpoint_section->section_descriptor.section_state = SA_CKPT_SECTION_VALID;
- checkpoint_section->section_descriptor.last_update = 0; /*current time*/
- checkpoint_section->section_descriptor.section_size = 0;
- checkpoint_section->section_data = NULL;
- checkpoint_section->expiration_timer = 0;
- }
- } else {
- if (req_exec_ckpt_checkpointopen->checkpoint_creation_attributes_set &&
- memcmp (&checkpoint->checkpoint_creation_attributes,
- &req_exec_ckpt_checkpointopen->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t)) != 0) {
- error = SA_AIS_ERR_EXIST;
- goto error_exit;
- }
- }
- assert (checkpoint->unlinked == 0);
- /*
- * Setup connection information and mark checkpoint as referenced
- */
- log_printf (LOG_LEVEL_DEBUG, "CHECKPOINT opened is %p\n", checkpoint);
- sync_refcount_increment (checkpoint, nodeid);
- sync_refcount_calculate (checkpoint);
- /*
- * Reset retention duration since this checkpoint was just opened
- */
- openais_timer_delete (checkpoint->retention_timer);
- checkpoint->retention_timer = 0;
- /*
- * Send error result to CKPT library
- */
- error_exit:
- /*
- * If this node was the source of the message, respond to this node
- */
- if (message_source_is_local(&req_exec_ckpt_checkpointopen->source)) {
- /*
- * If its an async call respond with the invocation and handle
- */
- if (req_exec_ckpt_checkpointopen->async_call) {
- res_lib_ckpt_checkpointopenasync.header.size = sizeof (struct res_lib_ckpt_checkpointopenasync);
- res_lib_ckpt_checkpointopenasync.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC;
- res_lib_ckpt_checkpointopenasync.header.error = error;
- res_lib_ckpt_checkpointopenasync.checkpoint_handle = req_exec_ckpt_checkpointopen->checkpoint_handle;
- res_lib_ckpt_checkpointopenasync.invocation = req_exec_ckpt_checkpointopen->invocation;
- if (error == SA_AIS_OK) {
- res_lib_ckpt_checkpointopenasync.ckpt_id = checkpoint->ckpt_id;
- }
- openais_conn_send_response (
- req_exec_ckpt_checkpointopen->source.conn,
- &res_lib_ckpt_checkpointopenasync,
- sizeof (struct res_lib_ckpt_checkpointopenasync));
- openais_conn_send_response (
- openais_conn_partner_get (req_exec_ckpt_checkpointopen->source.conn),
- &res_lib_ckpt_checkpointopenasync,
- sizeof (struct res_lib_ckpt_checkpointopenasync));
- } else {
- /*
- * otherwise respond with the normal checkpointopen response
- */
- res_lib_ckpt_checkpointopen.header.size = sizeof (struct res_lib_ckpt_checkpointopen);
- res_lib_ckpt_checkpointopen.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN;
- if (error == SA_AIS_OK) {
- res_lib_ckpt_checkpointopen.ckpt_id = checkpoint->ckpt_id;
- }
- res_lib_ckpt_checkpointopen.header.error = error;
- openais_conn_send_response (
- req_exec_ckpt_checkpointopen->source.conn,
- &res_lib_ckpt_checkpointopen,
- sizeof (struct res_lib_ckpt_checkpointopen));
- }
- /*
- * This is the path taken when all goes well and this call was local
- */
- if (error == SA_AIS_OK) {
- ckpt_pd = openais_conn_private_data_get (req_exec_ckpt_checkpointopen->source.conn);
- memcpy(&checkpoint_cleanup->checkpoint_name,
- &checkpoint->name, sizeof (mar_name_t));
- checkpoint_cleanup->ckpt_id = checkpoint->ckpt_id;
- list_add (&checkpoint_cleanup->list,
- &ckpt_pd->checkpoint_list);
- } else {
- /*
- * We allocated this in the hope of using it but an error occured
- * so deallocate it.
- */
- free (checkpoint_cleanup);
- }
- }
- }
- unsigned int abstime_to_msec (mar_time_t time)
- {
- struct timeval tv;
- unsigned long long curr_time;
- unsigned long long msec_time;
- gettimeofday (&tv, NULL);
- curr_time = ((((unsigned long long)tv.tv_sec) * ((unsigned long)1000)) +
- (((unsigned long long)tv.tv_usec) / ((unsigned long long)1000)));
- msec_time = (((unsigned long long)time) / 1000000) -
- (unsigned long long)curr_time;
- return ((unsigned int)(msec_time));
- }
- void timer_function_section_expire (void *data)
- {
- struct checkpoint *checkpoint = 0;
- struct checkpoint_section *checkpoint_section = 0;
- struct ckpt_identifier *ckpt_id = 0;
- ckpt_id = (struct ckpt_identifier *)data;
- log_printf (LOG_LEVEL_DEBUG, "timer_function_section_expire data = 0x%p\n",data);
- if (ckpt_id->ckpt_section_id.id_len && ckpt_id->ckpt_section_id.id) {
- log_printf (LOG_LEVEL_DEBUG, "Attempting to expire section %s in ckpt %s\n",
- ckpt_id->ckpt_section_id.id,
- ckpt_id->ckpt_name.value);
- }
- else {
- log_printf (LOG_LEVEL_ERROR, "timer_function_section_expire data incorect\n");
- goto free_mem;
- }
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &ckpt_id->ckpt_name,
- ckpt_id->ckpt_id);
- if (checkpoint == 0) {
- log_printf (LOG_LEVEL_ERROR, "timer_function_section_expire could not find ckpt %s\n",
- ckpt_id->ckpt_name.value);
- goto free_mem;
- }
- checkpoint_section = checkpoint_section_find (checkpoint,
- (char *)ckpt_id->ckpt_section_id.id,
- (int)ckpt_id->ckpt_section_id.id_len);
- if (checkpoint_section == 0) {
- log_printf (LOG_LEVEL_ERROR, "timer_function_section_expire could not find section %s in ckpt %s\n",
- ckpt_id->ckpt_section_id.id,
- ckpt_id->ckpt_name.value);
- goto free_mem;
- }
- log_printf (LOG_LEVEL_DEBUG, "Expiring section %s in ckpt %s\n",
- ckpt_id->ckpt_section_id.id,
- ckpt_id->ckpt_name.value);
- checkpoint->section_count -= 1;
- checkpoint_section_release (checkpoint_section);
- free_mem :
- free (ckpt_id);
- }
- void timer_function_retention (void *data)
- {
- struct checkpoint *checkpoint = (struct checkpoint *)data;
- struct req_exec_ckpt_checkpointretentiondurationexpire req_exec_ckpt_checkpointretentiondurationexpire;
- struct iovec iovec;
- checkpoint->retention_timer = 0;
- req_exec_ckpt_checkpointretentiondurationexpire.header.size =
- sizeof (struct req_exec_ckpt_checkpointretentiondurationexpire);
- req_exec_ckpt_checkpointretentiondurationexpire.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE);
- memcpy (&req_exec_ckpt_checkpointretentiondurationexpire.checkpoint_name,
- &checkpoint->name,
- sizeof (mar_name_t));
- req_exec_ckpt_checkpointretentiondurationexpire.ckpt_id =
- checkpoint->ckpt_id;
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationexpire;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationexpire);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_exec_ckpt_checkpointclose (
- void *message,
- unsigned int nodeid)
- {
- 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 checkpoint *checkpoint = 0;
- SaAisErrorT error = SA_AIS_OK;
- int release_checkpoint = 0;
- log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to close checkpoint %s\n",
- get_mar_name_t (&req_exec_ckpt_checkpointclose->checkpoint_name));
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_checkpointclose->checkpoint_name,
- req_exec_ckpt_checkpointclose->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- sync_refcount_decrement (checkpoint, nodeid);
- sync_refcount_calculate (checkpoint);
- log_printf (LOG_LEVEL_DEBUG, "Close checkpoint->reference_count %d\n",
- checkpoint->reference_count);
- assert (checkpoint->reference_count >= 0);
- /*
- * If checkpoint has been unlinked and this is the last reference, delete it
- */
- if (checkpoint->unlinked && checkpoint->reference_count == 0) {
- log_printf (LOG_LEVEL_DEBUG, "Unlinking checkpoint.\n");
- release_checkpoint = 1;
- } else
- if (checkpoint->reference_count == 0) {
- if (checkpoint->checkpoint_creation_attributes.retention_duration != SA_TIME_END) {
- openais_timer_add_duration (
- checkpoint->checkpoint_creation_attributes.retention_duration,
- checkpoint,
- timer_function_retention,
- &checkpoint->retention_timer);
- }
- }
- error_exit:
- /*
- * Remove the checkpoint from my connections checkpoint list
- */
- if (message_source_is_local(&req_exec_ckpt_checkpointclose->source)) {
- 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;
- openais_conn_send_response (req_exec_ckpt_checkpointclose->source.conn,
- &res_lib_ckpt_checkpointclose, sizeof (struct res_lib_ckpt_checkpointclose));
- }
- /*
- * Release the checkpoint if instructed to do so.
- */
- if (error == SA_AIS_OK && release_checkpoint) {
- checkpoint_release(checkpoint);
- }
- }
- static void message_handler_req_exec_ckpt_checkpointunlink (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message;
- struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink;
- struct checkpoint *checkpoint = 0;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink);
- checkpoint = checkpoint_find_linked (
- &checkpoint_list_head,
- &req_exec_ckpt_checkpointunlink->checkpoint_name);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- assert (checkpoint->unlinked == 0);
- checkpoint->unlinked = 1;
- /*
- * Immediately delete entry if reference count is zero
- */
- if (checkpoint->reference_count == 0) {
- /*
- * Remove retention timer since this checkpoint was unlinked and is no
- * longer referenced
- */
- checkpoint_release (checkpoint);
- }
- error_exit:
- /*
- * If this node was the source of the message, respond to this node
- */
- if (message_source_is_local(&req_exec_ckpt_checkpointunlink->source)) {
- 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.header.error = error;
- openais_conn_send_response (
- req_exec_ckpt_checkpointunlink->source.conn,
- &res_lib_ckpt_checkpointunlink,
- sizeof (struct res_lib_ckpt_checkpointunlink));
- }
- }
- static void message_handler_req_exec_ckpt_checkpointretentiondurationset (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message;
- struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset;
- struct checkpoint *checkpoint;
- SaAisErrorT error = SA_AIS_ERR_BAD_OPERATION;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_checkpointretentiondurationset->checkpoint_name,
- req_exec_ckpt_checkpointretentiondurationset->ckpt_id);
- if (checkpoint) {
- log_printf (LOG_LEVEL_DEBUG, "Setting retention duration for checkpoint %s\n",
- get_mar_name_t (&req_exec_ckpt_checkpointretentiondurationset->checkpoint_name));
- if (checkpoint->unlinked == 0) {
- checkpoint->checkpoint_creation_attributes.retention_duration =
- req_exec_ckpt_checkpointretentiondurationset->retention_duration;
- if (checkpoint->reference_count == 0) {
- openais_timer_delete (checkpoint->retention_timer);
- openais_timer_add_duration (
- checkpoint->checkpoint_creation_attributes.retention_duration,
- checkpoint,
- timer_function_retention,
- &checkpoint->retention_timer);
- }
- error = SA_AIS_OK;
- }
- }
- /*
- * Respond to library if this processor sent the duration set request
- */
- if (message_source_is_local(&req_exec_ckpt_checkpointretentiondurationset->source)) {
- 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 = error;
- openais_conn_send_response (
- req_exec_ckpt_checkpointretentiondurationset->source.conn,
- &res_lib_ckpt_checkpointretentiondurationset,
- sizeof (struct res_lib_ckpt_checkpointretentiondurationset));
- }
- }
- static void message_handler_req_exec_ckpt_checkpointretentiondurationexpire (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_checkpointretentiondurationexpire *req_exec_ckpt_checkpointretentiondurationexpire = (struct req_exec_ckpt_checkpointretentiondurationexpire *)message;
- struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
- struct checkpoint *checkpoint;
- struct iovec iovec;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_checkpointretentiondurationexpire->checkpoint_name,
- req_exec_ckpt_checkpointretentiondurationexpire->ckpt_id);
- log_printf (LOG_LEVEL_NOTICE, "Expiring checkpoint %s\n",
- get_mar_name_t (&req_exec_ckpt_checkpointretentiondurationexpire->checkpoint_name));
- if (checkpoint && (checkpoint->reference_count == 0)) {
- log_printf (LOG_LEVEL_NOTICE, "Expiring checkpoint %s\n",
- get_mar_name_t (&req_exec_ckpt_checkpointretentiondurationexpire->checkpoint_name));
- req_exec_ckpt_checkpointunlink.header.size =
- sizeof (struct req_exec_ckpt_checkpointunlink);
- req_exec_ckpt_checkpointunlink.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK);
- req_exec_ckpt_checkpointunlink.source.conn = 0;
- req_exec_ckpt_checkpointunlink.source.nodeid = 0;
- memcpy (&req_exec_ckpt_checkpointunlink.checkpoint_name,
- &req_exec_ckpt_checkpointretentiondurationexpire->checkpoint_name,
- sizeof (mar_name_t));
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointunlink;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointunlink);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_exec_ckpt_sectioncreate (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message;
- struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- void *initial_data;
- void *section_id;
- struct ckpt_identifier *ckpt_id = 0;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectioncreate->checkpoint_name,
- req_exec_ckpt_sectioncreate->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->section_count == checkpoint->checkpoint_creation_attributes.max_sections) {
- error = SA_AIS_ERR_NO_SPACE;
- goto error_exit;
- }
- if (checkpoint->checkpoint_creation_attributes.max_sections == 1) {
- error = SA_AIS_ERR_EXIST;
- goto error_exit;
- }
- if (checkpoint->checkpoint_creation_attributes.max_section_size <
- req_exec_ckpt_sectioncreate->initial_data_size) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
-
- if (checkpoint->checkpoint_creation_attributes.max_section_id_size <
- req_exec_ckpt_sectioncreate->id_len) {
-
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Determine if user-specified checkpoint section already exists
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)req_exec_ckpt_sectioncreate) +
- sizeof (struct req_exec_ckpt_sectioncreate),
- req_exec_ckpt_sectioncreate->id_len);
- if (checkpoint_section) {
- error = SA_AIS_ERR_EXIST;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section
- */
- checkpoint_section = malloc (sizeof (struct checkpoint_section));
- if (checkpoint_section == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section data
- */
- initial_data = malloc (req_exec_ckpt_sectioncreate->initial_data_size);
- if (initial_data == 0) {
- free (checkpoint_section);
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section id
- */
- section_id = malloc (req_exec_ckpt_sectioncreate->id_len + 1);
- if (section_id == 0) {
- free (checkpoint_section);
- free (initial_data);
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Copy checkpoint section and section ID
- */
- memcpy (section_id,
- ((char *)req_exec_ckpt_sectioncreate) +
- sizeof (struct req_exec_ckpt_sectioncreate),
- req_exec_ckpt_sectioncreate->id_len);
- /*Must be null terminated if it already isn't*/
- ((char*)(section_id))[req_exec_ckpt_sectioncreate->id_len] = '\0';
- memcpy (initial_data,
- ((char *)req_exec_ckpt_sectioncreate) +
- sizeof (struct req_exec_ckpt_sectioncreate) +
- req_exec_ckpt_sectioncreate->id_len,
- req_exec_ckpt_sectioncreate->initial_data_size);
- /*
- * Configure checkpoint section
- */
- checkpoint_section->section_descriptor.section_id.id = section_id;
- checkpoint_section->section_descriptor.section_id.id_len =
- req_exec_ckpt_sectioncreate->id_len;
- checkpoint_section->section_descriptor.section_size =
- req_exec_ckpt_sectioncreate->initial_data_size;
- checkpoint_section->section_descriptor.expiration_time =
- req_exec_ckpt_sectioncreate->expiration_time;
- checkpoint_section->section_descriptor.section_state =
- SA_CKPT_SECTION_VALID;
- checkpoint_section->section_descriptor.last_update = 0; /* TODO current time */
- checkpoint_section->section_data = initial_data;
- checkpoint_section->expiration_timer = 0;
- if (req_exec_ckpt_sectioncreate->expiration_time != SA_TIME_END) {
- ckpt_id = malloc (sizeof(struct ckpt_identifier));
- assert(ckpt_id);
- memcpy(&ckpt_id->ckpt_name,
- &req_exec_ckpt_sectioncreate->checkpoint_name,
- sizeof(mar_name_t));
- ckpt_id->ckpt_id = req_exec_ckpt_sectioncreate->ckpt_id;
- memcpy(&ckpt_id->ckpt_section_id,
- &checkpoint_section->section_descriptor.section_id,
- sizeof(mar_ckpt_section_id_t));
- log_printf (LOG_LEVEL_DEBUG, "req_exec_ckpt_sectioncreate Enqueuing Timer to Expire section %s in ckpt %s\n",
- ckpt_id->ckpt_section_id.id,
- ckpt_id->ckpt_name.value);
- openais_timer_add_absolute (
- checkpoint_section->section_descriptor.expiration_time,
- ckpt_id,
- timer_function_section_expire,
- &checkpoint_section->expiration_timer);
- log_printf (LOG_LEVEL_DEBUG,
- "req_exec_ckpt_sectionicreate expiration timer = 0x%p\n",
- checkpoint_section->expiration_timer);
- }
- log_printf (LOG_LEVEL_DEBUG,
- "message_handler_req_exec_ckpt_sectioncreate created section with id = %s, id_len = %d\n",
- checkpoint_section->section_descriptor.section_id.id,
- checkpoint_section->section_descriptor.section_id.id_len);
- /*
- * Add checkpoint section to checkpoint
- */
- list_init (&checkpoint_section->list);
- list_add (&checkpoint_section->list,
- &checkpoint->sections_list_head);
- checkpoint->section_count += 1;
- error_exit:
- if (message_source_is_local(&req_exec_ckpt_sectioncreate->source)) {
- 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 = error;
- openais_conn_send_response (req_exec_ckpt_sectioncreate->source.conn,
- &res_lib_ckpt_sectioncreate,
- sizeof (struct res_lib_ckpt_sectioncreate));
- }
- }
- static void message_handler_req_exec_ckpt_sectiondelete (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message;
- struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- SaAisErrorT error = SA_AIS_OK;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectiondelete->checkpoint_name,
- req_exec_ckpt_sectiondelete->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- log_printf (LOG_LEVEL_DEBUG, "sectiondelete: no active replica, returning error.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Determine if the user is trying to delete the default section
- */
- if (req_exec_ckpt_sectiondelete->id_len == 0) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Find checkpoint section to be deleted
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)(req_exec_ckpt_sectiondelete) + sizeof (struct req_exec_ckpt_sectiondelete)),
- req_exec_ckpt_sectiondelete->id_len);
- if (checkpoint_section == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Delete checkpoint section
- */
- checkpoint->section_count -= 1;
- checkpoint_section_release (checkpoint_section);
- /*
- * return result to CKPT library
- */
- error_exit:
- if (message_source_is_local(&req_exec_ckpt_sectiondelete->source)) {
- 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.header.error = error;
- openais_conn_send_response (
- req_exec_ckpt_sectiondelete->source.conn,
- &res_lib_ckpt_sectiondelete,
- sizeof (struct res_lib_ckpt_sectiondelete));
- }
- }
- static void message_handler_req_exec_ckpt_sectionexpirationtimeset (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message;
- struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- struct ckpt_identifier *ckpt_id = 0;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiration time\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectionexpirationtimeset->checkpoint_name,
- req_exec_ckpt_sectionexpirationtimeset->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- log_printf (LOG_LEVEL_DEBUG, "expirationset: no active replica, returning error.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Determine if the user is trying to set expiration time for the default section
- */
- if (req_exec_ckpt_sectionexpirationtimeset->id_len == 0) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Find checkpoint section that expiration time should be set for
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)req_exec_ckpt_sectionexpirationtimeset) +
- sizeof (struct req_exec_ckpt_sectionexpirationtimeset),
- req_exec_ckpt_sectionexpirationtimeset->id_len);
- if (checkpoint_section == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- checkpoint_section->section_descriptor.expiration_time =
- req_exec_ckpt_sectionexpirationtimeset->expiration_time;
- openais_timer_delete (checkpoint_section->expiration_timer);
- checkpoint_section->expiration_timer = 0;
- if (req_exec_ckpt_sectionexpirationtimeset->expiration_time != SA_TIME_END) {
- ckpt_id = malloc (sizeof(struct ckpt_identifier));
- assert(ckpt_id);
- memcpy(&ckpt_id->ckpt_name,
- &req_exec_ckpt_sectionexpirationtimeset->checkpoint_name,
- sizeof(mar_name_t));
- ckpt_id->ckpt_id =
- req_exec_ckpt_sectionexpirationtimeset->ckpt_id;
- memcpy(&ckpt_id->ckpt_section_id,
- &checkpoint_section->section_descriptor.section_id,
- sizeof(mar_ckpt_section_id_t));
- log_printf (LOG_LEVEL_DEBUG, "req_exec_ckpt_sectionexpirationtimeset Enqueuing Timer to Expire section %s in ckpt %s, ref = 0x%p\n",
- ckpt_id->ckpt_section_id.id,
- ckpt_id->ckpt_name.value,
- ckpt_id);
- openais_timer_add_absolute (
- checkpoint_section->section_descriptor.expiration_time,
- ckpt_id,
- timer_function_section_expire,
- &checkpoint_section->expiration_timer);
- log_printf (LOG_LEVEL_DEBUG, "req_exec_ckpt_sectionexpirationtimeset expiration timer = 0x%p\n",
- checkpoint_section->expiration_timer);
- }
- error_exit:
- if (message_source_is_local (&req_exec_ckpt_sectionexpirationtimeset->source)) {
- 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.header.error = error;
- openais_conn_send_response (
- req_exec_ckpt_sectionexpirationtimeset->source.conn,
- &res_lib_ckpt_sectionexpirationtimeset,
- sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
- }
- }
- static void message_handler_req_exec_ckpt_sectionwrite (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message;
- struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section = 0;
- int size_required;
- void *section_data;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to section write.\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectionwrite->checkpoint_name,
- req_exec_ckpt_sectionwrite->ckpt_id);
- if (checkpoint == 0) {
- log_printf (LOG_LEVEL_ERROR, "checkpoint_find returned 0 Calling error_exit.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- log_printf (LOG_LEVEL_DEBUG, "checkpointwrite: no active replica, returning error.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->checkpoint_creation_attributes.max_section_size < req_exec_ckpt_sectionwrite->data_size) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- log_printf (LOG_LEVEL_DEBUG, "writing checkpoint section is %s\n",
- ((char *)req_exec_ckpt_sectionwrite) +
- sizeof (struct req_exec_ckpt_sectionwrite));
- /*
- * Find checkpoint section to be written
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)req_exec_ckpt_sectionwrite) +
- sizeof (struct req_exec_ckpt_sectionwrite),
- req_exec_ckpt_sectionwrite->id_len);
- if (checkpoint_section == 0) {
- if (req_exec_ckpt_sectionwrite->id_len == 0) {
- log_printf (LOG_LEVEL_DEBUG, "CANT FIND DEFAULT SECTION.\n");
- }
- else {
- log_printf (LOG_LEVEL_DEBUG, "CANT FIND SECTION '%s'\n",
- ((char *)req_exec_ckpt_sectionwrite) +
- sizeof (struct req_exec_ckpt_sectionwrite));
- }
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * If write would extend past end of section data, enlarge section
- */
- size_required = req_exec_ckpt_sectionwrite->data_offset +
- req_exec_ckpt_sectionwrite->data_size;
- if (size_required > checkpoint_section->section_descriptor.section_size) {
- section_data = realloc (checkpoint_section->section_data, size_required);
- if (section_data == 0) {
- log_printf (LOG_LEVEL_ERROR, "section_data realloc returned 0 Calling error_exit.\n");
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- /*
- * Install new section data
- */
- checkpoint_section->section_data = section_data;
- checkpoint_section->section_descriptor.section_size = size_required;
- }
- /*
- * Write checkpoint section to section data
- */
- if (req_exec_ckpt_sectionwrite->data_size > 0) {
- char *sd;
- int *val;
- val = checkpoint_section->section_data;
- sd = (char *)checkpoint_section->section_data;
- memcpy (&sd[req_exec_ckpt_sectionwrite->data_offset],
- ((char *)req_exec_ckpt_sectionwrite) +
- sizeof (struct req_exec_ckpt_sectionwrite) +
- req_exec_ckpt_sectionwrite->id_len,
- req_exec_ckpt_sectionwrite->data_size);
- }
- /*
- * Write sectionwrite response to CKPT library
- */
- error_exit:
- if (message_source_is_local(&req_exec_ckpt_sectionwrite->source)) {
- 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 = error;
- openais_conn_send_response (
- req_exec_ckpt_sectionwrite->source.conn,
- &res_lib_ckpt_sectionwrite,
- sizeof (struct res_lib_ckpt_sectionwrite));
- }
- }
- static void message_handler_req_exec_ckpt_sectionoverwrite (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message;
- struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- void *section_data;
- SaAisErrorT error = SA_AIS_OK;
- log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectionoverwrite->checkpoint_name,
- req_exec_ckpt_sectionoverwrite->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- log_printf (LOG_LEVEL_DEBUG, "sectionoverwrite: no active replica, returning error.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->checkpoint_creation_attributes.max_section_size <
- req_exec_ckpt_sectionoverwrite->data_size) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Find checkpoint section to be overwritten
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)req_exec_ckpt_sectionoverwrite) +
- sizeof (struct req_exec_ckpt_sectionoverwrite),
- req_exec_ckpt_sectionoverwrite->id_len);
- if (checkpoint_section == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Allocate checkpoint section data
- */
- section_data = malloc (req_exec_ckpt_sectionoverwrite->data_size);
- if (section_data == 0) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_exit;
- }
- memcpy (section_data,
- ((char *)req_exec_ckpt_sectionoverwrite) +
- sizeof (struct req_exec_ckpt_sectionoverwrite) +
- req_exec_ckpt_sectionoverwrite->id_len,
- req_exec_ckpt_sectionoverwrite->data_size);
- /*
- * release old checkpoint section data
- */
- free (checkpoint_section->section_data);
- /*
- * Install overwritten checkpoint section data
- */
- checkpoint_section->section_descriptor.section_size =
- req_exec_ckpt_sectionoverwrite->data_size;
- checkpoint_section->section_descriptor.section_state =
- SA_CKPT_SECTION_VALID;
- /*
- * TODO current time
- */
- checkpoint_section->section_descriptor.last_update = 0;
- checkpoint_section->section_data = section_data;
- /*
- * return result to CKPT library
- */
- error_exit:
- if (message_source_is_local(&req_exec_ckpt_sectionoverwrite->source)) {
- 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 = error;
- openais_conn_send_response (
- req_exec_ckpt_sectionoverwrite->source.conn,
- &res_lib_ckpt_sectionoverwrite,
- sizeof (struct res_lib_ckpt_sectionoverwrite));
- }
- }
- static void message_handler_req_exec_ckpt_sectionread (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message;
- struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section = 0;
- int section_size = 0;
- SaAisErrorT error = SA_AIS_OK;
- res_lib_ckpt_sectionread.data_read = 0;
- log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_exec_ckpt_sectionread->checkpoint_name,
- req_exec_ckpt_sectionread->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_LIBRARY;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * Find checkpoint section to be read
- */
- checkpoint_section = checkpoint_section_find (checkpoint,
- ((char *)req_exec_ckpt_sectionread) +
- sizeof (struct req_exec_ckpt_sectionread),
- req_exec_ckpt_sectionread->id_len);
- if (checkpoint_section == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- /*
- * If data size is greater then max section size, return INVALID_PARAM
- */
- if (checkpoint->checkpoint_creation_attributes.max_section_size <
- req_exec_ckpt_sectionread->data_size) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * If data_offset is past end of data, return INVALID_PARAM
- */
- if (req_exec_ckpt_sectionread->data_offset > checkpoint_section->section_descriptor.section_size) {
- error = SA_AIS_ERR_INVALID_PARAM;
- goto error_exit;
- }
- /*
- * Determine the section size
- */
- section_size = checkpoint_section->section_descriptor.section_size -
- req_exec_ckpt_sectionread->data_offset;
- /*
- * If the library has less space available then can be sent from the
- * section, reduce bytes sent to library to max requested
- */
- if (section_size > req_exec_ckpt_sectionread->data_size) {
- section_size = req_exec_ckpt_sectionread->data_size;
- }
- /*
- * Write read response to CKPT library
- */
- error_exit:
- if (message_source_is_local(&req_exec_ckpt_sectionread->source)) {
- res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread) + section_size;
- res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
- res_lib_ckpt_sectionread.header.error = error;
- if (section_size != 0) {
- res_lib_ckpt_sectionread.data_read = section_size;
- }
- openais_conn_send_response (
- req_exec_ckpt_sectionread->source.conn,
- &res_lib_ckpt_sectionread,
- sizeof (struct res_lib_ckpt_sectionread));
- /*
- * Write checkpoint to CKPT library section if section has data
- */
- if (error == SA_AIS_OK) {
- char *sd;
- sd = (char *)checkpoint_section->section_data;
- openais_conn_send_response (
- req_exec_ckpt_sectionread->source.conn,
- &sd[req_exec_ckpt_sectionread->data_offset],
- section_size);
- }
- }
- }
- static int ckpt_lib_init_fn (void *conn)
- {
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- hdb_create (&ckpt_pd->iteration_hdb);
- list_init (&ckpt_pd->checkpoint_list);
- return (0);
- }
- static int ckpt_lib_exit_fn (void *conn)
- {
- struct checkpoint_cleanup *checkpoint_cleanup;
- struct list_head *list;
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- log_printf (LOG_LEVEL_DEBUG, "checkpoint exit conn %p\n", conn);
- /*
- * close all checkpoints opened on this connection
- */
- list = ckpt_pd->checkpoint_list.next;
- while (!list_empty(&ckpt_pd->checkpoint_list)) {
- checkpoint_cleanup = list_entry (list,
- struct checkpoint_cleanup, list);
- assert (checkpoint_cleanup->checkpoint_name.length != 0);
- ckpt_checkpoint_close (
- &checkpoint_cleanup->checkpoint_name,
- checkpoint_cleanup->ckpt_id);
- list_del (&checkpoint_cleanup->list);
- free (checkpoint_cleanup);
- list = ckpt_pd->checkpoint_list.next;
- }
- hdb_destroy (&ckpt_pd->iteration_hdb);
- return (0);
- }
- static void message_handler_req_lib_ckpt_checkpointopen (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)msg;
- struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
- struct iovec iovec;
- log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
- req_exec_ckpt_checkpointopen.header.size =
- sizeof (struct req_exec_ckpt_checkpointopen);
- req_exec_ckpt_checkpointopen.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE, MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN);
- message_source_set (&req_exec_ckpt_checkpointopen.source, conn);
- memcpy (&req_exec_ckpt_checkpointopen.checkpoint_name,
- &req_lib_ckpt_checkpointopen->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_checkpointopen.ckpt_id =
- req_lib_ckpt_checkpointopen->ckpt_id;
- memcpy (&req_exec_ckpt_checkpointopen.checkpoint_creation_attributes,
- &req_lib_ckpt_checkpointopen->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t));
- req_exec_ckpt_checkpointopen.checkpoint_creation_attributes_set =
- req_lib_ckpt_checkpointopen->checkpoint_creation_attributes_set;
- req_exec_ckpt_checkpointopen.checkpoint_open_flags =
- req_lib_ckpt_checkpointopen->checkpoint_open_flags;
- req_exec_ckpt_checkpointopen.invocation =
- req_lib_ckpt_checkpointopen->invocation;
- req_exec_ckpt_checkpointopen.checkpoint_handle =
- req_lib_ckpt_checkpointopen->checkpoint_handle;
- req_exec_ckpt_checkpointopen.fail_with_error =
- req_lib_ckpt_checkpointopen->fail_with_error;
- req_exec_ckpt_checkpointopen.async_call =
- req_lib_ckpt_checkpointopen->async_call;
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointopen;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointopen);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_ckpt_checkpointclose (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointclose *req_lib_ckpt_checkpointclose = (struct req_lib_ckpt_checkpointclose *)msg;
- struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
- struct iovec iovec;
- req_exec_ckpt_checkpointclose.header.size =
- sizeof (struct req_exec_ckpt_checkpointclose);
- req_exec_ckpt_checkpointclose.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE);
- message_source_set (&req_exec_ckpt_checkpointclose.source, conn);
- memcpy (&req_exec_ckpt_checkpointclose.checkpoint_name,
- &req_lib_ckpt_checkpointclose->checkpoint_name, sizeof (mar_name_t));
- req_exec_ckpt_checkpointclose.ckpt_id =
- req_lib_ckpt_checkpointclose->ckpt_id;
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointclose;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointclose);
- ckpt_checkpoint_remove_cleanup (
- conn,
- req_lib_ckpt_checkpointclose->checkpoint_name,
- req_lib_ckpt_checkpointclose->ckpt_id);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_ckpt_checkpointunlink (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)msg;
- struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
- struct iovec iovec;
- req_exec_ckpt_checkpointunlink.header.size =
- sizeof (struct req_exec_ckpt_checkpointunlink);
- req_exec_ckpt_checkpointunlink.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE, MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK);
- message_source_set (&req_exec_ckpt_checkpointunlink.source, conn);
- memcpy (&req_exec_ckpt_checkpointunlink.checkpoint_name,
- &req_lib_ckpt_checkpointunlink->checkpoint_name,
- sizeof (mar_name_t));
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointunlink;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointunlink);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_ckpt_checkpointretentiondurationset (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointretentiondurationset *req_lib_ckpt_checkpointretentiondurationset = (struct req_lib_ckpt_checkpointretentiondurationset *)msg;
- struct req_exec_ckpt_checkpointretentiondurationset req_exec_ckpt_checkpointretentiondurationset;
- struct iovec iovec;
- log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API conn %p\n", conn);
- req_exec_ckpt_checkpointretentiondurationset.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET);
- req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
- message_source_set (&req_exec_ckpt_checkpointretentiondurationset.source, conn);
- memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpoint_name,
- &req_lib_ckpt_checkpointretentiondurationset->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_checkpointretentiondurationset.ckpt_id =
- req_lib_ckpt_checkpointretentiondurationset->ckpt_id;
- req_exec_ckpt_checkpointretentiondurationset.retention_duration =
- req_lib_ckpt_checkpointretentiondurationset->retention_duration;
- iovec.iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationset;
- iovec.iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationset);
- assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1,
- TOTEMPG_AGREED) == 0);
- }
- static void message_handler_req_lib_ckpt_activereplicaset (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_activereplicaset *req_lib_ckpt_activereplicaset = (struct req_lib_ckpt_activereplicaset *)msg;
- struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset;
- struct checkpoint *checkpoint;
- SaAisErrorT error = SA_AIS_OK;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_lib_ckpt_activereplicaset->checkpoint_name,
- req_lib_ckpt_activereplicaset->ckpt_id);
- /*
- * Make sure checkpoint is collocated and async update option
- */
- if (((checkpoint->checkpoint_creation_attributes.creation_flags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) ||
- (checkpoint->checkpoint_creation_attributes.creation_flags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
- error = SA_AIS_ERR_BAD_OPERATION;
- }
- checkpoint->active_replica_set = 1;
- res_lib_ckpt_activereplicaset.header.size = sizeof (struct res_lib_ckpt_activereplicaset);
- res_lib_ckpt_activereplicaset.header.id = MESSAGE_RES_CKPT_ACTIVEREPLICASET;
- res_lib_ckpt_activereplicaset.header.error = error;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_activereplicaset,
- sizeof (struct res_lib_ckpt_activereplicaset));
- }
- static void message_handler_req_lib_ckpt_checkpointstatusget (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointstatusget *req_lib_ckpt_checkpointstatusget = (struct req_lib_ckpt_checkpointstatusget *)msg;
- struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
- struct checkpoint *checkpoint;
- int memory_used = 0;
- int number_of_sections = 0;
- struct list_head *checkpoint_section_list;
- struct checkpoint_section *checkpointSection;
- /*
- * Count memory used by checkpoint sections
- */
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_lib_ckpt_checkpointstatusget->checkpoint_name,
- req_lib_ckpt_checkpointstatusget->ckpt_id);
- if (checkpoint) {
- for (checkpoint_section_list = checkpoint->sections_list_head.next;
- checkpoint_section_list != &checkpoint->sections_list_head;
- checkpoint_section_list = checkpoint_section_list->next) {
- checkpointSection = list_entry (checkpoint_section_list,
- struct checkpoint_section, list);
- memory_used += checkpointSection->section_descriptor.section_size;
- number_of_sections += 1;
- }
- /*
- * Build checkpoint status get response
- */
- res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
- res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
- if (checkpoint->active_replica_set == 1) {
- res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_OK;
- } else {
- res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_ERR_NOT_EXIST;
- }
- memcpy (&res_lib_ckpt_checkpointstatusget.checkpoint_descriptor.checkpoint_creation_attributes,
- &checkpoint->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t));
- res_lib_ckpt_checkpointstatusget.checkpoint_descriptor.number_of_sections = number_of_sections;
- res_lib_ckpt_checkpointstatusget.checkpoint_descriptor.memory_used = memory_used;
- }
- else {
- log_printf (LOG_LEVEL_ERROR, "#### Could Not Find the Checkpoint's status so Returning Error. ####\n");
- 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_AIS_ERR_NOT_EXIST;
- }
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_checkpointstatusget,
- sizeof (struct res_lib_ckpt_checkpointstatusget));
- }
- static void message_handler_req_lib_ckpt_sectioncreate (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)msg;
- struct req_exec_ckpt_sectioncreate req_exec_ckpt_sectioncreate;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "Section create from conn %p\n", conn);
- req_exec_ckpt_sectioncreate.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE);
- req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
- message_source_set (&req_exec_ckpt_sectioncreate.source, conn);
- memcpy (&req_exec_ckpt_sectioncreate.checkpoint_name,
- &req_lib_ckpt_sectioncreate->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectioncreate.ckpt_id =
- req_lib_ckpt_sectioncreate->ckpt_id;
- req_exec_ckpt_sectioncreate.id_len = req_lib_ckpt_sectioncreate->id_len;
- req_exec_ckpt_sectioncreate.expiration_time =
- req_lib_ckpt_sectioncreate->expiration_time;
- req_exec_ckpt_sectioncreate.initial_data_size =
- req_lib_ckpt_sectioncreate->initial_data_size;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectioncreate.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len) {
- log_printf (LOG_LEVEL_DEBUG, "message_handler_req_lib_ckpt_sectioncreate Section = %p, id_len = %d\n",
- iovecs[1].iov_base,
- (int)iovecs[1].iov_len);
- }
- if (iovecs[1].iov_len > 0) {
- log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %p\n", iovecs[1].iov_base);
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_sectiondelete (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)msg;
- struct req_exec_ckpt_sectiondelete req_exec_ckpt_sectiondelete;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "section delete from conn %p\n", conn);
- req_exec_ckpt_sectiondelete.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE);
- req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
- message_source_set (&req_exec_ckpt_sectiondelete.source, conn);
- memcpy (&req_exec_ckpt_sectiondelete.checkpoint_name,
- &req_lib_ckpt_sectiondelete->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectiondelete.ckpt_id =
- req_lib_ckpt_sectiondelete->ckpt_id;
- req_exec_ckpt_sectiondelete.id_len = req_lib_ckpt_sectiondelete->id_len;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectiondelete.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_sectionexpirationtimeset (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)msg;
- struct req_exec_ckpt_sectionexpirationtimeset req_exec_ckpt_sectionexpirationtimeset;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "section expiration time set from conn %p\n", conn);
- req_exec_ckpt_sectionexpirationtimeset.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET);
- req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
- message_source_set (&req_exec_ckpt_sectionexpirationtimeset.source, conn);
- memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpoint_name,
- &req_lib_ckpt_sectionexpirationtimeset->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectionexpirationtimeset.ckpt_id =
- req_lib_ckpt_sectionexpirationtimeset->ckpt_id;
- req_exec_ckpt_sectionexpirationtimeset.id_len =
- req_lib_ckpt_sectionexpirationtimeset->id_len;
- req_exec_ckpt_sectionexpirationtimeset.expiration_time =
- req_lib_ckpt_sectionexpirationtimeset->expiration_time;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectionexpirationtimeset.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_sectionwrite (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)msg;
- struct req_exec_ckpt_sectionwrite req_exec_ckpt_sectionwrite;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "Received data from lib with len = %d and ref = 0x%lx\n",
- (int)req_lib_ckpt_sectionwrite->data_size,
- (long)req_lib_ckpt_sectionwrite->data_offset);
- log_printf (LOG_LEVEL_DEBUG, "Checkpoint section being written to is %s, id_len = %d\n",
- ((char *)req_lib_ckpt_sectionwrite) +
- sizeof (struct req_lib_ckpt_sectionwrite),
- req_lib_ckpt_sectionwrite->id_len);
- log_printf (LOG_LEVEL_DEBUG, "Section write from conn %p\n", conn);
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectionwrite.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE);
- req_exec_ckpt_sectionwrite.header.size =
- sizeof (struct req_exec_ckpt_sectionwrite);
- message_source_set (&req_exec_ckpt_sectionwrite.source, conn);
- memcpy (&req_exec_ckpt_sectionwrite.checkpoint_name,
- &req_lib_ckpt_sectionwrite->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectionwrite.ckpt_id =
- req_lib_ckpt_sectionwrite->ckpt_id;
- req_exec_ckpt_sectionwrite.id_len =
- req_lib_ckpt_sectionwrite->id_len;
- req_exec_ckpt_sectionwrite.data_offset =
- req_lib_ckpt_sectionwrite->data_offset;
- req_exec_ckpt_sectionwrite.data_size =
- req_lib_ckpt_sectionwrite->data_size;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectionwrite.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_sectionoverwrite (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)msg;
- struct req_exec_ckpt_sectionoverwrite req_exec_ckpt_sectionoverwrite;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "Section overwrite from conn %p\n", conn);
- req_exec_ckpt_sectionoverwrite.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE);
- req_exec_ckpt_sectionoverwrite.header.size =
- sizeof (struct req_exec_ckpt_sectionoverwrite);
- message_source_set (&req_exec_ckpt_sectionoverwrite.source, conn);
- memcpy (&req_exec_ckpt_sectionoverwrite.checkpoint_name,
- &req_lib_ckpt_sectionoverwrite->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectionoverwrite.ckpt_id =
- req_lib_ckpt_sectionoverwrite->ckpt_id;
- req_exec_ckpt_sectionoverwrite.id_len =
- req_lib_ckpt_sectionoverwrite->id_len;
- req_exec_ckpt_sectionoverwrite.data_size =
- req_lib_ckpt_sectionoverwrite->data_size;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectionoverwrite.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_sectionread (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)msg;
- struct req_exec_ckpt_sectionread req_exec_ckpt_sectionread;
- struct iovec iovecs[2];
- log_printf (LOG_LEVEL_DEBUG, "Section read from conn %p\n", conn);
- /*
- * checkpoint opened is writeable mode so send message to cluster
- */
- req_exec_ckpt_sectionread.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SECTIONREAD);
- req_exec_ckpt_sectionread.header.size =
- sizeof (struct req_exec_ckpt_sectionread);
- message_source_set (&req_exec_ckpt_sectionread.source, conn);
- memcpy (&req_exec_ckpt_sectionread.checkpoint_name,
- &req_lib_ckpt_sectionread->checkpoint_name,
- sizeof (mar_name_t));
- req_exec_ckpt_sectionread.ckpt_id =
- req_lib_ckpt_sectionread->ckpt_id;
- req_exec_ckpt_sectionread.id_len =
- req_lib_ckpt_sectionread->id_len;
- req_exec_ckpt_sectionread.data_offset =
- req_lib_ckpt_sectionread->data_offset;
- req_exec_ckpt_sectionread.data_size =
- req_lib_ckpt_sectionread->data_size;
- iovecs[0].iov_base = (char *)&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);
- req_exec_ckpt_sectionread.header.size += iovecs[1].iov_len;
- if (iovecs[1].iov_len > 0) {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
- } else {
- assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
- }
- }
- static void message_handler_req_lib_ckpt_checkpointsynchronize (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointsynchronize *req_lib_ckpt_checkpointsynchronize = (struct req_lib_ckpt_checkpointsynchronize *)msg;
- struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize;
- struct checkpoint *checkpoint;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_lib_ckpt_checkpointsynchronize->checkpoint_name,
- req_lib_ckpt_checkpointsynchronize->ckpt_id);
- if ((checkpoint->checkpoint_creation_attributes.creation_flags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
- res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_ERR_BAD_OPERATION;
- } else
- if (checkpoint->active_replica_set == 1) {
- res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_OK;
- } else {
- res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_ERR_NOT_EXIST;
- }
- res_lib_ckpt_checkpointsynchronize.header.size = sizeof (struct res_lib_ckpt_checkpointsynchronize);
- res_lib_ckpt_checkpointsynchronize.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_checkpointsynchronize,
- sizeof (struct res_lib_ckpt_checkpointsynchronize));
- }
- static void message_handler_req_lib_ckpt_checkpointsynchronizeasync (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_checkpointsynchronizeasync *req_lib_ckpt_checkpointsynchronizeasync = (struct req_lib_ckpt_checkpointsynchronizeasync *)msg;
- struct res_lib_ckpt_checkpointsynchronizeasync res_lib_ckpt_checkpointsynchronizeasync;
- struct checkpoint *checkpoint;
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_lib_ckpt_checkpointsynchronizeasync->checkpoint_name,
- req_lib_ckpt_checkpointsynchronizeasync->ckpt_id);
- if ((checkpoint->checkpoint_creation_attributes.creation_flags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
- res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_BAD_OPERATION;
- } else
- if (checkpoint->active_replica_set == 1) {
- res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_OK;
- } else {
- res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_NOT_EXIST;
- }
- res_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync);
- res_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
- res_lib_ckpt_checkpointsynchronizeasync.invocation = req_lib_ckpt_checkpointsynchronizeasync->invocation;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_checkpointsynchronizeasync,
- sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
- openais_conn_send_response (
- openais_conn_partner_get (conn),
- &res_lib_ckpt_checkpointsynchronizeasync,
- sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
- }
- static void message_handler_req_lib_ckpt_sectioniterationinitialize (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectioniterationinitialize *req_lib_ckpt_sectioniterationinitialize = (struct req_lib_ckpt_sectioniterationinitialize *)msg;
- struct res_lib_ckpt_sectioniterationinitialize res_lib_ckpt_sectioniterationinitialize;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- struct iteration_entry *iteration_entries;
- struct list_head *section_list;
- struct iteration_instance *iteration_instance;
- void *iteration_instance_p;
- unsigned int iteration_handle = 0;
- int res;
- SaAisErrorT error = SA_AIS_OK;
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- log_printf (LOG_LEVEL_DEBUG, "section iteration initialize\n");
- checkpoint = checkpoint_find (
- &checkpoint_list_head,
- &req_lib_ckpt_sectioniterationinitialize->checkpoint_name,
- req_lib_ckpt_sectioniterationinitialize->ckpt_id);
- if (checkpoint == 0) {
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- if (checkpoint->active_replica_set == 0) {
- log_printf (LOG_LEVEL_DEBUG, "iterationinitialize: no active replica, returning error.\n");
- error = SA_AIS_ERR_NOT_EXIST;
- goto error_exit;
- }
- res = hdb_handle_create (&ckpt_pd->iteration_hdb, sizeof(struct iteration_instance),
- &iteration_handle);
- if (res != 0) {
- goto error_exit;
- }
- res = hdb_handle_get (&ckpt_pd->iteration_hdb, iteration_handle,
- &iteration_instance_p);
- if (res != 0) {
- hdb_handle_destroy (&ckpt_pd->iteration_hdb, iteration_handle);
- goto error_exit;
- }
- iteration_instance = (struct iteration_instance *)iteration_instance_p;
- iteration_instance->iteration_entries = NULL;
- iteration_instance->iteration_entries_count = 0;
- iteration_instance->iteration_pos = 0;
- memcpy (&iteration_instance->checkpoint_name,
- &req_lib_ckpt_sectioniterationinitialize->checkpoint_name,
- sizeof (mar_name_t));
- iteration_instance->ckpt_id =
- req_lib_ckpt_sectioniterationinitialize->ckpt_id;
- /*
- * Iterate list of checkpoint sections
- */
- for (section_list = checkpoint->sections_list_head.next;
- section_list != &checkpoint->sections_list_head;
- section_list = section_list->next) {
- checkpoint_section = list_entry (section_list,
- struct checkpoint_section, list);
- switch (req_lib_ckpt_sectioniterationinitialize->sections_chosen) {
- case SA_CKPT_SECTIONS_FOREVER:
- if (checkpoint_section->section_descriptor.expiration_time != SA_TIME_END) {
- continue;
- }
- break;
- case SA_CKPT_SECTIONS_LEQ_EXPIRATION_TIME:
- if (checkpoint_section->section_descriptor.expiration_time > req_lib_ckpt_sectioniterationinitialize->expiration_time) {
- continue;
- }
- break;
- case SA_CKPT_SECTIONS_GEQ_EXPIRATION_TIME:
- if (checkpoint_section->section_descriptor.expiration_time < req_lib_ckpt_sectioniterationinitialize->expiration_time) {
- continue;
- }
- break;
- case SA_CKPT_SECTIONS_CORRUPTED:
- /* there can be no corrupted sections - do nothing */
- break;
- case SA_CKPT_SECTIONS_ANY:
- /* iterate all sections - do nothing */
- break;
- }
- iteration_entries = realloc (
- iteration_instance->iteration_entries,
- sizeof (struct iteration_entry) *
- (iteration_instance->iteration_entries_count + 1));
- if (iteration_entries == NULL) {
- error = SA_AIS_ERR_NO_MEMORY;
- goto error_put;
- }
- iteration_instance->iteration_entries = iteration_entries;
- iteration_entries[iteration_instance->iteration_entries_count].section_id =
- malloc (checkpoint_section->section_descriptor.section_id.id_len);
- assert (iteration_entries[iteration_instance->iteration_entries_count].section_id);
- memcpy (iteration_entries[iteration_instance->iteration_entries_count].section_id,
- checkpoint_section->section_descriptor.section_id.id,
- checkpoint_section->section_descriptor.section_id.id_len);
- iteration_entries[iteration_instance->iteration_entries_count].section_id_len = checkpoint_section->section_descriptor.section_id.id_len;
- iteration_instance->iteration_entries_count += 1;
-
- }
- error_put:
- hdb_handle_put (&ckpt_pd->iteration_hdb, iteration_handle);
- error_exit:
- res_lib_ckpt_sectioniterationinitialize.header.size = sizeof (struct res_lib_ckpt_sectioniterationinitialize);
- res_lib_ckpt_sectioniterationinitialize.header.id = MESSAGE_RES_CKPT_SECTIONITERATIONINITIALIZE;
- res_lib_ckpt_sectioniterationinitialize.header.error = error;
- res_lib_ckpt_sectioniterationinitialize.iteration_handle = iteration_handle;
- res_lib_ckpt_sectioniterationinitialize.max_section_id_size =
- checkpoint->checkpoint_creation_attributes.max_section_id_size;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_sectioniterationinitialize,
- sizeof (struct res_lib_ckpt_sectioniterationinitialize));
- }
- static void message_handler_req_lib_ckpt_sectioniterationfinalize (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectioniterationfinalize *req_lib_ckpt_sectioniterationfinalize = (struct req_lib_ckpt_sectioniterationfinalize *)msg;
- struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize;
- SaAisErrorT error = SA_AIS_OK;
- struct iteration_instance *iteration_instance;
- void *iteration_instance_p;
- unsigned int res;
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- res = hdb_handle_get (&ckpt_pd->iteration_hdb,
- req_lib_ckpt_sectioniterationfinalize->iteration_handle,
- &iteration_instance_p);
- if (res != 0) {
- error = SA_AIS_ERR_LIBRARY;
- goto error_exit;
- }
- iteration_instance = (struct iteration_instance *)iteration_instance_p;
- free (iteration_instance->iteration_entries);
- hdb_handle_put (&ckpt_pd->iteration_hdb,
- req_lib_ckpt_sectioniterationfinalize->iteration_handle);
- hdb_handle_destroy (&ckpt_pd->iteration_hdb,
- req_lib_ckpt_sectioniterationfinalize->iteration_handle);
- error_exit:
- res_lib_ckpt_sectioniterationfinalize.header.size = sizeof (struct res_lib_ckpt_sectioniterationfinalize);
- res_lib_ckpt_sectioniterationfinalize.header.id = MESSAGE_RES_CKPT_SECTIONITERATIONFINALIZE;
- res_lib_ckpt_sectioniterationfinalize.header.error = error;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_sectioniterationfinalize,
- sizeof (struct res_lib_ckpt_sectioniterationfinalize));
- }
- static void message_handler_req_lib_ckpt_sectioniterationnext (
- void *conn,
- void *msg)
- {
- struct req_lib_ckpt_sectioniterationnext *req_lib_ckpt_sectioniterationnext = (struct req_lib_ckpt_sectioniterationnext *)msg;
- struct res_lib_ckpt_sectioniterationnext res_lib_ckpt_sectioniterationnext;
- SaAisErrorT error = SA_AIS_OK;
- int section_id_size = 0;
- unsigned int res;
- struct iteration_instance *iteration_instance = NULL;
- void *iteration_instance_p;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section = NULL;
- struct ckpt_pd *ckpt_pd = (struct ckpt_pd *)openais_conn_private_data_get (conn);
- log_printf (LOG_LEVEL_DEBUG, "section iteration next\n");
- res = hdb_handle_get (&ckpt_pd->iteration_hdb,
- req_lib_ckpt_sectioniterationnext->iteration_handle,
- &iteration_instance_p);
- if (res != 0) {
- error = SA_AIS_ERR_LIBRARY;
- goto error_exit;
- }
- iteration_instance = (struct iteration_instance *)iteration_instance_p;
- assert (iteration_instance);
- /*
- * Find active iteration entry
- */
- for (;;) {
- /*
- * No more sections in iteration
- */
- if (iteration_instance->iteration_pos == iteration_instance->iteration_entries_count) {
- error = SA_AIS_ERR_NO_SECTIONS;
- goto error_put;
- }
- /*
- * Find the checkpoint section to respond to library
- */
- checkpoint = checkpoint_find_specific (
- &checkpoint_list_head,
- &iteration_instance->checkpoint_name,
- iteration_instance->ckpt_id);
- assert (checkpoint);
- checkpoint_section = checkpoint_section_find (
- checkpoint,
- iteration_instance->iteration_entries[iteration_instance->iteration_pos].section_id,
- iteration_instance->iteration_entries[iteration_instance->iteration_pos].section_id_len);
- iteration_instance->iteration_pos += 1;
- /*
- * If checkpoint section found, then return it in iteration
- */
- if (checkpoint_section) {
- section_id_size = checkpoint_section->section_descriptor.section_id.id_len;
- memcpy (&res_lib_ckpt_sectioniterationnext.section_descriptor,
- &checkpoint_section->section_descriptor,
- sizeof (mar_ckpt_section_descriptor_t));
- /*
- * This drops out of for loop
- */
- break;
- }
- }
- error_put:
- hdb_handle_put (&ckpt_pd->iteration_hdb, req_lib_ckpt_sectioniterationnext->iteration_handle);
- error_exit:
- res_lib_ckpt_sectioniterationnext.header.size = sizeof (struct res_lib_ckpt_sectioniterationnext) + section_id_size;
- res_lib_ckpt_sectioniterationnext.header.id = MESSAGE_RES_CKPT_SECTIONITERATIONNEXT;
- res_lib_ckpt_sectioniterationnext.header.error = error;
- openais_conn_send_response (
- conn,
- &res_lib_ckpt_sectioniterationnext,
- sizeof (struct res_lib_ckpt_sectioniterationnext));
- if (error == SA_AIS_OK) {
- openais_conn_send_response (
- conn,
- checkpoint_section->section_descriptor.section_id.id,
- checkpoint_section->section_descriptor.section_id.id_len);
- }
- }
- /*
- * Recovery after network partition or merge
- */
- void sync_refcount_increment (
- struct checkpoint *checkpoint,
- unsigned int nodeid)
- {
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- if (checkpoint->refcount_set[i].nodeid == 0) {
- checkpoint->refcount_set[i].nodeid = nodeid;
- checkpoint->refcount_set[i].refcount = 1;
- break;
- }
- if (checkpoint->refcount_set[i].nodeid == nodeid) {
- checkpoint->refcount_set[i].refcount += 1;
- break;
- }
- }
- }
- void sync_refcount_add (
- struct checkpoint *checkpoint,
- unsigned int nodeid,
- unsigned int count)
- {
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- if (checkpoint->refcount_set[i].nodeid == 0) {
- checkpoint->refcount_set[i].nodeid = nodeid;
- checkpoint->refcount_set[i].refcount = count;
- break;
- }
- if (checkpoint->refcount_set[i].nodeid == nodeid) {
- checkpoint->refcount_set[i].refcount += count;
- break;
- }
- }
- }
- void sync_refcount_decrement (
- struct checkpoint *checkpoint,
- unsigned int nodeid)
- {
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- if (checkpoint->refcount_set[i].nodeid == 0) {
- break;
- }
- if (checkpoint->refcount_set[i].nodeid == nodeid) {
- checkpoint->refcount_set[i].refcount -= 1;
- break;
- }
- }
- }
- /*
- * Sum all reference counts for the checkpoint
- */
- void sync_refcount_calculate (
- struct checkpoint *checkpoint)
- {
- checkpoint->reference_count = 0;
- unsigned int i;
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- if (checkpoint->refcount_set[i].nodeid == 0) {
- break;
- }
-
- checkpoint->reference_count += checkpoint->refcount_set[i].refcount;
- }
- }
- void sync_checkpoints_free (struct list_head *ckpt_list_head)
- {
- struct checkpoint *checkpoint;
- struct list_head *list;
- list = ckpt_list_head->next;
- while (list != ckpt_list_head) {
- checkpoint = list_entry (list, struct checkpoint, list);
- list = list->next;
- checkpoint_release (checkpoint);
- }
- list_init (ckpt_list_head);
- }
- static inline void sync_checkpoints_enter (void)
- {
- struct checkpoint *checkpoint;
- ENTER();
- my_sync_state = SYNC_STATE_CHECKPOINT;
- my_iteration_state = ITERATION_STATE_CHECKPOINT;
- my_iteration_state_checkpoint = checkpoint_list_head.next;
- checkpoint = list_entry (checkpoint_list_head.next, struct checkpoint,
- list);
- my_iteration_state_section = checkpoint->sections_list_head.next;
- LEAVE();
- }
- static inline void sync_refcounts_enter (void)
- {
- my_sync_state = SYNC_STATE_REFCOUNT;
- }
- static void ckpt_sync_init (void)
- {
- ENTER();
- sync_checkpoints_enter();
- LEAVE();
- }
- static int sync_checkpoint_transmit (struct checkpoint *checkpoint)
- {
- struct req_exec_ckpt_sync_checkpoint req_exec_ckpt_sync_checkpoint;
- struct iovec iovec;
- req_exec_ckpt_sync_checkpoint.header.size =
- sizeof (struct req_exec_ckpt_sync_checkpoint);
- req_exec_ckpt_sync_checkpoint.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINT);
- memcpy (&req_exec_ckpt_sync_checkpoint.ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id));
-
- memcpy (&req_exec_ckpt_sync_checkpoint.checkpoint_name,
- &checkpoint->name, sizeof (mar_name_t));
- req_exec_ckpt_sync_checkpoint.ckpt_id = checkpoint->ckpt_id;
- memcpy (&req_exec_ckpt_sync_checkpoint.checkpoint_creation_attributes,
- &checkpoint->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t));
- req_exec_ckpt_sync_checkpoint.active_replica_set =
- checkpoint->active_replica_set;
- req_exec_ckpt_sync_checkpoint.unlinked =
- checkpoint->unlinked;
- iovec.iov_base = (char *)&req_exec_ckpt_sync_checkpoint;
- iovec.iov_len = sizeof (req_exec_ckpt_sync_checkpoint);
- return (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED));
- }
- static int sync_checkpoint_section_transmit (
- struct checkpoint *checkpoint,
- struct checkpoint_section *checkpoint_section)
- {
- struct req_exec_ckpt_sync_checkpoint_section req_exec_ckpt_sync_checkpoint_section;
- struct iovec iovecs[3];
- ENTER();
- TRACE1 ("transmitting section\n");
- req_exec_ckpt_sync_checkpoint_section.header.size =
- sizeof (struct req_exec_ckpt_sync_checkpoint_section);
- req_exec_ckpt_sync_checkpoint_section.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINTSECTION);
- memcpy (&req_exec_ckpt_sync_checkpoint_section.ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id));
- memcpy (&req_exec_ckpt_sync_checkpoint_section.checkpoint_name,
- &checkpoint->name, sizeof (mar_name_t));
- req_exec_ckpt_sync_checkpoint_section.ckpt_id = checkpoint->ckpt_id;
- req_exec_ckpt_sync_checkpoint_section.id_len =
- checkpoint_section->section_descriptor.section_id.id_len;
- req_exec_ckpt_sync_checkpoint_section.section_size =
- checkpoint_section->section_descriptor.section_size;
- req_exec_ckpt_sync_checkpoint_section.section_size =
- checkpoint_section->section_descriptor.section_size;
- req_exec_ckpt_sync_checkpoint_section.expiration_time =
- checkpoint_section->section_descriptor.expiration_time;
- iovecs[0].iov_base = (char *)&req_exec_ckpt_sync_checkpoint_section;
- iovecs[0].iov_len = sizeof (req_exec_ckpt_sync_checkpoint_section);
- iovecs[1].iov_base = (char *)checkpoint_section->section_descriptor.section_id.id;
- iovecs[1].iov_len = checkpoint_section->section_descriptor.section_id.id_len;
- iovecs[2].iov_base = checkpoint_section->section_data;
- iovecs[2].iov_len = checkpoint_section->section_descriptor.section_size;
- LEAVE();
- return (totempg_groups_mcast_joined (openais_group_handle, iovecs, 3, TOTEMPG_AGREED));
- }
- static int sync_checkpoint_refcount_transmit (
- struct checkpoint *checkpoint)
- {
- struct req_exec_ckpt_sync_checkpoint_refcount req_exec_ckpt_sync_checkpoint_refcount;
- struct iovec iovec;
- ENTER();
- TRACE1 ("transmitting refcounts for checkpoints\n");
- req_exec_ckpt_sync_checkpoint_refcount.header.size =
- sizeof (struct req_exec_ckpt_sync_checkpoint_refcount);
- req_exec_ckpt_sync_checkpoint_refcount.header.id =
- SERVICE_ID_MAKE (CKPT_SERVICE,
- MESSAGE_REQ_EXEC_CKPT_SYNCCHECKPOINTREFCOUNT);
- memcpy (&req_exec_ckpt_sync_checkpoint_refcount.ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id));
- memcpy (&req_exec_ckpt_sync_checkpoint_refcount.checkpoint_name,
- &checkpoint->name, sizeof (mar_name_t));
- req_exec_ckpt_sync_checkpoint_refcount.ckpt_id = checkpoint->ckpt_id;
- marshall_to_mar_refcount_set_t_all (
- req_exec_ckpt_sync_checkpoint_refcount.refcount_set,
- checkpoint->refcount_set);
-
- iovec.iov_base = (char *)&req_exec_ckpt_sync_checkpoint_refcount;
- iovec.iov_len = sizeof (struct req_exec_ckpt_sync_checkpoint_refcount);
- LEAVE();
- return (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED));
- }
- unsigned int sync_checkpoints_iterate (void)
- {
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- struct list_head *checkpoint_list;
- struct list_head *section_list;
- unsigned int res = 0;
- for (checkpoint_list = checkpoint_list_head.next;
- checkpoint_list != &checkpoint_list_head;
- checkpoint_list = checkpoint_list->next) {
- checkpoint = list_entry (checkpoint_list, struct checkpoint, list);
- res = sync_checkpoint_transmit (checkpoint);
- if (res != 0) {
- break;
- }
- for (section_list = checkpoint->sections_list_head.next;
- section_list != &checkpoint->sections_list_head;
- section_list = section_list->next) {
- checkpoint_section = list_entry (section_list, struct checkpoint_section, list);
- res = sync_checkpoint_section_transmit (checkpoint, checkpoint_section);
- }
- }
- return (res);
- }
- unsigned int sync_refcounts_iterate (void)
- {
- struct checkpoint *checkpoint;
- struct list_head *list;
- unsigned int res = 0;
- for (list = checkpoint_list_head.next;
- list != &checkpoint_list_head;
- list = list->next) {
- checkpoint = list_entry (list, struct checkpoint, list);
- res = sync_checkpoint_refcount_transmit (checkpoint);
- if (res != 0) {
- break;
- }
- }
- return (res);
- }
- static int ckpt_sync_process (void)
- {
- unsigned int done_queueing = 1;
- unsigned int continue_processing = 0;
- unsigned int res;
- ENTER();
- switch (my_sync_state) {
- case SYNC_STATE_CHECKPOINT:
- if (my_lowest_nodeid == totempg_my_nodeid_get()) {
- TRACE1 ("should transmit checkpoints because lowest member in old configuration.\n");
- res = sync_checkpoints_iterate ();
- if (res == 0) {
- done_queueing = 1;
- }
- }
- if (done_queueing) {
- sync_refcounts_enter ();
- }
- /*
- * TODO recover current iteration state
- */
- continue_processing = 1;
- break;
- case SYNC_STATE_REFCOUNT:
- done_queueing = 1;
- if (my_lowest_nodeid == totempg_my_nodeid_get()) {
- TRACE1 ("transmit refcounts because this processor is the lowest member in old configuration.\n");
- res = sync_refcounts_iterate ();
- }
- if (done_queueing) {
- continue_processing = 0;
- }
- break;
- }
- LEAVE();
- return (continue_processing);
- }
- static void ckpt_sync_activate (void)
- {
- ENTER();
- sync_checkpoints_free (&checkpoint_list_head);
- list_init (&checkpoint_list_head);
- if (!list_empty (&sync_checkpoint_list_head)) {
- list_splice (&sync_checkpoint_list_head, &checkpoint_list_head);
- }
- list_init (&sync_checkpoint_list_head);
- my_sync_state = SYNC_STATE_CHECKPOINT;
- LEAVE();
- }
- static void ckpt_sync_abort (void)
- {
- sync_checkpoints_free (&sync_checkpoint_list_head);
- }
- static void message_handler_req_exec_ckpt_sync_checkpoint (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sync_checkpoint *req_exec_ckpt_sync_checkpoint =
- (struct req_exec_ckpt_sync_checkpoint *)message;
- struct checkpoint *checkpoint = 0;
- ENTER();
- /*
- * Ignore messages from previous ring ids
- */
- if (memcmp (&req_exec_ckpt_sync_checkpoint->ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id)) != 0) {
- return;
- }
- checkpoint = checkpoint_find_specific (
- &sync_checkpoint_list_head,
- &req_exec_ckpt_sync_checkpoint->checkpoint_name,
- req_exec_ckpt_sync_checkpoint->ckpt_id);
- /*
- * If checkpoint doesn't exist, create one
- */
- if (checkpoint == 0) {
- checkpoint = malloc (sizeof (struct checkpoint));
- if (checkpoint == 0) {
- LEAVE();
- openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
- }
- memset (checkpoint, 0, sizeof (struct checkpoint));
- memcpy (&checkpoint->name,
- &req_exec_ckpt_sync_checkpoint->checkpoint_name,
- sizeof (mar_name_t));
- memcpy (&checkpoint->checkpoint_creation_attributes,
- &req_exec_ckpt_sync_checkpoint->checkpoint_creation_attributes,
- sizeof (mar_ckpt_checkpoint_creation_attributes_t));
- memset (&checkpoint->refcount_set, 0, sizeof (struct refcount_set) * PROCESSOR_COUNT_MAX);
- checkpoint->ckpt_id = req_exec_ckpt_sync_checkpoint->ckpt_id;
- checkpoint->active_replica_set = req_exec_ckpt_sync_checkpoint->active_replica_set;
- checkpoint->unlinked = req_exec_ckpt_sync_checkpoint->unlinked;
- checkpoint->reference_count = 0;
- checkpoint->retention_timer = 0;
- checkpoint->section_count = 0;
- list_init (&checkpoint->list);
- list_init (&checkpoint->sections_list_head);
- list_add (&checkpoint->list, &sync_checkpoint_list_head);
- memset (checkpoint->refcount_set, 0,
- sizeof (struct refcount_set) * PROCESSOR_COUNT_MAX);
- }
- if (checkpoint->ckpt_id >= global_ckpt_id) {
- global_ckpt_id = checkpoint->ckpt_id + 1;
- }
- LEAVE();
- }
- static void message_handler_req_exec_ckpt_sync_checkpoint_section (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sync_checkpoint_section *req_exec_ckpt_sync_checkpoint_section =
- (struct req_exec_ckpt_sync_checkpoint_section *)message;
- struct checkpoint *checkpoint;
- struct checkpoint_section *checkpoint_section;
- char *section_contents;
- char *section_id;
- ENTER();
- /*
- * Ignore messages from previous ring ids
- */
- if (memcmp (&req_exec_ckpt_sync_checkpoint_section->ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id)) != 0) {
- LEAVE();
- return;
- }
- checkpoint = checkpoint_find_specific (
- &sync_checkpoint_list_head,
- &req_exec_ckpt_sync_checkpoint_section->checkpoint_name,
- req_exec_ckpt_sync_checkpoint_section->ckpt_id);
- assert (checkpoint != NULL);
- /*
- * Determine if user-specified checkpoint section already exists
- */
- checkpoint_section = checkpoint_section_find (
- checkpoint,
- ((char *)req_exec_ckpt_sync_checkpoint_section) +
- sizeof (struct req_exec_ckpt_sync_checkpoint_section),
- req_exec_ckpt_sync_checkpoint_section->id_len);
- if (checkpoint_section == NULL) {
- /*
- * Allocate checkpoint section
- */
- checkpoint_section = malloc (sizeof (struct checkpoint_section));
- if (checkpoint_section == 0) {
- LEAVE();
- openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
- }
- section_contents = malloc (req_exec_ckpt_sync_checkpoint_section->section_size);
- if (section_contents == 0) {
- free (checkpoint_section);
- LEAVE();
- openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
- }
- if (req_exec_ckpt_sync_checkpoint_section->id_len) {
-
- section_id = malloc (req_exec_ckpt_sync_checkpoint_section->id_len + 1);
- if (section_id == 0) {
- free (checkpoint_section);
- free (section_contents);
- LEAVE();
- openais_exit_error (AIS_DONE_OUT_OF_MEMORY);
- }
- /*
- * Copy checkpoint section and section ID
- */
- memcpy (section_id,
- ((char *)req_exec_ckpt_sync_checkpoint_section) +
- sizeof (struct req_exec_ckpt_sync_checkpoint_section),
- req_exec_ckpt_sync_checkpoint_section->id_len);
- /*
- * Null terminate the section id for printing purposes
- */
- ((char*)(section_id))[req_exec_ckpt_sync_checkpoint_section->id_len] = '\0';
- } else {
- /*
- * Default section
- */
- section_id = NULL;
- }
-
- memcpy (section_contents,
- ((char *)req_exec_ckpt_sync_checkpoint_section) +
- sizeof (struct req_exec_ckpt_sync_checkpoint_section) +
- req_exec_ckpt_sync_checkpoint_section->id_len,
- req_exec_ckpt_sync_checkpoint_section->section_size);
- /*
- * Configure checkpoint section
- */
- checkpoint_section->section_descriptor.section_id.id = (unsigned char *)section_id;
- checkpoint_section->section_descriptor.section_id.id_len =
- req_exec_ckpt_sync_checkpoint_section->id_len;
- checkpoint_section->section_descriptor.section_size =
- req_exec_ckpt_sync_checkpoint_section->section_size;
- checkpoint_section->section_descriptor.expiration_time =
- req_exec_ckpt_sync_checkpoint_section->expiration_time;
- checkpoint_section->section_descriptor.section_state =
- SA_CKPT_SECTION_VALID;
- checkpoint_section->section_descriptor.last_update = 0; /* TODO current time */
- checkpoint_section->section_data = section_contents;
- checkpoint_section->expiration_timer = 0;
- /*
- * Add checkpoint section to checkpoint
- */
- list_init (&checkpoint_section->list);
- list_add (&checkpoint_section->list,
- &checkpoint->sections_list_head);
- checkpoint->section_count += 1;
- }
- LEAVE();
- }
- static void message_handler_req_exec_ckpt_sync_checkpoint_refcount (
- void *message,
- unsigned int nodeid)
- {
- struct req_exec_ckpt_sync_checkpoint_refcount *req_exec_ckpt_sync_checkpoint_refcount
- = (struct req_exec_ckpt_sync_checkpoint_refcount *)message;
- struct checkpoint *checkpoint;
- unsigned int i, j;
- ENTER();
- /*
- * Ignore messages from previous ring ids
- */
- if (memcmp (&req_exec_ckpt_sync_checkpoint_refcount->ring_id,
- &my_saved_ring_id, sizeof (struct memb_ring_id)) != 0) {
- LEAVE();
- return;
- }
- checkpoint = checkpoint_find_specific (
- &sync_checkpoint_list_head,
- &req_exec_ckpt_sync_checkpoint_refcount->checkpoint_name,
- req_exec_ckpt_sync_checkpoint_refcount->ckpt_id);
- assert (checkpoint != NULL);
- for (i = 0; i < PROCESSOR_COUNT_MAX; i++) {
- if (req_exec_ckpt_sync_checkpoint_refcount->refcount_set[i].nodeid == 0) {
- break;
- }
- for (j = 0; j < PROCESSOR_COUNT_MAX; j++) {
- if (checkpoint->refcount_set[j].nodeid == 0) {
- checkpoint->refcount_set[j].nodeid =
- req_exec_ckpt_sync_checkpoint_refcount->refcount_set[i].nodeid;
- checkpoint->refcount_set[j].refcount =
- req_exec_ckpt_sync_checkpoint_refcount->refcount_set[i].refcount;
- /*
- * No match found, added processor reference count
- */
- break;
- }
- if (req_exec_ckpt_sync_checkpoint_refcount->refcount_set[i].nodeid == checkpoint->refcount_set[j].nodeid) {
- checkpoint->refcount_set[j].refcount +=
- req_exec_ckpt_sync_checkpoint_refcount->refcount_set[i].refcount;
- /*
- * Found match, so look at next processor ref count
- */
- break;
- }
- }
- }
- sync_refcount_calculate (checkpoint);
- LEAVE();
- }
- static void ckpt_dump_fn (void)
- {
- struct list_head *checkpoint_list;
- struct checkpoint *checkpoint;
- struct list_head *checkpoint_section_list;
- struct checkpoint_section *section;
- log_printf (LOG_LEVEL_NOTICE,
- "========== Checkpoint Information ===========");
- log_printf (LOG_LEVEL_NOTICE, "global_ckpt_id: %u", global_ckpt_id);
- for (checkpoint_list = checkpoint_list_head.next;
- checkpoint_list != &checkpoint_list_head;
- checkpoint_list = checkpoint_list->next) {
- checkpoint = list_entry (checkpoint_list, struct checkpoint, list);
- if (checkpoint == NULL) {
- return;
- }
- log_printf (LOG_LEVEL_NOTICE, "Checkpoint %s (%d):",
- checkpoint->name.value, checkpoint->name.length);
- log_printf (LOG_LEVEL_NOTICE, " id: %u", checkpoint->ckpt_id);
- log_printf (LOG_LEVEL_NOTICE, " sec cnt: %u", checkpoint->section_count);
- log_printf (LOG_LEVEL_NOTICE, " ref cnt: %u", checkpoint->reference_count);
- log_printf (LOG_LEVEL_NOTICE, " unlinked: %u", checkpoint->unlinked);
- for (checkpoint_section_list = checkpoint->sections_list_head.next;
- checkpoint_section_list != &checkpoint->sections_list_head;
- checkpoint_section_list = checkpoint_section_list->next) {
- section = list_entry (checkpoint_section_list,
- struct checkpoint_section, list);
- log_printf (LOG_LEVEL_NOTICE, " Section %s (%d)",
- section->section_descriptor.section_id.id,
- section->section_descriptor.section_id.id_len);
- log_printf (LOG_LEVEL_NOTICE, " size: %llu",
- section->section_descriptor.section_size);
- log_printf (LOG_LEVEL_NOTICE, " state: %u",
- section->section_descriptor.section_state);
- log_printf (LOG_LEVEL_NOTICE, " exp time: %llu",
- section->section_descriptor.expiration_time);
- }
- }
- }
|