ckpt.c 129 KB

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