Line data Source code
1 : #ifndef HEADER_fd_src_flamenco_runtime_fd_store_h 2 : #define HEADER_fd_src_flamenco_runtime_fd_store_h 3 : 4 : #include "../../flamenco/runtime/fd_blockstore.h" 5 : #include "../../flamenco/runtime/fd_runtime.h" 6 : 7 : #include "util.h" 8 : #include "fd_pending_slots.h" 9 : 10 0 : #define FD_STORE_SLOT_PREPARE_CONTINUE (0) 11 0 : #define FD_STORE_SLOT_PREPARE_NEED_ORPHAN (1) 12 0 : #define FD_STORE_SLOT_PREPARE_NEED_REPAIR (2) 13 0 : #define FD_STORE_SLOT_PREPARE_NEED_PARENT_EXEC (3) 14 0 : #define FD_STORE_SLOT_PREPARE_ALREADY_EXECUTED (4) 15 : 16 : /* The standard amount of time that we wait before repeating a slot */ 17 0 : #define FD_REPAIR_BACKOFF_TIME ( (long)150e6 ) 18 : 19 : struct fd_repair_backoff { 20 : ulong slot; 21 : long last_backoff_duration; 22 : long last_repair_time; 23 : }; 24 : typedef struct fd_repair_backoff fd_repair_backoff_t; 25 : static const fd_acct_addr_t chkdup_null_addr = {{ 0 }}; 26 : 27 : #define MAP_NAME fd_repair_backoff_map 28 0 : #define MAP_T fd_repair_backoff_t 29 0 : #define MAP_KEY_T ulong 30 0 : #define MAP_KEY slot 31 0 : #define MAP_KEY_NULL FD_SLOT_NULL 32 0 : #define MAP_KEY_INVAL(k) MAP_KEY_EQUAL(k, FD_SLOT_NULL) 33 0 : #define MAP_KEY_EQUAL(k0,k1) (k0==k1) 34 : #define MAP_KEY_EQUAL_IS_SLOW 0 35 : #define MAP_MEMOIZE 0 36 0 : #define MAP_KEY_HASH(key) ((uint)fd_ulong_hash( key )) 37 0 : #define MAP_LG_SLOT_CNT 14 38 : #include "../../util/tmpl/fd_map.c" 39 : 40 : 41 : struct __attribute__((aligned(128UL))) fd_store { 42 : long now; /* Current time */ 43 : 44 : /* metadata */ 45 : ulong snapshot_slot; /* the snapshot slot */ 46 : ulong first_turbine_slot; /* the first turbine slot we received on startup */ 47 : ulong curr_turbine_slot; 48 : ulong curr_pack_slot; 49 : ulong root; 50 : ulong expected_shred_version; 51 : 52 : fd_repair_backoff_t repair_backoff_map[ 1UL<<15UL ]; 53 : /* external joins */ 54 : fd_blockstore_t * blockstore; 55 : fd_valloc_t valloc; 56 : 57 : /* internal joins */ 58 : fd_pending_slots_t * pending_slots; 59 : }; 60 : typedef struct fd_store fd_store_t; 61 : 62 : FD_PROTOTYPES_BEGIN 63 : 64 : FD_FN_CONST static inline ulong 65 0 : fd_store_align( void ) { 66 0 : return alignof( fd_store_t ); 67 0 : } 68 : 69 : FD_FN_CONST static inline ulong 70 0 : fd_store_footprint( void ) { 71 0 : return sizeof( fd_store_t ) + fd_pending_slots_footprint(); 72 0 : } 73 : 74 : void * 75 : fd_store_new( void * mem, ulong lo_wmark_slot ); 76 : 77 : fd_store_t * 78 : fd_store_join( void * store ); 79 : 80 : void * 81 : fd_store_leave( fd_store_t const * store ); 82 : 83 : void * 84 : fd_store_delete( void * store ); 85 : 86 : void 87 : fd_store_expected_shred_version( fd_store_t * store, ulong expected_shred_version ); 88 : 89 : int 90 : fd_store_slot_prepare( fd_store_t * store, 91 : ulong slot, 92 : ulong * repair_slot_out, 93 : uchar const ** block_out, 94 : ulong * block_sz_out ); 95 : 96 : int 97 : fd_store_set_pack_slot( fd_store_t * store, 98 : ulong slot ); 99 : 100 : int 101 : fd_store_shred_insert( fd_store_t * store, 102 : fd_shred_t const * shred ); 103 : 104 : void 105 : fd_store_add_pending( fd_store_t * store, 106 : ulong slot, 107 : long delay, 108 : int should_backoff, 109 : int reset_backoff ); 110 : void 111 : fd_store_set_root( fd_store_t * store, 112 : ulong root ); 113 : 114 : ulong 115 : fd_store_slot_repair( fd_store_t * store, 116 : ulong slot, 117 : fd_repair_request_t * out_repair_reqs, 118 : ulong out_repair_reqs_sz ); 119 : 120 : void 121 : fd_store_shred_update_with_shred_from_turbine( fd_store_t * store, 122 : fd_shred_t const * shred ); 123 : 124 : FD_PROTOTYPES_END 125 : 126 : #endif