Skip to content

Commit

Permalink
Illumos #3639 zpool.cache should skip over readonly pools
Browse files Browse the repository at this point in the history
3639 zpool.cache should skip over readonly pools
Reviewed by: Eric Schrock <[email protected]>
Reviewed by: Adam Leventhal <[email protected]>
Reviewed by: Basil Crow <[email protected]>
Approved by: Gordon Ross <[email protected]>

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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
grwilson authored and behlendorf committed Aug 7, 2013
1 parent 78d7a5d commit c61f97f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion module/zfs/spa_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c61f97f

Please sign in to comment.