* 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
| 741 | * to complete. |
| 742 | */ |
| 743 | void |
| 744 | zil_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 | |
| 794 | void |
| 795 | zil_destroy_sync(zilog_t *zilog, dmu_tx_t *tx) |
no test coverage detected