ckpt.c 128 KB

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