diff options
Diffstat (limited to 'module/zfs/spa_misc.c')
-rw-r--r-- | module/zfs/spa_misc.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c index 36046e6df..485e83fce 100644 --- a/module/zfs/spa_misc.c +++ b/module/zfs/spa_misc.c @@ -230,7 +230,7 @@ static kmutex_t spa_l2cache_lock; static avl_tree_t spa_l2cache_avl; kmem_cache_t *spa_buffer_pool; -int spa_mode; +int spa_mode_global; #ifdef ZFS_DEBUG /* Everything except dprintf is on by default in debug builds */ @@ -880,8 +880,10 @@ spa_vdev_exit(spa_t *spa, vdev_t *vd, uint64_t txg, int error) txg_wait_synced(spa->spa_dsl_pool, txg); if (vd != NULL) { - ASSERT(!vd->vdev_detached || vd->vdev_dtl.smo_object == 0); + ASSERT(!vd->vdev_detached || vd->vdev_dtl_smo.smo_object == 0); + spa_config_enter(spa, SCL_ALL, spa, RW_WRITER); vdev_free(vd); + spa_config_exit(spa, SCL_ALL, spa); } /* @@ -912,6 +914,15 @@ spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error) spa_config_exit(spa, SCL_STATE_ALL, spa); + /* + * If anything changed, wait for it to sync. This ensures that, + * from the system administrator's perspective, zpool(1M) commands + * are synchronous. This is important for things like zpool offline: + * when the command completes, you expect no further I/O from ZFS. + */ + if (vd != NULL) + txg_wait_synced(spa->spa_dsl_pool, 0); + return (error); } @@ -1351,7 +1362,7 @@ spa_init(int mode) avl_create(&spa_l2cache_avl, spa_l2cache_compare, sizeof (spa_aux_t), offsetof(spa_aux_t, aux_avl)); - spa_mode = mode; + spa_mode_global = mode; refcount_init(); unique_init(); @@ -1408,3 +1419,15 @@ spa_is_root(spa_t *spa) { return (spa->spa_is_root); } + +boolean_t +spa_writeable(spa_t *spa) +{ + return (!!(spa->spa_mode & FWRITE)); +} + +int +spa_mode(spa_t *spa) +{ + return (spa->spa_mode); +} |