* This function will traverse the queue of itxs that need to be * committed, and move them onto the ZIL's zl_itx_commit_list. */
| 2054 | * committed, and move them onto the ZIL's zl_itx_commit_list. |
| 2055 | */ |
| 2056 | static void |
| 2057 | zil_get_commit_list(zilog_t *zilog) |
| 2058 | { |
| 2059 | uint64_t otxg, txg; |
| 2060 | list_t *commit_list = &zilog->zl_itx_commit_list; |
| 2061 | |
| 2062 | ASSERT(MUTEX_HELD(&zilog->zl_issuer_lock)); |
| 2063 | |
| 2064 | if (spa_freeze_txg(zilog->zl_spa) != UINT64_MAX) /* ziltest support */ |
| 2065 | otxg = ZILTEST_TXG; |
| 2066 | else |
| 2067 | otxg = spa_last_synced_txg(zilog->zl_spa) + 1; |
| 2068 | |
| 2069 | /* |
| 2070 | * This is inherently racy, since there is nothing to prevent |
| 2071 | * the last synced txg from changing. That's okay since we'll |
| 2072 | * only commit things in the future. |
| 2073 | */ |
| 2074 | for (txg = otxg; txg < (otxg + TXG_CONCURRENT_STATES); txg++) { |
| 2075 | itxg_t *itxg = &zilog->zl_itxg[txg & TXG_MASK]; |
| 2076 | |
| 2077 | mutex_enter(&itxg->itxg_lock); |
| 2078 | if (itxg->itxg_txg != txg) { |
| 2079 | mutex_exit(&itxg->itxg_lock); |
| 2080 | continue; |
| 2081 | } |
| 2082 | |
| 2083 | /* |
| 2084 | * If we're adding itx records to the zl_itx_commit_list, |
| 2085 | * then the zil better be dirty in this "txg". We can assert |
| 2086 | * that here since we're holding the itxg_lock which will |
| 2087 | * prevent spa_sync from cleaning it. Once we add the itxs |
| 2088 | * to the zl_itx_commit_list we must commit it to disk even |
| 2089 | * if it's unnecessary (i.e. the txg was synced). |
| 2090 | */ |
| 2091 | ASSERT(zilog_is_dirty_in_txg(zilog, txg) || |
| 2092 | spa_freeze_txg(zilog->zl_spa) != UINT64_MAX); |
| 2093 | list_move_tail(commit_list, &itxg->itxg_itxs->i_sync_list); |
| 2094 | |
| 2095 | mutex_exit(&itxg->itxg_lock); |
| 2096 | } |
| 2097 | } |
| 2098 | |
| 2099 | /* |
| 2100 | * Move the async itxs for a specified object to commit into sync lists. |
no test coverage detected