ckpt.c 129 KB

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