Line data Source code
1 : #define _GNU_SOURCE
2 : #include "utils/fd_ssctrl.h"
3 : #include "utils/fd_ssparse.h"
4 : #include "utils/fd_ssmanifest_parser.h"
5 :
6 : #include "../../disco/topo/fd_topo.h"
7 : #include "../../disco/metrics/fd_metrics.h"
8 :
9 : #include "generated/fd_snapwr_tile_seccomp.h"
10 :
11 : #include <errno.h>
12 : #include <fcntl.h>
13 : #include <unistd.h>
14 :
15 : #define NAME "snapwr"
16 :
17 0 : #define FD_SNAPWR_WRITE_BUF_SZ (2UL<<20) /* 2MiB */
18 :
19 : struct fd_snapwr_out {
20 : ulong idx;
21 : fd_wksp_t * mem;
22 : ulong chunk0;
23 : ulong wmark;
24 : ulong chunk;
25 : ulong mtu;
26 : };
27 :
28 : typedef struct fd_snapwr_out fd_snapwr_out_t;
29 :
30 : struct fd_snapwr_tile {
31 : int full;
32 : int state;
33 :
34 : ulong partition_sz;
35 :
36 : ulong accounts_off;
37 : ulong flush_off;
38 :
39 : uchar * write_buf;
40 : ulong write_buf_used;
41 :
42 : ulong seed;
43 :
44 : fd_ssparse_t ssparse[1];
45 : fd_ssmanifest_parser_t * manifest_parser;
46 :
47 : struct {
48 : fd_wksp_t * wksp;
49 : ulong chunk0;
50 : ulong wmark;
51 : ulong mtu;
52 : ulong pos;
53 : } in;
54 :
55 : fd_snapwr_out_t ct_out;
56 :
57 : struct {
58 : ulong accounts_off;
59 : ulong flush_off;
60 : } recovery;
61 :
62 : struct {
63 : ulong full_bytes_read;
64 : ulong incremental_bytes_read;
65 : ulong bytes_written;
66 : ulong accounts_written;
67 : ulong full_accounts_written;
68 : } metrics;
69 :
70 : fd_snapshot_manifest_t manifest[1];
71 : };
72 :
73 : typedef struct fd_snapwr_tile fd_snapwr_tile_t;
74 :
75 : static inline int
76 0 : should_shutdown( fd_snapwr_tile_t * ctx ) {
77 0 : return ctx->state==FD_SNAPSHOT_STATE_SHUTDOWN;
78 0 : }
79 :
80 : static void
81 0 : metrics_write( fd_snapwr_tile_t * ctx ) {
82 0 : FD_MGAUGE_SET( SNAPWR, FULL_BYTES_READ, ctx->metrics.full_bytes_read );
83 0 : FD_MGAUGE_SET( SNAPWR, INCREMENTAL_BYTES_READ, ctx->metrics.incremental_bytes_read );
84 0 : FD_MGAUGE_SET( SNAPWR, BYTES_WRITTEN, ctx->metrics.bytes_written );
85 0 : FD_MGAUGE_SET( SNAPWR, ACCOUNTS_WRITTEN, ctx->metrics.accounts_written );
86 0 : }
87 :
88 : static ulong
89 0 : scratch_align( void ) {
90 0 : return 512UL;
91 0 : }
92 :
93 : static ulong
94 0 : scratch_footprint( fd_topo_tile_t const * tile ) {
95 0 : (void)tile;
96 0 : ulong l = FD_LAYOUT_INIT;
97 0 : l = FD_LAYOUT_APPEND( l, alignof(fd_snapwr_tile_t), sizeof(fd_snapwr_tile_t) );
98 0 : l = FD_LAYOUT_APPEND( l, fd_ssmanifest_parser_align(), fd_ssmanifest_parser_footprint() );
99 0 : l = FD_LAYOUT_APPEND( l, 1UL, FD_SNAPWR_WRITE_BUF_SZ );
100 0 : return FD_LAYOUT_FINI( l, scratch_align() );
101 0 : }
102 :
103 : static void
104 : transition_malformed( fd_snapwr_tile_t * ctx,
105 0 : fd_stem_context_t * stem ) {
106 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) return;
107 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
108 0 : fd_stem_publish( stem, ctx->ct_out.idx, FD_SNAPSHOT_MSG_CTRL_ERROR, 0UL, 0UL, 0UL, 0UL, 0UL );
109 0 : }
110 :
111 : static void
112 0 : buffer_flush( fd_snapwr_tile_t * ctx ) {
113 0 : if( FD_UNLIKELY( !ctx->write_buf_used ) ) return;
114 :
115 0 : ulong sz = ctx->write_buf_used;
116 0 : ulong off = ctx->flush_off;
117 0 : ulong bytes_written = 0UL;
118 0 : while( bytes_written<sz ) {
119 0 : long res = pwrite( FD_ACCDB_FD_RW, ctx->write_buf+bytes_written, sz-bytes_written, (long)(off+bytes_written) );
120 0 : if( FD_UNLIKELY( -1==res ) ) FD_LOG_ERR(( "error writing to disk (%d-%s)", errno, fd_io_strerror( errno ) ));
121 0 : bytes_written += (ulong)res;
122 0 : ctx->metrics.bytes_written += (ulong)res;
123 0 : }
124 0 : ctx->flush_off += sz;
125 0 : ctx->write_buf_used = 0UL;
126 0 : }
127 :
128 : static void
129 : buffer_write( fd_snapwr_tile_t * ctx,
130 : uchar const * data,
131 0 : ulong sz ) {
132 0 : ctx->accounts_off += sz;
133 0 : while( sz ) {
134 0 : ulong avail = FD_SNAPWR_WRITE_BUF_SZ - ctx->write_buf_used;
135 0 : ulong n = fd_ulong_min( sz, avail );
136 0 : fd_memcpy( ctx->write_buf + ctx->write_buf_used, data, n );
137 0 : ctx->write_buf_used += n;
138 0 : data += n;
139 0 : sz -= n;
140 0 : if( FD_UNLIKELY( ctx->write_buf_used==FD_SNAPWR_WRITE_BUF_SZ ) ) buffer_flush( ctx );
141 0 : }
142 0 : }
143 :
144 : static void
145 : buffer_skip( fd_snapwr_tile_t * ctx,
146 0 : ulong sz ) {
147 0 : buffer_flush( ctx );
148 0 : ctx->accounts_off += sz;
149 0 : ctx->flush_off += sz;
150 0 : }
151 :
152 : static void
153 : process_account_header( fd_snapwr_tile_t * ctx,
154 0 : fd_ssparse_advance_result_t * result ) {
155 : /* Ensure header+data does not cross a partition boundary. If it
156 : would, pad with zeros so the account starts at the next one. */
157 0 : ulong account_sz = 68UL + (ulong)result->account_header.data_len;
158 0 : ulong cur_boundary = ctx->accounts_off / ctx->partition_sz;
159 0 : ulong end_boundary = (ctx->accounts_off + account_sz - 1UL) / ctx->partition_sz;
160 0 : if( FD_UNLIKELY( cur_boundary!=end_boundary ) ) {
161 0 : ulong next = (cur_boundary + 1UL) * ctx->partition_sz;
162 0 : buffer_skip( ctx, next - ctx->accounts_off );
163 0 : }
164 :
165 0 : uchar data[ 68UL ];
166 0 : fd_memcpy( data, result->account_header.pubkey, 32UL );
167 0 : fd_memcpy( data+32UL, &result->account_header.data_len, 4UL );
168 0 : fd_memcpy( data+36UL, result->account_header.owner, 32UL );
169 0 : buffer_write( ctx, data, 68UL );
170 0 : ctx->metrics.accounts_written++;
171 0 : }
172 :
173 : static void
174 : process_account_data( fd_snapwr_tile_t * ctx,
175 0 : fd_ssparse_advance_result_t * result ) {
176 0 : buffer_write( ctx, result->account_data.data, result->account_data.data_sz );
177 0 : }
178 :
179 : static int
180 : handle_data_frag( fd_snapwr_tile_t * ctx,
181 : ulong chunk,
182 : ulong sz,
183 0 : fd_stem_context_t * stem ) {
184 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_FINISHING ) ) {
185 0 : FD_LOG_WARNING(( "received unexpected data frag while in state %s (%lu)",
186 0 : fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
187 0 : transition_malformed( ctx, stem );
188 0 : return 0;
189 0 : }
190 0 : if( FD_UNLIKELY( ctx->state==FD_SNAPSHOT_STATE_ERROR ) ) {
191 : /* Ignore all data frags after observing an error in the stream until
192 : we receive fail & init control messages to restart processing. */
193 0 : return 0;
194 0 : }
195 0 : if( FD_UNLIKELY( ctx->state!=FD_SNAPSHOT_STATE_PROCESSING ) ) {
196 0 : FD_LOG_ERR(( "received data frag during invalid state %s (%lu)",
197 0 : fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
198 0 : }
199 :
200 0 : FD_TEST( chunk>=ctx->in.chunk0 && chunk<=ctx->in.wmark && sz<=ctx->in.mtu );
201 :
202 0 : for(;;) {
203 0 : if( FD_UNLIKELY( sz-ctx->in.pos==0UL ) ) break;
204 :
205 0 : uchar const * data = (uchar const *)fd_chunk_to_laddr_const( ctx->in.wksp, chunk ) + ctx->in.pos;
206 :
207 0 : fd_ssparse_advance_result_t result[1];
208 0 : int res = fd_ssparse_advance( ctx->ssparse, data, sz-ctx->in.pos, result );
209 0 : switch( res ) {
210 0 : case FD_SSPARSE_ADVANCE_ERROR:
211 0 : FD_LOG_WARNING(( "error while parsing snapshot stream" ));
212 0 : transition_malformed( ctx, stem );
213 0 : return 0;
214 0 : case FD_SSPARSE_ADVANCE_AGAIN:
215 0 : break;
216 0 : case FD_SSPARSE_ADVANCE_MANIFEST:
217 0 : case FD_SSPARSE_ADVANCE_MANIFEST_DONE: {
218 0 : int res = fd_ssmanifest_parser_consume( ctx->manifest_parser,
219 0 : result->manifest.data,
220 0 : result->manifest.data_sz );
221 0 : if( FD_UNLIKELY( res==FD_SSMANIFEST_PARSER_ADVANCE_ERROR ) ) {
222 0 : FD_LOG_WARNING(( "error while parsing snapshot manifest" ));
223 0 : transition_malformed( ctx, stem );
224 0 : return 0;
225 0 : }
226 0 : break;
227 0 : }
228 0 : case FD_SSPARSE_ADVANCE_STATUS_CACHE:
229 0 : break;
230 0 : case FD_SSPARSE_ADVANCE_ACCOUNT_HEADER:
231 0 : process_account_header( ctx, result );
232 0 : break;
233 0 : case FD_SSPARSE_ADVANCE_ACCOUNT_DATA:
234 0 : process_account_data( ctx, result );
235 0 : break;
236 0 : case FD_SSPARSE_ADVANCE_ACCOUNT_BATCH:
237 0 : FD_TEST( 0 );
238 0 : break;
239 0 : case FD_SSPARSE_ADVANCE_DONE:
240 0 : buffer_flush( ctx );
241 0 : ctx->state = FD_SNAPSHOT_STATE_FINISHING;
242 0 : break;
243 0 : default:
244 0 : FD_LOG_ERR(( "unexpected fd_ssparse_advance result %d", res ));
245 0 : break;
246 0 : }
247 :
248 0 : ctx->in.pos += result->bytes_consumed;
249 0 : if( FD_LIKELY( ctx->full ) ) ctx->metrics.full_bytes_read += result->bytes_consumed;
250 0 : else ctx->metrics.incremental_bytes_read += result->bytes_consumed;
251 0 : }
252 :
253 0 : int reprocess_frag = ctx->in.pos<sz;
254 0 : if( FD_LIKELY( !reprocess_frag ) ) ctx->in.pos = 0UL;
255 0 : return reprocess_frag;
256 0 : }
257 :
258 : static void
259 : handle_control_frag( fd_snapwr_tile_t * ctx,
260 : fd_stem_context_t * stem,
261 0 : ulong sig ) {
262 0 : if( FD_UNLIKELY( sig==FD_SNAPSHOT_MSG_META ) ) return;
263 :
264 0 : if( ctx->state==FD_SNAPSHOT_STATE_ERROR && sig!=FD_SNAPSHOT_MSG_CTRL_FAIL ) {
265 : /* Control messages move along the snapshot load pipeline. Since
266 : error conditions can be triggered by any tile in the pipeline,
267 : it is possible to be in error state and still receive otherwise
268 : valid messages. Only a fail message can revert this. */
269 0 : return;
270 0 : };
271 :
272 0 : int forward_msg = 1;
273 :
274 0 : switch( sig ) {
275 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_FULL:
276 0 : case FD_SNAPSHOT_MSG_CTRL_INIT_INCR: {
277 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
278 0 : ctx->state = FD_SNAPSHOT_STATE_PROCESSING;
279 0 : ctx->full = sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL;
280 0 : ctx->in.pos = 0UL;
281 0 : fd_ssparse_init( ctx->ssparse );
282 0 : fd_ssmanifest_parser_init( ctx->manifest_parser, ctx->manifest );
283 :
284 : /* Rewind metric counters (no-op unless recovering from a fail) */
285 0 : if( sig==FD_SNAPSHOT_MSG_CTRL_INIT_FULL ) {
286 0 : ctx->metrics.full_bytes_read = 0UL;
287 0 : ctx->metrics.incremental_bytes_read = 0UL;
288 0 : ctx->metrics.accounts_written = ctx->metrics.full_accounts_written = 0UL;
289 0 : } else {
290 0 : ctx->metrics.incremental_bytes_read = 0UL;
291 0 : ctx->metrics.accounts_written = ctx->metrics.full_accounts_written;
292 0 : }
293 0 : break;
294 0 : }
295 0 : case FD_SNAPSHOT_MSG_CTRL_FINI: {
296 : /* This is a special case: handle_data_frag must have already
297 : processed FD_SSPARSE_ADVANCE_DONE and moved the state into
298 : FD_SNAPSHOT_STATE_FINISHING. Otherwise, treat this as a
299 : malformed snapshot so that the pipeline can retry. */
300 0 : if( FD_UNLIKELY( ctx->state!=FD_SNAPSHOT_STATE_FINISHING ) ) {
301 0 : FD_LOG_WARNING(( "received FINI while in state %s (%lu), expected FINISHING (possibly truncated tar stream)",
302 0 : fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
303 0 : transition_malformed( ctx, stem );
304 0 : forward_msg = 0;
305 0 : break;
306 0 : }
307 0 : break;
308 0 : }
309 :
310 0 : case FD_SNAPSHOT_MSG_CTRL_NEXT: {
311 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
312 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
313 0 : ctx->recovery.accounts_off = ctx->accounts_off;
314 0 : ctx->recovery.flush_off = ctx->flush_off;
315 0 : ctx->metrics.full_accounts_written = ctx->metrics.accounts_written;
316 0 : break;
317 0 : }
318 :
319 0 : case FD_SNAPSHOT_MSG_CTRL_DONE: {
320 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_FINISHING );
321 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
322 0 : break;
323 0 : }
324 :
325 0 : case FD_SNAPSHOT_MSG_CTRL_ERROR: {
326 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
327 0 : ctx->state = FD_SNAPSHOT_STATE_ERROR;
328 0 : break;
329 0 : }
330 :
331 0 : case FD_SNAPSHOT_MSG_CTRL_FAIL: {
332 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
333 0 : ctx->write_buf_used = 0UL;
334 0 : ctx->accounts_off = ctx->full ? 0UL : ctx->recovery.accounts_off;
335 0 : ctx->flush_off = ctx->full ? 0UL : ctx->recovery.flush_off;
336 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
337 0 : break;
338 0 : }
339 :
340 0 : case FD_SNAPSHOT_MSG_CTRL_SHUTDOWN: {
341 0 : FD_TEST( ctx->state==FD_SNAPSHOT_STATE_IDLE );
342 0 : ctx->state = FD_SNAPSHOT_STATE_SHUTDOWN;
343 0 : break;
344 0 : }
345 :
346 0 : default: {
347 0 : FD_LOG_ERR(( "unexpected control frag %s (%lu) in state %s (%lu)",
348 0 : fd_ssctrl_msg_ctrl_str( sig ), sig,
349 0 : fd_ssctrl_state_str( (ulong)ctx->state ), (ulong)ctx->state ));
350 0 : break;
351 0 : }
352 0 : }
353 :
354 0 : if( FD_LIKELY( forward_msg ) ) {
355 0 : fd_stem_publish( stem, ctx->ct_out.idx, sig, 0UL, 0UL, 0UL, 0UL, 0UL );
356 0 : }
357 0 : }
358 :
359 : static inline int
360 : returnable_frag( fd_snapwr_tile_t * ctx,
361 : ulong in_idx FD_PARAM_UNUSED,
362 : ulong seq FD_PARAM_UNUSED,
363 : ulong sig,
364 : ulong chunk,
365 : ulong sz,
366 : ulong ctl FD_PARAM_UNUSED,
367 : ulong tsorig FD_PARAM_UNUSED,
368 : ulong tspub FD_PARAM_UNUSED,
369 0 : fd_stem_context_t * stem ) {
370 0 : FD_TEST( ctx->state!=FD_SNAPSHOT_STATE_SHUTDOWN );
371 :
372 0 : if( FD_UNLIKELY( sig==FD_SNAPSHOT_MSG_DATA ) ) return handle_data_frag( ctx, chunk, sz, stem );
373 0 : else handle_control_frag( ctx, stem, sig );
374 :
375 0 : return 0;
376 0 : }
377 :
378 : static ulong
379 : populate_allowed_fds( fd_topo_t const * topo FD_PARAM_UNUSED,
380 : fd_topo_tile_t const * tile FD_PARAM_UNUSED,
381 : ulong out_fds_cnt,
382 0 : int * out_fds ) {
383 0 : if( FD_UNLIKELY( out_fds_cnt<3UL ) ) FD_LOG_ERR(( "invalid out_fds_cnt %lu", out_fds_cnt ));
384 :
385 0 : ulong out_cnt = 0;
386 0 : out_fds[ out_cnt++ ] = 2UL; /* stderr */
387 0 : if( FD_LIKELY( -1!=fd_log_private_logfile_fd() ) ) {
388 0 : out_fds[ out_cnt++ ] = fd_log_private_logfile_fd(); /* logfile */
389 0 : }
390 0 : out_fds[ out_cnt++ ] = FD_ACCDB_FD_RW; /* accounts db */
391 :
392 0 : return out_cnt;
393 0 : }
394 :
395 : static ulong
396 : populate_allowed_seccomp( fd_topo_t const * topo,
397 : fd_topo_tile_t const * tile,
398 : ulong out_cnt,
399 0 : struct sock_filter * out ) {
400 0 : (void)topo; (void)tile;
401 :
402 0 : populate_sock_filter_policy_fd_snapwr_tile( out_cnt, out, (uint)fd_log_private_logfile_fd(), (uint)FD_ACCDB_FD_RW );
403 0 : return sock_filter_policy_fd_snapwr_tile_instr_cnt;
404 0 : }
405 :
406 : static inline fd_snapwr_out_t
407 : out1( fd_topo_t const * topo,
408 : fd_topo_tile_t const * tile,
409 0 : char const * name ) {
410 0 : ulong idx = fd_topo_find_tile_out_link( topo, tile, name, 0UL );
411 :
412 0 : if( FD_UNLIKELY( idx==ULONG_MAX ) ) return (fd_snapwr_out_t){ .idx = ULONG_MAX, .mem = NULL, .chunk0 = 0, .wmark = 0, .chunk = 0, .mtu = 0 };
413 :
414 0 : ulong mtu = topo->links[ tile->out_link_id[ idx ] ].mtu;
415 0 : if( FD_UNLIKELY( mtu==0UL ) ) return (fd_snapwr_out_t){ .idx = idx, .mem = NULL, .chunk0 = ULONG_MAX, .wmark = ULONG_MAX, .chunk = ULONG_MAX, .mtu = mtu };
416 :
417 0 : void * mem = topo->workspaces[ topo->objs[ topo->links[ tile->out_link_id[ idx ] ].dcache_obj_id ].wksp_id ].wksp;
418 0 : ulong chunk0 = fd_dcache_compact_chunk0( mem, topo->links[ tile->out_link_id[ idx ] ].dcache );
419 0 : ulong wmark = fd_dcache_compact_wmark ( mem, topo->links[ tile->out_link_id[ idx ] ].dcache, mtu );
420 0 : return (fd_snapwr_out_t){ .idx = idx, .mem = mem, .chunk0 = chunk0, .wmark = wmark, .chunk = chunk0, .mtu = mtu };
421 0 : }
422 :
423 : static void
424 : privileged_init( fd_topo_t const * topo,
425 0 : fd_topo_tile_t const * tile ) {
426 0 : fd_snapwr_tile_t * ctx = fd_topo_obj_laddr( topo, tile->tile_obj_id );
427 0 : FD_TEST( fd_rng_secure( &ctx->seed, 8UL ) );
428 0 : }
429 :
430 : static void
431 : unprivileged_init( fd_topo_t const * topo,
432 0 : fd_topo_tile_t const * tile ) {
433 0 : void * scratch = fd_topo_obj_laddr( topo, tile->tile_obj_id );
434 :
435 0 : FD_SCRATCH_ALLOC_INIT( l, scratch );
436 0 : fd_snapwr_tile_t * ctx = FD_SCRATCH_ALLOC_APPEND( l, alignof(fd_snapwr_tile_t), sizeof(fd_snapwr_tile_t) );
437 0 : void * _manifest_parser = FD_SCRATCH_ALLOC_APPEND( l, fd_ssmanifest_parser_align(), fd_ssmanifest_parser_footprint() );
438 0 : void * _write_buf = FD_SCRATCH_ALLOC_APPEND( l, 1UL, FD_SNAPWR_WRITE_BUF_SZ );
439 :
440 0 : ctx->full = 1;
441 0 : ctx->state = FD_SNAPSHOT_STATE_IDLE;
442 :
443 0 : ctx->partition_sz = tile->snapwr.partition_sz;
444 0 : if( FD_UNLIKELY( !ctx->partition_sz ) ) FD_LOG_ERR(( "tile `" NAME "` partition_sz is 0" ));
445 :
446 0 : ctx->accounts_off = 0UL;
447 0 : ctx->flush_off = 0UL;
448 0 : ctx->recovery.accounts_off = 0UL;
449 0 : ctx->recovery.flush_off = 0UL;
450 0 : ctx->write_buf = _write_buf;
451 0 : ctx->write_buf_used = 0UL;
452 :
453 0 : ctx->manifest_parser = fd_ssmanifest_parser_join( fd_ssmanifest_parser_new( _manifest_parser ) );
454 0 : FD_TEST( ctx->manifest_parser );
455 :
456 0 : fd_memset( &ctx->metrics, 0, sizeof(ctx->metrics) );
457 :
458 0 : if( FD_UNLIKELY( tile->in_cnt!=1UL ) ) FD_LOG_ERR(( "tile `" NAME "` has %lu ins, expected 1", tile->in_cnt ));
459 0 : ctx->ct_out = out1( topo, tile, "snapwr_ct" );
460 0 : if( FD_UNLIKELY( ctx->ct_out.idx==ULONG_MAX ) ) FD_LOG_ERR(( "tile `" NAME "` missing required out link `snapwr_ct`" ));
461 :
462 0 : fd_ssparse_init( ctx->ssparse );
463 0 : fd_ssparse_batch_enable( ctx->ssparse, 0 );
464 0 : fd_ssmanifest_parser_init( ctx->manifest_parser, ctx->manifest );
465 :
466 0 : fd_topo_link_t const * in_link = &topo->links[ tile->in_link_id[ 0UL ] ];
467 0 : FD_TEST( 0==strcmp( in_link->name, "snapdc_in" ) );
468 0 : fd_topo_wksp_t const * in_wksp = &topo->workspaces[ topo->objs[ in_link->dcache_obj_id ].wksp_id ];
469 0 : ctx->in.wksp = in_wksp->wksp;
470 0 : ctx->in.chunk0 = fd_dcache_compact_chunk0( ctx->in.wksp, in_link->dcache );
471 0 : ctx->in.wmark = fd_dcache_compact_wmark( ctx->in.wksp, in_link->dcache, in_link->mtu );
472 0 : ctx->in.mtu = in_link->mtu;
473 0 : ctx->in.pos = 0UL;
474 0 : }
475 :
476 0 : #define STEM_BURST 1UL
477 :
478 0 : #define STEM_LAZY (128L*3000L)
479 :
480 0 : #define STEM_CALLBACK_CONTEXT_TYPE fd_snapwr_tile_t
481 0 : #define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_snapwr_tile_t)
482 :
483 : #define STEM_CALLBACK_SHOULD_SHUTDOWN should_shutdown
484 0 : #define STEM_CALLBACK_METRICS_WRITE metrics_write
485 0 : #define STEM_CALLBACK_RETURNABLE_FRAG returnable_frag
486 :
487 : #include "../../disco/stem/fd_stem.c"
488 :
489 : fd_topo_run_tile_t fd_tile_snapwr = {
490 : .name = NAME,
491 : .populate_allowed_fds = populate_allowed_fds,
492 : .populate_allowed_seccomp = populate_allowed_seccomp,
493 : .scratch_align = scratch_align,
494 : .scratch_footprint = scratch_footprint,
495 : .privileged_init = privileged_init,
496 : .unprivileged_init = unprivileged_init,
497 : .run = stem_run,
498 : };
499 :
500 : #undef NAME
|