ckpt.c 101 KB

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