ckpt.c 129 KB

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