* Remove a vdev from the L2ARC. */
| 9610 | * Remove a vdev from the L2ARC. |
| 9611 | */ |
| 9612 | void |
| 9613 | l2arc_remove_vdev(vdev_t *vd) |
| 9614 | { |
| 9615 | l2arc_dev_t *remdev = NULL; |
| 9616 | |
| 9617 | /* |
| 9618 | * Find the device by vdev |
| 9619 | */ |
| 9620 | remdev = l2arc_vdev_get(vd); |
| 9621 | ASSERT3P(remdev, !=, NULL); |
| 9622 | |
| 9623 | /* |
| 9624 | * Cancel any ongoing or scheduled rebuild. |
| 9625 | */ |
| 9626 | mutex_enter(&l2arc_rebuild_thr_lock); |
| 9627 | if (remdev->l2ad_rebuild_began == B_TRUE) { |
| 9628 | remdev->l2ad_rebuild_cancel = B_TRUE; |
| 9629 | while (remdev->l2ad_rebuild == B_TRUE) |
| 9630 | cv_wait(&l2arc_rebuild_thr_cv, &l2arc_rebuild_thr_lock); |
| 9631 | } |
| 9632 | mutex_exit(&l2arc_rebuild_thr_lock); |
| 9633 | |
| 9634 | /* |
| 9635 | * Remove device from global list |
| 9636 | */ |
| 9637 | mutex_enter(&l2arc_dev_mtx); |
| 9638 | list_remove(l2arc_dev_list, remdev); |
| 9639 | l2arc_dev_last = NULL; /* may have been invalidated */ |
| 9640 | atomic_dec_64(&l2arc_ndev); |
| 9641 | mutex_exit(&l2arc_dev_mtx); |
| 9642 | |
| 9643 | /* |
| 9644 | * Clear all buflists and ARC references. L2ARC device flush. |
| 9645 | */ |
| 9646 | l2arc_evict(remdev, 0, B_TRUE); |
| 9647 | list_destroy(&remdev->l2ad_buflist); |
| 9648 | ASSERT(list_is_empty(&remdev->l2ad_lbptr_list)); |
| 9649 | list_destroy(&remdev->l2ad_lbptr_list); |
| 9650 | mutex_destroy(&remdev->l2ad_mtx); |
| 9651 | zfs_refcount_destroy(&remdev->l2ad_alloc); |
| 9652 | zfs_refcount_destroy(&remdev->l2ad_lb_asize); |
| 9653 | zfs_refcount_destroy(&remdev->l2ad_lb_count); |
| 9654 | kmem_free(remdev->l2ad_dev_hdr, remdev->l2ad_dev_hdr_asize); |
| 9655 | vmem_free(remdev, sizeof (l2arc_dev_t)); |
| 9656 | } |
| 9657 | |
| 9658 | void |
| 9659 | l2arc_init(void) |
no test coverage detected