Line data Source code
1 0 : case FD_VINYL_REQ_TYPE_FLUSH: { 2 : 3 0 : fd_vinyl_key_t const * req_key = MAP_REQ_GADDR( req->key_gaddr, fd_vinyl_key_t, batch_cnt ); 4 : 5 0 : if( FD_UNLIKELY( (!!batch_cnt) & (!req_key) ) ) break; /* flushes don't generate completions */ 6 : 7 0 : for( ulong batch_idx=0UL; batch_idx<batch_cnt; batch_idx++ ) { 8 : 9 : /* Query vinyl meta for key */ 10 : 11 0 : fd_vinyl_key_t const * key = req_key + batch_idx; 12 : 13 0 : ulong memo = fd_vinyl_key_memo( meta_seed, key ); 14 : 15 0 : ulong _ele_idx; /* avoid pointer escape */ 16 0 : int err = fd_vinyl_meta_query_fast( ele0, ele_max, key, memo, &_ele_idx ); 17 0 : ulong ele_idx = _ele_idx; /* In [0,ele_max) */ 18 : 19 0 : if( FD_UNLIKELY( err ) ) continue; /* Nothing to flush */ 20 : 21 : /* At this point, pair key exists at bstream seq_present or is 22 : in the process of being created. If pair key is not cached, 23 : there's nothing to flush. */ 24 : 25 0 : ulong line_idx = ele0[ ele_idx ].line_idx; 26 : 27 0 : if( FD_UNLIKELY( line_idx==ULONG_MAX ) ) continue; 28 : 29 : /* At this point, pair key is cached at line line_idx. Make this 30 : line the LRU. If pair key is currently acquired, that's as 31 : much as we can do now. */ 32 : 33 0 : FD_CRIT( line_idx<line_cnt, "corruption detected" ); 34 0 : FD_CRIT( line[ line_idx ].ele_idx==ele_idx, "corruption detected" ); 35 : 36 0 : fd_vinyl_data_obj_t * obj = line[ line_idx ].obj; 37 : 38 0 : FD_ALERT( fd_vinyl_data_is_valid_obj( obj, vol, vol_cnt ), "corruption detected" ); 39 0 : FD_CRIT ( obj->line_idx==line_idx, "corruption detected" ); 40 0 : FD_CRIT ( !obj->rd_active, "corruption detected" ); 41 : 42 0 : fd_vinyl_line_evict_prio( &vinyl->line_idx_lru, line, line_cnt, line_idx, FD_VINYL_LINE_EVICT_PRIO_LRU ); 43 : 44 0 : ulong ctl = line[ line_idx ].ctl; 45 : 46 0 : ulong ver = fd_vinyl_line_ctl_ver( ctl ); 47 0 : long ref = fd_vinyl_line_ctl_ref( ctl ); 48 : 49 0 : if( FD_UNLIKELY( ref ) ) continue; 50 : 51 : /* At this point, pair key is cached, not acquired and the line 52 : is at LRU position. Flush the cached data. We don't modify 53 : any shared fields of meta element ele_idx so we can do this 54 : fast. */ 55 : 56 0 : line[ line_idx ].obj = NULL; 57 0 : line[ line_idx ].ele_idx = ULONG_MAX; 58 0 : line[ line_idx ].ctl = fd_vinyl_line_ctl( ver+1UL, 0UL ); 59 : /* evict prio updated above */ 60 : 61 0 : ele0[ ele_idx ].line_idx = ULONG_MAX; 62 : 63 0 : fd_vinyl_data_free( data, obj ); 64 : 65 0 : } 66 : 67 0 : break; 68 0 : }