MCPcopy Create free account
hub / github.com/F-Stack/f-stack / zil_parse

Function zil_parse

freebsd/contrib/openzfs/module/zfs/zil.c:341–431  ·  view source on GitHub ↗

* Parse the intent log, and call parse_func for each valid record within. */

Source from the content-addressed store, hash-verified

339 * Parse the intent log, and call parse_func for each valid record within.
340 */
341int
342zil_parse(zilog_t *zilog, zil_parse_blk_func_t *parse_blk_func,
343 zil_parse_lr_func_t *parse_lr_func, void *arg, uint64_t txg,
344 boolean_t decrypt)
345{
346 const zil_header_t *zh = zilog->zl_header;
347 boolean_t claimed = !!zh->zh_claim_txg;
348 uint64_t claim_blk_seq = claimed ? zh->zh_claim_blk_seq : UINT64_MAX;
349 uint64_t claim_lr_seq = claimed ? zh->zh_claim_lr_seq : UINT64_MAX;
350 uint64_t max_blk_seq = 0;
351 uint64_t max_lr_seq = 0;
352 uint64_t blk_count = 0;
353 uint64_t lr_count = 0;
354 blkptr_t blk, next_blk;
355 char *lrbuf, *lrp;
356 int error = 0;
357
358 bzero(&next_blk, sizeof (blkptr_t));
359
360 /*
361 * Old logs didn't record the maximum zh_claim_lr_seq.
362 */
363 if (!(zh->zh_flags & ZIL_CLAIM_LR_SEQ_VALID))
364 claim_lr_seq = UINT64_MAX;
365
366 /*
367 * Starting at the block pointed to by zh_log we read the log chain.
368 * For each block in the chain we strongly check that block to
369 * ensure its validity. We stop when an invalid block is found.
370 * For each block pointer in the chain we call parse_blk_func().
371 * For each record in each valid block we call parse_lr_func().
372 * If the log has been claimed, stop if we encounter a sequence
373 * number greater than the highest claimed sequence number.
374 */
375 lrbuf = zio_buf_alloc(SPA_OLD_MAXBLOCKSIZE);
376 zil_bp_tree_init(zilog);
377
378 for (blk = zh->zh_log; !BP_IS_HOLE(&blk); blk = next_blk) {
379 uint64_t blk_seq = blk.blk_cksum.zc_word[ZIL_ZC_SEQ];
380 int reclen;
381 char *end = NULL;
382
383 if (blk_seq > claim_blk_seq)
384 break;
385
386 error = parse_blk_func(zilog, &blk, arg, txg);
387 if (error != 0)
388 break;
389 ASSERT3U(max_blk_seq, <, blk_seq);
390 max_blk_seq = blk_seq;
391 blk_count++;
392
393 if (max_lr_seq == claim_lr_seq && max_blk_seq == claim_blk_seq)
394 break;
395
396 error = zil_read_log_block(zilog, decrypt, &blk, &next_blk,
397 lrbuf, &end);
398 if (error != 0)

Callers 7

traverse_zilFunction · 0.85
dsl_scan_zilFunction · 0.85
zil_destroy_syncFunction · 0.85
zil_claimFunction · 0.85
zil_check_log_chainFunction · 0.85
zil_replayFunction · 0.85
dump_intent_logFunction · 0.85

Calls 6

bzeroFunction · 0.85
zio_buf_allocFunction · 0.85
zil_bp_tree_initFunction · 0.85
zil_read_log_blockFunction · 0.85
zil_bp_tree_finiFunction · 0.85
zio_buf_freeFunction · 0.85

Tested by

no test coverage detected