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

Function zil_commit

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

* Commit ZFS Intent Log transactions (itxs) to stable storage. * * When writing ZIL transactions to the on-disk representation of the * ZIL, the itxs are committed to a Log Write Block (lwb). Multiple * itxs can be committed to a single lwb. Once a lwb is written and * committed to stable storage (i.e. the lwb is written, and vdevs have * been flushed), each itx that was committed to that lw

Source from the content-addressed store, hash-verified

2902 * which they were created.
2903 */
2904void
2905zil_commit(zilog_t *zilog, uint64_t foid)
2906{
2907 /*
2908 * We should never attempt to call zil_commit on a snapshot for
2909 * a couple of reasons:
2910 *
2911 * 1. A snapshot may never be modified, thus it cannot have any
2912 * in-flight itxs that would have modified the dataset.
2913 *
2914 * 2. By design, when zil_commit() is called, a commit itx will
2915 * be assigned to this zilog; as a result, the zilog will be
2916 * dirtied. We must not dirty the zilog of a snapshot; there's
2917 * checks in the code that enforce this invariant, and will
2918 * cause a panic if it's not upheld.
2919 */
2920 ASSERT3B(dmu_objset_is_snapshot(zilog->zl_os), ==, B_FALSE);
2921
2922 if (zilog->zl_sync == ZFS_SYNC_DISABLED)
2923 return;
2924
2925 if (!spa_writeable(zilog->zl_spa)) {
2926 /*
2927 * If the SPA is not writable, there should never be any
2928 * pending itxs waiting to be committed to disk. If that
2929 * weren't true, we'd skip writing those itxs out, and
2930 * would break the semantics of zil_commit(); thus, we're
2931 * verifying that truth before we return to the caller.
2932 */
2933 ASSERT(list_is_empty(&zilog->zl_lwb_list));
2934 ASSERT3P(zilog->zl_last_lwb_opened, ==, NULL);
2935 for (int i = 0; i < TXG_SIZE; i++)
2936 ASSERT3P(zilog->zl_itxg[i].itxg_itxs, ==, NULL);
2937 return;
2938 }
2939
2940 /*
2941 * If the ZIL is suspended, we don't want to dirty it by calling
2942 * zil_commit_itx_assign() below, nor can we write out
2943 * lwbs like would be done in zil_commit_write(). Thus, we
2944 * simply rely on txg_wait_synced() to maintain the necessary
2945 * semantics, and avoid calling those functions altogether.
2946 */
2947 if (zilog->zl_suspend > 0) {
2948 txg_wait_synced(zilog->zl_dmu_pool, 0);
2949 return;
2950 }
2951
2952 zil_commit_impl(zilog, foid);
2953}
2954
2955void
2956zil_commit_impl(zilog_t *zilog, uint64_t foid)

Callers 15

zfs_createFunction · 0.85
zfs_remove_Function · 0.85
zfs_mkdirFunction · 0.85
zfs_rmdir_Function · 0.85
zfs_setattrFunction · 0.85
zfs_rename_Function · 0.85
zfs_symlinkFunction · 0.85
zfs_linkFunction · 0.85
zfs_putpagesFunction · 0.85
zfs_syncFunction · 0.85
zvol_geom_bio_strategyFunction · 0.85
zvol_cdev_writeFunction · 0.85

Calls 5

dmu_objset_is_snapshotFunction · 0.85
spa_writeableFunction · 0.85
txg_wait_syncedFunction · 0.85
zil_commit_implFunction · 0.85
list_is_emptyFunction · 0.50

Tested by 2

ztest_zil_commitFunction · 0.68
ztest_freezeFunction · 0.68