ckpt.c 134 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603
  1. /*
  2. * Copyright (c) 2003-2004 MontaVista Software, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@mvista.com)
  7. *
  8. * This software licensed under BSD license, the text of which follows:
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions are met:
  12. *
  13. * - Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * - Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  26. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  27. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  28. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  29. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  30. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  31. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  32. * THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include <sys/types.h>
  35. #include <sys/uio.h>
  36. #include <sys/socket.h>
  37. #include <sys/un.h>
  38. #include <sys/time.h>
  39. #include <netinet/in.h>
  40. #include <unistd.h>
  41. #include <fcntl.h>
  42. #include <stdlib.h>
  43. #include <stdio.h>
  44. #include <errno.h>
  45. #include <signal.h>
  46. #include <arpa/inet.h>
  47. #include "../include/saAis.h"
  48. #include "../include/saCkpt.h"
  49. #include "../include/ipc_ckpt.h"
  50. #include "../include/list.h"
  51. #include "../include/queue.h"
  52. #include "aispoll.h"
  53. #include "mempool.h"
  54. #include "util.h"
  55. #include "main.h"
  56. #include "totempg.h"
  57. #define LOG_SERVICE LOG_SERVICE_CKPT
  58. #define CKPT_MAX_SECTION_DATA_SEND (1024*400)
  59. #include "print.h"
  60. struct ckpt_identifier {
  61. SaNameT ckpt_name;
  62. SaCkptSectionIdT ckpt_section_id;
  63. };
  64. static int process_localhost_transition = 0;
  65. DECLARE_LIST_INIT(checkpoint_list_head);
  66. DECLARE_LIST_INIT(checkpoint_iterator_list_head);
  67. DECLARE_LIST_INIT(checkpoint_recovery_list_head);
  68. struct checkpoint_cleanup {
  69. struct list_head list;
  70. struct saCkptCheckpoint checkpoint;
  71. };
  72. typedef enum {
  73. SYNCHRONY_STATE_STARTED,
  74. SYNCHRONY_STATE_ENDED
  75. }synchrony_state;
  76. /* TODO static totempg_recovery_plug_handle ckpt_checkpoint_recovery_plug_handle; */
  77. static int ckpt_exec_init_fn (struct openais_config *);
  78. static int ckpt_exit_fn (struct conn_info *conn_info);
  79. static int ckpt_init_two_fn (struct conn_info *conn_info);
  80. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  81. static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  82. static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  83. static int message_handler_req_exec_ckpt_checkpointclose (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  84. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  85. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  86. static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  87. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  88. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  89. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  90. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  91. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  92. static int message_handler_req_exec_ckpt_sectionread (void *message, struct totem_ip_address *source_addr, int endian_conversion_required);
  93. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message);
  94. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message);
  95. static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message);
  96. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message);
  97. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message);
  98. static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message);
  99. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message);
  100. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message);
  101. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message);
  102. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message);
  103. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message);
  104. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message);
  105. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message);
  106. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message);
  107. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message);
  108. static int message_handler_req_lib_ckpt_sectioniterationinitialize (struct conn_info *conn_info, void *message);
  109. static int message_handler_req_lib_ckpt_sectioniterationfinalize (struct conn_info *conn_info, void *message);
  110. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message);
  111. static void ckpt_recovery_activate (void);
  112. static void ckpt_recovery_initialize (void);
  113. static int ckpt_recovery_process (void);
  114. static void ckpt_recovery_finalize();
  115. static void ckpt_recovery_abort(void);
  116. static void ckpt_recovery_process_members_exit(struct totem_ip_address *left_list,
  117. int left_list_entries);
  118. static void ckpt_replace_localhost_ip (struct totem_ip_address *joined_list);
  119. void checkpoint_release (struct saCkptCheckpoint *checkpoint);
  120. void timer_function_retention (void *data);
  121. unsigned int abstime_to_msec (SaTimeT time);
  122. void timer_function_section_expire (void *data);
  123. void clean_checkpoint_list(struct list_head* head);
  124. static int recovery_checkpoint_open(SaNameT *checkpointName,
  125. SaCkptCheckpointCreationAttributesT *ckptAttributes,
  126. struct ckpt_refcnt *ref_cnt);
  127. static int recovery_section_create (SaCkptSectionDescriptorT *sectionDescriptor,
  128. SaNameT *checkpointName,
  129. char* SectionId);
  130. static int recovery_section_write(int sectionIdLen, char* sectionId , SaNameT *checkpointName,
  131. void *newData, SaUint32T dataOffSet, SaUint32T dataSize);
  132. static synchrony_state recovery_state = SYNCHRONY_STATE_ENDED;
  133. static struct list_head *recovery_ckpt_next = 0;
  134. static struct list_head *recovery_ckpt_section_next = 0;
  135. static int recovery_section_data_offset = 0;
  136. static int recovery_section_send_flag = 0;
  137. static int recovery_abort = 0;
  138. static struct memb_ring_id saved_ring_id;
  139. static int ckpt_confchg_fn(
  140. enum totem_configuration_type configuration_type,
  141. struct totem_ip_address *member_list, int member_list_entries,
  142. struct totem_ip_address *left_list, int left_list_entries,
  143. struct totem_ip_address *joined_list, int joined_list_entries,
  144. struct memb_ring_id *ring_id);
  145. /*
  146. * Executive Handler Definition
  147. */
  148. struct libais_handler ckpt_libais_handlers[] =
  149. {
  150. { /* 0 */
  151. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopen,
  152. .response_size = sizeof (struct res_lib_ckpt_checkpointopen),
  153. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN,
  154. .flow_control = FLOW_CONTROL_REQUIRED
  155. },
  156. { /* 1 */
  157. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopenasync,
  158. .response_size = sizeof (struct res_lib_ckpt_checkpointopenasync),
  159. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC,
  160. .flow_control = FLOW_CONTROL_REQUIRED
  161. },
  162. { /* 2 */
  163. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointclose,
  164. .response_size = sizeof (struct res_lib_ckpt_checkpointclose),
  165. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE,
  166. .flow_control = FLOW_CONTROL_REQUIRED
  167. },
  168. { /* 3 */
  169. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointunlink,
  170. .response_size = sizeof (struct res_lib_ckpt_checkpointunlink),
  171. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
  172. .flow_control = FLOW_CONTROL_REQUIRED
  173. },
  174. { /* 4 */
  175. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointretentiondurationset,
  176. .response_size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
  177. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
  178. .flow_control = FLOW_CONTROL_REQUIRED
  179. },
  180. { /* 5 */
  181. .libais_handler_fn = message_handler_req_lib_ckpt_activereplicaset,
  182. .response_size = sizeof (struct res_lib_ckpt_activereplicaset),
  183. .response_id = MESSAGE_RES_CKPT_ACTIVEREPLICASET,
  184. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  185. },
  186. { /* 6 */
  187. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointstatusget,
  188. .response_size = sizeof (struct res_lib_ckpt_checkpointstatusget),
  189. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
  190. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  191. },
  192. { /* 7 */
  193. .libais_handler_fn = message_handler_req_lib_ckpt_sectioncreate,
  194. .response_size = sizeof (struct res_lib_ckpt_sectioncreate),
  195. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE,
  196. .flow_control = FLOW_CONTROL_REQUIRED
  197. },
  198. { /* 8 */
  199. .libais_handler_fn = message_handler_req_lib_ckpt_sectiondelete,
  200. .response_size = sizeof (struct res_lib_ckpt_sectiondelete),
  201. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE,
  202. .flow_control = FLOW_CONTROL_REQUIRED
  203. },
  204. { /* 9 */
  205. .libais_handler_fn = message_handler_req_lib_ckpt_sectionexpirationtimeset,
  206. .response_size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
  207. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
  208. .flow_control = FLOW_CONTROL_REQUIRED
  209. },
  210. { /* 10 */
  211. .libais_handler_fn = message_handler_req_lib_ckpt_sectionwrite,
  212. .response_size = sizeof (struct res_lib_ckpt_sectionwrite),
  213. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE,
  214. .flow_control = FLOW_CONTROL_REQUIRED
  215. },
  216. { /* 11 */
  217. .libais_handler_fn = message_handler_req_lib_ckpt_sectionoverwrite,
  218. .response_size = sizeof (struct res_lib_ckpt_sectionoverwrite),
  219. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE,
  220. .flow_control = FLOW_CONTROL_REQUIRED
  221. },
  222. { /* 12 */
  223. .libais_handler_fn = message_handler_req_lib_ckpt_sectionread,
  224. .response_size = sizeof (struct res_lib_ckpt_sectionread),
  225. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD,
  226. .flow_control = FLOW_CONTROL_REQUIRED
  227. },
  228. { /* 13 */
  229. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronize,
  230. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronize),
  231. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
  232. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  233. },
  234. { /* 14 */
  235. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronizeasync,
  236. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync), /* TODO RESPONSE */
  237. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC,
  238. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  239. },
  240. { /* 15 */
  241. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniterationinitialize,
  242. .response_size = sizeof (struct res_lib_ckpt_sectioniterationinitialize),
  243. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE,
  244. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  245. },
  246. { /* 16 */
  247. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniterationfinalize,
  248. .response_size = sizeof (struct res_lib_ckpt_sectioniterationfinalize),
  249. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE,
  250. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  251. },
  252. { /* 17 */
  253. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratornext,
  254. .response_size = sizeof (struct res_lib_ckpt_sectioniteratornext),
  255. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT,
  256. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  257. }
  258. };
  259. static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct totem_ip_address *source_addr, int endian_conversion_required) = {
  260. message_handler_req_exec_ckpt_checkpointopen,
  261. message_handler_req_exec_ckpt_checkpointclose,
  262. message_handler_req_exec_ckpt_checkpointunlink,
  263. message_handler_req_exec_ckpt_checkpointretentiondurationset,
  264. message_handler_req_exec_ckpt_checkpointretentiondurationexpire,
  265. message_handler_req_exec_ckpt_sectioncreate,
  266. message_handler_req_exec_ckpt_sectiondelete,
  267. message_handler_req_exec_ckpt_sectionexpirationtimeset,
  268. message_handler_req_exec_ckpt_sectionwrite,
  269. message_handler_req_exec_ckpt_sectionoverwrite,
  270. message_handler_req_exec_ckpt_sectionread,
  271. message_handler_req_exec_ckpt_synchronize_state,
  272. message_handler_req_exec_ckpt_synchronize_section
  273. };
  274. struct service_handler ckpt_service_handler = {
  275. .libais_handlers = ckpt_libais_handlers,
  276. .libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler),
  277. .aisexec_handler_fns = ckpt_aisexec_handler_fns,
  278. .aisexec_handler_fns_count = sizeof (ckpt_aisexec_handler_fns) / sizeof (int (*)),
  279. .confchg_fn = ckpt_confchg_fn,
  280. .libais_init_two_fn = ckpt_init_two_fn,
  281. .libais_exit_fn = ckpt_exit_fn,
  282. .exec_init_fn = ckpt_exec_init_fn,
  283. .exec_dump_fn = 0,
  284. .sync_init = ckpt_recovery_initialize,
  285. .sync_process = ckpt_recovery_process,
  286. .sync_activate = ckpt_recovery_activate,
  287. .sync_abort = ckpt_recovery_abort,
  288. };
  289. /*
  290. * All data types used for executive messages
  291. */
  292. struct req_exec_ckpt_checkpointclose {
  293. struct req_header header;
  294. struct message_source source;
  295. SaNameT checkpointName;
  296. };
  297. struct req_exec_ckpt_checkpointretentiondurationset {
  298. struct req_header header;
  299. struct message_source source;
  300. SaNameT checkpointName;
  301. SaTimeT retentionDuration;
  302. };
  303. struct req_exec_ckpt_checkpointretentiondurationexpire {
  304. struct req_header header;
  305. SaNameT checkpointName;
  306. };
  307. struct req_exec_ckpt_checkpointopen {
  308. struct req_header header;
  309. struct message_source source;
  310. struct req_lib_ckpt_checkpointopen req_lib_ckpt_checkpointopen;
  311. SaCkptCheckpointHandleT checkpointHandle;
  312. SaInvocationT invocation;
  313. int async_call;
  314. SaAisErrorT fail_with_error;
  315. };
  316. struct req_exec_ckpt_checkpointunlink {
  317. struct req_header header;
  318. struct message_source source;
  319. struct req_lib_ckpt_checkpointunlink req_lib_ckpt_checkpointunlink;
  320. };
  321. struct req_exec_ckpt_sectioncreate {
  322. struct req_header header;
  323. struct message_source source;
  324. SaNameT checkpointName;
  325. struct req_lib_ckpt_sectioncreate req_lib_ckpt_sectioncreate; /* this must be last */
  326. };
  327. struct req_exec_ckpt_sectiondelete {
  328. struct req_header header;
  329. struct message_source source;
  330. SaNameT checkpointName;
  331. struct req_lib_ckpt_sectiondelete req_lib_ckpt_sectiondelete; /* this must be last */
  332. };
  333. struct req_exec_ckpt_sectionexpirationtimeset {
  334. struct req_header header;
  335. struct message_source source;
  336. SaNameT checkpointName;
  337. struct req_lib_ckpt_sectionexpirationtimeset req_lib_ckpt_sectionexpirationtimeset;
  338. };
  339. struct req_exec_ckpt_sectionwrite {
  340. struct req_header header;
  341. struct message_source source;
  342. SaNameT checkpointName;
  343. struct req_lib_ckpt_sectionwrite req_lib_ckpt_sectionwrite;
  344. };
  345. struct req_exec_ckpt_sectionoverwrite {
  346. struct req_header header;
  347. struct message_source source;
  348. SaNameT checkpointName;
  349. struct req_lib_ckpt_sectionoverwrite req_lib_ckpt_sectionoverwrite;
  350. };
  351. struct req_exec_ckpt_sectionread {
  352. struct req_header header;
  353. struct message_source source;
  354. SaNameT checkpointName;
  355. struct req_lib_ckpt_sectionread req_lib_ckpt_sectionread;
  356. };
  357. struct req_exec_ckpt_synchronize_state {
  358. struct req_header header;
  359. struct memb_ring_id previous_ring_id;
  360. SaNameT checkpointName;
  361. SaCkptCheckpointCreationAttributesT checkpointCreationAttributes;
  362. SaCkptSectionDescriptorT sectionDescriptor;
  363. struct totem_ip_address *source_addr;
  364. struct ckpt_refcnt ckpt_refcount[PROCESSOR_COUNT_MAX];
  365. };
  366. struct req_exec_ckpt_synchronize_section {
  367. struct req_header header;
  368. struct memb_ring_id previous_ring_id;
  369. SaNameT checkpointName;
  370. SaCkptSectionIdT sectionId;
  371. SaUint32T dataOffSet;
  372. SaUint32T dataSize;
  373. };
  374. /*
  375. * Implementation
  376. */
  377. static int processor_index_set(struct totem_ip_address *proc_addr,
  378. struct ckpt_refcnt *ckpt_refcount)
  379. {
  380. int i;
  381. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  382. if (ckpt_refcount[i].addr.family == 0) {
  383. /*
  384. * If the source addresses do not match and this element
  385. * has no stored value then store the new value and
  386. * return the Index.
  387. */
  388. totemip_copy(&ckpt_refcount[i].addr, proc_addr);
  389. return i;
  390. }
  391. /*
  392. * If the source addresses match then this processor index
  393. * has already been set
  394. */
  395. else if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) {
  396. return -1;
  397. }
  398. }
  399. /*
  400. * Could not Find an empty slot
  401. * to store the new Processor.
  402. */
  403. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  404. if (ckpt_refcount[i].addr.family == 0) {
  405. log_printf (LOG_LEVEL_ERROR,"Processor Set: Index %d has proc 0 and count 0\n", i);
  406. }
  407. else {
  408. log_printf (LOG_LEVEL_ERROR,"Processor Set: Index %d has proc %s and count %d\n",
  409. i,
  410. totemip_print(&ckpt_refcount[i].addr),
  411. ckpt_refcount[i].count);
  412. }
  413. }
  414. return -1;
  415. }
  416. static int processor_add (struct totem_ip_address *proc_addr, int count, struct ckpt_refcnt *ckpt_refcount)
  417. {
  418. int i;
  419. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  420. if (ckpt_refcount[i].addr.family == 0) {
  421. log_printf (LOG_LEVEL_DEBUG,"processor_add found empty slot to insert new item\n");
  422. totemip_copy(&ckpt_refcount[i].addr, proc_addr);
  423. ckpt_refcount[i].count = count;
  424. return i;
  425. }
  426. /*Dont know how we missed this in the processor find but update this*/
  427. else if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) {
  428. ckpt_refcount[i].count += count;
  429. log_printf (LOG_LEVEL_DEBUG,"processor_add for existent proc. ip %s, New count = %d\n",
  430. totemip_print(&ckpt_refcount[i].addr),
  431. ckpt_refcount[i].count);
  432. return i;
  433. }
  434. }
  435. /*
  436. * Could not Find an empty slot
  437. * to store the new Processor.
  438. */
  439. log_printf (LOG_LEVEL_ERROR,"Processor Add Failed. Dumping Refcount Array\n");
  440. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  441. if (ckpt_refcount[i].addr.family == 0) {
  442. log_printf (LOG_LEVEL_ERROR,"Processor Add: Index %d has proc 0 and count 0\n", i);
  443. }
  444. else {
  445. log_printf (LOG_LEVEL_ERROR,"Processor Add: Index %d has proc %s and count %d\n",
  446. i,
  447. totemip_print(&ckpt_refcount[i].addr),
  448. ckpt_refcount[i].count);
  449. }
  450. }
  451. return -1;
  452. }
  453. static int processor_index_find(struct totem_ip_address *proc_addr,
  454. struct ckpt_refcnt *ckpt_refcount)
  455. {
  456. int i;
  457. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  458. /*
  459. * If the source addresses match then return the index
  460. */
  461. if (totemip_equal(&ckpt_refcount[i].addr, proc_addr)) {
  462. return i;
  463. }
  464. }
  465. /*
  466. * Could not Find the Processor
  467. */
  468. return -1;
  469. }
  470. static int ckpt_refcount_total(struct ckpt_refcnt *ckpt_refcount)
  471. {
  472. int i;
  473. int total = 0;
  474. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  475. total += ckpt_refcount[i].count;
  476. }
  477. return total;
  478. }
  479. static void initialize_ckpt_refcount_array (struct ckpt_refcnt *ckpt_refcount)
  480. {
  481. memset((char*)ckpt_refcount, 0, PROCESSOR_COUNT_MAX * sizeof(struct ckpt_refcnt));
  482. }
  483. static void merge_ckpt_refcounts(struct ckpt_refcnt *local, struct ckpt_refcnt *network)
  484. {
  485. int index,i;
  486. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  487. if (local[i].addr.family == 0) {
  488. continue;
  489. }
  490. index = processor_index_find (&local[i].addr, network);
  491. if (index == -1) { /*Could Not Find the Local Entry in the remote.Add to it*/
  492. log_printf (LOG_LEVEL_DEBUG,"calling processor_add for ip %s, count %d\n",
  493. totemip_print(&local[i].addr),
  494. local[i].count);
  495. index = processor_add (&local[i].addr, local[i].count, network);
  496. if (index == -1) {
  497. log_printf(LOG_LEVEL_ERROR,
  498. "merge_ckpt_refcounts : could not add a new processor as the MAX limit of procs is reached.Exiting\n");
  499. assert(0);
  500. }
  501. }
  502. else {
  503. if (local[i].count == network[index].count) {
  504. /*Nothing to do here as the network is already up 2 date*/
  505. log_printf (LOG_LEVEL_DEBUG,"merge_ckpt_refcounts counts match, continue\n");
  506. continue;
  507. }
  508. else {
  509. /*Found a match for this proc in the Network choose the larger of the 2.*/
  510. network[index].count += local[i].count;
  511. log_printf (LOG_LEVEL_DEBUG,"setting count for %s = %d\n",
  512. totemip_print(&network[index].addr),
  513. network[index].count);
  514. }
  515. }
  516. }
  517. }
  518. static void ckpt_recovery_initialize (void)
  519. {
  520. struct list_head *checkpoint_list;
  521. struct list_head *checkpoint_section_list;
  522. struct saCkptCheckpoint *checkpoint;
  523. struct saCkptCheckpointSection *section;
  524. struct saCkptCheckpoint *savedCheckpoint;
  525. struct saCkptCheckpointSection *savedSection;
  526. if (recovery_abort) { /*Abort was called.*/
  527. return;
  528. }
  529. /*
  530. * Save off the existing Checkpoints to be used by ckpt_recovery_process
  531. */
  532. for (checkpoint_list = checkpoint_list_head.next;
  533. checkpoint_list != &checkpoint_list_head;
  534. checkpoint_list = checkpoint_list->next) {
  535. checkpoint = list_entry (checkpoint_list,
  536. struct saCkptCheckpoint, list);
  537. if (checkpoint->referenceCount <= 0) {
  538. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_initialize checkpoint %s has referenceCount 0 ignoring.\n",
  539. (char*)&checkpoint->name.value);
  540. continue;
  541. }
  542. savedCheckpoint =
  543. (struct saCkptCheckpoint *) malloc (sizeof(struct saCkptCheckpoint));
  544. assert(savedCheckpoint);
  545. memcpy(savedCheckpoint, checkpoint, sizeof(struct saCkptCheckpoint));
  546. list_init(&savedCheckpoint->list);
  547. list_add(&savedCheckpoint->list,&checkpoint_recovery_list_head);
  548. list_init(&savedCheckpoint->checkpointSectionsListHead);
  549. for (checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  550. checkpoint_section_list != &checkpoint->checkpointSectionsListHead;
  551. checkpoint_section_list = checkpoint_section_list->next) {
  552. section = list_entry (checkpoint_section_list,
  553. struct saCkptCheckpointSection, list);
  554. savedSection =
  555. (struct saCkptCheckpointSection *) malloc (sizeof(struct saCkptCheckpointSection));
  556. assert(savedSection);
  557. poll_timer_delete_data (aisexec_poll_handle, section->expiration_timer);
  558. memcpy(savedSection, section, sizeof(struct saCkptCheckpointSection));
  559. list_init(&savedSection->list);
  560. list_add(&savedSection->list,&savedCheckpoint->checkpointSectionsListHead);
  561. }
  562. }
  563. if (list_empty (&checkpoint_recovery_list_head)) {
  564. return;
  565. }
  566. recovery_ckpt_next = checkpoint_recovery_list_head.next;
  567. savedCheckpoint = list_entry (recovery_ckpt_next,
  568. struct saCkptCheckpoint, list);
  569. recovery_ckpt_section_next = savedCheckpoint->checkpointSectionsListHead.next;
  570. }
  571. static int ckpt_recovery_process (void)
  572. {
  573. int i;
  574. struct req_exec_ckpt_synchronize_state request_exec_sync_state;
  575. struct req_exec_ckpt_synchronize_section request_exec_sync_section;
  576. struct iovec iovecs[3];
  577. struct saCkptCheckpoint *checkpoint;
  578. struct saCkptCheckpointSection *ckptCheckpointSection;
  579. SaSizeT origSectionSize;
  580. SaSizeT newSectionSize;
  581. if (recovery_abort) { /*Abort was called.*/
  582. goto recovery_exit_clean;
  583. }
  584. /*So Initialize did not have any checkpoints to Synchronize*/
  585. if ((recovery_ckpt_next == 0) && (recovery_ckpt_section_next == 0)) {
  586. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_process Nothing to Process ...\n");
  587. goto recovery_exit_clean;
  588. }
  589. /*
  590. * ALGORITHM :
  591. * 1.) extract the checkpoint if there.
  592. * 2.) If there is a checkpoint then there has to be a section
  593. * 3.) If the recovery_section_send_flag was not set in the previous
  594. * invocation that means we have to send out a sync_msg before
  595. * we send out the sections
  596. * 4.) Set the recovery_section_send_flag and send the sections.
  597. */
  598. while (1) { /*Go for as long as the oubound queue is not full*/
  599. if(recovery_ckpt_next != &checkpoint_recovery_list_head) {
  600. checkpoint = list_entry (recovery_ckpt_next,
  601. struct saCkptCheckpoint, list);
  602. if (recovery_ckpt_section_next == 0) {
  603. recovery_ckpt_section_next = checkpoint->checkpointSectionsListHead.next;
  604. }
  605. if (recovery_ckpt_section_next != &checkpoint->checkpointSectionsListHead) {
  606. ckptCheckpointSection = list_entry (recovery_ckpt_section_next,
  607. struct saCkptCheckpointSection, list);
  608. /*
  609. * None of the section data msgs have been sent
  610. * so lets start with sending the sync_msg
  611. */
  612. if (recovery_section_send_flag == 0) {
  613. if (ckptCheckpointSection->sectionDescriptor.sectionId.id) {
  614. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message for ckpt = %s, section = %s.\n",
  615. (char*)&checkpoint->name.value,
  616. ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id));
  617. } else {
  618. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message for ckpt = %s, section = default section.\n",
  619. (char*)&checkpoint->name.value);
  620. }
  621. request_exec_sync_state.header.size = sizeof (struct req_exec_ckpt_synchronize_state);
  622. request_exec_sync_state.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE;
  623. memcpy(&request_exec_sync_state.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
  624. memcpy(&request_exec_sync_state.checkpointName, &checkpoint->name, sizeof(SaNameT));
  625. memcpy(&request_exec_sync_state.checkpointCreationAttributes,
  626. &checkpoint->checkpointCreationAttributes,
  627. sizeof(SaCkptCheckpointCreationAttributesT));
  628. memcpy(&request_exec_sync_state.sectionDescriptor,
  629. &ckptCheckpointSection->sectionDescriptor,
  630. sizeof(SaCkptSectionDescriptorT));
  631. memcpy(&request_exec_sync_state.source_addr, &this_ip, sizeof(struct totem_ip_address));
  632. memcpy(request_exec_sync_state.ckpt_refcount,
  633. checkpoint->ckpt_refcount,
  634. sizeof(struct ckpt_refcnt)*PROCESSOR_COUNT_MAX);
  635. request_exec_sync_state.sectionDescriptor.sectionId.id = 0;
  636. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message Values\n");
  637. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  638. if (request_exec_sync_state.ckpt_refcount[i].addr.family == 0) {
  639. log_printf (LOG_LEVEL_DEBUG,"Index %d has proc 0 and count %d\n", i,
  640. request_exec_sync_state.ckpt_refcount[i].count);
  641. }
  642. else {
  643. log_printf (LOG_LEVEL_DEBUG,"Index %d has proc %s and count %d\n",
  644. i,
  645. totemip_print(&request_exec_sync_state.ckpt_refcount[i].addr),
  646. request_exec_sync_state.ckpt_refcount[i].count);
  647. }
  648. }
  649. iovecs[0].iov_base = (char *)&request_exec_sync_state;
  650. iovecs[0].iov_len = sizeof (struct req_exec_ckpt_synchronize_state);
  651. /*
  652. * Populate the Section ID
  653. */
  654. iovecs[1].iov_base = ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id);
  655. iovecs[1].iov_len = ckptCheckpointSection->sectionDescriptor.sectionId.idLen;
  656. request_exec_sync_state.header.size += iovecs[1].iov_len;
  657. /*
  658. * Check to see if we can queue the new message and if you can
  659. * then mcast the message else break and create callback.
  660. */
  661. if (totempg_groups_send_ok_joined (openais_group_handle, iovecs, 2)) {
  662. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  663. log_printf (LOG_LEVEL_DEBUG, "CKPT: Multicasted Sync State Message.\n");
  664. }
  665. else {
  666. log_printf (LOG_LEVEL_DEBUG, "CKPT: Sync State Message Outbound Queue full need to Wait for Callback.\n");
  667. return (1);
  668. }
  669. recovery_section_send_flag = 1;
  670. }
  671. origSectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize;
  672. newSectionSize = 0;
  673. /*
  674. * Now Create SyncSection messsages in chunks of CKPT_MAX_SECTION_DATA_SEND or less
  675. */
  676. while (recovery_section_data_offset < origSectionSize) {
  677. /*
  678. * Send a Max of CKPT_MAX_SECTION_DATA_SEND of section data
  679. */
  680. if ((origSectionSize - recovery_section_data_offset) > CKPT_MAX_SECTION_DATA_SEND) {
  681. newSectionSize = CKPT_MAX_SECTION_DATA_SEND;
  682. }
  683. else {
  684. newSectionSize = (origSectionSize - recovery_section_data_offset);
  685. }
  686. /*
  687. * Create and save a new Sync Section message.
  688. */
  689. request_exec_sync_section.header.size = sizeof (struct req_exec_ckpt_synchronize_section);
  690. request_exec_sync_section.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION;
  691. memcpy (&request_exec_sync_section.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
  692. memcpy (&request_exec_sync_section.checkpointName, &checkpoint->name, sizeof(SaNameT));
  693. memcpy (&request_exec_sync_section.sectionId,
  694. &ckptCheckpointSection->sectionDescriptor.sectionId,
  695. sizeof(SaCkptSectionIdT));
  696. request_exec_sync_section.sectionId.id = 0;
  697. memcpy (&request_exec_sync_section.dataOffSet, &recovery_section_data_offset, sizeof(SaUint32T));
  698. memcpy (&request_exec_sync_section.dataSize, &newSectionSize, sizeof(SaUint32T));
  699. if (ckptCheckpointSection->sectionDescriptor.sectionId.id) {
  700. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync Section Message for ckpt = %s, section = %s, Data size = %d.\n",
  701. (char*)&checkpoint->name.value,
  702. ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id),
  703. newSectionSize);
  704. } else {
  705. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync Section Message for ckpt = %s, default section, Data size = %d.\n",
  706. (char*)&checkpoint->name.value,newSectionSize);
  707. }
  708. /*
  709. * Populate the Sync Section Request
  710. */
  711. iovecs[0].iov_base = (char *)&request_exec_sync_section;
  712. iovecs[0].iov_len = sizeof (struct req_exec_ckpt_synchronize_section);
  713. /*
  714. * Populate the Section ID
  715. */
  716. iovecs[1].iov_base = ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id);
  717. iovecs[1].iov_len = ckptCheckpointSection->sectionDescriptor.sectionId.idLen;
  718. request_exec_sync_section.header.size += iovecs[1].iov_len;
  719. /*
  720. * Populate the Section Data.
  721. */
  722. iovecs[2].iov_base = ((char*)ckptCheckpointSection->sectionData + recovery_section_data_offset);
  723. iovecs[2].iov_len = newSectionSize;
  724. request_exec_sync_section.header.size += iovecs[2].iov_len;
  725. /*
  726. * Check to see if we can queue the new message and if you can
  727. * then mcast the message else break and create callback.
  728. */
  729. if (totempg_groups_send_ok_joined (openais_group_handle, iovecs, 2)) {
  730. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 3, TOTEMPG_AGREED) == 0);
  731. log_printf (LOG_LEVEL_DEBUG, "CKPT: Multicasted Sync Section Message.\n");
  732. }
  733. else {
  734. log_printf (LOG_LEVEL_DEBUG, "CKPT: Sync Section Message Outbound Queue full need to Wait for Callback.\n");
  735. return (1);
  736. }
  737. recovery_section_data_offset += newSectionSize;
  738. }
  739. recovery_section_send_flag = 0;
  740. recovery_section_data_offset = 0;
  741. recovery_ckpt_section_next = recovery_ckpt_section_next->next;
  742. continue;
  743. }
  744. else {
  745. /*
  746. * We have reached the end of a section List.
  747. * Move to the next element in the ckpt list.
  748. * Init the section ptr to 0 so it is re evaled
  749. */
  750. recovery_ckpt_next = recovery_ckpt_next->next;
  751. recovery_ckpt_section_next = 0;
  752. continue;
  753. }
  754. }
  755. /*Should only be here at the end of the traversal of the ckpt list*/
  756. ckpt_recovery_finalize();
  757. recovery_exit_clean:
  758. /*Re - Initialize the static's*/
  759. recovery_ckpt_next = 0;
  760. recovery_ckpt_section_next = 0;
  761. recovery_section_data_offset = 0;
  762. recovery_section_send_flag = 0;
  763. recovery_abort = 0;
  764. return (0);
  765. }
  766. }
  767. static void ckpt_recovery_finalize ()
  768. {
  769. struct list_head *checkpoint_list;
  770. struct list_head *checkpoint_section_list;
  771. struct saCkptCheckpoint *checkpoint;
  772. struct saCkptCheckpointSection *section;
  773. struct ckpt_identifier *ckpt_id;
  774. /*
  775. * Remove All elements from old checkpoint
  776. * list
  777. */
  778. checkpoint_list = checkpoint_list_head.next;
  779. while (!list_empty(&checkpoint_list_head)) {
  780. checkpoint = list_entry (checkpoint_list,
  781. struct saCkptCheckpoint, list);
  782. checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  783. while (!list_empty(&checkpoint->checkpointSectionsListHead)) {
  784. section = list_entry (checkpoint_section_list,
  785. struct saCkptCheckpointSection, list);
  786. list_del (&section->list);
  787. log_printf (LOG_LEVEL_DEBUG, "ckpt_recovery_finalize removed 0x%x.\n", section);
  788. free (section);
  789. checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  790. }
  791. list_del(&checkpoint->list);
  792. free(checkpoint);
  793. checkpoint_list = checkpoint_list_head.next;
  794. }
  795. /*
  796. * Initialize the old list again.
  797. */
  798. list_init(&checkpoint_list_head);
  799. /*
  800. * Copy the contents of the new list_head into the old list head
  801. */
  802. checkpoint_recovery_list_head.prev->next = &checkpoint_list_head;
  803. checkpoint_recovery_list_head.next->prev = &checkpoint_list_head;
  804. memcpy(&checkpoint_list_head, &checkpoint_recovery_list_head, sizeof(struct list_head));
  805. /*Timers might have been started before recovery happened .. restart them ..*/
  806. for (checkpoint_list = checkpoint_list_head.next;
  807. checkpoint_list != &checkpoint_list_head;
  808. checkpoint_list = checkpoint_list->next) {
  809. checkpoint = list_entry (checkpoint_list,
  810. struct saCkptCheckpoint, list);
  811. for (checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  812. checkpoint_section_list != &checkpoint->checkpointSectionsListHead;
  813. checkpoint_section_list = checkpoint_section_list->next) {
  814. section = list_entry (checkpoint_section_list,
  815. struct saCkptCheckpointSection, list);
  816. if (section->sectionDescriptor.expirationTime != SA_TIME_END) {
  817. ckpt_id = malloc (sizeof(struct ckpt_identifier));
  818. assert(ckpt_id);
  819. memcpy(&ckpt_id->ckpt_name,&checkpoint->name,sizeof(SaNameT));
  820. memcpy(&ckpt_id->ckpt_section_id, &section->sectionDescriptor.sectionId,sizeof(SaCkptSectionIdT));
  821. poll_timer_add (aisexec_poll_handle,
  822. abstime_to_msec (section->sectionDescriptor.expirationTime),
  823. ckpt_id,
  824. timer_function_section_expire,
  825. &section->expiration_timer);
  826. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_initialize expiration timer = 0x%x\n",
  827. section->expiration_timer);
  828. }
  829. }
  830. }
  831. /*
  832. * Initialize the new list head for reuse.
  833. */
  834. list_init(&checkpoint_recovery_list_head);
  835. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_finalize Done.\n");
  836. }
  837. static void ckpt_recovery_activate (void)
  838. {
  839. recovery_state = SYNCHRONY_STATE_ENDED;
  840. return;
  841. }
  842. static void ckpt_recovery_abort (void)
  843. {
  844. recovery_abort = 1;
  845. return;
  846. }
  847. static void ckpt_replace_localhost_ip (struct totem_ip_address *joined_list) {
  848. struct list_head *checkpoint_list;
  849. struct saCkptCheckpoint *checkpoint;
  850. struct totem_ip_address local_ip;
  851. int index;
  852. assert(joined_list);
  853. totemip_localhost(AF_INET, &local_ip);
  854. for (checkpoint_list = checkpoint_list_head.next;
  855. checkpoint_list != &checkpoint_list_head;
  856. checkpoint_list = checkpoint_list->next) {
  857. checkpoint = list_entry (checkpoint_list,
  858. struct saCkptCheckpoint, list);
  859. index = processor_index_find(&local_ip, checkpoint->ckpt_refcount);
  860. if (index == -1) {
  861. continue;
  862. }
  863. memcpy(&checkpoint->ckpt_refcount[index].addr, joined_list, sizeof(struct in_addr));
  864. log_printf (LOG_LEVEL_DEBUG, "Transitioning From Local Host replacing 127.0.0.1 with %s ...\n",
  865. totemip_print(joined_list));
  866. }
  867. process_localhost_transition = 0;
  868. }
  869. static void ckpt_recovery_process_members_exit(struct totem_ip_address *left_list,
  870. int left_list_entries)
  871. {
  872. struct list_head *checkpoint_list;
  873. struct saCkptCheckpoint *checkpoint;
  874. struct totem_ip_address *member;
  875. struct totem_ip_address local_ip;
  876. int index;
  877. int i;
  878. totemip_localhost(AF_INET, &local_ip);
  879. if (left_list_entries == 0) {
  880. return;
  881. }
  882. if ((left_list_entries == 1) &&
  883. (totemip_equal(left_list, &local_ip))) {
  884. process_localhost_transition = 1;
  885. return;
  886. }
  887. /*
  888. * Iterate left_list_entries.
  889. */
  890. member = left_list;
  891. for (i = 0; i < left_list_entries; i++) {
  892. checkpoint_list = checkpoint_list_head.next;
  893. iterate_while_loop:
  894. while (checkpoint_list != &checkpoint_list_head) {
  895. checkpoint = list_entry (checkpoint_list,
  896. struct saCkptCheckpoint, list);
  897. assert (checkpoint > 0);
  898. index = processor_index_find(member, checkpoint->ckpt_refcount);
  899. assert (-1 <= index);
  900. assert (index < PROCESSOR_COUNT_MAX);
  901. if (index < 0) {
  902. checkpoint_list = checkpoint_list->next;
  903. goto iterate_while_loop;
  904. }
  905. /*
  906. * Decrement
  907. *
  908. */
  909. if (checkpoint->referenceCount >= 0) {
  910. checkpoint->referenceCount -= checkpoint->ckpt_refcount[index].count;
  911. log_printf (LOG_LEVEL_DEBUG, "ckpt_recovery_process_members_exit: refCount for %s = %d.\n",
  912. &checkpoint->name.value,checkpoint->referenceCount);
  913. assert (checkpoint->referenceCount >= 0);
  914. } else {
  915. log_printf (LOG_LEVEL_ERROR, "ckpt_recovery_process_members_exit: refCount for %s = %d.\n",
  916. &checkpoint->name.value,checkpoint->referenceCount);
  917. assert(0);
  918. }
  919. checkpoint->ckpt_refcount[index].count = 0;
  920. memset((char*)&checkpoint->ckpt_refcount[index].addr, 0, sizeof(struct in_addr));
  921. checkpoint_list = checkpoint_list->next;
  922. }
  923. member++;
  924. }
  925. clean_checkpoint_list(&checkpoint_list_head);
  926. return;
  927. }
  928. void clean_checkpoint_list(struct list_head *head)
  929. {
  930. struct list_head *checkpoint_list;
  931. struct saCkptCheckpoint *checkpoint;
  932. if (list_empty(head)) {
  933. log_printf (LOG_LEVEL_NOTICE, "clean_checkpoint_list: List is empty \n");
  934. return;
  935. }
  936. checkpoint_list = head->next;
  937. while (checkpoint_list != head) {
  938. checkpoint = list_entry (checkpoint_list,
  939. struct saCkptCheckpoint, list);
  940. assert (checkpoint > 0);
  941. /*
  942. * If checkpoint has been unlinked and this is the last reference, delete it
  943. */
  944. if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
  945. log_printf (LOG_LEVEL_NOTICE,"clean_checkpoint_list: deallocating checkpoint %s.\n",
  946. &checkpoint->name.value);
  947. checkpoint_list = checkpoint_list->next;
  948. checkpoint_release (checkpoint);
  949. continue;
  950. }
  951. else if ((checkpoint->expired == 0) && (checkpoint->referenceCount == 0)) {
  952. log_printf (LOG_LEVEL_NOTICE, "clean_checkpoint_list: Starting timer to release checkpoint %s.\n",
  953. &checkpoint->name.value);
  954. poll_timer_delete (aisexec_poll_handle, checkpoint->retention_timer);
  955. poll_timer_add (aisexec_poll_handle,
  956. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  957. checkpoint,
  958. timer_function_retention,
  959. &checkpoint->retention_timer);
  960. }
  961. checkpoint_list = checkpoint_list->next;
  962. }
  963. }
  964. static int ckpt_confchg_fn (
  965. enum totem_configuration_type configuration_type,
  966. struct totem_ip_address *member_list, int member_list_entries,
  967. struct totem_ip_address *left_list, int left_list_entries,
  968. struct totem_ip_address *joined_list, int joined_list_entries,
  969. struct memb_ring_id *ring_id)
  970. {
  971. if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
  972. #ifdef TODO
  973. totempg_recovery_plug_unplug (ckpt_checkpoint_recovery_plug_handle);
  974. #endif
  975. if (recovery_state == SYNCHRONY_STATE_ENDED) {
  976. memcpy (&saved_ring_id, ring_id, sizeof(struct memb_ring_id));
  977. }
  978. if (process_localhost_transition) {
  979. ckpt_replace_localhost_ip (joined_list);
  980. }
  981. }
  982. else if (configuration_type == TOTEM_CONFIGURATION_TRANSITIONAL) {
  983. ckpt_recovery_process_members_exit(left_list, left_list_entries);
  984. recovery_state = SYNCHRONY_STATE_STARTED;
  985. recovery_abort = 0;
  986. }
  987. return (0);
  988. }
  989. static struct saCkptCheckpoint *ckpt_checkpoint_find_global (SaNameT *name)
  990. {
  991. struct list_head *checkpoint_list;
  992. struct saCkptCheckpoint *checkpoint;
  993. for (checkpoint_list = checkpoint_list_head.next;
  994. checkpoint_list != &checkpoint_list_head;
  995. checkpoint_list = checkpoint_list->next) {
  996. checkpoint = list_entry (checkpoint_list,
  997. struct saCkptCheckpoint, list);
  998. if (name_match (name, &checkpoint->name)) {
  999. return (checkpoint);
  1000. }
  1001. }
  1002. return (0);
  1003. }
  1004. static void ckpt_checkpoint_remove_cleanup (
  1005. struct conn_info *conn_info,
  1006. struct saCkptCheckpoint *checkpoint)
  1007. {
  1008. struct list_head *list;
  1009. struct checkpoint_cleanup *checkpoint_cleanup;
  1010. for (list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next;
  1011. list != &conn_info->ais_ci.u.libckpt_ci.checkpoint_list;
  1012. list = list->next) {
  1013. checkpoint_cleanup = list_entry (list,
  1014. struct checkpoint_cleanup, list);
  1015. if (name_match (&checkpoint_cleanup->checkpoint.name, &checkpoint->name)
  1016. || (checkpoint_cleanup->checkpoint.name.length == 0)) {
  1017. list_del (&checkpoint_cleanup->list);
  1018. free (checkpoint_cleanup);
  1019. return;
  1020. }
  1021. }
  1022. }
  1023. static struct saCkptCheckpointSection *ckpt_checkpoint_find_globalSection (
  1024. struct saCkptCheckpoint *ckptCheckpoint,
  1025. char *id,
  1026. int idLen)
  1027. {
  1028. struct list_head *checkpoint_section_list;
  1029. struct saCkptCheckpointSection *ckptCheckpointSection;
  1030. if (idLen != 0) {
  1031. log_printf (LOG_LEVEL_DEBUG, "Finding checkpoint section id %s %d\n", (char*)id, idLen);
  1032. }
  1033. else {
  1034. log_printf (LOG_LEVEL_DEBUG, "Finding default checkpoint section\n");
  1035. }
  1036. for (checkpoint_section_list = ckptCheckpoint->checkpointSectionsListHead.next;
  1037. checkpoint_section_list != &ckptCheckpoint->checkpointSectionsListHead;
  1038. checkpoint_section_list = checkpoint_section_list->next) {
  1039. ckptCheckpointSection = list_entry (checkpoint_section_list,
  1040. struct saCkptCheckpointSection, list);
  1041. if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen) {
  1042. log_printf (LOG_LEVEL_DEBUG, "Checking section id %*s\n",
  1043. ckptCheckpointSection->sectionDescriptor.sectionId.idLen,
  1044. ckptCheckpointSection->sectionDescriptor.sectionId.id);
  1045. }
  1046. else {
  1047. log_printf (LOG_LEVEL_DEBUG, "Checking default section id\n");
  1048. }
  1049. /*
  1050. All 3 of these values being checked MUST be = 0 to return
  1051. The default section. If even one of them is NON zero follow
  1052. the normal route
  1053. */
  1054. if ((idLen ||
  1055. ckptCheckpointSection->sectionDescriptor.sectionId.id ||
  1056. ckptCheckpointSection->sectionDescriptor.sectionId.idLen) == 0) {
  1057. log_printf (LOG_LEVEL_DEBUG, "Returning default section\n");
  1058. return (ckptCheckpointSection);
  1059. }
  1060. if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen == idLen &&
  1061. (ckptCheckpointSection->sectionDescriptor.sectionId.id)&&
  1062. (id)&&
  1063. (memcmp (ckptCheckpointSection->sectionDescriptor.sectionId.id,
  1064. id, idLen) == 0)) {
  1065. log_printf (LOG_LEVEL_DEBUG, "Returning section %s(0x%x)\n", ckptCheckpointSection->sectionDescriptor.sectionId.id,
  1066. ckptCheckpointSection);
  1067. return (ckptCheckpointSection);
  1068. }
  1069. }
  1070. return 0;
  1071. }
  1072. void checkpoint_section_release (struct saCkptCheckpointSection *section)
  1073. {
  1074. log_printf (LOG_LEVEL_DEBUG, "CKPT: checkpoint_section_release expiration timer = 0x%x\n", section->expiration_timer);
  1075. list_del (&section->list);
  1076. if (section->sectionDescriptor.sectionId.id) {
  1077. free (section->sectionDescriptor.sectionId.id);
  1078. }
  1079. if (section->sectionData) {
  1080. free (section->sectionData);
  1081. }
  1082. poll_timer_delete (aisexec_poll_handle, section->expiration_timer);
  1083. free (section);
  1084. }
  1085. void checkpoint_release (struct saCkptCheckpoint *checkpoint)
  1086. {
  1087. struct list_head *list;
  1088. struct saCkptCheckpointSection *section;
  1089. poll_timer_delete (aisexec_poll_handle, checkpoint->retention_timer);
  1090. /*
  1091. * Release all checkpoint sections for this checkpoint
  1092. */
  1093. for (list = checkpoint->checkpointSectionsListHead.next;
  1094. list != &checkpoint->checkpointSectionsListHead;) {
  1095. section = list_entry (list,
  1096. struct saCkptCheckpointSection, list);
  1097. list = list->next;
  1098. checkpoint->sectionCount -= 1;
  1099. checkpoint_section_release (section);
  1100. }
  1101. list_del (&checkpoint->list);
  1102. free (checkpoint);
  1103. }
  1104. int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) {
  1105. struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
  1106. struct iovec iovecs[2];
  1107. if (checkpoint->expired == 1) {
  1108. return (0);
  1109. }
  1110. req_exec_ckpt_checkpointclose.header.size =
  1111. sizeof (struct req_exec_ckpt_checkpointclose);
  1112. req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
  1113. memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
  1114. &checkpoint->name, sizeof (SaNameT));
  1115. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose;
  1116. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
  1117. if (totempg_groups_send_ok_joined (openais_group_handle, iovecs, 1)) {
  1118. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  1119. return (0);
  1120. }
  1121. return (-1);
  1122. }
  1123. static int ckpt_exec_init_fn (struct openais_config *openais_config)
  1124. {
  1125. /*
  1126. * Initialize the saved ring ID.
  1127. */
  1128. saved_ring_id.seq = 0;
  1129. totemip_copy(&saved_ring_id.rep, this_ip);
  1130. #ifdef TODO
  1131. int res;
  1132. res = totempg_recovery_plug_create (&ckpt_checkpoint_recovery_plug_handle);
  1133. if (res != 0) {
  1134. log_printf(LOG_LEVEL_ERROR,
  1135. "Could not create recovery plug for clm service.\n");
  1136. return (-1);
  1137. }
  1138. #endif
  1139. return (0);
  1140. }
  1141. static int ckpt_exit_fn (struct conn_info *conn_info)
  1142. {
  1143. struct checkpoint_cleanup *checkpoint_cleanup;
  1144. struct list_head *cleanup_list;
  1145. if (conn_info->conn_info_partner->service != CKPT_SERVICE) {
  1146. return 0;
  1147. }
  1148. log_printf(LOG_LEVEL_DEBUG, "ckpt_exit_fn conn_info = %#x, with fd = %d\n", conn_info, conn_info->fd);
  1149. /*
  1150. * close all checkpoints opened on this fd
  1151. */
  1152. cleanup_list = conn_info->conn_info_partner->ais_ci.u.libckpt_ci.checkpoint_list.next;
  1153. while (!list_empty(&conn_info->conn_info_partner->ais_ci.u.libckpt_ci.checkpoint_list)) {
  1154. checkpoint_cleanup = list_entry (cleanup_list,
  1155. struct checkpoint_cleanup, list);
  1156. if (checkpoint_cleanup->checkpoint.name.length > 0) {
  1157. ckpt_checkpoint_close (&checkpoint_cleanup->checkpoint);
  1158. }
  1159. list_del (&checkpoint_cleanup->list);
  1160. free (checkpoint_cleanup);
  1161. cleanup_list = conn_info->conn_info_partner->ais_ci.u.libckpt_ci.checkpoint_list.next;
  1162. }
  1163. if (conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) {
  1164. free (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries);
  1165. }
  1166. list_del (&conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.list);
  1167. return (0);
  1168. }
  1169. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1170. {
  1171. struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message;
  1172. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)&req_exec_ckpt_checkpointopen->req_lib_ckpt_checkpointopen;
  1173. struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
  1174. struct res_lib_ckpt_checkpointopenasync res_lib_ckpt_checkpointopenasync;
  1175. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1176. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  1177. struct checkpoint_cleanup *checkpoint_cleanup = 0;
  1178. SaErrorT error = SA_AIS_OK;
  1179. int proc_index;
  1180. log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen);
  1181. if (req_exec_ckpt_checkpointopen->fail_with_error != SA_AIS_OK) {
  1182. error = req_exec_ckpt_checkpointopen->fail_with_error;
  1183. goto error_exit;
  1184. }
  1185. if (message_source_is_local(&req_exec_ckpt_checkpointopen->source)) {
  1186. checkpoint_cleanup = malloc (sizeof (struct checkpoint_cleanup));
  1187. if (checkpoint_cleanup == 0) {
  1188. error = SA_AIS_ERR_NO_MEMORY;
  1189. goto error_exit;
  1190. }
  1191. }
  1192. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointopen->checkpointName);
  1193. /*
  1194. * If checkpoint doesn't exist, create one
  1195. */
  1196. if (ckptCheckpoint == 0) {
  1197. if ((req_lib_ckpt_checkpointopen->checkpointOpenFlags & SA_CKPT_CHECKPOINT_CREATE) == 0) {
  1198. error = SA_AIS_ERR_NOT_EXIST;
  1199. goto error_exit;
  1200. }
  1201. ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
  1202. if (ckptCheckpoint == 0) {
  1203. error = SA_AIS_ERR_NO_MEMORY;
  1204. goto error_exit;
  1205. }
  1206. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1207. if (ckptCheckpointSection == 0) {
  1208. free (ckptCheckpoint);
  1209. error = SA_AIS_ERR_NO_MEMORY;
  1210. goto error_exit;
  1211. }
  1212. memcpy (&ckptCheckpoint->name,
  1213. &req_lib_ckpt_checkpointopen->checkpointName,
  1214. sizeof (SaNameT));
  1215. memcpy (&ckptCheckpoint->checkpointCreationAttributes,
  1216. &req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
  1217. sizeof (SaCkptCheckpointCreationAttributesT));
  1218. ckptCheckpoint->unlinked = 0;
  1219. list_init (&ckptCheckpoint->list);
  1220. list_init (&ckptCheckpoint->checkpointSectionsListHead);
  1221. list_add (&ckptCheckpoint->list, &checkpoint_list_head);
  1222. ckptCheckpoint->referenceCount = 0;
  1223. ckptCheckpoint->retention_timer = 0;
  1224. ckptCheckpoint->expired = 0;
  1225. ckptCheckpoint->sectionCount = 0;
  1226. if ((ckptCheckpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) &&
  1227. (ckptCheckpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) {
  1228. ckptCheckpoint->active_replica_set = 1;
  1229. } else
  1230. if ((ckptCheckpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_WR_ALL_REPLICAS) == 1) {
  1231. ckptCheckpoint->active_replica_set = 1;
  1232. } else {
  1233. ckptCheckpoint->active_replica_set = 0;
  1234. }
  1235. initialize_ckpt_refcount_array(ckptCheckpoint->ckpt_refcount);
  1236. /*
  1237. * Add in default checkpoint section
  1238. */
  1239. list_init (&ckptCheckpointSection->list);
  1240. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  1241. /*
  1242. * Default section id
  1243. */
  1244. ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
  1245. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
  1246. ckptCheckpointSection->sectionDescriptor.expirationTime = SA_TIME_END;
  1247. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1248. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /*current time*/
  1249. ckptCheckpointSection->sectionDescriptor.sectionSize = strlen("Factory installed data\0")+1;
  1250. ckptCheckpointSection->sectionData = malloc(strlen("Factory installed data\0")+1);
  1251. assert(ckptCheckpointSection->sectionData);
  1252. memcpy(ckptCheckpointSection->sectionData, "Factory installed data\0", strlen("Factory installed data\0")+1);
  1253. ckptCheckpointSection->expiration_timer = 0;
  1254. } else {
  1255. if (req_lib_ckpt_checkpointopen->checkpointCreationAttributesSet &&
  1256. memcmp (&ckptCheckpoint->checkpointCreationAttributes,
  1257. &req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
  1258. sizeof (SaCkptCheckpointCreationAttributesT)) != 0) {
  1259. error = SA_AIS_ERR_EXIST;
  1260. goto error_exit;
  1261. }
  1262. }
  1263. /*
  1264. * If the checkpoint has been unlinked, it is an invalid name
  1265. */
  1266. if (ckptCheckpoint->unlinked) {
  1267. error = SA_AIS_ERR_NOT_EXIST; /* Is this the correct return ? */
  1268. goto error_exit;
  1269. }
  1270. /*
  1271. * Setup connection information and mark checkpoint as referenced
  1272. */
  1273. log_printf (LOG_LEVEL_DEBUG, "CHECKPOINT opened is %p\n", ckptCheckpoint);
  1274. ckptCheckpoint->referenceCount += 1;
  1275. /*
  1276. * Add the connection reference information to the Checkpoint to be
  1277. * sent out later as a part of the sync process.
  1278. *
  1279. */
  1280. proc_index = processor_index_find(source_addr,ckptCheckpoint->ckpt_refcount);
  1281. if (proc_index == -1) {/* Could not find, lets set the processor to an index.*/
  1282. proc_index = processor_index_set(source_addr,ckptCheckpoint->ckpt_refcount);
  1283. }
  1284. if (proc_index != -1 ) {
  1285. totemip_copy(&ckptCheckpoint->ckpt_refcount[proc_index].addr, source_addr);
  1286. ckptCheckpoint->ckpt_refcount[proc_index].count++;
  1287. }
  1288. else {
  1289. log_printf (LOG_LEVEL_ERROR,
  1290. "CKPT: MAX LIMIT OF PROCESSORS reached. Cannot store new proc %p info.\n",
  1291. ckptCheckpoint);
  1292. }
  1293. /*
  1294. * Reset retention duration since this checkpoint was just opened
  1295. */
  1296. poll_timer_delete (aisexec_poll_handle, ckptCheckpoint->retention_timer);
  1297. ckptCheckpoint->retention_timer = 0;
  1298. /*
  1299. * Send error result to CKPT library
  1300. */
  1301. error_exit:
  1302. /*
  1303. * If this node was the source of the message, respond to this node
  1304. */
  1305. if (message_source_is_local(&req_exec_ckpt_checkpointopen->source)) {
  1306. /*
  1307. * If its an async call respond with the invocation and handle
  1308. */
  1309. if (req_exec_ckpt_checkpointopen->async_call) {
  1310. res_lib_ckpt_checkpointopenasync.header.size = sizeof (struct res_lib_ckpt_checkpointopenasync);
  1311. res_lib_ckpt_checkpointopenasync.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC;
  1312. res_lib_ckpt_checkpointopenasync.header.error = error;
  1313. res_lib_ckpt_checkpointopenasync.checkpointHandle = req_exec_ckpt_checkpointopen->checkpointHandle;
  1314. res_lib_ckpt_checkpointopenasync.invocation = req_exec_ckpt_checkpointopen->invocation;
  1315. libais_send_response (
  1316. req_exec_ckpt_checkpointopen->source.conn_info,
  1317. &res_lib_ckpt_checkpointopenasync,
  1318. sizeof (struct res_lib_ckpt_checkpointopenasync));
  1319. libais_send_response (
  1320. req_exec_ckpt_checkpointopen->source.conn_info->conn_info_partner,
  1321. &res_lib_ckpt_checkpointopenasync,
  1322. sizeof (struct res_lib_ckpt_checkpointopenasync));
  1323. } else {
  1324. /*
  1325. * otherwise respond with the normal checkpointopen response
  1326. */
  1327. res_lib_ckpt_checkpointopen.header.size = sizeof (struct res_lib_ckpt_checkpointopen);
  1328. res_lib_ckpt_checkpointopen.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN;
  1329. res_lib_ckpt_checkpointopen.header.error = error;
  1330. libais_send_response (req_exec_ckpt_checkpointopen->source.conn_info, &res_lib_ckpt_checkpointopen,
  1331. sizeof (struct res_lib_ckpt_checkpointopen));
  1332. }
  1333. /*
  1334. * This is the path taken when all goes well and this call was local
  1335. */
  1336. if (error == SA_AIS_OK) {
  1337. memcpy(&checkpoint_cleanup->checkpoint,ckptCheckpoint,sizeof(struct saCkptCheckpoint));
  1338. list_add (&checkpoint_cleanup->list,
  1339. &req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpoint_list);
  1340. } else {
  1341. /*
  1342. * We allocated this in the hope of using it but an error occured
  1343. * so deallocate it.
  1344. */
  1345. free (checkpoint_cleanup);
  1346. }
  1347. }
  1348. return (0);
  1349. }
  1350. static int recovery_checkpoint_open(SaNameT *checkpointName,
  1351. SaCkptCheckpointCreationAttributesT *ckptAttributes,
  1352. struct ckpt_refcnt *ref_cnt)
  1353. {
  1354. int i;
  1355. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1356. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  1357. SaErrorT error = SA_AIS_OK;
  1358. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open %s\n", &checkpointName->value);
  1359. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open refcount Values\n");
  1360. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  1361. if (ref_cnt[i].addr.family == 0) {
  1362. log_printf (LOG_LEVEL_DEBUG,"Index %d has proc 0 and count %d\n", i,
  1363. ref_cnt[i].count);
  1364. }
  1365. else {
  1366. log_printf (LOG_LEVEL_DEBUG,"Index %d has proc %s and count %d\n",
  1367. i,
  1368. totemip_print(&ref_cnt[i].addr),
  1369. ref_cnt[i].count);
  1370. }
  1371. }
  1372. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  1373. /*
  1374. * If checkpoint doesn't exist, create one
  1375. */
  1376. if (ckptCheckpoint == 0) {
  1377. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open Allocating new Checkpoint %s\n", &checkpointName->value);
  1378. ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
  1379. if (ckptCheckpoint == 0) {
  1380. error = SA_AIS_ERR_NO_MEMORY;
  1381. goto error_exit;
  1382. }
  1383. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1384. if (ckptCheckpointSection == 0) {
  1385. free (ckptCheckpoint);
  1386. error = SA_AIS_ERR_NO_MEMORY;
  1387. goto error_exit;
  1388. }
  1389. memcpy (&ckptCheckpoint->name,
  1390. checkpointName,
  1391. sizeof (SaNameT));
  1392. memcpy (&ckptCheckpoint->checkpointCreationAttributes,
  1393. ckptAttributes,
  1394. sizeof (SaCkptCheckpointCreationAttributesT));
  1395. ckptCheckpoint->unlinked = 0;
  1396. list_init (&ckptCheckpoint->list);
  1397. list_init (&ckptCheckpoint->checkpointSectionsListHead);
  1398. list_add (&ckptCheckpoint->list, &checkpoint_list_head);
  1399. ckptCheckpoint->retention_timer = 0;
  1400. ckptCheckpoint->expired = 0;
  1401. /*
  1402. * Add in default checkpoint section
  1403. */
  1404. list_init (&ckptCheckpointSection->list);
  1405. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  1406. /*
  1407. * Default section id
  1408. */
  1409. ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
  1410. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
  1411. ckptCheckpointSection->sectionDescriptor.expirationTime = SA_TIME_END;
  1412. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1413. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /*current time*/
  1414. ckptCheckpointSection->sectionDescriptor.sectionSize = strlen("Factory installed data\0")+1;
  1415. ckptCheckpointSection->sectionData = malloc(strlen("Factory installed data\0")+1);
  1416. assert(ckptCheckpointSection->sectionData);
  1417. memcpy(ckptCheckpointSection->sectionData, "Factory installed data\0", strlen("Factory installed data\0")+1);
  1418. ckptCheckpointSection->expiration_timer = 0;
  1419. if ((ckptCheckpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) &&
  1420. (ckptCheckpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) {
  1421. ckptCheckpoint->active_replica_set = 1;
  1422. } else
  1423. if ((ckptCheckpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_WR_ALL_REPLICAS) == 1) {
  1424. ckptCheckpoint->active_replica_set = 1;
  1425. } else {
  1426. ckptCheckpoint->active_replica_set = 0;
  1427. }
  1428. initialize_ckpt_refcount_array(ckptCheckpoint->ckpt_refcount);
  1429. }
  1430. else {
  1431. /*
  1432. * Setup connection information and mark checkpoint as referenced
  1433. */
  1434. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery CHECKPOINT reopened is %p\n", ckptCheckpoint);
  1435. }
  1436. /*
  1437. * If the checkpoint has been unlinked, it is an invalid name
  1438. */
  1439. if (ckptCheckpoint->unlinked) {
  1440. error = SA_AIS_ERR_BAD_OPERATION; /* Is this the correct return ? */
  1441. goto error_exit;
  1442. }
  1443. /*CHECK to see if there are any existing ckpts*/
  1444. if ((ckptCheckpoint->ckpt_refcount) && (ckpt_refcount_total(ckptCheckpoint->ckpt_refcount) > 0)) {
  1445. log_printf (LOG_LEVEL_DEBUG,"calling merge_ckpt_refcounts\n");
  1446. merge_ckpt_refcounts(ckptCheckpoint->ckpt_refcount, ref_cnt);
  1447. }
  1448. else {
  1449. initialize_ckpt_refcount_array(ckptCheckpoint->ckpt_refcount);
  1450. }
  1451. /*No Existing ckpts. Lets assign what we got over the network or the merged with network values*/
  1452. ckptCheckpoint->referenceCount = ckpt_refcount_total(ref_cnt);
  1453. log_printf (LOG_LEVEL_DEBUG, "CKPT: OPEN ckptCheckpoint->referenceCount %d\n",ckptCheckpoint->referenceCount);
  1454. memcpy(ckptCheckpoint->ckpt_refcount,ref_cnt,sizeof(struct ckpt_refcnt)*PROCESSOR_COUNT_MAX);
  1455. /*
  1456. * Reset retention duration since this checkpoint was just opened
  1457. */
  1458. poll_timer_delete (aisexec_poll_handle, ckptCheckpoint->retention_timer);
  1459. ckptCheckpoint->retention_timer = 0;
  1460. /*
  1461. * Send error result to CKPT library
  1462. */
  1463. error_exit:
  1464. return (error);
  1465. }
  1466. static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1467. {
  1468. int retcode;
  1469. struct req_exec_ckpt_synchronize_state *req_exec_ckpt_sync_state
  1470. = (struct req_exec_ckpt_synchronize_state *)message;
  1471. /*
  1472. * If the Incoming message's previous ring id == saved_ring_id
  1473. * Ignore because we have seen this message before.
  1474. */
  1475. if (memcmp (&req_exec_ckpt_sync_state->previous_ring_id, &saved_ring_id,sizeof (struct memb_ring_id)) == 0) {
  1476. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state ignoring ...\n");
  1477. return(0);
  1478. }
  1479. retcode = recovery_checkpoint_open(&req_exec_ckpt_sync_state->checkpointName,
  1480. &req_exec_ckpt_sync_state->checkpointCreationAttributes,
  1481. req_exec_ckpt_sync_state->ckpt_refcount);
  1482. if (retcode != SA_AIS_OK) {
  1483. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state\n");
  1484. log_printf(LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open returned %d\n",retcode);
  1485. }
  1486. retcode = recovery_section_create (&req_exec_ckpt_sync_state->sectionDescriptor,
  1487. &req_exec_ckpt_sync_state->checkpointName,
  1488. (char*)req_exec_ckpt_sync_state
  1489. + sizeof (struct req_exec_ckpt_synchronize_state));
  1490. if (retcode != SA_AIS_OK) {
  1491. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state\n");
  1492. log_printf(LOG_LEVEL_DEBUG, "CKPT: recovery_section_create returned %d\n",retcode);
  1493. }
  1494. return (0);
  1495. }
  1496. static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1497. {
  1498. int retcode;
  1499. struct req_exec_ckpt_synchronize_section *req_exec_ckpt_sync_section
  1500. = (struct req_exec_ckpt_synchronize_section *)message;
  1501. /*
  1502. * If the Incoming message's previous ring id == saved_ring_id
  1503. * Ignore because we have seen this message before.
  1504. */
  1505. if (memcmp (&req_exec_ckpt_sync_section->previous_ring_id, &saved_ring_id,sizeof (struct memb_ring_id)) == 0) {
  1506. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_section ignoring ...\n");
  1507. return(0);
  1508. }
  1509. /*
  1510. * Write the contents of the section to the checkpoint section.
  1511. */
  1512. retcode = recovery_section_write(req_exec_ckpt_sync_section->sectionId.idLen,
  1513. (char*)req_exec_ckpt_sync_section
  1514. + sizeof (struct req_exec_ckpt_synchronize_section),
  1515. &req_exec_ckpt_sync_section->checkpointName,
  1516. (char*)req_exec_ckpt_sync_section
  1517. + sizeof (struct req_exec_ckpt_synchronize_section)
  1518. + req_exec_ckpt_sync_section->sectionId.idLen,
  1519. req_exec_ckpt_sync_section->dataOffSet,
  1520. req_exec_ckpt_sync_section->dataSize);
  1521. if (retcode != SA_AIS_OK) {
  1522. log_printf(LOG_LEVEL_ERROR, "CKPT: message_handler_req_exec_ckpt_synchronize_section\n");
  1523. log_printf(LOG_LEVEL_ERROR, "CKPT: recovery_section_write returned %d\n",retcode);
  1524. }
  1525. return (0);
  1526. }
  1527. unsigned int abstime_to_msec (SaTimeT time)
  1528. {
  1529. struct timeval tv;
  1530. unsigned long long curr_time;
  1531. unsigned long long msec_time;
  1532. gettimeofday (&tv, NULL);
  1533. curr_time = ((((unsigned long long)tv.tv_sec) * ((unsigned long)1000)) +
  1534. (((unsigned long long)tv.tv_usec) / ((unsigned long long)1000)));
  1535. msec_time = (((unsigned long long)time) / 1000000) -
  1536. (unsigned long long)curr_time;
  1537. return ((unsigned int)(msec_time));
  1538. }
  1539. void timer_function_section_expire (void *data)
  1540. {
  1541. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1542. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  1543. struct ckpt_identifier *ckpt_id = 0;
  1544. ckpt_id = (struct ckpt_identifier *)data;
  1545. log_printf (LOG_LEVEL_DEBUG, "CKPT: timer_function_section_expire data = 0x%x \n",data);
  1546. if (ckpt_id->ckpt_section_id.idLen && ckpt_id->ckpt_section_id.id) {
  1547. log_printf (LOG_LEVEL_DEBUG, "CKPT: Attempting to Expire section %s in ckpt %s\n",
  1548. ckpt_id->ckpt_section_id.id,
  1549. (char *)&ckpt_id->ckpt_name.value);
  1550. }
  1551. else {
  1552. log_printf (LOG_LEVEL_ERROR, "CKPT: timer_function_section_expire data incorect\n");
  1553. goto free_mem;
  1554. }
  1555. ckptCheckpoint = ckpt_checkpoint_find_global (&ckpt_id->ckpt_name);
  1556. if (ckptCheckpoint == 0) {
  1557. log_printf (LOG_LEVEL_ERROR, "CKPT: timer_function_section_expire could not find ckpt %s\n",
  1558. (char *)&ckpt_id->ckpt_name.value);
  1559. goto free_mem;
  1560. }
  1561. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1562. (char *)ckpt_id->ckpt_section_id.id,
  1563. (int)ckpt_id->ckpt_section_id.idLen);
  1564. if (ckptCheckpointSection == 0) {
  1565. log_printf (LOG_LEVEL_ERROR, "CKPT: timer_function_section_expire could not find section %s in ckpt %s\n",
  1566. ckpt_id->ckpt_section_id.id,
  1567. (char *)&ckpt_id->ckpt_name.value);
  1568. goto free_mem;
  1569. }
  1570. log_printf (LOG_LEVEL_DEBUG, "CKPT: Expiring section %s in ckpt %s\n",
  1571. ckpt_id->ckpt_section_id.id,
  1572. (char *)&ckpt_id->ckpt_name.value);
  1573. ckptCheckpoint->sectionCount -= 1;
  1574. checkpoint_section_release (ckptCheckpointSection);
  1575. free_mem :
  1576. free (ckpt_id);
  1577. }
  1578. void timer_function_retention (void *data)
  1579. {
  1580. struct saCkptCheckpoint *checkpoint = (struct saCkptCheckpoint *)data;
  1581. struct req_exec_ckpt_checkpointretentiondurationexpire req_exec_ckpt_checkpointretentiondurationexpire;
  1582. struct iovec iovec;
  1583. checkpoint->retention_timer = 0;
  1584. req_exec_ckpt_checkpointretentiondurationexpire.header.size =
  1585. sizeof (struct req_exec_ckpt_checkpointretentiondurationexpire);
  1586. req_exec_ckpt_checkpointretentiondurationexpire.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE;
  1587. memcpy (&req_exec_ckpt_checkpointretentiondurationexpire.checkpointName,
  1588. &checkpoint->name,
  1589. sizeof (SaNameT));
  1590. iovec.iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationexpire;
  1591. iovec.iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationexpire);
  1592. assert (totempg_groups_mcast_joined (openais_group_handle, &iovec, 1, TOTEMPG_AGREED) == 0);
  1593. }
  1594. extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1595. {
  1596. struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message;
  1597. struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose;
  1598. struct saCkptCheckpoint *checkpoint = 0;
  1599. SaAisErrorT error = SA_AIS_OK;
  1600. int proc_index;
  1601. int release_checkpoint = 0;
  1602. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to close checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointclose->checkpointName));
  1603. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointclose->checkpointName);
  1604. if (checkpoint == 0) {
  1605. goto error_exit;
  1606. }
  1607. log_printf (LOG_LEVEL_DEBUG, "CKPT:CLOSE checkpoint->referenceCount %d\n",checkpoint->referenceCount);
  1608. checkpoint->referenceCount--;
  1609. /*
  1610. * Modify the connection reference information to the Checkpoint to be
  1611. * sent out later as a part of the sync process.
  1612. */
  1613. proc_index = processor_index_find(source_addr, checkpoint->ckpt_refcount);
  1614. if (proc_index != -1 ) {
  1615. checkpoint->ckpt_refcount[proc_index].count--;
  1616. }
  1617. else {
  1618. log_printf (LOG_LEVEL_ERROR,
  1619. "CKPT: Could Not find Processor Info %p info.\n",
  1620. checkpoint);
  1621. }
  1622. assert (checkpoint->referenceCount >= 0);
  1623. log_printf (LOG_LEVEL_DEBUG, "disconnect called, new CKPT ref count is %d\n",
  1624. checkpoint->referenceCount);
  1625. /*
  1626. * If checkpoint has been unlinked and this is the last reference, delete it
  1627. */
  1628. if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
  1629. log_printf (LOG_LEVEL_DEBUG, "Unlinking checkpoint.\n");
  1630. release_checkpoint = 1;
  1631. } else
  1632. if (checkpoint->referenceCount == 0) {
  1633. poll_timer_add (aisexec_poll_handle,
  1634. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  1635. checkpoint,
  1636. timer_function_retention,
  1637. &checkpoint->retention_timer);
  1638. }
  1639. error_exit:
  1640. /*Remove the checkpoint from my connections checkpoint list*/
  1641. if (message_source_is_local(&req_exec_ckpt_checkpointclose->source)) {
  1642. ckpt_checkpoint_remove_cleanup (req_exec_ckpt_checkpointclose->source.conn_info,
  1643. checkpoint);
  1644. res_lib_ckpt_checkpointclose.header.size = sizeof (struct res_lib_ckpt_checkpointclose);
  1645. res_lib_ckpt_checkpointclose.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE;
  1646. res_lib_ckpt_checkpointclose.header.error = error;
  1647. libais_send_response (req_exec_ckpt_checkpointclose->source.conn_info,
  1648. &res_lib_ckpt_checkpointclose, sizeof (struct res_lib_ckpt_checkpointclose));
  1649. }
  1650. /*Release the checkpoint if instructed to do so.*/
  1651. if (release_checkpoint) {
  1652. checkpoint_release(checkpoint);
  1653. }
  1654. return (0);
  1655. }
  1656. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1657. {
  1658. struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message;
  1659. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)&req_exec_ckpt_checkpointunlink->req_lib_ckpt_checkpointunlink;
  1660. struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink;
  1661. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1662. SaErrorT error = SA_AIS_OK;
  1663. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink);
  1664. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointunlink->checkpointName);
  1665. if (ckptCheckpoint == 0) {
  1666. error = SA_AIS_ERR_NOT_EXIST;
  1667. goto error_exit;
  1668. }
  1669. if (ckptCheckpoint->unlinked) {
  1670. error = SA_AIS_ERR_INVALID_PARAM;
  1671. goto error_exit;
  1672. }
  1673. ckptCheckpoint->unlinked = 1;
  1674. /*
  1675. * Immediately delete entry if reference count is zero
  1676. */
  1677. if (ckptCheckpoint->referenceCount == 0) {
  1678. /*
  1679. * Remove retention timer since this checkpoint was unlinked and is no
  1680. * longer referenced
  1681. */
  1682. checkpoint_release (ckptCheckpoint);
  1683. }
  1684. error_exit:
  1685. /*
  1686. * If this node was the source of the message, respond to this node
  1687. */
  1688. if (message_source_is_local(&req_exec_ckpt_checkpointunlink->source)) {
  1689. res_lib_ckpt_checkpointunlink.header.size = sizeof (struct res_lib_ckpt_checkpointunlink);
  1690. res_lib_ckpt_checkpointunlink.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
  1691. res_lib_ckpt_checkpointunlink.header.error = error;
  1692. libais_send_response (req_exec_ckpt_checkpointunlink->source.conn_info, &res_lib_ckpt_checkpointunlink,
  1693. sizeof (struct res_lib_ckpt_checkpointunlink));
  1694. }
  1695. return (0);
  1696. }
  1697. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1698. {
  1699. struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message;
  1700. struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset;
  1701. struct saCkptCheckpoint *checkpoint;
  1702. SaAisErrorT error = SA_AIS_ERR_BAD_OPERATION;
  1703. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationset->checkpointName);
  1704. if (checkpoint) {
  1705. log_printf (LOG_LEVEL_DEBUG, "CKPT: Setting retention duration for checkpoint %s\n",
  1706. getSaNameT (&req_exec_ckpt_checkpointretentiondurationset->checkpointName));
  1707. if (checkpoint->unlinked == 0) {
  1708. checkpoint->checkpointCreationAttributes.retentionDuration =
  1709. req_exec_ckpt_checkpointretentiondurationset->retentionDuration;
  1710. if (checkpoint->expired == 0 && checkpoint->referenceCount == 0) {
  1711. poll_timer_delete (aisexec_poll_handle, checkpoint->retention_timer);
  1712. poll_timer_add (aisexec_poll_handle,
  1713. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  1714. checkpoint,
  1715. timer_function_retention,
  1716. &checkpoint->retention_timer);
  1717. }
  1718. error = SA_AIS_OK;
  1719. }
  1720. }
  1721. /*
  1722. * Respond to library if this processor sent the duration set request
  1723. */
  1724. if (message_source_is_local(&req_exec_ckpt_checkpointretentiondurationset->source)) {
  1725. res_lib_ckpt_checkpointretentiondurationset.header.size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset);
  1726. res_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET;
  1727. res_lib_ckpt_checkpointretentiondurationset.header.error = error;
  1728. libais_send_response (req_exec_ckpt_checkpointretentiondurationset->source.conn_info,
  1729. &res_lib_ckpt_checkpointretentiondurationset,
  1730. sizeof (struct res_lib_ckpt_checkpointretentiondurationset));
  1731. }
  1732. return (0);
  1733. }
  1734. static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct totem_ip_address *source_addr, int endian_conversion_required)
  1735. {
  1736. struct req_exec_ckpt_checkpointretentiondurationexpire *req_exec_ckpt_checkpointretentiondurationexpire = (struct req_exec_ckpt_checkpointretentiondurationexpire *)message;
  1737. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  1738. struct saCkptCheckpoint *checkpoint;
  1739. struct iovec iovecs[2];
  1740. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName);
  1741. if (checkpoint && (checkpoint->expired == 0) && (checkpoint->referenceCount < 1)) {
  1742. log_printf (LOG_LEVEL_NOTICE, "CKPT: Expiring checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName));
  1743. checkpoint->expired = 1;
  1744. req_exec_ckpt_checkpointunlink.header.size =
  1745. sizeof (struct req_exec_ckpt_checkpointunlink);
  1746. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  1747. req_exec_ckpt_checkpointunlink.source.conn_info = 0;
  1748. req_exec_ckpt_checkpointunlink.source.addr.family = 0;
  1749. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink.checkpointName,
  1750. &req_exec_ckpt_checkpointretentiondurationexpire->checkpointName,
  1751. sizeof (SaNameT));
  1752. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  1753. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  1754. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  1755. }
  1756. return (0);
  1757. }
  1758. static int recovery_section_create (SaCkptSectionDescriptorT *sectionDescriptor,
  1759. SaNameT *checkpointName,
  1760. char* SectionId)
  1761. {
  1762. struct saCkptCheckpoint *ckptCheckpoint;
  1763. struct saCkptCheckpointSection *ckptCheckpointSection;
  1764. void *initialData;
  1765. void *sectionId;
  1766. struct ckpt_identifier *ckpt_id = 0;
  1767. SaErrorT error = SA_AIS_OK;
  1768. if ((int)sectionDescriptor->sectionId.idLen) {
  1769. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create for checkpoint %s, section %s.\n",
  1770. &checkpointName->value, SectionId);
  1771. } else {
  1772. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create for checkpoint %s, default section.\n",
  1773. &checkpointName->value);
  1774. }
  1775. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  1776. if (ckptCheckpoint == 0) {
  1777. error = SA_AIS_ERR_NOT_EXIST;
  1778. goto error_exit;
  1779. }
  1780. /*
  1781. * Determine if user-specified checkpoint ID already exists
  1782. */
  1783. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1784. SectionId,
  1785. (int)sectionDescriptor->sectionId.idLen);
  1786. if (ckptCheckpointSection) {
  1787. /*
  1788. * This use case is mostly for the default section and is not probable for any other
  1789. * sections.
  1790. */
  1791. if (sectionDescriptor->sectionSize
  1792. > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  1793. log_printf (LOG_LEVEL_NOTICE,
  1794. "CKPT: recovery_section_create reallocating data. Present Size: %d, New Size: %d\n",
  1795. ckptCheckpointSection->sectionDescriptor.sectionSize,sectionDescriptor->sectionSize);
  1796. ckptCheckpointSection->sectionData =
  1797. realloc (ckptCheckpointSection->sectionData, sectionDescriptor->sectionSize);
  1798. if (ckptCheckpointSection->sectionData == 0) {
  1799. log_printf (LOG_LEVEL_ERROR,
  1800. "CKPT: recovery_section_create sectionData realloc returned 0 Calling error_exit.\n");
  1801. error = SA_AIS_ERR_NO_MEMORY;
  1802. checkpoint_section_release(ckptCheckpointSection);
  1803. goto error_exit;
  1804. }
  1805. ckptCheckpointSection->sectionDescriptor.sectionSize = sectionDescriptor->sectionSize;
  1806. error = SA_AIS_OK;
  1807. }
  1808. else {
  1809. error = SA_AIS_ERR_EXIST;
  1810. }
  1811. goto error_exit;
  1812. }
  1813. /*
  1814. * Allocate checkpoint section
  1815. */
  1816. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1817. if (ckptCheckpointSection == 0) {
  1818. error = SA_AIS_ERR_NO_MEMORY;
  1819. goto error_exit;
  1820. }
  1821. /*
  1822. * Allocate checkpoint section data
  1823. */
  1824. initialData = malloc (sectionDescriptor->sectionSize);
  1825. if (initialData == 0) {
  1826. free (ckptCheckpointSection);
  1827. error = SA_AIS_ERR_NO_MEMORY;
  1828. goto error_exit;
  1829. }
  1830. /*
  1831. * Allocate checkpoint section id
  1832. */
  1833. if (sectionDescriptor->sectionId.idLen) {
  1834. sectionId = malloc ((int)sectionDescriptor->sectionId.idLen);
  1835. if (sectionId == 0) {
  1836. free (ckptCheckpointSection);
  1837. free (initialData);
  1838. error = SA_AIS_ERR_NO_MEMORY;
  1839. goto error_exit;
  1840. }
  1841. } else {
  1842. sectionId = 0;
  1843. }
  1844. /*
  1845. * Copy checkpoint section ID and initialize data.
  1846. */
  1847. if (SectionId) {
  1848. memcpy ((char*)sectionId, (char*)SectionId, (int)sectionDescriptor->sectionId.idLen);
  1849. } else {
  1850. sectionId = 0;
  1851. }
  1852. memset (initialData, 0, sectionDescriptor->sectionSize);
  1853. /*
  1854. * Configure checkpoint section
  1855. */
  1856. memcpy(&ckptCheckpointSection->sectionDescriptor,
  1857. sectionDescriptor,
  1858. sizeof(SaCkptSectionDescriptorT));
  1859. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1860. ckptCheckpointSection->sectionData = initialData;
  1861. ckptCheckpointSection->expiration_timer = 0;
  1862. ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
  1863. if (sectionDescriptor->expirationTime != SA_TIME_END) {
  1864. ckpt_id = malloc (sizeof(struct ckpt_identifier));
  1865. assert(ckpt_id);
  1866. memcpy(&ckpt_id->ckpt_name,checkpointName,sizeof(SaNameT));
  1867. memcpy(&ckpt_id->ckpt_section_id, &ckptCheckpointSection->sectionDescriptor.sectionId,sizeof(SaCkptSectionIdT));
  1868. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create Enqueuing Timer to Expire section %s in ckpt %s\n",
  1869. ckpt_id->ckpt_section_id.id,
  1870. (char *)&ckpt_id->ckpt_name.value);
  1871. poll_timer_add (aisexec_poll_handle,
  1872. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  1873. ckpt_id,
  1874. timer_function_section_expire,
  1875. &ckptCheckpointSection->expiration_timer);
  1876. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create expiration timer = 0x%x\n",
  1877. ckptCheckpointSection->expiration_timer);
  1878. }
  1879. /*
  1880. * Add checkpoint section to checkpoint
  1881. */
  1882. list_init (&ckptCheckpointSection->list);
  1883. list_add (&ckptCheckpointSection->list,
  1884. &ckptCheckpoint->checkpointSectionsListHead);
  1885. error_exit:
  1886. return (error);
  1887. }
  1888. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  1889. struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message;
  1890. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)&req_exec_ckpt_sectioncreate->req_lib_ckpt_sectioncreate;
  1891. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  1892. struct saCkptCheckpoint *ckptCheckpoint;
  1893. struct saCkptCheckpointSection *ckptCheckpointSection;
  1894. void *initialData;
  1895. void *sectionId;
  1896. struct ckpt_identifier *ckpt_id = 0;
  1897. SaErrorT error = SA_AIS_OK;
  1898. log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n");
  1899. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectioncreate->checkpointName);
  1900. if (ckptCheckpoint == 0) {
  1901. error = SA_AIS_ERR_LIBRARY; /* TODO find the right error for this*/
  1902. goto error_exit;
  1903. }
  1904. if (ckptCheckpoint->sectionCount == ckptCheckpoint->checkpointCreationAttributes.maxSections) {
  1905. error = SA_AIS_ERR_NO_SPACE;
  1906. goto error_exit;
  1907. }
  1908. if (ckptCheckpoint->checkpointCreationAttributes.maxSections == 1) {
  1909. error = SA_AIS_ERR_EXIST;
  1910. goto error_exit;
  1911. }
  1912. if (ckptCheckpoint->checkpointCreationAttributes.maxSectionSize <
  1913. req_lib_ckpt_sectioncreate->initialDataSize) {
  1914. error = SA_AIS_ERR_INVALID_PARAM;
  1915. goto error_exit;
  1916. }
  1917. /*
  1918. * Determine if user-specified checkpoint ID already exists
  1919. */
  1920. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1921. ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  1922. req_lib_ckpt_sectioncreate->idLen);
  1923. if (ckptCheckpointSection) {
  1924. error = SA_AIS_ERR_EXIST;
  1925. goto error_exit;
  1926. }
  1927. /*
  1928. * Allocate checkpoint section
  1929. */
  1930. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1931. if (ckptCheckpointSection == 0) {
  1932. error = SA_AIS_ERR_NO_MEMORY;
  1933. goto error_exit;
  1934. }
  1935. /*
  1936. * Allocate checkpoint section data
  1937. */
  1938. initialData = malloc (req_lib_ckpt_sectioncreate->initialDataSize);
  1939. if (initialData == 0) {
  1940. free (ckptCheckpointSection);
  1941. error = SA_AIS_ERR_NO_MEMORY;
  1942. goto error_exit;
  1943. }
  1944. /*
  1945. * Allocate checkpoint section id
  1946. */
  1947. sectionId = malloc (req_lib_ckpt_sectioncreate->idLen);
  1948. if (sectionId == 0) {
  1949. free (ckptCheckpointSection);
  1950. free (initialData);
  1951. error = SA_AIS_ERR_NO_MEMORY;
  1952. goto error_exit;
  1953. }
  1954. /*
  1955. * Copy checkpoint section and section ID
  1956. */
  1957. memcpy (sectionId, ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  1958. req_lib_ckpt_sectioncreate->idLen);
  1959. memcpy (initialData,
  1960. ((char *)req_lib_ckpt_sectioncreate) +
  1961. sizeof (struct req_lib_ckpt_sectioncreate) +
  1962. req_lib_ckpt_sectioncreate->idLen,
  1963. req_lib_ckpt_sectioncreate->initialDataSize);
  1964. /*
  1965. * Configure checkpoint section
  1966. */
  1967. ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
  1968. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = req_lib_ckpt_sectioncreate->idLen;
  1969. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectioncreate->initialDataSize;
  1970. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectioncreate->expirationTime;
  1971. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1972. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /* TODO current time */
  1973. ckptCheckpointSection->sectionData = initialData;
  1974. ckptCheckpointSection->expiration_timer = 0;
  1975. if (req_lib_ckpt_sectioncreate->expirationTime != SA_TIME_END) {
  1976. ckpt_id = malloc (sizeof(struct ckpt_identifier));
  1977. assert(ckpt_id);
  1978. memcpy(&ckpt_id->ckpt_name,&req_exec_ckpt_sectioncreate->checkpointName,sizeof(SaNameT));
  1979. memcpy(&ckpt_id->ckpt_section_id, &ckptCheckpointSection->sectionDescriptor.sectionId,sizeof(SaCkptSectionIdT));
  1980. log_printf (LOG_LEVEL_DEBUG, "CKPT: req_exec_ckpt_sectioncreate Enqueuing Timer to Expire section %s in ckpt %s\n",
  1981. ckpt_id->ckpt_section_id.id,
  1982. (char *)&ckpt_id->ckpt_name.value);
  1983. poll_timer_add (aisexec_poll_handle,
  1984. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  1985. ckpt_id,
  1986. timer_function_section_expire,
  1987. &ckptCheckpointSection->expiration_timer);
  1988. log_printf (LOG_LEVEL_DEBUG, "CKPT: req_exec_ckpt_sectionicreate expiration timer = 0x%x\n",
  1989. ckptCheckpointSection->expiration_timer);
  1990. }
  1991. log_printf (LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_sectioncreate created section with id = %s, idLen = %d\n",
  1992. ckptCheckpointSection->sectionDescriptor.sectionId.id,
  1993. ckptCheckpointSection->sectionDescriptor.sectionId.idLen);
  1994. /*
  1995. * Add checkpoint section to checkpoint
  1996. */
  1997. list_init (&ckptCheckpointSection->list);
  1998. list_add (&ckptCheckpointSection->list,
  1999. &ckptCheckpoint->checkpointSectionsListHead);
  2000. ckptCheckpoint->sectionCount += 1;
  2001. error_exit:
  2002. if (message_source_is_local(&req_exec_ckpt_sectioncreate->source)) {
  2003. res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate);
  2004. res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE;
  2005. res_lib_ckpt_sectioncreate.header.error = error;
  2006. libais_send_response (req_exec_ckpt_sectioncreate->source.conn_info,
  2007. &res_lib_ckpt_sectioncreate,
  2008. sizeof (struct res_lib_ckpt_sectioncreate));
  2009. }
  2010. return (0);
  2011. }
  2012. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  2013. struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message;
  2014. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)&req_exec_ckpt_sectiondelete->req_lib_ckpt_sectiondelete;
  2015. struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
  2016. struct saCkptCheckpoint *ckptCheckpoint;
  2017. struct saCkptCheckpointSection *ckptCheckpointSection;
  2018. SaErrorT error = SA_AIS_OK;
  2019. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectiondelete->checkpointName);
  2020. if (ckptCheckpoint == 0) {
  2021. error = SA_AIS_ERR_NOT_EXIST;
  2022. goto error_exit;
  2023. }
  2024. if (ckptCheckpoint->active_replica_set == 0) {
  2025. log_printf (LOG_LEVEL_NOTICE, "sectiondelete: no active replica, returning error.\n");
  2026. error = SA_AIS_ERR_NOT_EXIST;
  2027. goto error_exit;
  2028. }
  2029. /*
  2030. * Determine if the user is trying to delete the default section
  2031. */
  2032. if (req_lib_ckpt_sectiondelete->idLen == 0) {
  2033. error = SA_AIS_ERR_INVALID_PARAM;
  2034. goto error_exit;
  2035. }
  2036. /*
  2037. * Find checkpoint section to be deleted
  2038. */
  2039. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2040. ((char *)(req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete)),
  2041. req_lib_ckpt_sectiondelete->idLen);
  2042. if (ckptCheckpointSection == 0) {
  2043. error = SA_AIS_ERR_NOT_EXIST;
  2044. goto error_exit;
  2045. }
  2046. printf ("delete ckptCheckpointSection name %s\n",
  2047. ckptCheckpointSection->sectionDescriptor.sectionId.id);
  2048. /*
  2049. * Delete checkpoint section
  2050. */
  2051. ckptCheckpoint->sectionCount -= 1;
  2052. checkpoint_section_release (ckptCheckpointSection);
  2053. /*
  2054. * return result to CKPT library
  2055. */
  2056. error_exit:
  2057. if (message_source_is_local(&req_exec_ckpt_sectiondelete->source)) {
  2058. res_lib_ckpt_sectiondelete.header.size = sizeof (struct res_lib_ckpt_sectiondelete);
  2059. res_lib_ckpt_sectiondelete.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE;
  2060. res_lib_ckpt_sectiondelete.header.error = error;
  2061. libais_send_response (req_exec_ckpt_sectiondelete->source.conn_info,
  2062. &res_lib_ckpt_sectiondelete,
  2063. sizeof (struct res_lib_ckpt_sectiondelete));
  2064. }
  2065. return (0);
  2066. }
  2067. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  2068. struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message;
  2069. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)&req_exec_ckpt_sectionexpirationtimeset->req_lib_ckpt_sectionexpirationtimeset;
  2070. struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
  2071. struct saCkptCheckpoint *ckptCheckpoint;
  2072. struct saCkptCheckpointSection *ckptCheckpointSection;
  2073. struct ckpt_identifier *ckpt_id = 0;
  2074. SaErrorT error = SA_AIS_OK;
  2075. log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiratoin time\n");
  2076. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionexpirationtimeset->checkpointName);
  2077. if (ckptCheckpoint == 0) {
  2078. error = SA_AIS_ERR_NOT_EXIST;
  2079. goto error_exit;
  2080. }
  2081. if (ckptCheckpoint->active_replica_set == 0) {
  2082. log_printf (LOG_LEVEL_NOTICE, "expirationset: no active replica, returning error.\n");
  2083. error = SA_AIS_ERR_NOT_EXIST;
  2084. goto error_exit;
  2085. }
  2086. /*
  2087. * Determine if the user is trying to set expiration time for the default section
  2088. */
  2089. if (req_lib_ckpt_sectionexpirationtimeset->idLen == 0) {
  2090. error = SA_AIS_ERR_INVALID_PARAM;
  2091. goto error_exit;
  2092. }
  2093. /*
  2094. * Find checkpoint section that expiration time should be set for
  2095. */
  2096. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2097. ((char *)req_lib_ckpt_sectionexpirationtimeset) +
  2098. sizeof (struct req_lib_ckpt_sectionexpirationtimeset),
  2099. req_lib_ckpt_sectionexpirationtimeset->idLen);
  2100. if (ckptCheckpointSection == 0) {
  2101. error = SA_AIS_ERR_NOT_EXIST;
  2102. goto error_exit;
  2103. }
  2104. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectionexpirationtimeset->expirationTime;
  2105. poll_timer_delete (aisexec_poll_handle, ckptCheckpointSection->expiration_timer);
  2106. ckptCheckpointSection->expiration_timer = 0;
  2107. if (req_lib_ckpt_sectionexpirationtimeset->expirationTime != SA_TIME_END) {
  2108. ckpt_id = malloc (sizeof(struct ckpt_identifier));
  2109. assert(ckpt_id);
  2110. memcpy(&ckpt_id->ckpt_name,&req_exec_ckpt_sectionexpirationtimeset->checkpointName,sizeof(SaNameT));
  2111. memcpy(&ckpt_id->ckpt_section_id, &ckptCheckpointSection->sectionDescriptor.sectionId,sizeof(SaCkptSectionIdT));
  2112. log_printf (LOG_LEVEL_DEBUG, "CKPT: req_exec_ckpt_sectionexpirationtimeset Enqueuing Timer to Expire section %s in ckpt %s, ref = 0x%x\n",
  2113. ckpt_id->ckpt_section_id.id,
  2114. (char *)&ckpt_id->ckpt_name.value,
  2115. ckpt_id);
  2116. poll_timer_add (aisexec_poll_handle,
  2117. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  2118. ckpt_id,
  2119. timer_function_section_expire,
  2120. &ckptCheckpointSection->expiration_timer);
  2121. log_printf (LOG_LEVEL_DEBUG, "CKPT: req_exec_ckpt_sectionexpirationtimeset expiration timer = 0x%x\n",
  2122. ckptCheckpointSection->expiration_timer);
  2123. }
  2124. error_exit:
  2125. if (message_source_is_local(&req_exec_ckpt_sectionexpirationtimeset->source)) {
  2126. res_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset);
  2127. res_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
  2128. res_lib_ckpt_sectionexpirationtimeset.header.error = error;
  2129. libais_send_response (req_exec_ckpt_sectionexpirationtimeset->source.conn_info,
  2130. &res_lib_ckpt_sectionexpirationtimeset,
  2131. sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
  2132. }
  2133. return (0);
  2134. }
  2135. static int recovery_section_write(int sectionIdLen,
  2136. char* sectionId,
  2137. SaNameT *checkpointName,
  2138. void *newData,
  2139. SaUint32T dataOffSet,
  2140. SaUint32T dataSize)
  2141. {
  2142. struct saCkptCheckpoint *ckptCheckpoint;
  2143. struct saCkptCheckpointSection *ckptCheckpointSection;
  2144. int sizeRequired;
  2145. SaErrorT error = SA_AIS_OK;
  2146. char *sd;
  2147. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_write.\n");
  2148. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  2149. if (ckptCheckpoint == 0) {
  2150. error = SA_AIS_ERR_NOT_EXIST;
  2151. goto error_exit;
  2152. }
  2153. /*
  2154. * Find checkpoint section to be written
  2155. */
  2156. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2157. sectionId,
  2158. sectionIdLen);
  2159. if (ckptCheckpointSection == 0) {
  2160. error = SA_AIS_ERR_NOT_EXIST;
  2161. goto error_exit;
  2162. }
  2163. /*
  2164. * If write would extend past end of section data, return error;
  2165. */
  2166. sizeRequired = dataOffSet + dataSize;
  2167. if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  2168. log_printf (LOG_LEVEL_ERROR,
  2169. "recovery_section_write. write-past-end sizeRequired:(%d), dataOffSet:(%d), dataSize:(%d), sync-section-size:(%d)\n",
  2170. sizeRequired, dataOffSet, dataSize,
  2171. (int)ckptCheckpointSection->sectionDescriptor.sectionSize);
  2172. error = SA_AIS_ERR_ACCESS;
  2173. goto error_exit;
  2174. }
  2175. /*
  2176. * Write checkpoint section to section data
  2177. */
  2178. if (dataSize > 0) {
  2179. sd = (char *)ckptCheckpointSection->sectionData;
  2180. memcpy (&sd[dataOffSet],
  2181. newData,
  2182. dataSize);
  2183. }
  2184. error_exit:
  2185. return (error);
  2186. }
  2187. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  2188. struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message;
  2189. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)&req_exec_ckpt_sectionwrite->req_lib_ckpt_sectionwrite;
  2190. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  2191. struct saCkptCheckpoint *ckptCheckpoint;
  2192. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  2193. int sizeRequired;
  2194. void *sectionData;
  2195. SaErrorT error = SA_AIS_OK;
  2196. log_printf (LOG_LEVEL_DEBUG, "Executive request to section write.\n");
  2197. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionwrite->checkpointName);
  2198. if (ckptCheckpoint == 0) {
  2199. log_printf (LOG_LEVEL_ERROR, "CKPT: ckpt_checkpoint_find_global returned 0 Calling error_exit.\n");
  2200. error = SA_AIS_ERR_NOT_EXIST;
  2201. goto error_exit;
  2202. }
  2203. if (ckptCheckpoint->active_replica_set == 0) {
  2204. log_printf (LOG_LEVEL_NOTICE, "checkpointwrite: no active replica, returning error.\n");
  2205. error = SA_AIS_ERR_NOT_EXIST;
  2206. goto error_exit;
  2207. }
  2208. if (ckptCheckpoint->checkpointCreationAttributes.maxSectionSize < req_lib_ckpt_sectionwrite->dataSize) {
  2209. error = SA_AIS_ERR_INVALID_PARAM;
  2210. goto error_exit;
  2211. }
  2212. /*
  2213. printf ("writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  2214. */
  2215. /*
  2216. * Find checkpoint section to be written
  2217. */
  2218. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2219. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite),
  2220. req_lib_ckpt_sectionwrite->idLen);
  2221. if (ckptCheckpointSection == 0) {
  2222. if (req_lib_ckpt_sectionwrite->idLen == 0) {
  2223. log_printf (LOG_LEVEL_DEBUG, "CANT FIND DEFAULT SECTION.\n");
  2224. }
  2225. else {
  2226. log_printf (LOG_LEVEL_DEBUG, "CANT FIND SECTION '%s'\n",
  2227. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  2228. }
  2229. error = SA_AIS_ERR_NOT_EXIST;
  2230. goto error_exit;
  2231. }
  2232. /*
  2233. * If write would extend past end of section data, enlarge section
  2234. */
  2235. sizeRequired = req_lib_ckpt_sectionwrite->dataOffset + req_lib_ckpt_sectionwrite->dataSize;
  2236. if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  2237. sectionData = realloc (ckptCheckpointSection->sectionData, sizeRequired);
  2238. if (sectionData == 0) {
  2239. log_printf (LOG_LEVEL_ERROR, "CKPT: sectionData realloc returned 0 Calling error_exit.\n");
  2240. error = SA_AIS_ERR_NO_MEMORY;
  2241. goto error_exit;
  2242. }
  2243. /*
  2244. * Install new section data
  2245. */
  2246. ckptCheckpointSection->sectionData = sectionData;
  2247. ckptCheckpointSection->sectionDescriptor.sectionSize = sizeRequired;
  2248. }
  2249. /*
  2250. * Write checkpoint section to section data
  2251. */
  2252. if (req_lib_ckpt_sectionwrite->dataSize > 0) {
  2253. char *sd;
  2254. int *val;
  2255. val = ckptCheckpointSection->sectionData;
  2256. sd = (char *)ckptCheckpointSection->sectionData;
  2257. memcpy (&sd[req_lib_ckpt_sectionwrite->dataOffset],
  2258. ((char *)req_exec_ckpt_sectionwrite) + sizeof (struct req_exec_ckpt_sectionwrite) +
  2259. req_lib_ckpt_sectionwrite->idLen,
  2260. req_lib_ckpt_sectionwrite->dataSize);
  2261. }
  2262. /*
  2263. * Write write response to CKPT library
  2264. */
  2265. error_exit:
  2266. if (message_source_is_local(&req_exec_ckpt_sectionwrite->source)) {
  2267. res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  2268. res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE;
  2269. res_lib_ckpt_sectionwrite.header.error = error;
  2270. libais_send_response (req_exec_ckpt_sectionwrite->source.conn_info,
  2271. &res_lib_ckpt_sectionwrite,
  2272. sizeof (struct res_lib_ckpt_sectionwrite));
  2273. }
  2274. return (0);
  2275. }
  2276. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  2277. struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message;
  2278. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)&req_exec_ckpt_sectionoverwrite->req_lib_ckpt_sectionoverwrite;
  2279. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  2280. struct saCkptCheckpoint *ckptCheckpoint;
  2281. struct saCkptCheckpointSection *ckptCheckpointSection;
  2282. void *sectionData;
  2283. SaErrorT error = SA_AIS_OK;
  2284. log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n");
  2285. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionoverwrite->checkpointName);
  2286. if (ckptCheckpoint == 0) {
  2287. error = SA_AIS_ERR_NOT_EXIST;
  2288. goto error_exit;
  2289. }
  2290. if (ckptCheckpoint->checkpointCreationAttributes.maxSectionSize < req_lib_ckpt_sectionoverwrite->dataSize) {
  2291. error = SA_AIS_ERR_INVALID_PARAM;
  2292. goto error_exit;
  2293. }
  2294. /*
  2295. * Find checkpoint section to be overwritten
  2296. */
  2297. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2298. ((char *)req_lib_ckpt_sectionoverwrite) +
  2299. sizeof (struct req_lib_ckpt_sectionoverwrite),
  2300. req_lib_ckpt_sectionoverwrite->idLen);
  2301. if (ckptCheckpointSection == 0) {
  2302. error = SA_AIS_ERR_NOT_EXIST;
  2303. goto error_exit;
  2304. }
  2305. /*
  2306. * Allocate checkpoint section data
  2307. */
  2308. sectionData = malloc (req_lib_ckpt_sectionoverwrite->dataSize);
  2309. if (sectionData == 0) {
  2310. error = SA_AIS_ERR_NO_MEMORY;
  2311. goto error_exit;
  2312. }
  2313. memcpy (sectionData,
  2314. ((char *)req_lib_ckpt_sectionoverwrite) +
  2315. sizeof (struct req_lib_ckpt_sectionoverwrite) +
  2316. req_lib_ckpt_sectionoverwrite->idLen,
  2317. req_lib_ckpt_sectionoverwrite->dataSize);
  2318. /*
  2319. * release old checkpoint section data
  2320. */
  2321. free (ckptCheckpointSection->sectionData);
  2322. /*
  2323. * Install overwritten checkpoint section data
  2324. */
  2325. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectionoverwrite->dataSize;
  2326. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  2327. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /* TODO current time */
  2328. ckptCheckpointSection->sectionData = sectionData;
  2329. /*
  2330. * return result to CKPT library
  2331. */
  2332. error_exit:
  2333. if (message_source_is_local(&req_exec_ckpt_sectionoverwrite->source)) {
  2334. res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionoverwrite);
  2335. res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  2336. res_lib_ckpt_sectionoverwrite.header.error = error;
  2337. libais_send_response (req_exec_ckpt_sectionoverwrite->source.conn_info,
  2338. &res_lib_ckpt_sectionoverwrite,
  2339. sizeof (struct res_lib_ckpt_sectionoverwrite));
  2340. }
  2341. return (0);
  2342. }
  2343. static int message_handler_req_exec_ckpt_sectionread (void *message, struct totem_ip_address *source_addr, int endian_conversion_required) {
  2344. struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message;
  2345. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)&req_exec_ckpt_sectionread->req_lib_ckpt_sectionread;
  2346. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  2347. struct saCkptCheckpoint *ckptCheckpoint;
  2348. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  2349. int sectionSize = 0;
  2350. SaErrorT error = SA_AIS_OK;
  2351. log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n");
  2352. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionread->checkpointName);
  2353. if (ckptCheckpoint == 0) {
  2354. error = SA_AIS_ERR_LIBRARY; /* TODO find the right error for this */
  2355. goto error_exit;
  2356. }
  2357. /*
  2358. * Find checkpoint section to be read
  2359. */
  2360. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  2361. ((char *)req_lib_ckpt_sectionread) +
  2362. sizeof (struct req_lib_ckpt_sectionread),
  2363. req_lib_ckpt_sectionread->idLen);
  2364. if (ckptCheckpointSection == 0) {
  2365. error = SA_AIS_ERR_NOT_EXIST;
  2366. goto error_exit;
  2367. }
  2368. /*
  2369. * Determine the section size
  2370. */
  2371. sectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize -
  2372. req_lib_ckpt_sectionread->dataOffset;
  2373. /*
  2374. * If the library has less space available then can be sent from the
  2375. * section, reduce bytes sent to library to max requested
  2376. */
  2377. if (sectionSize > req_lib_ckpt_sectionread->dataSize) {
  2378. sectionSize = req_lib_ckpt_sectionread->dataSize;
  2379. }
  2380. /*
  2381. * If dataOffset is past end of data, return INVALID PARAM
  2382. */
  2383. if (req_lib_ckpt_sectionread->dataOffset > sectionSize) {
  2384. sectionSize = 0;
  2385. error = SA_AIS_ERR_INVALID_PARAM;
  2386. goto error_exit;
  2387. }
  2388. /*
  2389. * Write read response to CKPT library
  2390. */
  2391. error_exit:
  2392. if (message_source_is_local(&req_exec_ckpt_sectionread->source)) {
  2393. res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread) + sectionSize;
  2394. res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
  2395. res_lib_ckpt_sectionread.header.error = error;
  2396. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  2397. &res_lib_ckpt_sectionread,
  2398. sizeof (struct res_lib_ckpt_sectionread));
  2399. /*
  2400. * Write checkpoint to CKPT library section if section has data
  2401. */
  2402. if (sectionSize) {
  2403. char *sd;
  2404. sd = (char *)ckptCheckpointSection->sectionData;
  2405. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  2406. &sd[req_lib_ckpt_sectionread->dataOffset],
  2407. sectionSize);
  2408. }
  2409. }
  2410. return (0);
  2411. }
  2412. static int ckpt_init_two_fn (struct conn_info *conn_info)
  2413. {
  2414. list_init (&conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator
  2415. .list);
  2416. conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries = 0;
  2417. conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.iteratorCount = 0;
  2418. conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.iteratorPos = 0;
  2419. list_add (&conn_info->conn_info_partner->ais_ci.u.libckpt_ci.sectionIterator.list,
  2420. &checkpoint_iterator_list_head);
  2421. list_init (&conn_info->conn_info_partner->ais_ci.u.libckpt_ci.checkpoint_list);
  2422. return (0);
  2423. }
  2424. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message)
  2425. {
  2426. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)message;
  2427. struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
  2428. struct iovec iovecs[2];
  2429. log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
  2430. req_exec_ckpt_checkpointopen.header.size =
  2431. sizeof (struct req_exec_ckpt_checkpointopen);
  2432. req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
  2433. message_source_set (&req_exec_ckpt_checkpointopen.source, conn_info);
  2434. memcpy (&req_exec_ckpt_checkpointopen.req_lib_ckpt_checkpointopen,
  2435. req_lib_ckpt_checkpointopen,
  2436. sizeof (struct req_lib_ckpt_checkpointopen));
  2437. req_exec_ckpt_checkpointopen.async_call = 0;
  2438. req_exec_ckpt_checkpointopen.invocation = 0;
  2439. req_exec_ckpt_checkpointopen.checkpointHandle = 0;
  2440. req_exec_ckpt_checkpointopen.fail_with_error = SA_AIS_OK;
  2441. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointopen;
  2442. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointopen);
  2443. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2444. return (0);
  2445. }
  2446. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message)
  2447. {
  2448. struct req_lib_ckpt_checkpointopenasync *req_lib_ckpt_checkpointopenasync = (struct req_lib_ckpt_checkpointopenasync *)message;
  2449. struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
  2450. struct iovec iovecs[2];
  2451. log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint async.\n");
  2452. req_exec_ckpt_checkpointopen.header.size =
  2453. sizeof (struct req_exec_ckpt_checkpointopen);
  2454. req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
  2455. message_source_set (&req_exec_ckpt_checkpointopen.source, conn_info);
  2456. memcpy (&req_exec_ckpt_checkpointopen.req_lib_ckpt_checkpointopen,
  2457. req_lib_ckpt_checkpointopenasync,
  2458. sizeof (struct req_lib_ckpt_checkpointopen));
  2459. req_exec_ckpt_checkpointopen.async_call = 1;
  2460. req_exec_ckpt_checkpointopen.invocation = req_lib_ckpt_checkpointopenasync->invocation;
  2461. req_exec_ckpt_checkpointopen.checkpointHandle = req_lib_ckpt_checkpointopenasync->checkpointHandle;
  2462. req_exec_ckpt_checkpointopen.fail_with_error = req_lib_ckpt_checkpointopenasync->fail_with_error;
  2463. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointopen;
  2464. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointopen);
  2465. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2466. return (0);
  2467. }
  2468. static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message) {
  2469. struct req_lib_ckpt_checkpointclose *req_lib_ckpt_checkpointclose = (struct req_lib_ckpt_checkpointclose *)message;
  2470. struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
  2471. struct iovec iovecs[2];
  2472. struct saCkptCheckpoint *checkpoint;
  2473. struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose;
  2474. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointclose->checkpointName);
  2475. if (checkpoint && (checkpoint->expired == 0)) {
  2476. req_exec_ckpt_checkpointclose.header.size =
  2477. sizeof (struct req_exec_ckpt_checkpointclose);
  2478. req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
  2479. message_source_set (&req_exec_ckpt_checkpointclose.source, conn_info);
  2480. memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
  2481. &req_lib_ckpt_checkpointclose->checkpointName, sizeof (SaNameT));
  2482. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose;
  2483. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
  2484. if (totempg_groups_send_ok_joined (openais_group_handle, iovecs, 1)) {
  2485. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2486. }
  2487. }
  2488. else {
  2489. log_printf (LOG_LEVEL_ERROR, "#### CKPT: Could Not Find the Checkpoint to close so Returning Error. ####\n");
  2490. res_lib_ckpt_checkpointclose.header.size = sizeof (struct res_lib_ckpt_checkpointclose);
  2491. res_lib_ckpt_checkpointclose.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE;
  2492. res_lib_ckpt_checkpointclose.header.error = SA_AIS_ERR_NOT_EXIST;
  2493. libais_send_response (conn_info,
  2494. &res_lib_ckpt_checkpointclose,
  2495. sizeof (struct res_lib_ckpt_checkpointclose));
  2496. }
  2497. return (0);
  2498. }
  2499. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message)
  2500. {
  2501. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)message;
  2502. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  2503. struct iovec iovecs[2];
  2504. req_exec_ckpt_checkpointunlink.header.size =
  2505. sizeof (struct req_exec_ckpt_checkpointunlink);
  2506. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  2507. message_source_set (&req_exec_ckpt_checkpointunlink.source, conn_info);
  2508. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink,
  2509. req_lib_ckpt_checkpointunlink,
  2510. sizeof (struct req_lib_ckpt_checkpointunlink));
  2511. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  2512. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  2513. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2514. return (0);
  2515. }
  2516. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message)
  2517. {
  2518. struct req_lib_ckpt_checkpointretentiondurationset *req_lib_ckpt_checkpointretentiondurationset = (struct req_lib_ckpt_checkpointretentiondurationset *)message;
  2519. struct req_exec_ckpt_checkpointretentiondurationset req_exec_ckpt_checkpointretentiondurationset;
  2520. struct iovec iovecs[2];
  2521. log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API fd %d\n", conn_info->fd);
  2522. req_exec_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET;
  2523. req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
  2524. message_source_set (&req_exec_ckpt_checkpointretentiondurationset.source, conn_info);
  2525. memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpointName,
  2526. &req_lib_ckpt_checkpointretentiondurationset->checkpointName,
  2527. sizeof (SaNameT));
  2528. req_exec_ckpt_checkpointretentiondurationset.retentionDuration = req_lib_ckpt_checkpointretentiondurationset->retentionDuration;
  2529. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationset;
  2530. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationset);
  2531. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2532. return (0);
  2533. }
  2534. static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message)
  2535. {
  2536. struct req_lib_ckpt_activereplicaset *req_lib_ckpt_activereplicaset = (struct req_lib_ckpt_activereplicaset *)message;
  2537. struct res_lib_ckpt_activereplicaset res_lib_ckpt_activereplicaset;
  2538. struct saCkptCheckpoint *checkpoint;
  2539. SaAisErrorT error = SA_AIS_OK;
  2540. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_activereplicaset->checkpointName);
  2541. /*
  2542. * Make sure checkpoint is collocated and async update option
  2543. */
  2544. if (((checkpoint->checkpointCreationAttributes.creationFlags & SA_CKPT_CHECKPOINT_COLLOCATED) == 0) ||
  2545. (checkpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
  2546. error = SA_AIS_ERR_BAD_OPERATION;
  2547. }
  2548. checkpoint->active_replica_set = 1;
  2549. res_lib_ckpt_activereplicaset.header.size = sizeof (struct res_lib_ckpt_activereplicaset);
  2550. res_lib_ckpt_activereplicaset.header.id = MESSAGE_RES_CKPT_ACTIVEREPLICASET;
  2551. res_lib_ckpt_activereplicaset.header.error = error;
  2552. libais_send_response (conn_info, &res_lib_ckpt_activereplicaset,
  2553. sizeof (struct res_lib_ckpt_activereplicaset));
  2554. return (0);
  2555. }
  2556. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message)
  2557. {
  2558. struct req_lib_ckpt_checkpointstatusget *req_lib_ckpt_checkpointstatusget = (struct req_lib_ckpt_checkpointstatusget *)message;
  2559. struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
  2560. struct saCkptCheckpoint *checkpoint;
  2561. int memoryUsed = 0;
  2562. int numberOfSections = 0;
  2563. struct list_head *checkpoint_section_list;
  2564. struct saCkptCheckpointSection *checkpointSection;
  2565. log_printf (LOG_LEVEL_DEBUG, "in status get\n");
  2566. /*
  2567. * Count memory used by checkpoint sections
  2568. */
  2569. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointstatusget->checkpointName);
  2570. if (checkpoint && (checkpoint->expired == 0)) {
  2571. for (checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  2572. checkpoint_section_list != &checkpoint->checkpointSectionsListHead;
  2573. checkpoint_section_list = checkpoint_section_list->next) {
  2574. checkpointSection = list_entry (checkpoint_section_list,
  2575. struct saCkptCheckpointSection, list);
  2576. memoryUsed += checkpointSection->sectionDescriptor.sectionSize;
  2577. numberOfSections += 1;
  2578. }
  2579. /*
  2580. * Build checkpoint status get response
  2581. */
  2582. res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
  2583. res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  2584. if (checkpoint->active_replica_set == 1) {
  2585. res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_OK;
  2586. } else {
  2587. res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_ERR_NOT_EXIST;
  2588. }
  2589. memcpy (&res_lib_ckpt_checkpointstatusget.checkpointDescriptor.checkpointCreationAttributes,
  2590. &checkpoint->checkpointCreationAttributes,
  2591. sizeof (SaCkptCheckpointCreationAttributesT));
  2592. res_lib_ckpt_checkpointstatusget.checkpointDescriptor.numberOfSections = numberOfSections;
  2593. res_lib_ckpt_checkpointstatusget.checkpointDescriptor.memoryUsed = memoryUsed;
  2594. }
  2595. else {
  2596. log_printf (LOG_LEVEL_ERROR, "#### CKPT: Could Not Find the Checkpoint's status so Returning Error. ####\n");
  2597. res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
  2598. res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  2599. res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_ERR_NOT_EXIST;
  2600. }
  2601. log_printf (LOG_LEVEL_DEBUG, "before sending message\n");
  2602. libais_send_response (conn_info, &res_lib_ckpt_checkpointstatusget,
  2603. sizeof (struct res_lib_ckpt_checkpointstatusget));
  2604. return (0);
  2605. }
  2606. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message)
  2607. {
  2608. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)message;
  2609. struct req_exec_ckpt_sectioncreate req_exec_ckpt_sectioncreate;
  2610. struct iovec iovecs[2];
  2611. struct saCkptCheckpoint *checkpoint;
  2612. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  2613. log_printf (LOG_LEVEL_DEBUG, "Section create from API fd %d\n", conn_info->fd);
  2614. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioncreate->checkpointName);
  2615. if (checkpoint && (checkpoint->expired == 0)) {
  2616. /*
  2617. * checkpoint opened is writeable mode so send message to cluster
  2618. */
  2619. req_exec_ckpt_sectioncreate.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE;
  2620. req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
  2621. memcpy (&req_exec_ckpt_sectioncreate.req_lib_ckpt_sectioncreate,
  2622. req_lib_ckpt_sectioncreate,
  2623. sizeof (struct req_lib_ckpt_sectioncreate));
  2624. memcpy (&req_exec_ckpt_sectioncreate.checkpointName,
  2625. &req_lib_ckpt_sectioncreate->checkpointName,
  2626. sizeof (SaNameT));
  2627. message_source_set (&req_exec_ckpt_sectioncreate.source, conn_info);
  2628. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectioncreate;
  2629. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectioncreate);
  2630. /*
  2631. * Send section name and initial data in message
  2632. */
  2633. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate);
  2634. iovecs[1].iov_len = req_lib_ckpt_sectioncreate->header.size - sizeof (struct req_lib_ckpt_sectioncreate);
  2635. req_exec_ckpt_sectioncreate.header.size += iovecs[1].iov_len;
  2636. if (iovecs[1].iov_len) {
  2637. log_printf (LOG_LEVEL_DEBUG, "CKPT: message_handler_req_lib_ckpt_sectioncreate Section = %s, idLen = %d\n",
  2638. iovecs[1].iov_base,
  2639. iovecs[1].iov_len);
  2640. }
  2641. #ifdef DEBUG
  2642. printf ("LIBRARY SECTIONCREATE string is %s len is %d\n", (unsigned char *)iovecs[1].iov_base,
  2643. iovecs[1].iov_len);
  2644. printf ("|\n");
  2645. { int i;
  2646. char *abc = iovecs[1].iov_base;
  2647. for (i = 0; i < 14;i++) {
  2648. printf ("%c ", abc[i]);
  2649. }
  2650. }
  2651. printf ("|\n");
  2652. #endif
  2653. if (iovecs[1].iov_len > 0) {
  2654. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %p\n", iovecs[1].iov_base);
  2655. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2656. } else {
  2657. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2658. }
  2659. }
  2660. else {
  2661. log_printf (LOG_LEVEL_ERROR, "#### CKPT: Could Not Find the Checkpoint to create a section in so Returning Error. ####\n");
  2662. res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate);
  2663. res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE;
  2664. res_lib_ckpt_sectioncreate.header.error = SA_AIS_ERR_NOT_EXIST;
  2665. libais_send_response (conn_info,
  2666. &res_lib_ckpt_sectioncreate,
  2667. sizeof (struct res_lib_ckpt_sectioncreate));
  2668. }
  2669. return (0);
  2670. }
  2671. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message)
  2672. {
  2673. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)message;
  2674. struct req_exec_ckpt_sectiondelete req_exec_ckpt_sectiondelete;
  2675. struct iovec iovecs[2];
  2676. log_printf (LOG_LEVEL_DEBUG, "section delete from API fd %d\n", conn_info->fd);
  2677. req_exec_ckpt_sectiondelete.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE;
  2678. req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
  2679. memcpy (&req_exec_ckpt_sectiondelete.checkpointName,
  2680. &req_lib_ckpt_sectiondelete->checkpointName,
  2681. sizeof (SaNameT));
  2682. memcpy (&req_exec_ckpt_sectiondelete.req_lib_ckpt_sectiondelete,
  2683. req_lib_ckpt_sectiondelete,
  2684. sizeof (struct req_lib_ckpt_sectiondelete));
  2685. message_source_set (&req_exec_ckpt_sectiondelete.source, conn_info);
  2686. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectiondelete;
  2687. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectiondelete);
  2688. /*
  2689. * Send section name
  2690. */
  2691. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete);
  2692. iovecs[1].iov_len = req_lib_ckpt_sectiondelete->header.size - sizeof (struct req_lib_ckpt_sectiondelete);
  2693. req_exec_ckpt_sectiondelete.header.size += iovecs[1].iov_len;
  2694. if (iovecs[1].iov_len > 0) {
  2695. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2696. } else {
  2697. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2698. }
  2699. return (0);
  2700. }
  2701. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message)
  2702. {
  2703. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)message;
  2704. struct req_exec_ckpt_sectionexpirationtimeset req_exec_ckpt_sectionexpirationtimeset;
  2705. struct iovec iovecs[2];
  2706. log_printf (LOG_LEVEL_DEBUG, "section expiration time set fd=%d\n", conn_info->fd);
  2707. req_exec_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET;
  2708. req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
  2709. memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName,
  2710. &req_lib_ckpt_sectionexpirationtimeset->checkpointName,
  2711. sizeof (SaNameT));
  2712. memcpy (&req_exec_ckpt_sectionexpirationtimeset.req_lib_ckpt_sectionexpirationtimeset,
  2713. req_lib_ckpt_sectionexpirationtimeset,
  2714. sizeof (struct req_lib_ckpt_sectionexpirationtimeset));
  2715. message_source_set (&req_exec_ckpt_sectionexpirationtimeset.source, conn_info);
  2716. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionexpirationtimeset;
  2717. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionexpirationtimeset);
  2718. /*
  2719. * Send section name
  2720. */
  2721. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionexpirationtimeset) + sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  2722. iovecs[1].iov_len = req_lib_ckpt_sectionexpirationtimeset->header.size - sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  2723. req_exec_ckpt_sectionexpirationtimeset.header.size += iovecs[1].iov_len;
  2724. if (iovecs[1].iov_len > 0) {
  2725. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %p\n", iovecs[1].iov_base);
  2726. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2727. } else {
  2728. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2729. }
  2730. return (0);
  2731. }
  2732. int write_inv = 0;
  2733. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message)
  2734. {
  2735. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)message;
  2736. struct req_exec_ckpt_sectionwrite req_exec_ckpt_sectionwrite;
  2737. struct iovec iovecs[2];
  2738. struct saCkptCheckpoint *checkpoint;
  2739. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  2740. log_printf (LOG_LEVEL_DEBUG, "CKPT: Received data from lib with len = %d and ref = 0x%x\n",
  2741. req_lib_ckpt_sectionwrite->dataSize,
  2742. req_lib_ckpt_sectionwrite->dataOffset);
  2743. log_printf (LOG_LEVEL_DEBUG, "CKPT: Checkpoint section being written to is %s, idLen = %d\n",
  2744. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite),
  2745. req_lib_ckpt_sectionwrite->idLen);
  2746. log_printf (LOG_LEVEL_DEBUG, "Section write from API fd %d\n", conn_info->fd);
  2747. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionwrite->checkpointName);
  2748. if (checkpoint && (checkpoint->expired == 0)) {
  2749. /*
  2750. * checkpoint opened is writeable mode so send message to cluster
  2751. */
  2752. req_exec_ckpt_sectionwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE;
  2753. req_exec_ckpt_sectionwrite.header.size = sizeof (struct req_exec_ckpt_sectionwrite);
  2754. memcpy (&req_exec_ckpt_sectionwrite.req_lib_ckpt_sectionwrite,
  2755. req_lib_ckpt_sectionwrite,
  2756. sizeof (struct req_lib_ckpt_sectionwrite));
  2757. memcpy (&req_exec_ckpt_sectionwrite.checkpointName,
  2758. &req_lib_ckpt_sectionwrite->checkpointName,
  2759. sizeof (SaNameT));
  2760. message_source_set (&req_exec_ckpt_sectionwrite.source, conn_info);
  2761. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionwrite;
  2762. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionwrite);
  2763. /*
  2764. * Send section name and data to write in message
  2765. */
  2766. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite);
  2767. iovecs[1].iov_len = req_lib_ckpt_sectionwrite->header.size - sizeof (struct req_lib_ckpt_sectionwrite);
  2768. req_exec_ckpt_sectionwrite.header.size += iovecs[1].iov_len;
  2769. if (iovecs[1].iov_len > 0) {
  2770. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2771. } else {
  2772. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2773. }
  2774. }
  2775. else {
  2776. log_printf (LOG_LEVEL_ERROR, "#### CKPT: Could Not Find the Checkpoint to write to Returning Error. ####\n");
  2777. res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  2778. res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE;
  2779. res_lib_ckpt_sectionwrite.header.error = SA_AIS_ERR_NOT_EXIST;
  2780. libais_send_response (conn_info,
  2781. &res_lib_ckpt_sectionwrite,
  2782. sizeof (struct res_lib_ckpt_sectionwrite));
  2783. }
  2784. return (0);
  2785. }
  2786. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message)
  2787. {
  2788. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)message;
  2789. struct req_exec_ckpt_sectionoverwrite req_exec_ckpt_sectionoverwrite;
  2790. struct iovec iovecs[2];
  2791. struct saCkptCheckpoint *checkpoint;
  2792. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  2793. log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info->fd);
  2794. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionoverwrite->checkpointName);
  2795. if (checkpoint && (checkpoint->expired == 0) && (checkpoint->active_replica_set == 1)) {
  2796. /*
  2797. * checkpoint opened is writeable mode so send message to cluster
  2798. */
  2799. req_exec_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE;
  2800. req_exec_ckpt_sectionoverwrite.header.size = sizeof (struct req_exec_ckpt_sectionoverwrite);
  2801. memcpy (&req_exec_ckpt_sectionoverwrite.req_lib_ckpt_sectionoverwrite,
  2802. req_lib_ckpt_sectionoverwrite,
  2803. sizeof (struct req_lib_ckpt_sectionoverwrite));
  2804. memcpy (&req_exec_ckpt_sectionoverwrite.checkpointName,
  2805. &req_lib_ckpt_sectionoverwrite->checkpointName,
  2806. sizeof (SaNameT));
  2807. message_source_set (&req_exec_ckpt_sectionoverwrite.source, conn_info);
  2808. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionoverwrite;
  2809. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionoverwrite);
  2810. /*
  2811. * Send section name and data to overwrite in message
  2812. */
  2813. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionoverwrite) + sizeof (struct req_lib_ckpt_sectionoverwrite);
  2814. iovecs[1].iov_len = req_lib_ckpt_sectionoverwrite->header.size - sizeof (struct req_lib_ckpt_sectionoverwrite);
  2815. req_exec_ckpt_sectionoverwrite.header.size += iovecs[1].iov_len;
  2816. if (iovecs[1].iov_len > 0) {
  2817. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2818. } else {
  2819. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2820. }
  2821. }
  2822. else {
  2823. log_printf (LOG_LEVEL_ERROR, "#### CKPT: Could Not Find the Checkpoint to over write so Returning Error. ####\n");
  2824. res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  2825. res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  2826. res_lib_ckpt_sectionoverwrite.header.error = SA_AIS_ERR_NOT_EXIST;
  2827. libais_send_response (conn_info,
  2828. &res_lib_ckpt_sectionoverwrite,
  2829. sizeof (struct res_lib_ckpt_sectionoverwrite));
  2830. }
  2831. return (0);
  2832. }
  2833. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message)
  2834. {
  2835. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)message;
  2836. struct req_exec_ckpt_sectionread req_exec_ckpt_sectionread;
  2837. struct iovec iovecs[2];
  2838. struct saCkptCheckpoint *checkpoint;
  2839. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  2840. SaAisErrorT error = SA_AIS_OK;
  2841. log_printf (LOG_LEVEL_DEBUG, "Section read from API fd %d\n", conn_info->fd);
  2842. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionread->checkpointName);
  2843. if (checkpoint && (checkpoint->expired == 0) &&
  2844. checkpoint->active_replica_set &&
  2845. req_lib_ckpt_sectionread->dataSize <=
  2846. checkpoint->checkpointCreationAttributes.maxSectionSize) {
  2847. /*
  2848. * checkpoint opened is writeable mode so send message to cluster
  2849. */
  2850. req_exec_ckpt_sectionread.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONREAD;
  2851. req_exec_ckpt_sectionread.header.size = sizeof (struct req_exec_ckpt_sectionread);
  2852. memcpy (&req_exec_ckpt_sectionread.req_lib_ckpt_sectionread,
  2853. req_lib_ckpt_sectionread,
  2854. sizeof (struct req_lib_ckpt_sectionread));
  2855. memcpy (&req_exec_ckpt_sectionread.checkpointName,
  2856. &req_lib_ckpt_sectionread->checkpointName,
  2857. sizeof (SaNameT));
  2858. message_source_set (&req_exec_ckpt_sectionread.source, conn_info);
  2859. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionread;
  2860. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionread);
  2861. /*
  2862. * Send section name and data to overwrite in message
  2863. */
  2864. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionread) + sizeof (struct req_lib_ckpt_sectionread);
  2865. iovecs[1].iov_len = req_lib_ckpt_sectionread->header.size - sizeof (struct req_lib_ckpt_sectionread);
  2866. req_exec_ckpt_sectionread.header.size += iovecs[1].iov_len;
  2867. if (iovecs[1].iov_len > 0) {
  2868. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 2, TOTEMPG_AGREED) == 0);
  2869. } else {
  2870. assert (totempg_groups_mcast_joined (openais_group_handle, iovecs, 1, TOTEMPG_AGREED) == 0);
  2871. }
  2872. return (0); /* DO NOT REMOVE */
  2873. }
  2874. if (checkpoint) {
  2875. if (checkpoint->active_replica_set == 0) {
  2876. log_printf (LOG_LEVEL_DEBUG,
  2877. "sectionread - active replica not set.\n");
  2878. error = SA_AIS_ERR_NOT_EXIST;
  2879. }
  2880. if (req_lib_ckpt_sectionread->dataSize >
  2881. checkpoint->checkpointCreationAttributes.maxSectionSize) {
  2882. log_printf (LOG_LEVEL_DEBUG,
  2883. "sectionread - data size greater then max section size.\n");
  2884. error = SA_AIS_ERR_INVALID_PARAM;
  2885. }
  2886. } else {
  2887. log_printf (LOG_LEVEL_ERROR,
  2888. "sectionread - could not find checkpoint.\n");
  2889. }
  2890. res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread);
  2891. res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
  2892. res_lib_ckpt_sectionread.header.error = error;
  2893. libais_send_response (conn_info,
  2894. &res_lib_ckpt_sectionread,
  2895. sizeof (struct res_lib_ckpt_sectionread));
  2896. return (0);
  2897. }
  2898. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message)
  2899. {
  2900. struct req_lib_ckpt_checkpointsynchronize *req_lib_ckpt_checkpointsynchronize = (struct req_lib_ckpt_checkpointsynchronize *)message;
  2901. struct res_lib_ckpt_checkpointsynchronize res_lib_ckpt_checkpointsynchronize;
  2902. struct saCkptCheckpoint *checkpoint;
  2903. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointsynchronize->checkpointName);
  2904. if ((checkpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
  2905. res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_ERR_BAD_OPERATION;
  2906. } else
  2907. if (checkpoint->active_replica_set == 1) {
  2908. res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_OK;
  2909. } else {
  2910. res_lib_ckpt_checkpointsynchronize.header.error = SA_AIS_ERR_NOT_EXIST;
  2911. }
  2912. res_lib_ckpt_checkpointsynchronize.header.size = sizeof (struct res_lib_ckpt_checkpointsynchronize);
  2913. res_lib_ckpt_checkpointsynchronize.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE;
  2914. libais_send_response (conn_info,
  2915. &res_lib_ckpt_checkpointsynchronize,
  2916. sizeof (struct res_lib_ckpt_checkpointsynchronize));
  2917. return (0);
  2918. }
  2919. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message)
  2920. {
  2921. struct req_lib_ckpt_checkpointsynchronizeasync *req_lib_ckpt_checkpointsynchronizeasync = (struct req_lib_ckpt_checkpointsynchronizeasync *)message;
  2922. struct res_lib_ckpt_checkpointsynchronizeasync res_lib_ckpt_checkpointsynchronizeasync;
  2923. struct saCkptCheckpoint *checkpoint;
  2924. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointsynchronizeasync->checkpointName);
  2925. if ((checkpoint->checkpointCreationAttributes.creationFlags & (SA_CKPT_WR_ACTIVE_REPLICA | SA_CKPT_WR_ACTIVE_REPLICA_WEAK)) == 0) {
  2926. res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_BAD_OPERATION;
  2927. } else
  2928. if (checkpoint->active_replica_set == 1) {
  2929. res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_OK;
  2930. } else {
  2931. res_lib_ckpt_checkpointsynchronizeasync.header.error = SA_AIS_ERR_NOT_EXIST;
  2932. }
  2933. res_lib_ckpt_checkpointsynchronizeasync.header.size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync);
  2934. res_lib_ckpt_checkpointsynchronizeasync.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC;
  2935. res_lib_ckpt_checkpointsynchronizeasync.invocation = req_lib_ckpt_checkpointsynchronizeasync->invocation;
  2936. libais_send_response (conn_info,
  2937. &res_lib_ckpt_checkpointsynchronizeasync,
  2938. sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
  2939. libais_send_response (conn_info->conn_info_partner,
  2940. &res_lib_ckpt_checkpointsynchronizeasync,
  2941. sizeof (struct res_lib_ckpt_checkpointsynchronizeasync));
  2942. return (0);
  2943. }
  2944. static int message_handler_req_lib_ckpt_sectioniterationinitialize (struct conn_info *conn_info, void *message)
  2945. {
  2946. struct req_lib_ckpt_sectioniterationinitialize *req_lib_ckpt_sectioniterationinitialize = (struct req_lib_ckpt_sectioniterationinitialize *)message;
  2947. struct res_lib_ckpt_sectioniterationinitialize res_lib_ckpt_sectioniterationinitialize;
  2948. struct saCkptCheckpoint *ckptCheckpoint;
  2949. struct saCkptCheckpointSection *ckptCheckpointSection;
  2950. struct saCkptSectionIteratorEntry *ckptSectionIteratorEntries;
  2951. struct saCkptSectionIterator *ckptSectionIterator;
  2952. struct list_head *checkpoint_section_list;
  2953. int addEntry = 0;
  2954. int iteratorEntries = 0;
  2955. SaErrorT error = SA_AIS_OK;
  2956. log_printf (LOG_LEVEL_DEBUG, "section iterator initialize\n");
  2957. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  2958. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioniterationinitialize->checkpointName);
  2959. if (ckptCheckpoint == 0) {
  2960. error = SA_AIS_ERR_NOT_EXIST;
  2961. goto error_exit;
  2962. }
  2963. if (ckptCheckpoint->active_replica_set == 0) {
  2964. log_printf (LOG_LEVEL_NOTICE, "iterationinitialize: no active replica, returning error.\n");
  2965. error = SA_AIS_ERR_NOT_EXIST;
  2966. goto error_exit;
  2967. }
  2968. /*
  2969. * Iterate list of checkpoint sections
  2970. */
  2971. for (checkpoint_section_list = ckptCheckpoint->checkpointSectionsListHead.next;
  2972. checkpoint_section_list != &ckptCheckpoint->checkpointSectionsListHead;
  2973. checkpoint_section_list = checkpoint_section_list->next) {
  2974. ckptCheckpointSection = list_entry (checkpoint_section_list,
  2975. struct saCkptCheckpointSection, list);
  2976. addEntry = 1;
  2977. /*
  2978. * Item should be added to iterator list
  2979. */
  2980. if (addEntry) {
  2981. iteratorEntries += 1;
  2982. ckptSectionIteratorEntries =
  2983. realloc (ckptSectionIterator->sectionIteratorEntries,
  2984. sizeof (struct saCkptSectionIteratorEntry) * iteratorEntries);
  2985. if (ckptSectionIteratorEntries == 0) {
  2986. if (ckptSectionIterator->sectionIteratorEntries) {
  2987. free (ckptSectionIterator->sectionIteratorEntries);
  2988. }
  2989. error = SA_AIS_ERR_NO_MEMORY;
  2990. goto error_exit;
  2991. }
  2992. ckptSectionIteratorEntries[iteratorEntries - 1].active = 1;
  2993. ckptSectionIteratorEntries[iteratorEntries - 1].checkpointSection = ckptCheckpointSection;
  2994. ckptSectionIterator->sectionIteratorEntries = ckptSectionIteratorEntries;
  2995. }
  2996. }
  2997. ckptSectionIterator->iteratorCount = iteratorEntries;
  2998. error_exit:
  2999. res_lib_ckpt_sectioniterationinitialize.header.size = sizeof (struct res_lib_ckpt_sectioniterationinitialize);
  3000. res_lib_ckpt_sectioniterationinitialize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
  3001. res_lib_ckpt_sectioniterationinitialize.header.error = error;
  3002. libais_send_response (conn_info, &res_lib_ckpt_sectioniterationinitialize,
  3003. sizeof (struct res_lib_ckpt_sectioniterationinitialize));
  3004. return (0);
  3005. }
  3006. static int message_handler_req_lib_ckpt_sectioniterationfinalize (struct conn_info *conn_info, void *message)
  3007. {
  3008. struct req_lib_ckpt_sectioniterationfinalize *req_lib_ckpt_sectioniterationfinalize = (struct req_lib_ckpt_sectioniterationfinalize *)message;
  3009. struct res_lib_ckpt_sectioniterationfinalize res_lib_ckpt_sectioniterationfinalize;
  3010. struct saCkptCheckpoint *ckptCheckpoint;
  3011. SaErrorT error = SA_AIS_OK;
  3012. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioniterationfinalize->checkpointName);
  3013. if (ckptCheckpoint == 0) {
  3014. error = SA_AIS_ERR_NOT_EXIST;
  3015. goto error_exit;
  3016. }
  3017. if (ckptCheckpoint->active_replica_set == 0) {
  3018. log_printf (LOG_LEVEL_NOTICE, "iterationfinalize: no active replica, returning error.\n");
  3019. error = SA_AIS_ERR_NOT_EXIST;
  3020. goto error_exit;
  3021. }
  3022. error_exit:
  3023. res_lib_ckpt_sectioniterationfinalize.header.size = sizeof (struct res_lib_ckpt_sectioniterationfinalize);
  3024. res_lib_ckpt_sectioniterationfinalize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORFINALIZE;
  3025. res_lib_ckpt_sectioniterationfinalize.header.error = error;
  3026. libais_send_response (conn_info, &res_lib_ckpt_sectioniterationfinalize,
  3027. sizeof (struct res_lib_ckpt_sectioniterationfinalize));
  3028. return (0);
  3029. }
  3030. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message)
  3031. {
  3032. struct req_lib_ckpt_sectioniteratornext *req_lib_ckpt_sectioniteratornext = (struct req_lib_ckpt_sectioniteratornext *)message;
  3033. struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext;
  3034. struct saCkptSectionIterator *ckptSectionIterator;
  3035. SaErrorT error = SA_AIS_OK;
  3036. int sectionIdSize = 0;
  3037. int iteratorPos = 0;
  3038. req_lib_ckpt_sectioniteratornext = 0; /* this variable not used */
  3039. log_printf (LOG_LEVEL_DEBUG, "section iterator next\n");
  3040. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  3041. /*
  3042. * Find active iterator entry
  3043. */
  3044. for (;;) {
  3045. /*
  3046. * No more sections in iterator
  3047. */
  3048. if (ckptSectionIterator->iteratorPos + 1 >= ckptSectionIterator->iteratorCount) {
  3049. error = SA_AIS_ERR_NO_SECTIONS;
  3050. goto error_exit;
  3051. }
  3052. /*
  3053. * active iterator entry
  3054. */
  3055. if (ckptSectionIterator->sectionIteratorEntries[ckptSectionIterator->iteratorPos].active == 1) {
  3056. break;
  3057. }
  3058. ckptSectionIterator->iteratorPos += 1;
  3059. }
  3060. /*
  3061. * Prepare response to API
  3062. */
  3063. iteratorPos = ckptSectionIterator->iteratorPos;
  3064. sectionIdSize = ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.idLen;
  3065. memcpy (&res_lib_ckpt_sectioniteratornext.sectionDescriptor,
  3066. &ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor,
  3067. sizeof (SaCkptSectionDescriptorT));
  3068. /*
  3069. * Get to next iterator entry
  3070. */
  3071. ckptSectionIterator->iteratorPos += 1;
  3072. error_exit:
  3073. res_lib_ckpt_sectioniteratornext.header.size = sizeof (struct res_lib_ckpt_sectioniteratornext) + sectionIdSize;
  3074. res_lib_ckpt_sectioniteratornext.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
  3075. res_lib_ckpt_sectioniteratornext.header.error = error;
  3076. libais_send_response (conn_info, &res_lib_ckpt_sectioniteratornext,
  3077. sizeof (struct res_lib_ckpt_sectioniteratornext));
  3078. libais_send_response (conn_info,
  3079. ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.id,
  3080. sectionIdSize);
  3081. return (0);
  3082. }