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

Function zil_destroy

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

* In one tx, free all log blocks and clear the log header. If keep_first * is set, then we're replaying a log with no content. We want to keep the * first block, however, so that the first synchronous transaction doesn't * require a txg_wait_synced() in zil_create(). We don't need to * txg_wait_synced() here either when keep_first is set, because both * zil_create() and zil_destroy() will wai

Source from the content-addressed store, hash-verified

741 * to complete.
742 */
743void
744zil_destroy(zilog_t *zilog, boolean_t keep_first)
745{
746 const zil_header_t *zh = zilog->zl_header;
747 lwb_t *lwb;
748 dmu_tx_t *tx;
749 uint64_t txg;
750
751 /*
752 * Wait for any previous destroy to complete.
753 */
754 txg_wait_synced(zilog->zl_dmu_pool, zilog->zl_destroy_txg);
755
756 zilog->zl_old_header = *zh; /* debugging aid */
757
758 if (BP_IS_HOLE(&zh->zh_log))
759 return;
760
761 tx = dmu_tx_create(zilog->zl_os);
762 VERIFY0(dmu_tx_assign(tx, TXG_WAIT));
763 dsl_dataset_dirty(dmu_objset_ds(zilog->zl_os), tx);
764 txg = dmu_tx_get_txg(tx);
765
766 mutex_enter(&zilog->zl_lock);
767
768 ASSERT3U(zilog->zl_destroy_txg, <, txg);
769 zilog->zl_destroy_txg = txg;
770 zilog->zl_keep_first = keep_first;
771
772 if (!list_is_empty(&zilog->zl_lwb_list)) {
773 ASSERT(zh->zh_claim_txg == 0);
774 VERIFY(!keep_first);
775 while ((lwb = list_head(&zilog->zl_lwb_list)) != NULL) {
776 if (lwb->lwb_fastwrite)
777 metaslab_fastwrite_unmark(zilog->zl_spa,
778 &lwb->lwb_blk);
779
780 list_remove(&zilog->zl_lwb_list, lwb);
781 if (lwb->lwb_buf != NULL)
782 zio_buf_free(lwb->lwb_buf, lwb->lwb_sz);
783 zio_free(zilog->zl_spa, txg, &lwb->lwb_blk);
784 zil_free_lwb(zilog, lwb);
785 }
786 } else if (!keep_first) {
787 zil_destroy_sync(zilog, tx);
788 }
789 mutex_exit(&zilog->zl_lock);
790
791 dmu_tx_commit(tx);
792}
793
794void
795zil_destroy_sync(zilog_t *zilog, dmu_tx_t *tx)

Callers 6

zfsvfs_setupFunction · 0.85
zvol_create_minor_implFunction · 0.85
zfsvfs_setupFunction · 0.85
zvol_os_create_minorFunction · 0.85
zil_suspendFunction · 0.85
zil_replayFunction · 0.85

Calls 15

txg_wait_syncedFunction · 0.85
dmu_tx_createFunction · 0.85
dmu_tx_assignFunction · 0.85
dsl_dataset_dirtyFunction · 0.85
dmu_objset_dsFunction · 0.85
dmu_tx_get_txgFunction · 0.85
mutex_enterFunction · 0.85
zio_buf_freeFunction · 0.85
zio_freeFunction · 0.85
zil_free_lwbFunction · 0.85
zil_destroy_syncFunction · 0.85

Tested by

no test coverage detected