ckpt.c 129 KB

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