FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
/*
 * Add a vdev for use by the L2ARC.  By this point the spa has already
 * validated the vdev and opened it.
 */
Add a vdev for use by the L2ARC.  By this point the spa has already
validated the vdev and opened it.
Add a vdev for use by the L2ARC . By this point the spa has already validated the vdev and opened it .
void
l2arc_add_vdev(spa_t *spa, vdev_t *vd)
{
	l2arc_dev_t *adddev;
	ASSERT(!l2arc_vdev_present(vd));
	vdev_ashift_optimize(vd);
	adddev = kmem_zalloc(sizeof (l2arc_dev_t), KM_SLEEP);
	adddev->l2ad_spa = spa;
	adddev->l2ad_vdev = vd;
	adddev->l2ad_start = VDEV_LABEL_START_SIZE;
	adddev->l2ad_end = VDEV_LABEL_START_SIZE + vdev_get_min_asize(vd);
	adddev->l2ad_hand = adddev->l2ad_start;
	adddev->l2ad_first = B_TRUE;
	adddev->l2ad_writing = B_FALSE;
	mutex_init(&adddev->l2ad_mtx, NULL, MUTEX_DEFAULT, NULL);
	list_create(&adddev->l2ad_buflist, sizeof (arc_buf_hdr_t),
	    offsetof(arc_buf_hdr_t, b_l2hdr.b_l2node));
	vdev_space_update(vd, 0, 0, adddev->l2ad_end - adddev->l2ad_hand);
	refcount_create(&adddev->l2ad_alloc);
	mutex_enter(&l2arc_dev_mtx);
	list_insert_head(l2arc_dev_list, adddev);
	atomic_inc_64(&l2arc_ndev);
	mutex_exit(&l2arc_dev_mtx);
}
void l2arc_add_vdev ( spa_t * spa , vdev_t * vd ) { l2arc_dev_t * adddev ; ASSERT ( ! l2arc_vdev_present ( vd ) ) ; vdev_ashift_optimize ( vd ) ; adddev = kmem_zalloc ( sizeof ( l2arc_dev_t ) , KM_SLEEP ) ; adddev -> l2ad_spa = spa ; adddev -> l2ad_vdev = vd ; adddev -> l2ad_start = VDEV_LABEL_START_SIZE ; adddev -> l2ad_end = VDEV_LABEL_START_SIZE + vdev_get_min_asize ( vd ) ; adddev -> l2ad_hand = adddev -> l2ad_start ; adddev -> l2ad_first = B_TRUE ; adddev -> l2ad_writing = B_FALSE ; mutex_init ( & adddev -> l2ad_mtx , NULL , MUTEX_DEFAULT , NULL ) ; list_create ( & adddev -> l2ad_buflist , sizeof ( arc_buf_hdr_t ) , offsetof ( arc_buf_hdr_t , b_l2hdr . b_l2node ) ) ; vdev_space_update ( vd , 0 , 0 , adddev -> l2ad_end - adddev -> l2ad_hand ) ; refcount_create ( & adddev -> l2ad_alloc ) ; mutex_enter ( & l2arc_dev_mtx ) ; list_insert_head ( l2arc_dev_list , adddev ) ; atomic_inc_64 ( & l2arc_ndev ) ; mutex_exit ( & l2arc_dev_mtx ) ; }
Add a vdev for use by the L2ARC.
Add a vdev for use by the L2ARC .
/*
	 * Create a new l2arc device entry.
	 */ /*
	 * This is a list of all ARC buffers that are still valid on the
	 * device.
	 */ /*
	 * Add device to global list
	 */