Mercurial > illumos > illumos-gate
changeset 7897:e520d8258820
6748436 inconsistent zpool.cache in boot_archive could panic a zfs root filesystem upon boot-up
author | Lin Ling <Lin.Ling@Sun.COM> |
---|---|
date | Tue, 21 Oct 2008 12:14:32 -0700 |
parents | 53b9fab3b62c |
children | aabf3b67d20c |
files | usr/src/uts/common/fs/zfs/spa.c |
diffstat | 1 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/spa.c Tue Oct 21 12:04:35 2008 -0700 +++ b/usr/src/uts/common/fs/zfs/spa.c Tue Oct 21 12:14:32 2008 -0700 @@ -2100,9 +2100,19 @@ * If a pool with this name exists, return failure. */ mutex_enter(&spa_namespace_lock); - if (spa_lookup(pool) != NULL) { - mutex_exit(&spa_namespace_lock); - return (EEXIST); + if ((spa = spa_lookup(pool)) != NULL) { + if (isroot) { + /* + * Remove the existing root pool from the + * namespace so that we can replace it with + * the correct config we just read in. + */ + ASSERT(spa->spa_state == POOL_STATE_UNINITIALIZED); + spa_remove(spa); + } else { + mutex_exit(&spa_namespace_lock); + return (EEXIST); + } } /* @@ -2421,8 +2431,7 @@ * pool open, not import. */ error = spa_import_common(pname, conf, NULL, B_TRUE, B_TRUE); - if (error == EEXIST) - error = 0; + ASSERT(error != EEXIST); nvlist_free(conf); return (error);