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

Function l2arc_remove_vdev

freebsd/contrib/openzfs/module/zfs/arc.c:9612–9656  ·  view source on GitHub ↗

* Remove a vdev from the L2ARC. */

Source from the content-addressed store, hash-verified

9610 * Remove a vdev from the L2ARC.
9611 */
9612void
9613l2arc_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
9658void
9659l2arc_init(void)

Callers 2

spa_load_l2cacheFunction · 0.85
spa_l2cache_dropFunction · 0.85

Calls 13

l2arc_vdev_getFunction · 0.85
mutex_enterFunction · 0.85
cv_waitFunction · 0.85
mutex_exitFunction · 0.85
l2arc_evictFunction · 0.85
mutex_destroyFunction · 0.85
zfs_refcount_destroyFunction · 0.85
vmem_freeFunction · 0.85
list_removeFunction · 0.50
atomic_dec_64Function · 0.50
list_destroyFunction · 0.50
list_is_emptyFunction · 0.50

Tested by

no test coverage detected