| 7704 | } |
| 7705 | |
| 7706 | void |
| 7707 | arc_fini(void) |
| 7708 | { |
| 7709 | arc_prune_t *p; |
| 7710 | |
| 7711 | #ifdef _KERNEL |
| 7712 | arc_lowmem_fini(); |
| 7713 | #endif /* _KERNEL */ |
| 7714 | |
| 7715 | /* Use B_TRUE to ensure *all* buffers are evicted */ |
| 7716 | arc_flush(NULL, B_TRUE); |
| 7717 | |
| 7718 | if (arc_ksp != NULL) { |
| 7719 | kstat_delete(arc_ksp); |
| 7720 | arc_ksp = NULL; |
| 7721 | } |
| 7722 | |
| 7723 | taskq_wait(arc_prune_taskq); |
| 7724 | taskq_destroy(arc_prune_taskq); |
| 7725 | |
| 7726 | mutex_enter(&arc_prune_mtx); |
| 7727 | while ((p = list_head(&arc_prune_list)) != NULL) { |
| 7728 | list_remove(&arc_prune_list, p); |
| 7729 | zfs_refcount_remove(&p->p_refcnt, &arc_prune_list); |
| 7730 | zfs_refcount_destroy(&p->p_refcnt); |
| 7731 | kmem_free(p, sizeof (*p)); |
| 7732 | } |
| 7733 | mutex_exit(&arc_prune_mtx); |
| 7734 | |
| 7735 | list_destroy(&arc_prune_list); |
| 7736 | mutex_destroy(&arc_prune_mtx); |
| 7737 | |
| 7738 | (void) zthr_cancel(arc_evict_zthr); |
| 7739 | (void) zthr_cancel(arc_reap_zthr); |
| 7740 | |
| 7741 | mutex_destroy(&arc_evict_lock); |
| 7742 | list_destroy(&arc_evict_waiters); |
| 7743 | |
| 7744 | /* |
| 7745 | * Free any buffers that were tagged for destruction. This needs |
| 7746 | * to occur before arc_state_fini() runs and destroys the aggsum |
| 7747 | * values which are updated when freeing scatter ABDs. |
| 7748 | */ |
| 7749 | l2arc_do_free_on_write(); |
| 7750 | |
| 7751 | /* |
| 7752 | * buf_fini() must proceed arc_state_fini() because buf_fin() may |
| 7753 | * trigger the release of kmem magazines, which can callback to |
| 7754 | * arc_space_return() which accesses aggsums freed in act_state_fini(). |
| 7755 | */ |
| 7756 | buf_fini(); |
| 7757 | arc_state_fini(); |
| 7758 | |
| 7759 | arc_unregister_hotplug(); |
| 7760 | |
| 7761 | /* |
| 7762 | * We destroy the zthrs after all the ARC state has been |
| 7763 | * torn down to avoid the case of them receiving any |
no test coverage detected