Skip to content

Commit c61f97f

Browse files
grwilsonbehlendorf
authored andcommitted
Illumos #3639 zpool.cache should skip over readonly pools
3639 zpool.cache should skip over readonly pools Reviewed by: Eric Schrock <eric.schrock@delphix.com> Reviewed by: Adam Leventhal <ahl@delphix.com> Reviewed by: Basil Crow <basil.crow@delphix.com> Approved by: Gordon Ross <gwr@nexenta.com> References: illumos/illumos-gate@fb02ae0 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 <ryao@gentoo.org> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
1 parent 78d7a5d commit c61f97f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

module/zfs/spa_config.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,15 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent)
225225
*/
226226
nvl = NULL;
227227
while ((spa = spa_next(spa)) != NULL) {
228-
if (spa == target && removing)
228+
/*
229+
* Skip over our own pool if we're about to remove
230+
* ourselves from the spa namespace or any pool that
231+
* is readonly. Since we cannot guarantee that a
232+
* readonly pool would successfully import upon reboot,
233+
* we don't allow them to be written to the cache file.
234+
*/
235+
if ((spa == target && removing) ||
236+
!spa_writeable(spa))
229237
continue;
230238

231239
mutex_enter(&spa->spa_props_lock);

0 commit comments

Comments
 (0)