From: George Wilson Date: Fri, 5 Jul 2013 19:14:17 +0000 (-0400) Subject: Illumos #3639 zpool.cache should skip over readonly pools X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=zfs.git;a=commitdiff_plain;h=c61f97f426b7e0bc106b7e6795d4ea2ecbd2384d Illumos #3639 zpool.cache should skip over readonly pools 3639 zpool.cache should skip over readonly pools Reviewed by: Eric Schrock Reviewed by: Adam Leventhal Reviewed by: Basil Crow Approved by: Gordon Ross References: illumos/illumos-gate@fb02ae025247e3b662600e5a9c1b4c33ecab7d72 https://www.illumos.org/issues/3639 Normally we don't list pools that are imported read-only in the cache file, however you can accidentally get one into the cache file by importing and exporting a read-write pool while a read-only pool is imported: $ zpool import -o readonly test1 $ zpool import test2 $ zpool export test2 $ zdb -C This is a problem because if the machine reboots we import all pools in the cache file as read-write. Ported-by: Richard Yao Signed-off-by: Brian Behlendorf --- diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index 849ae46..5e5b405 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -225,7 +225,15 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent) */ nvl = NULL; while ((spa = spa_next(spa)) != NULL) { - if (spa == target && removing) + /* + * Skip over our own pool if we're about to remove + * ourselves from the spa namespace or any pool that + * is readonly. Since we cannot guarantee that a + * readonly pool would successfully import upon reboot, + * we don't allow them to be written to the cache file. + */ + if ((spa == target && removing) || + !spa_writeable(spa)) continue; mutex_enter(&spa->spa_props_lock);