X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=module%2Fzfs%2Fspa_config.c;h=5e5b4052620d1e69b6beedd9606e5842efc30387;hb=refs%2Fheads%2Frertzinger%2Ffeature-zpool-get--p;hp=09149e622661ff74d45f5420a70526c90ce2de29;hpb=9ae529ec5dbdc828ff8326beae58062971d74b2e;p=zfs.git diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index 09149e6..5e5b405 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -65,6 +65,7 @@ static uint64_t spa_config_generation = 1; * userland pools when doing testing. */ char *spa_config_path = ZPOOL_CACHE; +int zfs_autoimport_disable = 0; /* * Called when the module is first loaded, this routine loads the configuration @@ -81,6 +82,9 @@ spa_config_load(void) struct _buf *file; uint64_t fsize; + if (zfs_autoimport_disable) + return; + /* * Open the configuration file. */ @@ -221,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); @@ -508,4 +520,8 @@ EXPORT_SYMBOL(spa_config_update); module_param(spa_config_path, charp, 0444); MODULE_PARM_DESC(spa_config_path, "SPA config file (/etc/zfs/zpool.cache)"); + +module_param(zfs_autoimport_disable, int, 0644); +MODULE_PARM_DESC(zfs_autoimport_disable, "Disable pool import at module load"); + #endif