ckpt.c 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778
  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 "../include/ais_types.h"
  47. #include "../include/saCkpt.h"
  48. #include "../include/ipc_ckpt.h"
  49. #include "../include/list.h"
  50. #include "../include/queue.h"
  51. #include "aispoll.h"
  52. #include "mempool.h"
  53. #include "util.h"
  54. #include "parse.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. DECLARE_LIST_INIT(checkpoint_list_head);
  61. DECLARE_LIST_INIT(checkpoint_iterator_list_head);
  62. DECLARE_LIST_INIT(checkpoint_recovery_list_head);
  63. struct checkpoint_cleanup {
  64. struct list_head list;
  65. struct saCkptCheckpoint checkpoint;
  66. };
  67. typedef enum {
  68. SYNCHRONY_STATE_STARTED,
  69. SYNCHRONY_STATE_ENDED
  70. }synchrony_state;
  71. /* TODO static totempg_recovery_plug_handle ckpt_checkpoint_recovery_plug_handle; */
  72. static int ckpt_exec_init_fn (void);
  73. static int ckpt_exit_fn (struct conn_info *conn_info);
  74. static int message_handler_req_lib_activatepoll (struct conn_info *, void *message);
  75. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr, int endian_conversion_required);
  76. static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct in_addr source_addr, int endian_conversion_required);
  77. static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct in_addr source_addr, int endian_conversion_required);
  78. static int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr, int endian_conversion_required);
  79. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr, int endian_conversion_required);
  80. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr, int endian_conversion_required);
  81. static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct in_addr source_addr, int endian_conversion_required);
  82. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr, int endian_conversion_required);
  83. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr, int endian_conversion_required);
  84. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr, int endian_conversion_required);
  85. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr, int endian_conversion_required);
  86. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr, int endian_conversion_required);
  87. static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr, int endian_conversion_required);
  88. static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message);
  89. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message);
  90. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message);
  91. static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message);
  92. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message);
  93. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message);
  94. static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message);
  95. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message);
  96. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message);
  97. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message);
  98. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message);
  99. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message);
  100. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message);
  101. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message);
  102. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message);
  103. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message);
  104. static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_info *conn_info, void *message);
  105. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message);
  106. static void ckpt_recovery_activate (void);
  107. static void ckpt_recovery_initialize (void);
  108. static int ckpt_recovery_process (void);
  109. static void ckpt_recovery_finalize();
  110. static void ckpt_recovery_abort(void);
  111. static void ckpt_recovery_process_members_exit(struct in_addr *left_list, int left_list_entries);
  112. void checkpoint_release (struct saCkptCheckpoint *checkpoint);
  113. void timer_function_retention (void *data);
  114. static int recovery_checkpoint_open(SaNameT *checkpointName,
  115. SaCkptCheckpointCreationAttributesT *ckptAttributes,
  116. struct ckpt_refcnt *ref_cnt);
  117. static int recovery_section_create (SaCkptSectionDescriptorT *sectionDescriptor,
  118. SaNameT *checkpointName,
  119. char* SectionId);
  120. static int recovery_section_write(int sectionIdLen, char* sectionId , SaNameT *checkpointName,
  121. void *newData, SaUint32T dataOffSet, SaUint32T dataSize);
  122. static synchrony_state recovery_state = SYNCHRONY_STATE_ENDED;
  123. static struct list_head *recovery_ckpt_next = 0;
  124. static struct list_head *recovery_ckpt_section_next = 0;
  125. static int recovery_section_data_offset = 0;
  126. static int recovery_section_send_flag = 0;
  127. static int recovery_abort = 0;
  128. static struct memb_ring_id saved_ring_id;
  129. static int ckpt_confchg_fn(
  130. enum totem_configuration_type configuration_type,
  131. struct in_addr *member_list, int member_list_entries,
  132. struct in_addr *left_list, int left_list_entries,
  133. struct in_addr *joined_list, int joined_list_entries,
  134. struct memb_ring_id *ring_id);
  135. struct libais_handler ckpt_libais_handlers[] =
  136. {
  137. { /* 0 */
  138. .libais_handler_fn = message_handler_req_lib_activatepoll,
  139. .response_size = sizeof (struct res_lib_activatepoll),
  140. .response_id = MESSAGE_RES_LIB_ACTIVATEPOLL,
  141. .flow_control = FLOW_CONTROL_REQUIRED
  142. },
  143. { /* 1 */
  144. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopen,
  145. .response_size = sizeof (struct res_lib_ckpt_checkpointopen),
  146. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN,
  147. .flow_control = FLOW_CONTROL_REQUIRED
  148. },
  149. { /* 2 */
  150. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointopenasync,
  151. .response_size = sizeof (struct res_lib_ckpt_checkpointopenasync),
  152. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPENASYNC,
  153. .flow_control = FLOW_CONTROL_REQUIRED
  154. },
  155. { /* 3 */
  156. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointclose,
  157. .response_size = sizeof (struct res_lib_ckpt_checkpointclose),
  158. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE,
  159. .flow_control = FLOW_CONTROL_REQUIRED
  160. },
  161. { /* 4 */
  162. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointunlink,
  163. .response_size = sizeof (struct res_lib_ckpt_checkpointunlink),
  164. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK,
  165. .flow_control = FLOW_CONTROL_REQUIRED
  166. },
  167. { /* 5 */
  168. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointretentiondurationset,
  169. .response_size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset),
  170. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET,
  171. .flow_control = FLOW_CONTROL_REQUIRED
  172. },
  173. { /* 6 */
  174. .libais_handler_fn = message_handler_req_lib_ckpt_activereplicaset,
  175. .response_size = sizeof (struct res_lib_ckpt_activereplicaset),
  176. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_ACTIVEREPLICASET,
  177. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  178. },
  179. { /* 7 */
  180. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointstatusget,
  181. .response_size = sizeof (struct res_lib_ckpt_checkpointstatusget),
  182. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET,
  183. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  184. },
  185. { /* 8 */
  186. .libais_handler_fn = message_handler_req_lib_ckpt_sectioncreate,
  187. .response_size = sizeof (struct res_lib_ckpt_sectioncreate),
  188. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE,
  189. .flow_control = FLOW_CONTROL_REQUIRED
  190. },
  191. { /* 9 */
  192. .libais_handler_fn = message_handler_req_lib_ckpt_sectiondelete,
  193. .response_size = sizeof (struct res_lib_ckpt_sectiondelete),
  194. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE,
  195. .flow_control = FLOW_CONTROL_REQUIRED
  196. },
  197. { /* 10 */
  198. .libais_handler_fn = message_handler_req_lib_ckpt_sectionexpirationtimeset,
  199. .response_size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset),
  200. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET,
  201. .flow_control = FLOW_CONTROL_REQUIRED
  202. },
  203. { /* 11 */
  204. .libais_handler_fn = message_handler_req_lib_ckpt_sectionwrite,
  205. .response_size = sizeof (struct res_lib_ckpt_sectionwrite),
  206. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE,
  207. .flow_control = FLOW_CONTROL_REQUIRED
  208. },
  209. { /* 12 */
  210. .libais_handler_fn = message_handler_req_lib_ckpt_sectionoverwrite,
  211. .response_size = sizeof (struct res_lib_ckpt_sectionoverwrite),
  212. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE,
  213. .flow_control = FLOW_CONTROL_REQUIRED
  214. },
  215. { /* 13 */
  216. .libais_handler_fn = message_handler_req_lib_ckpt_sectionread,
  217. .response_size = sizeof (struct res_lib_ckpt_sectionread),
  218. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD,
  219. .flow_control = FLOW_CONTROL_REQUIRED
  220. },
  221. { /* 14 */
  222. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronize,
  223. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronize),
  224. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZE,
  225. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  226. },
  227. { /* 15 */
  228. .libais_handler_fn = message_handler_req_lib_ckpt_checkpointsynchronizeasync,
  229. .response_size = sizeof (struct res_lib_ckpt_checkpointsynchronizeasync), /* TODO RESPONSE */
  230. .response_id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSYNCHRONIZEASYNC,
  231. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  232. },
  233. { /* 16 */
  234. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratorinitialize,
  235. .response_size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize),
  236. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE,
  237. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  238. },
  239. { /* 17 */
  240. .libais_handler_fn = message_handler_req_lib_ckpt_sectioniteratornext,
  241. .response_size = sizeof (struct res_lib_ckpt_sectioniteratornext),
  242. .response_id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT,
  243. .flow_control = FLOW_CONTROL_NOT_REQUIRED
  244. }
  245. };
  246. static int (*ckpt_aisexec_handler_fns[]) (void *msg, struct in_addr source_addr, int endian_conversion_required) = {
  247. message_handler_req_exec_ckpt_checkpointopen,
  248. message_handler_req_exec_ckpt_checkpointclose,
  249. message_handler_req_exec_ckpt_checkpointunlink,
  250. message_handler_req_exec_ckpt_checkpointretentiondurationset,
  251. message_handler_req_exec_ckpt_checkpointretentiondurationexpire,
  252. message_handler_req_exec_ckpt_sectioncreate,
  253. message_handler_req_exec_ckpt_sectiondelete,
  254. message_handler_req_exec_ckpt_sectionexpirationtimeset,
  255. message_handler_req_exec_ckpt_sectionwrite,
  256. message_handler_req_exec_ckpt_sectionoverwrite,
  257. message_handler_req_exec_ckpt_sectionread,
  258. message_handler_req_exec_ckpt_synchronize_state,
  259. message_handler_req_exec_ckpt_synchronize_section
  260. };
  261. struct service_handler ckpt_service_handler = {
  262. .libais_handlers = ckpt_libais_handlers,
  263. .libais_handlers_count = sizeof (ckpt_libais_handlers) / sizeof (struct libais_handler),
  264. .aisexec_handler_fns = ckpt_aisexec_handler_fns,
  265. .aisexec_handler_fns_count = sizeof (ckpt_aisexec_handler_fns) / sizeof (int (*)),
  266. .confchg_fn = ckpt_confchg_fn,
  267. .libais_init_fn = message_handler_req_lib_ckpt_init,
  268. .libais_exit_fn = ckpt_exit_fn,
  269. .exec_init_fn = ckpt_exec_init_fn,
  270. .exec_dump_fn = 0,
  271. .sync_init = ckpt_recovery_initialize,
  272. .sync_process = ckpt_recovery_process,
  273. .sync_activate = ckpt_recovery_activate,
  274. .sync_abort = ckpt_recovery_abort,
  275. };
  276. static int processor_index_set(struct in_addr *proc_addr,
  277. struct ckpt_refcnt *ckpt_refcount)
  278. {
  279. int i;
  280. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  281. /*
  282. * If the source addresses match then this processor index
  283. * has already been set
  284. */
  285. if (ckpt_refcount[i].addr.s_addr == proc_addr->s_addr) {
  286. return -1;
  287. } else if (ckpt_refcount[i].addr.s_addr == 0) {
  288. /*
  289. * If the source addresses do not match and this element
  290. * has no stored value then store the new value and
  291. * return the Index.
  292. */
  293. memcpy(&ckpt_refcount[i].addr, proc_addr, sizeof(struct in_addr));
  294. return i;
  295. }
  296. }
  297. /*
  298. * Could not Find an empty slot
  299. * to store the new Processor.
  300. */
  301. return -1;
  302. }
  303. static int processor_index_find(struct in_addr *proc_addr,
  304. struct ckpt_refcnt *ckpt_refcount)
  305. {
  306. int i;
  307. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  308. /*
  309. * If the source addresses match then return the index
  310. */
  311. if (ckpt_refcount[i].addr.s_addr == proc_addr->s_addr) {
  312. return i;
  313. }
  314. }
  315. /*
  316. * Could not Find the Processor
  317. */
  318. return -1;
  319. }
  320. static int ckpt_refcount_total(struct ckpt_refcnt *ckpt_refcount)
  321. {
  322. int i;
  323. int total = 0;
  324. for (i = 0; i < PROCESSOR_COUNT_MAX; i ++) {
  325. total += ckpt_refcount[i].count;
  326. }
  327. return total;
  328. }
  329. static void initialize_ckpt_refcount_array (struct ckpt_refcnt *ckpt_refcount)
  330. {
  331. memset((char*)ckpt_refcount, 0, PROCESSOR_COUNT_MAX * sizeof(struct ckpt_refcnt));
  332. }
  333. static void ckpt_recovery_initialize (void)
  334. {
  335. struct list_head *checkpoint_list;
  336. struct list_head *checkpoint_section_list;
  337. struct saCkptCheckpoint *checkpoint;
  338. struct saCkptCheckpointSection *section;
  339. struct saCkptCheckpoint *savedCheckpoint;
  340. struct saCkptCheckpointSection *savedSection;
  341. if (recovery_abort) { /*Abort was called.*/
  342. return;
  343. }
  344. /*
  345. * Save off the existing Checkpoints to be used by ckpt_recovery_process
  346. */
  347. for (checkpoint_list = checkpoint_list_head.next;
  348. checkpoint_list != &checkpoint_list_head;
  349. checkpoint_list = checkpoint_list->next) {
  350. checkpoint = list_entry (checkpoint_list,
  351. struct saCkptCheckpoint, list);
  352. if (checkpoint->referenceCount <= 0) {
  353. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_initialize checkpoint %s has referenceCount 0 ignoring.\n",
  354. (char*)&checkpoint->name.value);
  355. continue;
  356. }
  357. savedCheckpoint =
  358. (struct saCkptCheckpoint *) malloc (sizeof(struct saCkptCheckpoint));
  359. assert(savedCheckpoint);
  360. memcpy(savedCheckpoint, checkpoint, sizeof(struct saCkptCheckpoint));
  361. list_init(&savedCheckpoint->list);
  362. list_add(&savedCheckpoint->list,&checkpoint_recovery_list_head);
  363. list_init(&savedCheckpoint->checkpointSectionsListHead);
  364. for (checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  365. checkpoint_section_list != &checkpoint->checkpointSectionsListHead;
  366. checkpoint_section_list = checkpoint_section_list->next) {
  367. section = list_entry (checkpoint_section_list,
  368. struct saCkptCheckpointSection, list);
  369. savedSection =
  370. (struct saCkptCheckpointSection *) malloc (sizeof(struct saCkptCheckpointSection));
  371. assert(savedSection);
  372. memcpy(savedSection, section, sizeof(struct saCkptCheckpointSection));
  373. list_init(&savedSection->list);
  374. list_add(&savedSection->list,&savedCheckpoint->checkpointSectionsListHead);
  375. }
  376. }
  377. if (list_empty (&checkpoint_recovery_list_head)) {
  378. return;
  379. }
  380. recovery_ckpt_next = checkpoint_recovery_list_head.next;
  381. savedCheckpoint = list_entry (recovery_ckpt_next,
  382. struct saCkptCheckpoint, list);
  383. recovery_ckpt_section_next = savedCheckpoint->checkpointSectionsListHead.next;
  384. }
  385. static int ckpt_recovery_process (void)
  386. {
  387. struct req_exec_ckpt_synchronize_state request_exec_sync_state;
  388. struct req_exec_ckpt_synchronize_section request_exec_sync_section;
  389. struct iovec iovecs[3];
  390. struct saCkptCheckpoint *checkpoint;
  391. struct saCkptCheckpointSection *ckptCheckpointSection;
  392. SaSizeT origSectionSize;
  393. SaSizeT newSectionSize;
  394. if (recovery_abort) { /*Abort was called.*/
  395. goto recovery_exit_clean;
  396. }
  397. /*So Initialize did not have any checkpoints to Synchronize*/
  398. if ((recovery_ckpt_next == 0) && (recovery_ckpt_section_next == 0)) {
  399. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_process Nothing to Process ...\n");
  400. goto recovery_exit_clean;
  401. }
  402. /*
  403. * ALGORITHM :
  404. * 1.) extract the checkpoint if there.
  405. * 2.) If there is a checkpoint then there has to be a section
  406. * 3.) If the recovery_section_send_flag was not set in the previous
  407. * invocation that means we have to send out a sync_msg before
  408. * we send out the sections
  409. * 4.) Set the recovery_section_send_flag and send the sections.
  410. */
  411. while (1) { /*Go for as long as the oubound queue is not full*/
  412. if(recovery_ckpt_next != &checkpoint_recovery_list_head) {
  413. checkpoint = list_entry (recovery_ckpt_next,
  414. struct saCkptCheckpoint, list);
  415. if (recovery_ckpt_section_next == 0) {
  416. recovery_ckpt_section_next = checkpoint->checkpointSectionsListHead.next;
  417. }
  418. if (recovery_ckpt_section_next != &checkpoint->checkpointSectionsListHead) {
  419. ckptCheckpointSection = list_entry (recovery_ckpt_section_next,
  420. struct saCkptCheckpointSection, list);
  421. /*
  422. * None of the section data msgs have been sent
  423. * so lets start with sending the sync_msg
  424. */
  425. if (recovery_section_send_flag == 0) {
  426. if ((int)ckptCheckpointSection->sectionDescriptor.sectionId.id) {
  427. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message for ckpt = %s, section = %s.\n",
  428. (char*)&checkpoint->name.value,
  429. ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id));
  430. } else {
  431. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync State Message for ckpt = %s, section = default section.\n",
  432. (char*)&checkpoint->name.value);
  433. }
  434. request_exec_sync_state.header.size = sizeof (struct req_exec_ckpt_synchronize_state);
  435. request_exec_sync_state.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESTATE;
  436. memcpy(&request_exec_sync_state.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
  437. memcpy(&request_exec_sync_state.checkpointName, &checkpoint->name, sizeof(SaNameT));
  438. memcpy(&request_exec_sync_state.checkpointCreationAttributes,
  439. &checkpoint->checkpointCreationAttributes,
  440. sizeof(SaCkptCheckpointCreationAttributesT));
  441. memcpy(&request_exec_sync_state.sectionDescriptor,
  442. &ckptCheckpointSection->sectionDescriptor,
  443. sizeof(SaCkptSectionDescriptorT));
  444. memcpy(&request_exec_sync_state.source_addr, &this_ip->sin_addr, sizeof(struct in_addr));
  445. memcpy(request_exec_sync_state.ckpt_refcount,
  446. checkpoint->ckpt_refcount,
  447. sizeof(struct ckpt_refcnt)*PROCESSOR_COUNT_MAX);
  448. request_exec_sync_state.sectionDescriptor.sectionId.id = 0;
  449. iovecs[0].iov_base = (char *)&request_exec_sync_state;
  450. iovecs[0].iov_len = sizeof (struct req_exec_ckpt_synchronize_state);
  451. /*
  452. * Populate the Section ID
  453. */
  454. iovecs[1].iov_base = ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id);
  455. iovecs[1].iov_len = ckptCheckpointSection->sectionDescriptor.sectionId.idLen;
  456. request_exec_sync_state.header.size += iovecs[1].iov_len;
  457. /*
  458. * Check to see if we can queue the new message and if you can
  459. * then mcast the message else break and create callback.
  460. */
  461. if (totempg_send_ok(iovecs[0].iov_len + iovecs[1].iov_len)){
  462. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  463. log_printf (LOG_LEVEL_DEBUG, "CKPT: Multicasted Sync State Message.\n");
  464. }
  465. else {
  466. log_printf (LOG_LEVEL_DEBUG, "CKPT: Sync State Message Outbound Queue full need to Wait for Callback.\n");
  467. return (1);
  468. }
  469. recovery_section_send_flag = 1;
  470. }
  471. origSectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize;
  472. newSectionSize = 0;
  473. /*
  474. * Now Create SyncSection messsages in chunks of CKPT_MAX_SECTION_DATA_SEND or less
  475. */
  476. while (recovery_section_data_offset < origSectionSize) {
  477. /*
  478. * Send a Max of CKPT_MAX_SECTION_DATA_SEND of section data
  479. */
  480. if ((origSectionSize - recovery_section_data_offset) > CKPT_MAX_SECTION_DATA_SEND) {
  481. newSectionSize = CKPT_MAX_SECTION_DATA_SEND;
  482. }
  483. else {
  484. newSectionSize = (origSectionSize - recovery_section_data_offset);
  485. }
  486. /*
  487. * Create and save a new Sync Section message.
  488. */
  489. request_exec_sync_section.header.size = sizeof (struct req_exec_ckpt_synchronize_section);
  490. request_exec_sync_section.header.id = MESSAGE_REQ_EXEC_CKPT_SYNCHRONIZESECTION;
  491. memcpy (&request_exec_sync_section.previous_ring_id, &saved_ring_id, sizeof(struct memb_ring_id));
  492. memcpy (&request_exec_sync_section.checkpointName, &checkpoint->name, sizeof(SaNameT));
  493. memcpy (&request_exec_sync_section.sectionId,
  494. &ckptCheckpointSection->sectionDescriptor.sectionId,
  495. sizeof(SaCkptSectionIdT));
  496. request_exec_sync_section.sectionId.id = 0;
  497. memcpy (&request_exec_sync_section.dataOffSet, &recovery_section_data_offset, sizeof(SaUint32T));
  498. memcpy (&request_exec_sync_section.dataSize, &newSectionSize, sizeof(SaUint32T));
  499. if (ckptCheckpointSection->sectionDescriptor.sectionId.id) {
  500. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync Section Message for ckpt = %s, section = %s, Data size = %d.\n",
  501. (char*)&checkpoint->name.value,
  502. ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id),
  503. newSectionSize);
  504. } else {
  505. log_printf (LOG_LEVEL_DEBUG, "CKPT: New Sync Section Message for ckpt = %s, default section, Data size = %d.\n",
  506. (char*)&checkpoint->name.value,newSectionSize);
  507. }
  508. /*
  509. * Populate the Sync Section Request
  510. */
  511. iovecs[0].iov_base = (char *)&request_exec_sync_section;
  512. iovecs[0].iov_len = sizeof (struct req_exec_ckpt_synchronize_section);
  513. /*
  514. * Populate the Section ID
  515. */
  516. iovecs[1].iov_base = ((char*)ckptCheckpointSection->sectionDescriptor.sectionId.id);
  517. iovecs[1].iov_len = ckptCheckpointSection->sectionDescriptor.sectionId.idLen;
  518. request_exec_sync_section.header.size += iovecs[1].iov_len;
  519. /*
  520. * Populate the Section Data.
  521. */
  522. iovecs[2].iov_base = ((char*)ckptCheckpointSection->sectionData + recovery_section_data_offset);
  523. iovecs[2].iov_len = newSectionSize;
  524. request_exec_sync_section.header.size += iovecs[2].iov_len;
  525. /*
  526. * Check to see if we can queue the new message and if you can
  527. * then mcast the message else break and create callback.
  528. */
  529. if (totempg_send_ok(iovecs[0].iov_len + iovecs[1].iov_len + iovecs[2].iov_len)){
  530. assert (totempg_mcast (iovecs, 3, TOTEMPG_AGREED) == 0);
  531. log_printf (LOG_LEVEL_DEBUG, "CKPT: Multicasted Sync Section Message.\n");
  532. }
  533. else {
  534. log_printf (LOG_LEVEL_DEBUG, "CKPT: Sync Section Message Outbound Queue full need to Wait for Callback.\n");
  535. return (1);
  536. }
  537. recovery_section_data_offset += newSectionSize;
  538. }
  539. recovery_section_send_flag = 0;
  540. recovery_section_data_offset = 0;
  541. recovery_ckpt_section_next = recovery_ckpt_section_next->next;
  542. continue;
  543. }
  544. else {
  545. /*
  546. * We have reached the end of a section List.
  547. * Move to the next element in the ckpt list.
  548. * Init the section ptr to 0 so it is re evaled
  549. */
  550. recovery_ckpt_next = recovery_ckpt_next->next;
  551. recovery_ckpt_section_next = 0;
  552. continue;
  553. }
  554. }
  555. /*Should only be here at the end of the traversal of the ckpt list*/
  556. ckpt_recovery_finalize();
  557. recovery_exit_clean:
  558. /*Re - Initialize the static's*/
  559. recovery_ckpt_next = 0;
  560. recovery_ckpt_section_next = 0;
  561. recovery_section_data_offset = 0;
  562. recovery_section_send_flag = 0;
  563. recovery_abort = 0;
  564. return (0);
  565. }
  566. }
  567. static void ckpt_recovery_finalize ()
  568. {
  569. struct list_head *checkpoint_list;
  570. struct list_head *checkpoint_section_list;
  571. struct saCkptCheckpoint *checkpoint;
  572. struct saCkptCheckpointSection *section;
  573. /*
  574. * Remove All elements from old checkpoint
  575. * list
  576. */
  577. checkpoint_list = checkpoint_list_head.next;
  578. while (!list_empty(&checkpoint_list_head)) {
  579. checkpoint = list_entry (checkpoint_list,
  580. struct saCkptCheckpoint, list);
  581. checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  582. while (!list_empty(&checkpoint->checkpointSectionsListHead)) {
  583. section = list_entry (checkpoint_section_list,
  584. struct saCkptCheckpointSection, list);
  585. list_del (&section->list);
  586. free (section);
  587. checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  588. }
  589. list_del(&checkpoint->list);
  590. free(checkpoint);
  591. checkpoint_list = checkpoint_list_head.next;
  592. }
  593. /*
  594. * Initialize the old list again.
  595. */
  596. list_init(&checkpoint_list_head);
  597. /*
  598. * Copy the contents of the new list_head into the old list head
  599. */
  600. checkpoint_recovery_list_head.prev->next = &checkpoint_list_head;
  601. checkpoint_recovery_list_head.next->prev = &checkpoint_list_head;
  602. memcpy(&checkpoint_list_head, &checkpoint_recovery_list_head, sizeof(struct list_head));
  603. /*
  604. * Initialize the new list head for reuse.
  605. */
  606. list_init(&checkpoint_recovery_list_head);
  607. log_printf (LOG_LEVEL_DEBUG, "CKPT: ckpt_recovery_finalize Done.\n");
  608. }
  609. static void ckpt_recovery_activate (void)
  610. {
  611. recovery_state = SYNCHRONY_STATE_ENDED;
  612. return;
  613. }
  614. static void ckpt_recovery_abort (void)
  615. {
  616. recovery_abort = 1;
  617. return;
  618. }
  619. static void ckpt_recovery_process_members_exit(struct in_addr *left_list, int left_list_entries)
  620. {
  621. struct list_head *checkpoint_list;
  622. struct saCkptCheckpoint *checkpoint;
  623. struct in_addr *member;
  624. int index;
  625. int i;
  626. if (left_list_entries == 0) {
  627. return;
  628. }
  629. /*
  630. * Iterate left_list_entries.
  631. */
  632. member = left_list;
  633. for (i = 0; i < left_list_entries; i++) {
  634. for (checkpoint_list = checkpoint_list_head.next;
  635. checkpoint_list != &checkpoint_list_head;
  636. checkpoint_list = checkpoint_list->next) {
  637. checkpoint = list_entry (checkpoint_list,
  638. struct saCkptCheckpoint, list);
  639. index = processor_index_find(member, checkpoint->ckpt_refcount);
  640. if (index == -1) {
  641. continue;
  642. }
  643. /*
  644. * Decrement
  645. *
  646. */
  647. if (checkpoint->referenceCount >= 0) {
  648. checkpoint->referenceCount -= checkpoint->ckpt_refcount[index].count;
  649. log_printf (LOG_LEVEL_DEBUG, "ckpt_recovery_process_members_exit: refCount for %s = %d.\n",
  650. &checkpoint->name.value,checkpoint->referenceCount);
  651. assert (checkpoint->referenceCount >= 0);
  652. } else {
  653. log_printf (LOG_LEVEL_ERROR, "ckpt_recovery_process_members_exit: refCount for %s = %d.\n",
  654. &checkpoint->name.value,checkpoint->referenceCount);
  655. assert(0);
  656. }
  657. checkpoint->ckpt_refcount[index].count = 0;
  658. memset((char*)&checkpoint->ckpt_refcount[index].addr, 0, sizeof(struct in_addr));
  659. /*
  660. * If checkpoint has been unlinked and this is the last reference, delete it
  661. */
  662. if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
  663. log_printf (LOG_LEVEL_DEBUG, "ckpt_recovery_process_members_exit: Unlinking checkpoint %s.\n",
  664. &checkpoint->name.value);
  665. checkpoint_release (checkpoint);
  666. } else
  667. if (checkpoint->referenceCount == 0) {
  668. log_printf (LOG_LEVEL_DEBUG, "ckpt_recovery_process_members_exit: Starting timer to release checkpoint %s.\n",
  669. &checkpoint->name.value);
  670. poll_timer_add (aisexec_poll_handle,
  671. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  672. checkpoint,
  673. timer_function_retention,
  674. &checkpoint->retention_timer);
  675. }
  676. }
  677. member++;
  678. }
  679. return;
  680. }
  681. static int ckpt_confchg_fn (
  682. enum totem_configuration_type configuration_type,
  683. struct in_addr *member_list, int member_list_entries,
  684. struct in_addr *left_list, int left_list_entries,
  685. struct in_addr *joined_list, int joined_list_entries,
  686. struct memb_ring_id *ring_id)
  687. {
  688. if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
  689. #ifdef TODO
  690. totempg_recovery_plug_unplug (ckpt_checkpoint_recovery_plug_handle);
  691. #endif
  692. if (recovery_state == SYNCHRONY_STATE_ENDED) {
  693. memcpy (&saved_ring_id, ring_id, sizeof(struct memb_ring_id));
  694. }
  695. }
  696. else if (configuration_type == TOTEM_CONFIGURATION_TRANSITIONAL) {
  697. ckpt_recovery_process_members_exit(left_list, left_list_entries);
  698. recovery_state = SYNCHRONY_STATE_STARTED;
  699. recovery_abort = 0;
  700. }
  701. return (0);
  702. }
  703. static struct saCkptCheckpoint *ckpt_checkpoint_find_global (SaNameT *name)
  704. {
  705. struct list_head *checkpoint_list;
  706. struct saCkptCheckpoint *checkpoint;
  707. for (checkpoint_list = checkpoint_list_head.next;
  708. checkpoint_list != &checkpoint_list_head;
  709. checkpoint_list = checkpoint_list->next) {
  710. checkpoint = list_entry (checkpoint_list,
  711. struct saCkptCheckpoint, list);
  712. if (name_match (name, &checkpoint->name)) {
  713. return (checkpoint);
  714. }
  715. }
  716. return (0);
  717. }
  718. static void ckpt_checkpoint_remove_cleanup (
  719. struct conn_info *conn_info,
  720. struct saCkptCheckpoint *checkpoint)
  721. {
  722. struct list_head *list;
  723. struct checkpoint_cleanup *checkpoint_cleanup;
  724. for (list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next;
  725. list != &conn_info->ais_ci.u.libckpt_ci.checkpoint_list;
  726. list = list->next) {
  727. checkpoint_cleanup = list_entry (list,
  728. struct checkpoint_cleanup, list);
  729. if (name_match (&checkpoint_cleanup->checkpoint.name, &checkpoint->name)
  730. || (checkpoint_cleanup->checkpoint.name.length == 0)) {
  731. list_del (&checkpoint_cleanup->list);
  732. free (checkpoint_cleanup);
  733. return;
  734. }
  735. }
  736. }
  737. static struct saCkptCheckpointSection *ckpt_checkpoint_find_globalSection (
  738. struct saCkptCheckpoint *ckptCheckpoint,
  739. char *id,
  740. int idLen)
  741. {
  742. struct list_head *checkpoint_section_list;
  743. struct saCkptCheckpointSection *ckptCheckpointSection;
  744. if (idLen != 0) {
  745. log_printf (LOG_LEVEL_DEBUG, "Finding checkpoint section id %s %d\n", (char*)id, idLen);
  746. }
  747. else {
  748. log_printf (LOG_LEVEL_DEBUG, "Finding default checkpoint section\n");
  749. }
  750. for (checkpoint_section_list = ckptCheckpoint->checkpointSectionsListHead.next;
  751. checkpoint_section_list != &ckptCheckpoint->checkpointSectionsListHead;
  752. checkpoint_section_list = checkpoint_section_list->next) {
  753. ckptCheckpointSection = list_entry (checkpoint_section_list,
  754. struct saCkptCheckpointSection, list);
  755. if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen) {
  756. log_printf (LOG_LEVEL_DEBUG, "Checking section id %*s\n",
  757. ckptCheckpointSection->sectionDescriptor.sectionId.idLen,
  758. ckptCheckpointSection->sectionDescriptor.sectionId.id);
  759. }
  760. else {
  761. log_printf (LOG_LEVEL_DEBUG, "Checking default section id\n");
  762. }
  763. /*
  764. All 3 of these values being checked MUST be = 0 to return
  765. The default section. If even one of them is NON zero follow
  766. the normal route
  767. */
  768. if ((idLen ||
  769. ckptCheckpointSection->sectionDescriptor.sectionId.id ||
  770. ckptCheckpointSection->sectionDescriptor.sectionId.idLen) == 0) {
  771. log_printf (LOG_LEVEL_DEBUG, "Returning default section\n");
  772. return (ckptCheckpointSection);
  773. }
  774. if (ckptCheckpointSection->sectionDescriptor.sectionId.idLen == idLen &&
  775. (ckptCheckpointSection->sectionDescriptor.sectionId.id)&&
  776. (id)&&
  777. (memcmp (ckptCheckpointSection->sectionDescriptor.sectionId.id,
  778. id, idLen) == 0)) {
  779. return (ckptCheckpointSection);
  780. }
  781. }
  782. return 0;
  783. }
  784. void checkpoint_section_release (struct saCkptCheckpointSection *section)
  785. {
  786. list_del (&section->list);
  787. if (section->sectionDescriptor.sectionId.id) {
  788. free (section->sectionDescriptor.sectionId.id);
  789. }
  790. if (section->sectionData) {
  791. free (section->sectionData);
  792. }
  793. poll_timer_delete (aisexec_poll_handle, section->expiration_timer);
  794. free (section);
  795. }
  796. void checkpoint_release (struct saCkptCheckpoint *checkpoint)
  797. {
  798. struct list_head *list;
  799. struct saCkptCheckpointSection *section;
  800. poll_timer_delete (aisexec_poll_handle, checkpoint->retention_timer);
  801. /*
  802. * Release all checkpoint sections for this checkpoint
  803. */
  804. for (list = checkpoint->checkpointSectionsListHead.next;
  805. list != &checkpoint->checkpointSectionsListHead;) {
  806. section = list_entry (list,
  807. struct saCkptCheckpointSection, list);
  808. list = list->next;
  809. checkpoint_section_release (section);
  810. }
  811. list_del (&checkpoint->list);
  812. free (checkpoint);
  813. }
  814. int ckpt_checkpoint_close (struct saCkptCheckpoint *checkpoint) {
  815. struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
  816. struct iovec iovecs[2];
  817. if (checkpoint->expired == 1) {
  818. return (0);
  819. }
  820. req_exec_ckpt_checkpointclose.header.size =
  821. sizeof (struct req_exec_ckpt_checkpointclose);
  822. req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
  823. memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
  824. &checkpoint->name, sizeof (SaNameT));
  825. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose;
  826. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
  827. if (totempg_send_ok (sizeof (struct req_exec_ckpt_checkpointclose))) {
  828. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  829. return (0);
  830. }
  831. return (-1);
  832. }
  833. static int ckpt_exec_init_fn (void)
  834. {
  835. /*
  836. * Initialize the saved ring ID.
  837. */
  838. saved_ring_id.seq = 0;
  839. saved_ring_id.rep.s_addr = this_ip->sin_addr.s_addr;
  840. #ifdef TODO
  841. int res;
  842. res = totempg_recovery_plug_create (&ckpt_checkpoint_recovery_plug_handle);
  843. if (res != 0) {
  844. log_printf(LOG_LEVEL_ERROR,
  845. "Could not create recovery plug for clm service.\n");
  846. return (-1);
  847. }
  848. #endif
  849. return (0);
  850. }
  851. static int ckpt_exit_fn (struct conn_info *conn_info)
  852. {
  853. struct checkpoint_cleanup *checkpoint_cleanup;
  854. struct list_head *cleanup_list;
  855. if (conn_info->service != SOCKET_SERVICE_CKPT) {
  856. return 0;
  857. }
  858. /*
  859. * close all checkpoints opened on this fd
  860. */
  861. cleanup_list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next;
  862. while (!list_empty(&conn_info->ais_ci.u.libckpt_ci.checkpoint_list)) {
  863. checkpoint_cleanup = list_entry (cleanup_list,
  864. struct checkpoint_cleanup, list);
  865. if (checkpoint_cleanup->checkpoint.name.length > 0) {
  866. ckpt_checkpoint_close (&checkpoint_cleanup->checkpoint);
  867. }
  868. list_del (&checkpoint_cleanup->list);
  869. free (checkpoint_cleanup);
  870. cleanup_list = conn_info->ais_ci.u.libckpt_ci.checkpoint_list.next;
  871. }
  872. if (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries) {
  873. free (conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries);
  874. }
  875. list_del (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list);
  876. return (0);
  877. }
  878. static int message_handler_req_lib_activatepoll (struct conn_info *conn_info, void *message)
  879. {
  880. struct res_lib_activatepoll res_lib_activatepoll;
  881. res_lib_activatepoll.header.size = sizeof (struct res_lib_activatepoll);
  882. res_lib_activatepoll.header.id = MESSAGE_RES_LIB_ACTIVATEPOLL;
  883. res_lib_activatepoll.header.error = SA_AIS_OK;
  884. libais_send_response (conn_info, &res_lib_activatepoll,
  885. sizeof (struct res_lib_activatepoll));
  886. return (0);
  887. }
  888. static int message_handler_req_exec_ckpt_checkpointopen (void *message, struct in_addr source_addr, int endian_conversion_required)
  889. {
  890. struct req_exec_ckpt_checkpointopen *req_exec_ckpt_checkpointopen = (struct req_exec_ckpt_checkpointopen *)message;
  891. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)&req_exec_ckpt_checkpointopen->req_lib_ckpt_checkpointopen;
  892. struct res_lib_ckpt_checkpointopen res_lib_ckpt_checkpointopen;
  893. struct saCkptCheckpoint *ckptCheckpoint = 0;
  894. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  895. struct checkpoint_cleanup *checkpoint_cleanup;
  896. SaErrorT error = SA_AIS_OK;
  897. log_printf (LOG_LEVEL_DEBUG, "Executive request to open checkpoint %p\n", req_exec_ckpt_checkpointopen);
  898. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointopen->checkpointName);
  899. /*
  900. * If checkpoint doesn't exist, create one
  901. */
  902. if (ckptCheckpoint == 0) {
  903. ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
  904. if (ckptCheckpoint == 0) {
  905. error = SA_AIS_ERR_NO_MEMORY;
  906. goto error_exit;
  907. }
  908. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  909. if (ckptCheckpointSection == 0) {
  910. free (ckptCheckpoint);
  911. error = SA_AIS_ERR_NO_MEMORY;
  912. goto error_exit;
  913. }
  914. memcpy (&ckptCheckpoint->name,
  915. &req_lib_ckpt_checkpointopen->checkpointName,
  916. sizeof (SaNameT));
  917. memcpy (&ckptCheckpoint->checkpointCreationAttributes,
  918. &req_lib_ckpt_checkpointopen->checkpointCreationAttributes,
  919. sizeof (SaCkptCheckpointCreationAttributesT));
  920. ckptCheckpoint->unlinked = 0;
  921. list_init (&ckptCheckpoint->list);
  922. list_init (&ckptCheckpoint->checkpointSectionsListHead);
  923. list_add (&ckptCheckpoint->list, &checkpoint_list_head);
  924. ckptCheckpoint->referenceCount = 0;
  925. ckptCheckpoint->retention_timer = 0;
  926. ckptCheckpoint->expired = 0;
  927. initialize_ckpt_refcount_array(ckptCheckpoint->ckpt_refcount);
  928. /*
  929. * Add in default checkpoint section
  930. */
  931. list_init (&ckptCheckpointSection->list);
  932. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  933. /*
  934. * Default section id
  935. */
  936. ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
  937. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
  938. ckptCheckpointSection->sectionDescriptor.expirationTime = SA_TIME_END;
  939. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  940. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /*current time*/
  941. ckptCheckpointSection->sectionDescriptor.sectionSize = strlen("Factory installed data\0")+1;
  942. ckptCheckpointSection->sectionData = malloc(strlen("Factory installed data\0")+1);
  943. assert(ckptCheckpointSection->sectionData);
  944. memcpy(ckptCheckpointSection->sectionData, "Factory installed data\0", strlen("Factory installed data\0")+1);
  945. ckptCheckpointSection->expiration_timer = 0;
  946. }
  947. /*
  948. * If the checkpoint has been unlinked, it is an invalid name
  949. */
  950. if (ckptCheckpoint->unlinked) {
  951. error = SA_AIS_ERR_INVALID_PARAM; /* Is this the correct return ? */
  952. goto error_exit;
  953. }
  954. /*
  955. * Setup connection information and mark checkpoint as referenced
  956. */
  957. log_printf (LOG_LEVEL_DEBUG, "CHECKPOINT opened is %p\n", ckptCheckpoint);
  958. ckptCheckpoint->referenceCount += 1;
  959. /*
  960. * Add the connection reference information to the Checkpoint to be
  961. * sent out later as a part of the sync process.
  962. *
  963. */
  964. int proc_index = processor_index_find(&source_addr,ckptCheckpoint->ckpt_refcount);
  965. if (proc_index == -1) {/* Could not find, lets set the processor to an index.*/
  966. proc_index = processor_index_set(&source_addr,ckptCheckpoint->ckpt_refcount);
  967. }
  968. if (proc_index != -1 ) {
  969. ckptCheckpoint->ckpt_refcount[proc_index].addr = source_addr;
  970. ckptCheckpoint->ckpt_refcount[proc_index].count++;
  971. }
  972. else {
  973. log_printf (LOG_LEVEL_ERROR,
  974. "CKPT: MAX LIMIT OF PROCESSORS reached. Cannot store new proc %p info.\n",
  975. ckptCheckpoint);
  976. }
  977. /*
  978. * Reset retention duration since this checkpoint was just opened
  979. */
  980. poll_timer_delete (aisexec_poll_handle, ckptCheckpoint->retention_timer);
  981. ckptCheckpoint->retention_timer = 0;
  982. /*
  983. * Send error result to CKPT library
  984. */
  985. error_exit:
  986. /*
  987. * If this node was the source of the message, respond to this node
  988. */
  989. if (message_source_is_local(&req_exec_ckpt_checkpointopen->source)) {
  990. res_lib_ckpt_checkpointopen.header.size = sizeof (struct res_lib_ckpt_checkpointopen);
  991. res_lib_ckpt_checkpointopen.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTOPEN;
  992. res_lib_ckpt_checkpointopen.header.error = error;
  993. if (error == SA_AIS_OK) {
  994. checkpoint_cleanup = malloc (sizeof (struct checkpoint_cleanup));
  995. if (checkpoint_cleanup == 0) {
  996. free (ckptCheckpoint);
  997. error = SA_AIS_ERR_NO_MEMORY;
  998. } else {
  999. memcpy(&checkpoint_cleanup->checkpoint,ckptCheckpoint,sizeof(struct saCkptCheckpoint));
  1000. list_add (&checkpoint_cleanup->list,
  1001. &req_exec_ckpt_checkpointopen->source.conn_info->ais_ci.u.libckpt_ci.checkpoint_list);
  1002. }
  1003. }
  1004. libais_send_response (req_exec_ckpt_checkpointopen->source.conn_info, &res_lib_ckpt_checkpointopen,
  1005. sizeof (struct res_lib_ckpt_checkpointopen));
  1006. }
  1007. /* return (error == SA_AIS_OK ? 0 : -1); */
  1008. return (0);
  1009. }
  1010. static int recovery_checkpoint_open(SaNameT *checkpointName,
  1011. SaCkptCheckpointCreationAttributesT *ckptAttributes,
  1012. struct ckpt_refcnt *ref_cnt)
  1013. {
  1014. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1015. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  1016. SaErrorT error = SA_AIS_OK;
  1017. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open %s\n", &checkpointName->value);
  1018. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  1019. /*
  1020. * If checkpoint doesn't exist, create one
  1021. */
  1022. if (ckptCheckpoint == 0) {
  1023. ckptCheckpoint = malloc (sizeof (struct saCkptCheckpoint));
  1024. if (ckptCheckpoint == 0) {
  1025. error = SA_AIS_ERR_NO_MEMORY;
  1026. goto error_exit;
  1027. }
  1028. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1029. if (ckptCheckpointSection == 0) {
  1030. free (ckptCheckpoint);
  1031. error = SA_AIS_ERR_NO_MEMORY;
  1032. goto error_exit;
  1033. }
  1034. memcpy (&ckptCheckpoint->name,
  1035. checkpointName,
  1036. sizeof (SaNameT));
  1037. memcpy (&ckptCheckpoint->checkpointCreationAttributes,
  1038. ckptAttributes,
  1039. sizeof (SaCkptCheckpointCreationAttributesT));
  1040. ckptCheckpoint->unlinked = 0;
  1041. list_init (&ckptCheckpoint->list);
  1042. list_init (&ckptCheckpoint->checkpointSectionsListHead);
  1043. list_add (&ckptCheckpoint->list, &checkpoint_list_head);
  1044. ckptCheckpoint->retention_timer = 0;
  1045. ckptCheckpoint->expired = 0;
  1046. /*
  1047. * Add in default checkpoint section
  1048. */
  1049. list_init (&ckptCheckpointSection->list);
  1050. list_add (&ckptCheckpointSection->list, &ckptCheckpoint->checkpointSectionsListHead);
  1051. /*
  1052. * Default section id
  1053. */
  1054. ckptCheckpointSection->sectionDescriptor.sectionId.id = 0;
  1055. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = 0;
  1056. ckptCheckpointSection->sectionDescriptor.expirationTime = SA_TIME_END;
  1057. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1058. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /*current time*/
  1059. ckptCheckpointSection->sectionDescriptor.sectionSize = strlen("Factory installed data\0")+1;
  1060. ckptCheckpointSection->sectionData = malloc(strlen("Factory installed data\0")+1);
  1061. assert(ckptCheckpointSection->sectionData);
  1062. memcpy(ckptCheckpointSection->sectionData, "Factory installed data\0", strlen("Factory installed data\0")+1);
  1063. ckptCheckpointSection->expiration_timer = 0;
  1064. }
  1065. /*
  1066. * If the checkpoint has been unlinked, it is an invalid name
  1067. */
  1068. if (ckptCheckpoint->unlinked) {
  1069. error = SA_AIS_ERR_BAD_CHECKPOINT; /* Is this the correct return ? */
  1070. goto error_exit;
  1071. }
  1072. initialize_ckpt_refcount_array(ckptCheckpoint->ckpt_refcount);
  1073. ckptCheckpoint->referenceCount = ckpt_refcount_total(ref_cnt);
  1074. log_printf (LOG_LEVEL_DEBUG, "CKPT: OPEN ckptCheckpoint->referenceCount %d\n",ckptCheckpoint->referenceCount);
  1075. memcpy(ckptCheckpoint->ckpt_refcount,ref_cnt,sizeof(struct ckpt_refcnt)*PROCESSOR_COUNT_MAX);
  1076. /*
  1077. * Setup connection information and mark checkpoint as referenced
  1078. */
  1079. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery CHECKPOINT reopened is %p\n", ckptCheckpoint);
  1080. /*
  1081. * Reset retention duration since this checkpoint was just opened
  1082. */
  1083. poll_timer_delete (aisexec_poll_handle, ckptCheckpoint->retention_timer);
  1084. ckptCheckpoint->retention_timer = 0;
  1085. /*
  1086. * Send error result to CKPT library
  1087. */
  1088. error_exit:
  1089. return (error);
  1090. }
  1091. static int message_handler_req_exec_ckpt_synchronize_state (void *message, struct in_addr source_addr, int endian_conversion_required)
  1092. {
  1093. int retcode;
  1094. struct req_exec_ckpt_synchronize_state *req_exec_ckpt_sync_state
  1095. = (struct req_exec_ckpt_synchronize_state *)message;
  1096. /*
  1097. * If the Incoming message's previous ring id == saved_ring_id
  1098. * Ignore because we have seen this message before.
  1099. */
  1100. if (memcmp (&req_exec_ckpt_sync_state->previous_ring_id, &saved_ring_id,sizeof (struct memb_ring_id)) == 0) {
  1101. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state ignoring ...\n");
  1102. return(0);
  1103. }
  1104. retcode = recovery_checkpoint_open(&req_exec_ckpt_sync_state->checkpointName,
  1105. &req_exec_ckpt_sync_state->checkpointCreationAttributes,
  1106. req_exec_ckpt_sync_state->ckpt_refcount);
  1107. if (retcode != SA_AIS_OK) {
  1108. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state\n");
  1109. log_printf(LOG_LEVEL_DEBUG, "CKPT: recovery_checkpoint_open returned %d\n",retcode);
  1110. }
  1111. retcode = recovery_section_create (&req_exec_ckpt_sync_state->sectionDescriptor,
  1112. &req_exec_ckpt_sync_state->checkpointName,
  1113. (char*)req_exec_ckpt_sync_state
  1114. + sizeof (struct req_exec_ckpt_synchronize_state));
  1115. if (retcode != SA_AIS_OK) {
  1116. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_state\n");
  1117. log_printf(LOG_LEVEL_DEBUG, "CKPT: recovery_section_create returned %d\n",retcode);
  1118. }
  1119. return (0);
  1120. }
  1121. static int message_handler_req_exec_ckpt_synchronize_section (void *message, struct in_addr source_addr, int endian_conversion_required)
  1122. {
  1123. int retcode;
  1124. struct req_exec_ckpt_synchronize_section *req_exec_ckpt_sync_section
  1125. = (struct req_exec_ckpt_synchronize_section *)message;
  1126. /*
  1127. * If the Incoming message's previous ring id == saved_ring_id
  1128. * Ignore because we have seen this message before.
  1129. */
  1130. if (memcmp (&req_exec_ckpt_sync_section->previous_ring_id, &saved_ring_id,sizeof (struct memb_ring_id)) == 0) {
  1131. log_printf(LOG_LEVEL_DEBUG, "CKPT: message_handler_req_exec_ckpt_synchronize_section ignoring ...\n");
  1132. return(0);
  1133. }
  1134. /*
  1135. * Write the contents of the section to the checkpoint section.
  1136. */
  1137. retcode = recovery_section_write(req_exec_ckpt_sync_section->sectionId.idLen,
  1138. (char*)req_exec_ckpt_sync_section
  1139. + sizeof (struct req_exec_ckpt_synchronize_section),
  1140. &req_exec_ckpt_sync_section->checkpointName,
  1141. (char*)req_exec_ckpt_sync_section
  1142. + sizeof (struct req_exec_ckpt_synchronize_section)
  1143. + req_exec_ckpt_sync_section->sectionId.idLen,
  1144. req_exec_ckpt_sync_section->dataOffSet,
  1145. req_exec_ckpt_sync_section->dataSize);
  1146. if (retcode != SA_AIS_OK) {
  1147. log_printf(LOG_LEVEL_ERROR, "CKPT: message_handler_req_exec_ckpt_synchronize_section\n");
  1148. log_printf(LOG_LEVEL_ERROR, "CKPT: recovery_section_write returned %d\n",retcode);
  1149. }
  1150. return (0);
  1151. }
  1152. unsigned int abstime_to_msec (SaTimeT time)
  1153. {
  1154. struct timeval tv;
  1155. unsigned long long curr_time;
  1156. unsigned long long msec_time;
  1157. gettimeofday (&tv, NULL);
  1158. curr_time = ((((unsigned long long)tv.tv_sec) * ((unsigned long)1000)) +
  1159. (((unsigned long long)tv.tv_usec) / ((unsigned long long)1000)));
  1160. msec_time = (((unsigned long long)time) / 1000000) -
  1161. (unsigned long long)curr_time;
  1162. return ((unsigned int)(msec_time));
  1163. }
  1164. void timer_function_section_expire (void *data)
  1165. {
  1166. struct saCkptCheckpointSection *section = (struct saCkptCheckpointSection *)data;
  1167. if (section->sectionDescriptor.sectionId.id) {
  1168. log_printf (LOG_LEVEL_NOTICE, "CKPT: Expiring section %s\n", section->sectionDescriptor.sectionId.id);
  1169. }
  1170. checkpoint_section_release (section);
  1171. }
  1172. void timer_function_retention (void *data)
  1173. {
  1174. struct saCkptCheckpoint *checkpoint = (struct saCkptCheckpoint *)data;
  1175. struct req_exec_ckpt_checkpointretentiondurationexpire req_exec_ckpt_checkpointretentiondurationexpire;
  1176. struct iovec iovec;
  1177. checkpoint->retention_timer = 0;
  1178. req_exec_ckpt_checkpointretentiondurationexpire.header.size =
  1179. sizeof (struct req_exec_ckpt_checkpointretentiondurationexpire);
  1180. req_exec_ckpt_checkpointretentiondurationexpire.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONEXPIRE;
  1181. memcpy (&req_exec_ckpt_checkpointretentiondurationexpire.checkpointName,
  1182. &checkpoint->name,
  1183. sizeof (SaNameT));
  1184. iovec.iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationexpire;
  1185. iovec.iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationexpire);
  1186. assert (totempg_mcast (&iovec, 1, TOTEMPG_AGREED) == 0);
  1187. }
  1188. extern int message_handler_req_exec_ckpt_checkpointclose (void *message, struct in_addr source_addr, int endian_conversion_required)
  1189. {
  1190. struct req_exec_ckpt_checkpointclose *req_exec_ckpt_checkpointclose = (struct req_exec_ckpt_checkpointclose *)message;
  1191. struct res_lib_ckpt_checkpointclose res_lib_ckpt_checkpointclose;
  1192. struct saCkptCheckpoint *checkpoint = 0;
  1193. SaAisErrorT error = SA_AIS_OK;
  1194. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to close checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointclose->checkpointName));
  1195. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointclose->checkpointName);
  1196. if (checkpoint == 0) {
  1197. goto error_exit;
  1198. }
  1199. log_printf (LOG_LEVEL_DEBUG, "CKPT:CLOSE checkpoint->referenceCount %d\n",checkpoint->referenceCount);
  1200. checkpoint->referenceCount--;
  1201. /*
  1202. * Modify the connection reference information to the Checkpoint to be
  1203. * sent out later as a part of the sync process.
  1204. */
  1205. int proc_index = processor_index_find(&source_addr, checkpoint->ckpt_refcount);
  1206. if (proc_index != -1 ) {
  1207. checkpoint->ckpt_refcount[proc_index].count--;
  1208. }
  1209. else {
  1210. log_printf (LOG_LEVEL_ERROR,
  1211. "CKPT: Could Not find Processor Info %p info.\n",
  1212. checkpoint);
  1213. }
  1214. assert (checkpoint->referenceCount >= 0);
  1215. log_printf (LOG_LEVEL_DEBUG, "disconnect called, new CKPT ref count is %d\n",
  1216. checkpoint->referenceCount);
  1217. /*
  1218. * If checkpoint has been unlinked and this is the last reference, delete it
  1219. */
  1220. if (checkpoint->unlinked && checkpoint->referenceCount == 0) {
  1221. log_printf (LOG_LEVEL_DEBUG, "Unlinking checkpoint.\n");
  1222. checkpoint_release (checkpoint);
  1223. } else
  1224. if (checkpoint->referenceCount == 0) {
  1225. poll_timer_add (aisexec_poll_handle,
  1226. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  1227. checkpoint,
  1228. timer_function_retention,
  1229. &checkpoint->retention_timer);
  1230. }
  1231. error_exit:
  1232. if (message_source_is_local(&req_exec_ckpt_checkpointclose->source)) {
  1233. ckpt_checkpoint_remove_cleanup (req_exec_ckpt_checkpointclose->source.conn_info,
  1234. checkpoint);
  1235. res_lib_ckpt_checkpointclose.header.size = sizeof (struct res_lib_ckpt_checkpointclose);
  1236. res_lib_ckpt_checkpointclose.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTCLOSE;
  1237. res_lib_ckpt_checkpointclose.header.error = error;
  1238. libais_send_response (req_exec_ckpt_checkpointclose->source.conn_info,
  1239. &res_lib_ckpt_checkpointclose, sizeof (struct res_lib_ckpt_checkpointclose));
  1240. }
  1241. return (0);
  1242. }
  1243. static int message_handler_req_exec_ckpt_checkpointunlink (void *message, struct in_addr source_addr, int endian_conversion_required)
  1244. {
  1245. struct req_exec_ckpt_checkpointunlink *req_exec_ckpt_checkpointunlink = (struct req_exec_ckpt_checkpointunlink *)message;
  1246. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)&req_exec_ckpt_checkpointunlink->req_lib_ckpt_checkpointunlink;
  1247. struct res_lib_ckpt_checkpointunlink res_lib_ckpt_checkpointunlink;
  1248. struct saCkptCheckpoint *ckptCheckpoint = 0;
  1249. SaErrorT error = SA_AIS_OK;
  1250. log_printf (LOG_LEVEL_DEBUG, "Got EXEC request to unlink checkpoint %p\n", req_exec_ckpt_checkpointunlink);
  1251. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointunlink->checkpointName);
  1252. if (ckptCheckpoint == 0) {
  1253. error = SA_AIS_ERR_NOT_EXIST;
  1254. goto error_exit;
  1255. }
  1256. if (ckptCheckpoint->unlinked) {
  1257. error = SA_AIS_ERR_INVALID_PARAM;
  1258. goto error_exit;
  1259. }
  1260. ckptCheckpoint->unlinked = 1;
  1261. /*
  1262. * Immediately delete entry if reference count is zero
  1263. */
  1264. if (ckptCheckpoint->referenceCount == 0) {
  1265. /*
  1266. * Remove retention timer since this checkpoint was unlinked and is no
  1267. * longer referenced
  1268. */
  1269. checkpoint_release (ckptCheckpoint);
  1270. }
  1271. error_exit:
  1272. /*
  1273. * If this node was the source of the message, respond to this node
  1274. */
  1275. if (message_source_is_local(&req_exec_ckpt_checkpointunlink->source)) {
  1276. res_lib_ckpt_checkpointunlink.header.size = sizeof (struct res_lib_ckpt_checkpointunlink);
  1277. res_lib_ckpt_checkpointunlink.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTUNLINK;
  1278. res_lib_ckpt_checkpointunlink.header.error = error;
  1279. libais_send_response (req_exec_ckpt_checkpointunlink->source.conn_info, &res_lib_ckpt_checkpointunlink,
  1280. sizeof (struct res_lib_ckpt_checkpointunlink));
  1281. }
  1282. return (0);
  1283. }
  1284. static int message_handler_req_exec_ckpt_checkpointretentiondurationset (void *message, struct in_addr source_addr, int endian_conversion_required)
  1285. {
  1286. struct req_exec_ckpt_checkpointretentiondurationset *req_exec_ckpt_checkpointretentiondurationset = (struct req_exec_ckpt_checkpointretentiondurationset *)message;
  1287. struct res_lib_ckpt_checkpointretentiondurationset res_lib_ckpt_checkpointretentiondurationset;
  1288. struct saCkptCheckpoint *checkpoint;
  1289. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationset->checkpointName);
  1290. if (checkpoint) {
  1291. log_printf (LOG_LEVEL_NOTICE, "CKPT: Setting retention duration for checkpoint %s\n",
  1292. getSaNameT (&req_exec_ckpt_checkpointretentiondurationset->checkpointName));
  1293. checkpoint->checkpointCreationAttributes.retentionDuration = req_exec_ckpt_checkpointretentiondurationset->retentionDuration;
  1294. if (checkpoint->expired == 0 && checkpoint->referenceCount == 0) {
  1295. poll_timer_delete (aisexec_poll_handle, checkpoint->retention_timer);
  1296. poll_timer_add (aisexec_poll_handle,
  1297. checkpoint->checkpointCreationAttributes.retentionDuration / 1000000,
  1298. checkpoint,
  1299. timer_function_retention,
  1300. &checkpoint->retention_timer);
  1301. }
  1302. }
  1303. /*
  1304. * Respond to library if this processor sent the duration set request
  1305. */
  1306. if (message_source_is_local(&req_exec_ckpt_checkpointretentiondurationset->source)) {
  1307. res_lib_ckpt_checkpointretentiondurationset.header.size = sizeof (struct res_lib_ckpt_checkpointretentiondurationset);
  1308. res_lib_ckpt_checkpointretentiondurationset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTRETENTIONDURATIONSET;
  1309. res_lib_ckpt_checkpointretentiondurationset.header.error = SA_AIS_OK;
  1310. libais_send_response (req_exec_ckpt_checkpointretentiondurationset->source.conn_info,
  1311. &res_lib_ckpt_checkpointretentiondurationset,
  1312. sizeof (struct res_lib_ckpt_checkpointretentiondurationset));
  1313. }
  1314. return (0);
  1315. }
  1316. static int message_handler_req_exec_ckpt_checkpointretentiondurationexpire (void *message, struct in_addr source_addr, int endian_conversion_required)
  1317. {
  1318. struct req_exec_ckpt_checkpointretentiondurationexpire *req_exec_ckpt_checkpointretentiondurationexpire = (struct req_exec_ckpt_checkpointretentiondurationexpire *)message;
  1319. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  1320. struct saCkptCheckpoint *checkpoint;
  1321. struct iovec iovecs[2];
  1322. checkpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName);
  1323. if (checkpoint && checkpoint->expired == 0) {
  1324. log_printf (LOG_LEVEL_NOTICE, "CKPT: Expiring checkpoint %s\n", getSaNameT (&req_exec_ckpt_checkpointretentiondurationexpire->checkpointName));
  1325. checkpoint->expired = 1;
  1326. req_exec_ckpt_checkpointunlink.header.size =
  1327. sizeof (struct req_exec_ckpt_checkpointunlink);
  1328. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  1329. req_exec_ckpt_checkpointunlink.source.conn_info = 0;
  1330. req_exec_ckpt_checkpointunlink.source.in_addr.s_addr = 0;
  1331. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink.checkpointName,
  1332. &req_exec_ckpt_checkpointretentiondurationexpire->checkpointName,
  1333. sizeof (SaNameT));
  1334. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  1335. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  1336. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  1337. }
  1338. return (0);
  1339. }
  1340. static int recovery_section_create (SaCkptSectionDescriptorT *sectionDescriptor,
  1341. SaNameT *checkpointName,
  1342. char* SectionId)
  1343. {
  1344. struct saCkptCheckpoint *ckptCheckpoint;
  1345. struct saCkptCheckpointSection *ckptCheckpointSection;
  1346. void *initialData;
  1347. void *sectionId;
  1348. SaErrorT error = SA_AIS_OK;
  1349. if ((int)sectionDescriptor->sectionId.idLen) {
  1350. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create for checkpoint %s, section %s.\n",
  1351. &checkpointName->value, SectionId);
  1352. } else {
  1353. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_create for checkpoint %s, default section.\n",
  1354. &checkpointName->value);
  1355. }
  1356. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  1357. if (ckptCheckpoint == 0) {
  1358. error = SA_AIS_ERR_NOT_EXIST;
  1359. goto error_exit;
  1360. }
  1361. /*
  1362. * Determine if user-specified checkpoint ID already exists
  1363. */
  1364. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1365. SectionId,
  1366. (int)sectionDescriptor->sectionId.idLen);
  1367. if (ckptCheckpointSection) {
  1368. error = SA_AIS_ERR_EXIST;
  1369. goto error_exit;
  1370. }
  1371. /*
  1372. * Allocate checkpoint section
  1373. */
  1374. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1375. if (ckptCheckpointSection == 0) {
  1376. error = SA_AIS_ERR_NO_MEMORY;
  1377. goto error_exit;
  1378. }
  1379. /*
  1380. * Allocate checkpoint section data
  1381. */
  1382. initialData = malloc (sectionDescriptor->sectionSize);
  1383. if (initialData == 0) {
  1384. free (ckptCheckpointSection);
  1385. error = SA_AIS_ERR_NO_MEMORY;
  1386. goto error_exit;
  1387. }
  1388. /*
  1389. * Allocate checkpoint section id
  1390. */
  1391. if (sectionDescriptor->sectionId.idLen) {
  1392. sectionId = malloc ((int)sectionDescriptor->sectionId.idLen);
  1393. if (sectionId == 0) {
  1394. free (ckptCheckpointSection);
  1395. free (initialData);
  1396. error = SA_AIS_ERR_NO_MEMORY;
  1397. goto error_exit;
  1398. }
  1399. } else {
  1400. sectionId = 0;
  1401. }
  1402. /*
  1403. * Copy checkpoint section ID and initialize data.
  1404. */
  1405. if (SectionId) {
  1406. memcpy ((char*)sectionId, (char*)SectionId, (int)sectionDescriptor->sectionId.idLen);
  1407. } else {
  1408. sectionId = 0;
  1409. }
  1410. memset (initialData, 0, sectionDescriptor->sectionSize);
  1411. /*
  1412. * Configure checkpoint section
  1413. */
  1414. memcpy(&ckptCheckpointSection->sectionDescriptor,
  1415. sectionDescriptor,
  1416. sizeof(SaCkptSectionDescriptorT));
  1417. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1418. ckptCheckpointSection->sectionData = initialData;
  1419. ckptCheckpointSection->expiration_timer = 0;
  1420. ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
  1421. if (sectionDescriptor->expirationTime != SA_TIME_END) {
  1422. poll_timer_add (aisexec_poll_handle,
  1423. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  1424. ckptCheckpointSection,
  1425. timer_function_section_expire,
  1426. &ckptCheckpointSection->expiration_timer);
  1427. }
  1428. /*
  1429. * Add checkpoint section to checkpoint
  1430. */
  1431. list_init (&ckptCheckpointSection->list);
  1432. list_add (&ckptCheckpointSection->list,
  1433. &ckptCheckpoint->checkpointSectionsListHead);
  1434. error_exit:
  1435. return (error);
  1436. }
  1437. static int message_handler_req_exec_ckpt_sectioncreate (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1438. struct req_exec_ckpt_sectioncreate *req_exec_ckpt_sectioncreate = (struct req_exec_ckpt_sectioncreate *)message;
  1439. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)&req_exec_ckpt_sectioncreate->req_lib_ckpt_sectioncreate;
  1440. struct res_lib_ckpt_sectioncreate res_lib_ckpt_sectioncreate;
  1441. struct saCkptCheckpoint *ckptCheckpoint;
  1442. struct saCkptCheckpointSection *ckptCheckpointSection;
  1443. void *initialData;
  1444. void *sectionId;
  1445. SaErrorT error = SA_AIS_OK;
  1446. log_printf (LOG_LEVEL_DEBUG, "Executive request to create a checkpoint section.\n");
  1447. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectioncreate->checkpointName);
  1448. if (ckptCheckpoint == 0) {
  1449. error = SA_AIS_ERR_LIBRARY; /* TODO find the right error for this*/
  1450. goto error_exit;
  1451. }
  1452. /*
  1453. * Determine if user-specified checkpoint ID already exists
  1454. */
  1455. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1456. ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  1457. req_lib_ckpt_sectioncreate->idLen);
  1458. if (ckptCheckpointSection) {
  1459. error = SA_AIS_ERR_EXIST;
  1460. goto error_exit;
  1461. }
  1462. /*
  1463. * Allocate checkpoint section
  1464. */
  1465. ckptCheckpointSection = malloc (sizeof (struct saCkptCheckpointSection));
  1466. if (ckptCheckpointSection == 0) {
  1467. error = SA_AIS_ERR_NO_MEMORY;
  1468. goto error_exit;
  1469. }
  1470. /*
  1471. * Allocate checkpoint section data
  1472. */
  1473. initialData = malloc (req_lib_ckpt_sectioncreate->initialDataSize);
  1474. if (initialData == 0) {
  1475. free (ckptCheckpointSection);
  1476. error = SA_AIS_ERR_NO_MEMORY;
  1477. goto error_exit;
  1478. }
  1479. /*
  1480. * Allocate checkpoint section id
  1481. */
  1482. sectionId = malloc (req_lib_ckpt_sectioncreate->idLen);
  1483. if (sectionId == 0) {
  1484. free (ckptCheckpointSection);
  1485. free (initialData);
  1486. error = SA_AIS_ERR_NO_MEMORY;
  1487. goto error_exit;
  1488. }
  1489. /*
  1490. * Copy checkpoint section and section ID
  1491. */
  1492. memcpy (sectionId, ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate),
  1493. req_lib_ckpt_sectioncreate->idLen);
  1494. memcpy (initialData,
  1495. ((char *)req_lib_ckpt_sectioncreate) +
  1496. sizeof (struct req_lib_ckpt_sectioncreate) +
  1497. req_lib_ckpt_sectioncreate->idLen,
  1498. req_lib_ckpt_sectioncreate->initialDataSize);
  1499. /*
  1500. * Configure checkpoint section
  1501. */
  1502. ckptCheckpointSection->sectionDescriptor.sectionId.id = sectionId;
  1503. ckptCheckpointSection->sectionDescriptor.sectionId.idLen = req_lib_ckpt_sectioncreate->idLen;
  1504. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectioncreate->initialDataSize;
  1505. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectioncreate->expirationTime;
  1506. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1507. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /* TODO current time */
  1508. ckptCheckpointSection->sectionData = initialData;
  1509. ckptCheckpointSection->expiration_timer = 0;
  1510. if (req_lib_ckpt_sectioncreate->expirationTime != SA_TIME_END) {
  1511. poll_timer_add (aisexec_poll_handle,
  1512. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  1513. ckptCheckpointSection,
  1514. timer_function_section_expire,
  1515. &ckptCheckpointSection->expiration_timer);
  1516. }
  1517. /*
  1518. * Add checkpoint section to checkpoint
  1519. */
  1520. list_init (&ckptCheckpointSection->list);
  1521. list_add (&ckptCheckpointSection->list,
  1522. &ckptCheckpoint->checkpointSectionsListHead);
  1523. error_exit:
  1524. if (message_source_is_local(&req_exec_ckpt_sectioncreate->source)) {
  1525. res_lib_ckpt_sectioncreate.header.size = sizeof (struct res_lib_ckpt_sectioncreate);
  1526. res_lib_ckpt_sectioncreate.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONCREATE;
  1527. res_lib_ckpt_sectioncreate.header.error = error;
  1528. libais_send_response (req_exec_ckpt_sectioncreate->source.conn_info,
  1529. &res_lib_ckpt_sectioncreate,
  1530. sizeof (struct res_lib_ckpt_sectioncreate));
  1531. }
  1532. return (0);
  1533. }
  1534. static int message_handler_req_exec_ckpt_sectiondelete (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1535. struct req_exec_ckpt_sectiondelete *req_exec_ckpt_sectiondelete = (struct req_exec_ckpt_sectiondelete *)message;
  1536. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)&req_exec_ckpt_sectiondelete->req_lib_ckpt_sectiondelete;
  1537. struct res_lib_ckpt_sectiondelete res_lib_ckpt_sectiondelete;
  1538. struct saCkptCheckpoint *ckptCheckpoint;
  1539. struct saCkptCheckpointSection *ckptCheckpointSection;
  1540. SaErrorT error = SA_AIS_OK;
  1541. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectiondelete->checkpointName);
  1542. if (ckptCheckpoint == 0) {
  1543. error = SA_AIS_ERR_NOT_EXIST;
  1544. goto error_exit;
  1545. }
  1546. /*
  1547. * Determine if the user is trying to delete the default section
  1548. */
  1549. if (req_lib_ckpt_sectiondelete->idLen == 0) {
  1550. error = SA_AIS_ERR_INVALID_PARAM;
  1551. goto error_exit;
  1552. }
  1553. /*
  1554. * Find checkpoint section to be deleted
  1555. */
  1556. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1557. ((char *)(req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete)),
  1558. req_lib_ckpt_sectiondelete->idLen);
  1559. if (ckptCheckpointSection == 0) {
  1560. error = SA_AIS_ERR_NOT_EXIST;
  1561. goto error_exit;
  1562. }
  1563. /*
  1564. * Delete checkpoint section
  1565. */
  1566. checkpoint_section_release (ckptCheckpointSection);
  1567. /*
  1568. * return result to CKPT library
  1569. */
  1570. error_exit:
  1571. if (message_source_is_local(&req_exec_ckpt_sectiondelete->source)) {
  1572. res_lib_ckpt_sectiondelete.header.size = sizeof (struct res_lib_ckpt_sectiondelete);
  1573. res_lib_ckpt_sectiondelete.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONDELETE;
  1574. res_lib_ckpt_sectiondelete.header.error = error;
  1575. libais_send_response (req_exec_ckpt_sectiondelete->source.conn_info,
  1576. &res_lib_ckpt_sectiondelete,
  1577. sizeof (struct res_lib_ckpt_sectiondelete));
  1578. }
  1579. return (0);
  1580. }
  1581. static int message_handler_req_exec_ckpt_sectionexpirationtimeset (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1582. struct req_exec_ckpt_sectionexpirationtimeset *req_exec_ckpt_sectionexpirationtimeset = (struct req_exec_ckpt_sectionexpirationtimeset *)message;
  1583. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)&req_exec_ckpt_sectionexpirationtimeset->req_lib_ckpt_sectionexpirationtimeset;
  1584. struct res_lib_ckpt_sectionexpirationtimeset res_lib_ckpt_sectionexpirationtimeset;
  1585. struct saCkptCheckpoint *ckptCheckpoint;
  1586. struct saCkptCheckpointSection *ckptCheckpointSection;
  1587. SaErrorT error = SA_AIS_OK;
  1588. log_printf (LOG_LEVEL_DEBUG, "Executive request to set section expiratoin time\n");
  1589. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionexpirationtimeset->checkpointName);
  1590. if (ckptCheckpoint == 0) {
  1591. error = SA_AIS_ERR_NOT_EXIST;
  1592. goto error_exit;
  1593. }
  1594. /*
  1595. * Determine if the user is trying to set expiration time for the default section
  1596. */
  1597. if (req_lib_ckpt_sectionexpirationtimeset->idLen == 0) {
  1598. error = SA_AIS_ERR_INVALID_PARAM;
  1599. goto error_exit;
  1600. }
  1601. /*
  1602. * Find checkpoint section that expiration time should be set for
  1603. */
  1604. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1605. ((char *)req_lib_ckpt_sectionexpirationtimeset) +
  1606. sizeof (struct req_lib_ckpt_sectionexpirationtimeset),
  1607. req_lib_ckpt_sectionexpirationtimeset->idLen);
  1608. if (ckptCheckpointSection == 0) {
  1609. error = SA_AIS_ERR_NOT_EXIST;
  1610. goto error_exit;
  1611. }
  1612. ckptCheckpointSection->sectionDescriptor.expirationTime = req_lib_ckpt_sectionexpirationtimeset->expirationTime;
  1613. poll_timer_delete (aisexec_poll_handle, ckptCheckpointSection->expiration_timer);
  1614. ckptCheckpointSection->expiration_timer = 0;
  1615. if (req_lib_ckpt_sectionexpirationtimeset->expirationTime != SA_TIME_END) {
  1616. poll_timer_add (aisexec_poll_handle,
  1617. abstime_to_msec (ckptCheckpointSection->sectionDescriptor.expirationTime),
  1618. ckptCheckpointSection,
  1619. timer_function_section_expire,
  1620. &ckptCheckpointSection->expiration_timer);
  1621. }
  1622. error_exit:
  1623. if (message_source_is_local(&req_exec_ckpt_sectionexpirationtimeset->source)) {
  1624. res_lib_ckpt_sectionexpirationtimeset.header.size = sizeof (struct res_lib_ckpt_sectionexpirationtimeset);
  1625. res_lib_ckpt_sectionexpirationtimeset.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONEXPIRATIONTIMESET;
  1626. res_lib_ckpt_sectionexpirationtimeset.header.error = error;
  1627. libais_send_response (req_exec_ckpt_sectionexpirationtimeset->source.conn_info,
  1628. &res_lib_ckpt_sectionexpirationtimeset,
  1629. sizeof (struct res_lib_ckpt_sectionexpirationtimeset));
  1630. }
  1631. return (0);
  1632. }
  1633. static int recovery_section_write(int sectionIdLen,
  1634. char* sectionId,
  1635. SaNameT *checkpointName,
  1636. void *newData,
  1637. SaUint32T dataOffSet,
  1638. SaUint32T dataSize)
  1639. {
  1640. struct saCkptCheckpoint *ckptCheckpoint;
  1641. struct saCkptCheckpointSection *ckptCheckpointSection;
  1642. int sizeRequired;
  1643. SaErrorT error = SA_AIS_OK;
  1644. char *sd;
  1645. log_printf (LOG_LEVEL_DEBUG, "CKPT: recovery_section_write.\n");
  1646. ckptCheckpoint = ckpt_checkpoint_find_global (checkpointName);
  1647. if (ckptCheckpoint == 0) {
  1648. error = SA_AIS_ERR_NOT_EXIST;
  1649. goto error_exit;
  1650. }
  1651. /*
  1652. * Find checkpoint section to be written
  1653. */
  1654. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1655. sectionId,
  1656. sectionIdLen);
  1657. if (ckptCheckpointSection == 0) {
  1658. error = SA_AIS_ERR_NOT_EXIST;
  1659. goto error_exit;
  1660. }
  1661. /*
  1662. * If write would extend past end of section data, return error;
  1663. */
  1664. sizeRequired = dataOffSet + dataSize;
  1665. if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  1666. error = SA_AIS_ERR_ACCESS;
  1667. goto error_exit;
  1668. }
  1669. /*
  1670. * Write checkpoint section to section data
  1671. */
  1672. if (dataSize > 0) {
  1673. sd = (char *)ckptCheckpointSection->sectionData;
  1674. memcpy (&sd[dataOffSet],
  1675. newData,
  1676. dataSize);
  1677. }
  1678. error_exit:
  1679. return (error);
  1680. }
  1681. static int message_handler_req_exec_ckpt_sectionwrite (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1682. struct req_exec_ckpt_sectionwrite *req_exec_ckpt_sectionwrite = (struct req_exec_ckpt_sectionwrite *)message;
  1683. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)&req_exec_ckpt_sectionwrite->req_lib_ckpt_sectionwrite;
  1684. struct res_lib_ckpt_sectionwrite res_lib_ckpt_sectionwrite;
  1685. struct saCkptCheckpoint *ckptCheckpoint;
  1686. struct saCkptCheckpointSection *ckptCheckpointSection;
  1687. int sizeRequired;
  1688. void *sectionData;
  1689. SaErrorT error = SA_AIS_OK;
  1690. log_printf (LOG_LEVEL_DEBUG, "Executive request to section write.\n");
  1691. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionwrite->checkpointName);
  1692. if (ckptCheckpoint == 0) {
  1693. error = SA_AIS_ERR_NOT_EXIST;
  1694. goto error_exit;
  1695. }
  1696. /*
  1697. printf ("writing checkpoint section is %s\n", ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  1698. */
  1699. /*
  1700. * Find checkpoint section to be written
  1701. */
  1702. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1703. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite),
  1704. req_lib_ckpt_sectionwrite->idLen);
  1705. if (ckptCheckpointSection == 0) {
  1706. if (req_lib_ckpt_sectionwrite->idLen == 0) {
  1707. log_printf (LOG_LEVEL_ERROR, "CANT FIND DEFAULT SECTION.\n");
  1708. }
  1709. else {
  1710. printf ("CANT FIND SECTION '%s'\n",
  1711. ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite));
  1712. }
  1713. error = SA_AIS_ERR_NOT_EXIST;
  1714. goto error_exit;
  1715. }
  1716. /*
  1717. * If write would extend past end of section data, enlarge section
  1718. */
  1719. sizeRequired = req_lib_ckpt_sectionwrite->dataOffset + req_lib_ckpt_sectionwrite->dataSize;
  1720. if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
  1721. sectionData = realloc (ckptCheckpointSection->sectionData, sizeRequired);
  1722. if (sectionData == 0) {
  1723. error = SA_AIS_ERR_NO_MEMORY;
  1724. goto error_exit;
  1725. }
  1726. /*
  1727. * Install new section data
  1728. */
  1729. ckptCheckpointSection->sectionData = sectionData;
  1730. ckptCheckpointSection->sectionDescriptor.sectionSize = sizeRequired;
  1731. }
  1732. /*
  1733. * Write checkpoint section to section data
  1734. */
  1735. if (req_lib_ckpt_sectionwrite->dataSize > 0) {
  1736. char *sd;
  1737. int *val;
  1738. val = ckptCheckpointSection->sectionData;
  1739. sd = (char *)ckptCheckpointSection->sectionData;
  1740. memcpy (&sd[req_lib_ckpt_sectionwrite->dataOffset],
  1741. ((char *)req_exec_ckpt_sectionwrite) + sizeof (struct req_exec_ckpt_sectionwrite) +
  1742. req_lib_ckpt_sectionwrite->idLen,
  1743. req_lib_ckpt_sectionwrite->dataSize);
  1744. }
  1745. /*
  1746. * Write write response to CKPT library
  1747. */
  1748. error_exit:
  1749. if (message_source_is_local(&req_exec_ckpt_sectionwrite->source)) {
  1750. res_lib_ckpt_sectionwrite.header.size = sizeof (struct res_lib_ckpt_sectionwrite);
  1751. res_lib_ckpt_sectionwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONWRITE;
  1752. res_lib_ckpt_sectionwrite.header.error = error;
  1753. libais_send_response (req_exec_ckpt_sectionwrite->source.conn_info,
  1754. &res_lib_ckpt_sectionwrite,
  1755. sizeof (struct res_lib_ckpt_sectionwrite));
  1756. }
  1757. return (0);
  1758. }
  1759. static int message_handler_req_exec_ckpt_sectionoverwrite (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1760. struct req_exec_ckpt_sectionoverwrite *req_exec_ckpt_sectionoverwrite = (struct req_exec_ckpt_sectionoverwrite *)message;
  1761. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)&req_exec_ckpt_sectionoverwrite->req_lib_ckpt_sectionoverwrite;
  1762. struct res_lib_ckpt_sectionoverwrite res_lib_ckpt_sectionoverwrite;
  1763. struct saCkptCheckpoint *ckptCheckpoint;
  1764. struct saCkptCheckpointSection *ckptCheckpointSection;
  1765. void *sectionData;
  1766. SaErrorT error = SA_AIS_OK;
  1767. log_printf (LOG_LEVEL_DEBUG, "Executive request to section overwrite.\n");
  1768. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionoverwrite->checkpointName);
  1769. if (ckptCheckpoint == 0) {
  1770. error = SA_AIS_ERR_NOT_EXIST;
  1771. goto error_exit;
  1772. }
  1773. /*
  1774. * Find checkpoint section to be overwritten
  1775. */
  1776. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1777. ((char *)req_lib_ckpt_sectionoverwrite) +
  1778. sizeof (struct req_lib_ckpt_sectionoverwrite),
  1779. req_lib_ckpt_sectionoverwrite->idLen);
  1780. if (ckptCheckpointSection == 0) {
  1781. error = SA_AIS_ERR_NOT_EXIST;
  1782. goto error_exit;
  1783. }
  1784. /*
  1785. * Allocate checkpoint section data
  1786. */
  1787. sectionData = malloc (req_lib_ckpt_sectionoverwrite->dataSize);
  1788. if (sectionData == 0) {
  1789. error = SA_AIS_ERR_NO_MEMORY;
  1790. goto error_exit;
  1791. }
  1792. memcpy (sectionData,
  1793. ((char *)req_lib_ckpt_sectionoverwrite) +
  1794. sizeof (struct req_lib_ckpt_sectionoverwrite) +
  1795. req_lib_ckpt_sectionoverwrite->idLen,
  1796. req_lib_ckpt_sectionoverwrite->dataSize);
  1797. /*
  1798. * release old checkpoint section data
  1799. */
  1800. free (ckptCheckpointSection->sectionData);
  1801. /*
  1802. * Install overwritten checkpoint section data
  1803. */
  1804. ckptCheckpointSection->sectionDescriptor.sectionSize = req_lib_ckpt_sectionoverwrite->dataSize;
  1805. ckptCheckpointSection->sectionDescriptor.sectionState = SA_CKPT_SECTION_VALID;
  1806. ckptCheckpointSection->sectionDescriptor.lastUpdate = 0; /* TODO current time */
  1807. ckptCheckpointSection->sectionData = sectionData;
  1808. /*
  1809. * return result to CKPT library
  1810. */
  1811. error_exit:
  1812. if (message_source_is_local(&req_exec_ckpt_sectionoverwrite->source)) {
  1813. res_lib_ckpt_sectionoverwrite.header.size = sizeof (struct res_lib_ckpt_sectionoverwrite);
  1814. res_lib_ckpt_sectionoverwrite.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONOVERWRITE;
  1815. res_lib_ckpt_sectionoverwrite.header.error = error;
  1816. libais_send_response (req_exec_ckpt_sectionoverwrite->source.conn_info,
  1817. &res_lib_ckpt_sectionoverwrite,
  1818. sizeof (struct res_lib_ckpt_sectionoverwrite));
  1819. }
  1820. return (0);
  1821. }
  1822. static int message_handler_req_exec_ckpt_sectionread (void *message, struct in_addr source_addr, int endian_conversion_required) {
  1823. struct req_exec_ckpt_sectionread *req_exec_ckpt_sectionread = (struct req_exec_ckpt_sectionread *)message;
  1824. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)&req_exec_ckpt_sectionread->req_lib_ckpt_sectionread;
  1825. struct res_lib_ckpt_sectionread res_lib_ckpt_sectionread;
  1826. struct saCkptCheckpoint *ckptCheckpoint;
  1827. struct saCkptCheckpointSection *ckptCheckpointSection = 0;
  1828. int sectionSize = 0;
  1829. SaErrorT error = SA_AIS_OK;
  1830. log_printf (LOG_LEVEL_DEBUG, "Executive request for section read.\n");
  1831. ckptCheckpoint = ckpt_checkpoint_find_global (&req_exec_ckpt_sectionread->checkpointName);
  1832. if (ckptCheckpoint == 0) {
  1833. error = SA_AIS_ERR_LIBRARY; /* TODO find the right error for this */
  1834. goto error_exit;
  1835. }
  1836. /*
  1837. * Find checkpoint section to be read
  1838. */
  1839. ckptCheckpointSection = ckpt_checkpoint_find_globalSection (ckptCheckpoint,
  1840. ((char *)req_lib_ckpt_sectionread) +
  1841. sizeof (struct req_lib_ckpt_sectionread),
  1842. req_lib_ckpt_sectionread->idLen);
  1843. if (ckptCheckpointSection == 0) {
  1844. error = SA_AIS_ERR_NOT_EXIST;
  1845. goto error_exit;
  1846. }
  1847. /*
  1848. * Determine the section size
  1849. */
  1850. sectionSize = ckptCheckpointSection->sectionDescriptor.sectionSize -
  1851. req_lib_ckpt_sectionread->dataOffset;
  1852. /*
  1853. * If the library has less space available then can be sent from the
  1854. * section, reduce bytes sent to library to max requested
  1855. */
  1856. if (sectionSize > req_lib_ckpt_sectionread->dataSize) {
  1857. sectionSize = req_lib_ckpt_sectionread->dataSize;
  1858. }
  1859. /*
  1860. * If dataOffset is past end of data, return INVALID PARAM
  1861. */
  1862. if (req_lib_ckpt_sectionread->dataOffset > sectionSize) {
  1863. sectionSize = 0;
  1864. error = SA_AIS_ERR_INVALID_PARAM;
  1865. goto error_exit;
  1866. }
  1867. /*
  1868. * Write read response to CKPT library
  1869. */
  1870. error_exit:
  1871. if (message_source_is_local(&req_exec_ckpt_sectionread->source)) {
  1872. res_lib_ckpt_sectionread.header.size = sizeof (struct res_lib_ckpt_sectionread) + sectionSize;
  1873. res_lib_ckpt_sectionread.header.id = MESSAGE_RES_CKPT_CHECKPOINT_SECTIONREAD;
  1874. res_lib_ckpt_sectionread.header.error = error;
  1875. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  1876. &res_lib_ckpt_sectionread,
  1877. sizeof (struct res_lib_ckpt_sectionread));
  1878. /*
  1879. * Write checkpoint to CKPT library section if section has data
  1880. */
  1881. if (sectionSize) {
  1882. char *sd;
  1883. sd = (char *)ckptCheckpointSection->sectionData;
  1884. libais_send_response (req_exec_ckpt_sectionread->source.conn_info,
  1885. &sd[req_lib_ckpt_sectionread->dataOffset],
  1886. sectionSize);
  1887. }
  1888. }
  1889. return (0);
  1890. }
  1891. static int message_handler_req_lib_ckpt_init (struct conn_info *conn_info, void *message)
  1892. {
  1893. struct res_lib_init res_lib_init;
  1894. SaErrorT error = SA_AIS_ERR_ACCESS;
  1895. log_printf (LOG_LEVEL_DEBUG, "Got request to initialize CKPT checkpoint.\n");
  1896. if (conn_info->authenticated) {
  1897. conn_info->service = SOCKET_SERVICE_CKPT;
  1898. list_init (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list);
  1899. conn_info->ais_ci.u.libckpt_ci.sectionIterator.sectionIteratorEntries = 0;
  1900. conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorCount = 0;
  1901. conn_info->ais_ci.u.libckpt_ci.sectionIterator.iteratorPos = 0;
  1902. list_add (&conn_info->ais_ci.u.libckpt_ci.sectionIterator.list,
  1903. &checkpoint_iterator_list_head);
  1904. list_init (&conn_info->ais_ci.u.libckpt_ci.checkpoint_list);
  1905. error = SA_AIS_OK;
  1906. }
  1907. res_lib_init.header.size = sizeof (struct res_lib_init);
  1908. res_lib_init.header.id = MESSAGE_RES_INIT;
  1909. res_lib_init.header.error = error;
  1910. libais_send_response (conn_info, &res_lib_init, sizeof (res_lib_init));
  1911. if (conn_info->authenticated) {
  1912. return (0);
  1913. }
  1914. return (-1);
  1915. }
  1916. static int message_handler_req_lib_ckpt_checkpointopen (struct conn_info *conn_info, void *message)
  1917. {
  1918. struct req_lib_ckpt_checkpointopen *req_lib_ckpt_checkpointopen = (struct req_lib_ckpt_checkpointopen *)message;
  1919. struct req_exec_ckpt_checkpointopen req_exec_ckpt_checkpointopen;
  1920. struct iovec iovecs[2];
  1921. log_printf (LOG_LEVEL_DEBUG, "Library request to open checkpoint.\n");
  1922. req_exec_ckpt_checkpointopen.header.size =
  1923. sizeof (struct req_exec_ckpt_checkpointopen);
  1924. req_exec_ckpt_checkpointopen.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTOPEN;
  1925. message_source_set (&req_exec_ckpt_checkpointopen.source, conn_info);
  1926. memcpy (&req_exec_ckpt_checkpointopen.req_lib_ckpt_checkpointopen,
  1927. req_lib_ckpt_checkpointopen,
  1928. sizeof (struct req_lib_ckpt_checkpointopen));
  1929. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointopen;
  1930. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointopen);
  1931. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  1932. return (0);
  1933. }
  1934. static int message_handler_req_lib_ckpt_checkpointopenasync (struct conn_info *conn_info, void *message)
  1935. {
  1936. return (0);
  1937. }
  1938. static int message_handler_req_lib_ckpt_checkpointclose (struct conn_info *conn_info, void *message) {
  1939. struct req_lib_ckpt_checkpointclose *req_lib_ckpt_checkpointclose = (struct req_lib_ckpt_checkpointclose *)message;
  1940. struct req_exec_ckpt_checkpointclose req_exec_ckpt_checkpointclose;
  1941. struct saCkptCheckpoint *checkpoint;
  1942. struct iovec iovecs[2];
  1943. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointclose->checkpointName);
  1944. if (checkpoint->expired == 1) {
  1945. return (0);
  1946. }
  1947. req_exec_ckpt_checkpointclose.header.size =
  1948. sizeof (struct req_exec_ckpt_checkpointclose);
  1949. req_exec_ckpt_checkpointclose.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTCLOSE;
  1950. message_source_set (&req_exec_ckpt_checkpointclose.source, conn_info);
  1951. memcpy (&req_exec_ckpt_checkpointclose.checkpointName,
  1952. &checkpoint->name, sizeof (SaNameT));
  1953. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointclose;
  1954. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointclose);
  1955. if (totempg_send_ok (sizeof (struct req_exec_ckpt_checkpointclose))) {
  1956. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  1957. }
  1958. return (0);
  1959. }
  1960. static int message_handler_req_lib_ckpt_checkpointunlink (struct conn_info *conn_info, void *message)
  1961. {
  1962. struct req_lib_ckpt_checkpointunlink *req_lib_ckpt_checkpointunlink = (struct req_lib_ckpt_checkpointunlink *)message;
  1963. struct req_exec_ckpt_checkpointunlink req_exec_ckpt_checkpointunlink;
  1964. struct iovec iovecs[2];
  1965. req_exec_ckpt_checkpointunlink.header.size =
  1966. sizeof (struct req_exec_ckpt_checkpointunlink);
  1967. req_exec_ckpt_checkpointunlink.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTUNLINK;
  1968. message_source_set (&req_exec_ckpt_checkpointunlink.source, conn_info);
  1969. memcpy (&req_exec_ckpt_checkpointunlink.req_lib_ckpt_checkpointunlink,
  1970. req_lib_ckpt_checkpointunlink,
  1971. sizeof (struct req_lib_ckpt_checkpointunlink));
  1972. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointunlink;
  1973. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointunlink);
  1974. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  1975. return (0);
  1976. }
  1977. static int message_handler_req_lib_ckpt_checkpointretentiondurationset (struct conn_info *conn_info, void *message)
  1978. {
  1979. struct req_lib_ckpt_checkpointretentiondurationset *req_lib_ckpt_checkpointretentiondurationset = (struct req_lib_ckpt_checkpointretentiondurationset *)message;
  1980. struct req_exec_ckpt_checkpointretentiondurationset req_exec_ckpt_checkpointretentiondurationset;
  1981. struct iovec iovecs[2];
  1982. log_printf (LOG_LEVEL_DEBUG, "DURATION SET FROM API fd %d\n", conn_info->fd);
  1983. req_exec_ckpt_checkpointretentiondurationset.header.id = MESSAGE_REQ_EXEC_CKPT_CHECKPOINTRETENTIONDURATIONSET;
  1984. req_exec_ckpt_checkpointretentiondurationset.header.size = sizeof (struct req_exec_ckpt_checkpointretentiondurationset);
  1985. message_source_set (&req_exec_ckpt_checkpointretentiondurationset.source, conn_info);
  1986. memcpy (&req_exec_ckpt_checkpointretentiondurationset.checkpointName,
  1987. &req_lib_ckpt_checkpointretentiondurationset->checkpointName,
  1988. sizeof (SaNameT));
  1989. req_exec_ckpt_checkpointretentiondurationset.retentionDuration = req_lib_ckpt_checkpointretentiondurationset->retentionDuration;
  1990. iovecs[0].iov_base = (char *)&req_exec_ckpt_checkpointretentiondurationset;
  1991. iovecs[0].iov_len = sizeof (req_exec_ckpt_checkpointretentiondurationset);
  1992. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  1993. return (0);
  1994. }
  1995. static int message_handler_req_lib_ckpt_activereplicaset (struct conn_info *conn_info, void *message)
  1996. {
  1997. return (0);
  1998. }
  1999. static int message_handler_req_lib_ckpt_checkpointstatusget (struct conn_info *conn_info, void *message)
  2000. {
  2001. struct req_lib_ckpt_checkpointstatusget *req_lib_ckpt_checkpointstatusget = (struct req_lib_ckpt_checkpointstatusget *)message;
  2002. struct res_lib_ckpt_checkpointstatusget res_lib_ckpt_checkpointstatusget;
  2003. struct saCkptCheckpoint *checkpoint;
  2004. int memoryUsed = 0;
  2005. int numberOfSections = 0;
  2006. struct list_head *checkpoint_section_list;
  2007. struct saCkptCheckpointSection *checkpointSection;
  2008. log_printf (LOG_LEVEL_DEBUG, "in status get\n");
  2009. /*
  2010. * Count memory used by checkpoint sections
  2011. */
  2012. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_checkpointstatusget->checkpointName);
  2013. for (checkpoint_section_list = checkpoint->checkpointSectionsListHead.next;
  2014. checkpoint_section_list != &checkpoint->checkpointSectionsListHead;
  2015. checkpoint_section_list = checkpoint_section_list->next) {
  2016. checkpointSection = list_entry (checkpoint_section_list,
  2017. struct saCkptCheckpointSection, list);
  2018. memoryUsed += checkpointSection->sectionDescriptor.sectionSize;
  2019. numberOfSections += 1;
  2020. }
  2021. /*
  2022. * Build checkpoint status get response
  2023. */
  2024. res_lib_ckpt_checkpointstatusget.header.size = sizeof (struct res_lib_ckpt_checkpointstatusget);
  2025. res_lib_ckpt_checkpointstatusget.header.id = MESSAGE_RES_CKPT_CHECKPOINT_CHECKPOINTSTATUSGET;
  2026. res_lib_ckpt_checkpointstatusget.header.error = SA_AIS_OK;
  2027. memcpy (&res_lib_ckpt_checkpointstatusget.checkpointDescriptor.checkpointCreationAttributes,
  2028. &checkpoint->checkpointCreationAttributes,
  2029. sizeof (SaCkptCheckpointCreationAttributesT));
  2030. res_lib_ckpt_checkpointstatusget.checkpointDescriptor.numberOfSections = numberOfSections;
  2031. res_lib_ckpt_checkpointstatusget.checkpointDescriptor.memoryUsed = memoryUsed;
  2032. log_printf (LOG_LEVEL_DEBUG, "before sending message\n");
  2033. libais_send_response (conn_info, &res_lib_ckpt_checkpointstatusget,
  2034. sizeof (struct res_lib_ckpt_checkpointstatusget));
  2035. return (0);
  2036. }
  2037. static int message_handler_req_lib_ckpt_sectioncreate (struct conn_info *conn_info, void *message)
  2038. {
  2039. struct req_lib_ckpt_sectioncreate *req_lib_ckpt_sectioncreate = (struct req_lib_ckpt_sectioncreate *)message;
  2040. struct req_exec_ckpt_sectioncreate req_exec_ckpt_sectioncreate;
  2041. struct iovec iovecs[2];
  2042. struct saCkptCheckpoint *checkpoint;
  2043. log_printf (LOG_LEVEL_DEBUG, "Section create from API fd %d\n", conn_info->fd);
  2044. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioncreate->checkpointName);
  2045. /*
  2046. * checkpoint opened is writeable mode so send message to cluster
  2047. */
  2048. req_exec_ckpt_sectioncreate.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONCREATE;
  2049. req_exec_ckpt_sectioncreate.header.size = sizeof (struct req_exec_ckpt_sectioncreate);
  2050. memcpy (&req_exec_ckpt_sectioncreate.req_lib_ckpt_sectioncreate,
  2051. req_lib_ckpt_sectioncreate,
  2052. sizeof (struct req_lib_ckpt_sectioncreate));
  2053. memcpy (&req_exec_ckpt_sectioncreate.checkpointName,
  2054. &req_lib_ckpt_sectioncreate->checkpointName,
  2055. sizeof (SaNameT));
  2056. message_source_set (&req_exec_ckpt_sectioncreate.source, conn_info);
  2057. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectioncreate;
  2058. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectioncreate);
  2059. /*
  2060. * Send section name and initial data in message
  2061. */
  2062. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectioncreate) + sizeof (struct req_lib_ckpt_sectioncreate);
  2063. iovecs[1].iov_len = req_lib_ckpt_sectioncreate->header.size - sizeof (struct req_lib_ckpt_sectioncreate);
  2064. req_exec_ckpt_sectioncreate.header.size += iovecs[1].iov_len;
  2065. #ifdef DEBUG
  2066. printf ("LIBRARY SECTIONCREATE string is %s len is %d\n", (unsigned char *)iovecs[1].iov_base,
  2067. iovecs[1].iov_len);
  2068. printf ("|\n");
  2069. { int i;
  2070. char *abc = iovecs[1].iov_base;
  2071. for (i = 0; i < 14;i++) {
  2072. printf ("%c ", abc[i]);
  2073. }
  2074. }
  2075. printf ("|\n");
  2076. #endif
  2077. if (iovecs[1].iov_len > 0) {
  2078. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %p\n", iovecs[1].iov_base);
  2079. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2080. } else {
  2081. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2082. }
  2083. return (0);
  2084. }
  2085. static int message_handler_req_lib_ckpt_sectiondelete (struct conn_info *conn_info, void *message)
  2086. {
  2087. struct req_lib_ckpt_sectiondelete *req_lib_ckpt_sectiondelete = (struct req_lib_ckpt_sectiondelete *)message;
  2088. struct req_exec_ckpt_sectiondelete req_exec_ckpt_sectiondelete;
  2089. struct iovec iovecs[2];
  2090. log_printf (LOG_LEVEL_DEBUG, "section delete from API fd %d\n", conn_info->fd);
  2091. req_exec_ckpt_sectiondelete.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONDELETE;
  2092. req_exec_ckpt_sectiondelete.header.size = sizeof (struct req_exec_ckpt_sectiondelete);
  2093. memcpy (&req_exec_ckpt_sectiondelete.checkpointName,
  2094. &req_lib_ckpt_sectiondelete->checkpointName,
  2095. sizeof (SaNameT));
  2096. memcpy (&req_exec_ckpt_sectiondelete.req_lib_ckpt_sectiondelete,
  2097. req_lib_ckpt_sectiondelete,
  2098. sizeof (struct req_lib_ckpt_sectiondelete));
  2099. message_source_set (&req_exec_ckpt_sectiondelete.source, conn_info);
  2100. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectiondelete;
  2101. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectiondelete);
  2102. /*
  2103. * Send section name
  2104. */
  2105. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectiondelete) + sizeof (struct req_lib_ckpt_sectiondelete);
  2106. iovecs[1].iov_len = req_lib_ckpt_sectiondelete->header.size - sizeof (struct req_lib_ckpt_sectiondelete);
  2107. req_exec_ckpt_sectiondelete.header.size += iovecs[1].iov_len;
  2108. if (iovecs[1].iov_len > 0) {
  2109. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2110. } else {
  2111. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2112. }
  2113. return (0);
  2114. }
  2115. static int message_handler_req_lib_ckpt_sectionexpirationtimeset (struct conn_info *conn_info, void *message)
  2116. {
  2117. struct req_lib_ckpt_sectionexpirationtimeset *req_lib_ckpt_sectionexpirationtimeset = (struct req_lib_ckpt_sectionexpirationtimeset *)message;
  2118. struct req_exec_ckpt_sectionexpirationtimeset req_exec_ckpt_sectionexpirationtimeset;
  2119. struct iovec iovecs[2];
  2120. log_printf (LOG_LEVEL_DEBUG, "section expiration time set fd=%d\n", conn_info->fd);
  2121. req_exec_ckpt_sectionexpirationtimeset.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONEXPIRATIONTIMESET;
  2122. req_exec_ckpt_sectionexpirationtimeset.header.size = sizeof (struct req_exec_ckpt_sectionexpirationtimeset);
  2123. memcpy (&req_exec_ckpt_sectionexpirationtimeset.checkpointName,
  2124. &req_lib_ckpt_sectionexpirationtimeset->checkpointName,
  2125. sizeof (SaNameT));
  2126. memcpy (&req_exec_ckpt_sectionexpirationtimeset.req_lib_ckpt_sectionexpirationtimeset,
  2127. req_lib_ckpt_sectionexpirationtimeset,
  2128. sizeof (struct req_lib_ckpt_sectionexpirationtimeset));
  2129. message_source_set (&req_exec_ckpt_sectionexpirationtimeset.source, conn_info);
  2130. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionexpirationtimeset;
  2131. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionexpirationtimeset);
  2132. /*
  2133. * Send section name
  2134. */
  2135. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionexpirationtimeset) + sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  2136. iovecs[1].iov_len = req_lib_ckpt_sectionexpirationtimeset->header.size - sizeof (struct req_lib_ckpt_sectionexpirationtimeset);
  2137. req_exec_ckpt_sectionexpirationtimeset.header.size += iovecs[1].iov_len;
  2138. if (iovecs[1].iov_len > 0) {
  2139. log_printf (LOG_LEVEL_DEBUG, "IOV_BASE is %p\n", iovecs[1].iov_base);
  2140. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2141. } else {
  2142. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2143. }
  2144. return (0);
  2145. }
  2146. int write_inv = 0;
  2147. static int message_handler_req_lib_ckpt_sectionwrite (struct conn_info *conn_info, void *message)
  2148. {
  2149. struct req_lib_ckpt_sectionwrite *req_lib_ckpt_sectionwrite = (struct req_lib_ckpt_sectionwrite *)message;
  2150. struct req_exec_ckpt_sectionwrite req_exec_ckpt_sectionwrite;
  2151. struct iovec iovecs[2];
  2152. struct saCkptCheckpoint *checkpoint;
  2153. log_printf (LOG_LEVEL_DEBUG, "Section write from API fd %d\n", conn_info->fd);
  2154. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionwrite->checkpointName);
  2155. /*
  2156. * checkpoint opened is writeable mode so send message to cluster
  2157. */
  2158. req_exec_ckpt_sectionwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONWRITE;
  2159. req_exec_ckpt_sectionwrite.header.size = sizeof (struct req_exec_ckpt_sectionwrite);
  2160. memcpy (&req_exec_ckpt_sectionwrite.req_lib_ckpt_sectionwrite,
  2161. req_lib_ckpt_sectionwrite,
  2162. sizeof (struct req_lib_ckpt_sectionwrite));
  2163. memcpy (&req_exec_ckpt_sectionwrite.checkpointName,
  2164. &req_lib_ckpt_sectionwrite->checkpointName,
  2165. sizeof (SaNameT));
  2166. message_source_set (&req_exec_ckpt_sectionwrite.source, conn_info);
  2167. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionwrite;
  2168. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionwrite);
  2169. /*
  2170. * Send section name and data to write in message
  2171. */
  2172. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionwrite) + sizeof (struct req_lib_ckpt_sectionwrite);
  2173. iovecs[1].iov_len = req_lib_ckpt_sectionwrite->header.size - sizeof (struct req_lib_ckpt_sectionwrite);
  2174. req_exec_ckpt_sectionwrite.header.size += iovecs[1].iov_len;
  2175. if (iovecs[1].iov_len > 0) {
  2176. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2177. } else {
  2178. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2179. }
  2180. return (0);
  2181. }
  2182. static int message_handler_req_lib_ckpt_sectionoverwrite (struct conn_info *conn_info, void *message)
  2183. {
  2184. struct req_lib_ckpt_sectionoverwrite *req_lib_ckpt_sectionoverwrite = (struct req_lib_ckpt_sectionoverwrite *)message;
  2185. struct req_exec_ckpt_sectionoverwrite req_exec_ckpt_sectionoverwrite;
  2186. struct iovec iovecs[2];
  2187. struct saCkptCheckpoint *checkpoint;
  2188. log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info->fd);
  2189. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionoverwrite->checkpointName);
  2190. /*
  2191. * checkpoint opened is writeable mode so send message to cluster
  2192. */
  2193. req_exec_ckpt_sectionoverwrite.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONOVERWRITE;
  2194. req_exec_ckpt_sectionoverwrite.header.size = sizeof (struct req_exec_ckpt_sectionoverwrite);
  2195. memcpy (&req_exec_ckpt_sectionoverwrite.req_lib_ckpt_sectionoverwrite,
  2196. req_lib_ckpt_sectionoverwrite,
  2197. sizeof (struct req_lib_ckpt_sectionoverwrite));
  2198. memcpy (&req_exec_ckpt_sectionoverwrite.checkpointName,
  2199. &req_lib_ckpt_sectionoverwrite->checkpointName,
  2200. sizeof (SaNameT));
  2201. message_source_set (&req_exec_ckpt_sectionoverwrite.source, conn_info);
  2202. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionoverwrite;
  2203. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionoverwrite);
  2204. /*
  2205. * Send section name and data to overwrite in message
  2206. */
  2207. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionoverwrite) + sizeof (struct req_lib_ckpt_sectionoverwrite);
  2208. iovecs[1].iov_len = req_lib_ckpt_sectionoverwrite->header.size - sizeof (struct req_lib_ckpt_sectionoverwrite);
  2209. req_exec_ckpt_sectionoverwrite.header.size += iovecs[1].iov_len;
  2210. if (iovecs[1].iov_len > 0) {
  2211. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2212. } else {
  2213. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2214. }
  2215. return (0);
  2216. }
  2217. static int message_handler_req_lib_ckpt_sectionread (struct conn_info *conn_info, void *message)
  2218. {
  2219. struct req_lib_ckpt_sectionread *req_lib_ckpt_sectionread = (struct req_lib_ckpt_sectionread *)message;
  2220. struct req_exec_ckpt_sectionread req_exec_ckpt_sectionread;
  2221. struct iovec iovecs[2];
  2222. struct saCkptCheckpoint *checkpoint;
  2223. log_printf (LOG_LEVEL_DEBUG, "Section overwrite from API fd %d\n", conn_info->fd);
  2224. checkpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectionread->checkpointName);
  2225. /*
  2226. * checkpoint opened is writeable mode so send message to cluster
  2227. */
  2228. req_exec_ckpt_sectionread.header.id = MESSAGE_REQ_EXEC_CKPT_SECTIONREAD;
  2229. req_exec_ckpt_sectionread.header.size = sizeof (struct req_exec_ckpt_sectionread);
  2230. memcpy (&req_exec_ckpt_sectionread.req_lib_ckpt_sectionread,
  2231. req_lib_ckpt_sectionread,
  2232. sizeof (struct req_lib_ckpt_sectionread));
  2233. memcpy (&req_exec_ckpt_sectionread.checkpointName,
  2234. &req_lib_ckpt_sectionread->checkpointName,
  2235. sizeof (SaNameT));
  2236. message_source_set (&req_exec_ckpt_sectionread.source, conn_info);
  2237. iovecs[0].iov_base = (char *)&req_exec_ckpt_sectionread;
  2238. iovecs[0].iov_len = sizeof (req_exec_ckpt_sectionread);
  2239. /*
  2240. * Send section name and data to overwrite in message
  2241. */
  2242. iovecs[1].iov_base = ((char *)req_lib_ckpt_sectionread) + sizeof (struct req_lib_ckpt_sectionread);
  2243. iovecs[1].iov_len = req_lib_ckpt_sectionread->header.size - sizeof (struct req_lib_ckpt_sectionread);
  2244. req_exec_ckpt_sectionread.header.size += iovecs[1].iov_len;
  2245. if (iovecs[1].iov_len > 0) {
  2246. assert (totempg_mcast (iovecs, 2, TOTEMPG_AGREED) == 0);
  2247. } else {
  2248. assert (totempg_mcast (iovecs, 1, TOTEMPG_AGREED) == 0);
  2249. }
  2250. return (0);
  2251. }
  2252. static int message_handler_req_lib_ckpt_checkpointsynchronize (struct conn_info *conn_info, void *message)
  2253. {
  2254. return (0);
  2255. }
  2256. static int message_handler_req_lib_ckpt_checkpointsynchronizeasync (struct conn_info *conn_info, void *message)
  2257. {
  2258. return (0);
  2259. }
  2260. static int message_handler_req_lib_ckpt_sectioniteratorinitialize (struct conn_info *conn_info, void *message)
  2261. {
  2262. struct req_lib_ckpt_sectioniteratorinitialize *req_lib_ckpt_sectioniteratorinitialize = (struct req_lib_ckpt_sectioniteratorinitialize *)message;
  2263. struct res_lib_ckpt_sectioniteratorinitialize res_lib_ckpt_sectioniteratorinitialize;
  2264. struct saCkptCheckpoint *ckptCheckpoint;
  2265. struct saCkptCheckpointSection *ckptCheckpointSection;
  2266. struct saCkptSectionIteratorEntry *ckptSectionIteratorEntries;
  2267. struct saCkptSectionIterator *ckptSectionIterator;
  2268. struct list_head *checkpoint_section_list;
  2269. int addEntry = 0;
  2270. int iteratorEntries = 0;
  2271. SaErrorT error = SA_AIS_OK;
  2272. log_printf (LOG_LEVEL_DEBUG, "section iterator initialize\n");
  2273. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  2274. ckptCheckpoint = ckpt_checkpoint_find_global (&req_lib_ckpt_sectioniteratorinitialize->checkpointName);
  2275. if (ckptCheckpoint == 0) {
  2276. error = SA_AIS_ERR_NOT_EXIST;
  2277. goto error_exit;
  2278. }
  2279. /*
  2280. * Iterate list of checkpoint sections
  2281. */
  2282. for (checkpoint_section_list = ckptCheckpoint->checkpointSectionsListHead.next;
  2283. checkpoint_section_list != &ckptCheckpoint->checkpointSectionsListHead;
  2284. checkpoint_section_list = checkpoint_section_list->next) {
  2285. ckptCheckpointSection = list_entry (checkpoint_section_list,
  2286. struct saCkptCheckpointSection, list);
  2287. addEntry = 1;
  2288. /*
  2289. * Item should be added to iterator list
  2290. */
  2291. if (addEntry) {
  2292. iteratorEntries += 1;
  2293. ckptSectionIteratorEntries =
  2294. realloc (ckptSectionIterator->sectionIteratorEntries,
  2295. sizeof (struct saCkptSectionIteratorEntry) * iteratorEntries);
  2296. if (ckptSectionIteratorEntries == 0) {
  2297. if (ckptSectionIterator->sectionIteratorEntries) {
  2298. free (ckptSectionIterator->sectionIteratorEntries);
  2299. }
  2300. error = SA_AIS_ERR_NO_MEMORY;
  2301. goto error_exit;
  2302. }
  2303. ckptSectionIteratorEntries[iteratorEntries - 1].active = 1;
  2304. ckptSectionIteratorEntries[iteratorEntries - 1].checkpointSection = ckptCheckpointSection;
  2305. ckptSectionIterator->sectionIteratorEntries = ckptSectionIteratorEntries;
  2306. }
  2307. }
  2308. ckptSectionIterator->iteratorCount = iteratorEntries;
  2309. error_exit:
  2310. res_lib_ckpt_sectioniteratorinitialize.header.size = sizeof (struct res_lib_ckpt_sectioniteratorinitialize);
  2311. res_lib_ckpt_sectioniteratorinitialize.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORINITIALIZE;
  2312. res_lib_ckpt_sectioniteratorinitialize.header.error = error;
  2313. libais_send_response (conn_info, &res_lib_ckpt_sectioniteratorinitialize,
  2314. sizeof (struct res_lib_ckpt_sectioniteratorinitialize));
  2315. return (0);
  2316. }
  2317. static int message_handler_req_lib_ckpt_sectioniteratornext (struct conn_info *conn_info, void *message)
  2318. {
  2319. struct req_lib_ckpt_sectioniteratornext *req_lib_ckpt_sectioniteratornext = (struct req_lib_ckpt_sectioniteratornext *)message;
  2320. struct res_lib_ckpt_sectioniteratornext res_lib_ckpt_sectioniteratornext;
  2321. struct saCkptSectionIterator *ckptSectionIterator;
  2322. SaErrorT error = SA_AIS_OK;
  2323. int sectionIdSize = 0;
  2324. int iteratorPos = 0;
  2325. req_lib_ckpt_sectioniteratornext = 0; /* this variable not used */
  2326. log_printf (LOG_LEVEL_DEBUG, "section iterator next\n");
  2327. ckptSectionIterator = &conn_info->ais_ci.u.libckpt_ci.sectionIterator;
  2328. /*
  2329. * Find active iterator entry
  2330. */
  2331. for (;;) {
  2332. /*
  2333. * No more sections in iterator
  2334. */
  2335. if (ckptSectionIterator->iteratorPos + 1 >= ckptSectionIterator->iteratorCount) {
  2336. error = SA_AIS_ERR_NOT_EXIST;
  2337. goto error_exit;
  2338. }
  2339. /*
  2340. * active iterator entry
  2341. */
  2342. if (ckptSectionIterator->sectionIteratorEntries[ckptSectionIterator->iteratorPos].active == 1) {
  2343. break;
  2344. }
  2345. ckptSectionIterator->iteratorPos += 1;
  2346. }
  2347. /*
  2348. * Prepare response to API
  2349. */
  2350. iteratorPos = ckptSectionIterator->iteratorPos;
  2351. sectionIdSize = ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.idLen;
  2352. memcpy (&res_lib_ckpt_sectioniteratornext.sectionDescriptor,
  2353. &ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor,
  2354. sizeof (SaCkptSectionDescriptorT));
  2355. /*
  2356. * Get to next iterator entry
  2357. */
  2358. ckptSectionIterator->iteratorPos += 1;
  2359. error_exit:
  2360. res_lib_ckpt_sectioniteratornext.header.size = sizeof (struct res_lib_ckpt_sectioniteratornext) + sectionIdSize;
  2361. res_lib_ckpt_sectioniteratornext.header.id = MESSAGE_RES_CKPT_SECTIONITERATOR_SECTIONITERATORNEXT;
  2362. res_lib_ckpt_sectioniteratornext.header.error = error;
  2363. libais_send_response (conn_info, &res_lib_ckpt_sectioniteratornext,
  2364. sizeof (struct res_lib_ckpt_sectioniteratornext));
  2365. libais_send_response (conn_info,
  2366. ckptSectionIterator->sectionIteratorEntries[iteratorPos].checkpointSection->sectionDescriptor.sectionId.id,
  2367. sectionIdSize);
  2368. return (0);
  2369. }