Print this page
zpool import speedup
@@ -456,28 +456,29 @@
* Returns NULL if no matching spa_t is found.
*/
spa_t *
spa_lookup(const char *name)
{
- static spa_t search; /* spa_t is large; don't allocate on stack */
+ spa_t *search;
spa_t *spa;
avl_index_t where;
char *cp;
- ASSERT(MUTEX_HELD(&spa_namespace_lock));
+ search = kmem_alloc(sizeof(*search), KM_SLEEP);
- (void) strlcpy(search.spa_name, name, sizeof (search.spa_name));
+ (void) strlcpy(search->spa_name, name, sizeof (search->spa_name));
/*
* If it's a full dataset name, figure out the pool name and
* just use that.
*/
- cp = strpbrk(search.spa_name, "/@#");
+ cp = strpbrk(search->spa_name, "/@#");
if (cp != NULL)
*cp = '\0';
- spa = avl_find(&spa_namespace_avl, &search, &where);
+ spa = avl_find(&spa_namespace_avl, search, &where);
+ kmem_free(search, sizeof(*search));
return (spa);
}
/*