FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_misc.c
/*
 * Return the spa_t associated with given pool_guid, if it exists.  If
 * device_guid is non-zero, determine whether the pool exists *and* contains
 * a device with the specified device_guid.
 */
Return the spa_t associated with given pool_guid, if it exists.  If
device_guid is non-zero, determine whether the pool exists *and* contains
a device with the specified device_guid.
Return the spa_t associated with given pool_guid if it exists . If device_guid is non - zero determine whether the pool exists * and * contains a device with the specified device_guid .
spa_t *
spa_by_guid(uint64_t pool_guid, uint64_t device_guid)
{
	spa_t *spa;
	avl_tree_t *t = &spa_namespace_avl;
	ASSERT(MUTEX_HELD(&spa_namespace_lock));
	for (spa = avl_first(t); spa != NULL; spa = AVL_NEXT(t, spa)) {
		if (spa->spa_state == POOL_STATE_UNINITIALIZED)
			continue;
		if (spa->spa_root_vdev == NULL)
			continue;
		if (spa_guid(spa) == pool_guid) {
			if (device_guid == 0)
				break;
			if (vdev_lookup_by_guid(spa->spa_root_vdev,
			    device_guid) != NULL)
				break;
			if (spa->spa_pending_vdev) {
				if (vdev_lookup_by_guid(spa->spa_pending_vdev,
				    device_guid) != NULL)
					break;
			}
		}
	}
	return (spa);
}
spa_t * spa_by_guid ( uint64_t pool_guid , uint64_t device_guid ) { spa_t * spa ; avl_tree_t * t = & spa_namespace_avl ; ASSERT ( MUTEX_HELD ( & spa_namespace_lock ) ) ; for ( spa = avl_first ( t ) ; spa != NULL ; spa = AVL_NEXT ( t , spa ) ) { if ( spa -> spa_state == POOL_STATE_UNINITIALIZED ) continue ; if ( spa -> spa_root_vdev == NULL ) continue ; if ( spa_guid ( spa ) == pool_guid ) { if ( device_guid == 0 ) break ; if ( vdev_lookup_by_guid ( spa -> spa_root_vdev , device_guid ) != NULL ) break ; if ( spa -> spa_pending_vdev ) { if ( vdev_lookup_by_guid ( spa -> spa_pending_vdev , device_guid ) != NULL ) break ; } } } return ( spa ) ; }
Return the spa_t associated with given pool_guid, if it exists.
Return the spa_t associated with given pool_guid if it exists .
/*
			 * Check any devices we may be in the process of adding.
			 */