ckpt.c 129 KB

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