Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
Show All 26 Lines | |||||
* Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. | * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved. | ||||
* Copyright 2013 Saso Kiselkov. All rights reserved. | * Copyright 2013 Saso Kiselkov. All rights reserved. | ||||
* Copyright (c) 2014 Integros [integros.com] | * Copyright (c) 2014 Integros [integros.com] | ||||
* Copyright 2016 Toomas Soome <tsoome@me.com> | * Copyright 2016 Toomas Soome <tsoome@me.com> | ||||
* Copyright 2018 Joyent, Inc. | * Copyright 2018 Joyent, Inc. | ||||
* Copyright (c) 2017, Intel Corporation. | * Copyright (c) 2017, Intel Corporation. | ||||
* Copyright (c) 2017 Datto Inc. | * Copyright (c) 2017 Datto Inc. | ||||
* Copyright 2018 OmniOS Community Edition (OmniOSce) Association. | * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. | ||||
* Copyright (c) 2016 Actifio, Inc. All rights reserved. | |||||
*/ | */ | ||||
/* | /* | ||||
* SPA: Storage Pool Allocator | * SPA: Storage Pool Allocator | ||||
* | * | ||||
* This file contains all the routines used when modifying on-disk SPA state. | * This file contains all the routines used when modifying on-disk SPA state. | ||||
* This includes opening, importing, destroying, exporting a pool, and syncing a | * This includes opening, importing, destroying, exporting a pool, and syncing a | ||||
* pool. | * pool. | ||||
▲ Show 20 Lines • Show All 1,232 Lines • ▼ Show 20 Lines | if (spa->spa_proc == &p0) { | ||||
spa_create_zio_taskqs(spa); | spa_create_zio_taskqs(spa); | ||||
} | } | ||||
/* | /* | ||||
* Start TRIM thread. | * Start TRIM thread. | ||||
*/ | */ | ||||
trim_thread_create(spa); | trim_thread_create(spa); | ||||
/* | |||||
* This taskq is used to perform zvol-minor-related tasks | |||||
* asynchronously. This has several advantages, including easy | |||||
* resolution of various deadlocks (zfsonlinux bug #3681). | |||||
* | |||||
* The taskq must be single threaded to ensure tasks are always | |||||
* processed in the order in which they were dispatched. | |||||
* | |||||
* A taskq per pool allows one to keep the pools independent. | |||||
* This way if one pool is suspended, it will not impact another. | |||||
* | |||||
* The preferred location to dispatch a zvol minor task is a sync | |||||
* task. In this context, there is easy access to the spa_t and minimal | |||||
* error handling is required because the sync task must succeed. | |||||
*/ | |||||
spa->spa_zvol_taskq = taskq_create("z_zvol", 1, minclsyspri, | |||||
1, INT_MAX, 0); | |||||
for (size_t i = 0; i < TXG_SIZE; i++) { | for (size_t i = 0; i < TXG_SIZE; i++) { | ||||
spa->spa_txg_zio[i] = zio_root(spa, NULL, NULL, | spa->spa_txg_zio[i] = zio_root(spa, NULL, NULL, | ||||
ZIO_FLAG_CANFAIL); | ZIO_FLAG_CANFAIL); | ||||
} | } | ||||
list_create(&spa->spa_config_dirty_list, sizeof (vdev_t), | list_create(&spa->spa_config_dirty_list, sizeof (vdev_t), | ||||
offsetof(vdev_t, vdev_config_dirty_node)); | offsetof(vdev_t, vdev_config_dirty_node)); | ||||
list_create(&spa->spa_evicting_os_list, sizeof (objset_t), | list_create(&spa->spa_evicting_os_list, sizeof (objset_t), | ||||
Show All 27 Lines | spa_deactivate(spa_t *spa) | ||||
/* | /* | ||||
* Stop TRIM thread in case spa_unload() wasn't called directly | * Stop TRIM thread in case spa_unload() wasn't called directly | ||||
* before spa_deactivate(). | * before spa_deactivate(). | ||||
*/ | */ | ||||
trim_thread_destroy(spa); | trim_thread_destroy(spa); | ||||
spa_evicting_os_wait(spa); | spa_evicting_os_wait(spa); | ||||
if (spa->spa_zvol_taskq) { | |||||
taskq_destroy(spa->spa_zvol_taskq); | |||||
spa->spa_zvol_taskq = NULL; | |||||
} | |||||
txg_list_destroy(&spa->spa_vdev_txg_list); | txg_list_destroy(&spa->spa_vdev_txg_list); | ||||
list_destroy(&spa->spa_config_dirty_list); | list_destroy(&spa->spa_config_dirty_list); | ||||
list_destroy(&spa->spa_evicting_os_list); | list_destroy(&spa->spa_evicting_os_list); | ||||
list_destroy(&spa->spa_state_dirty_list); | list_destroy(&spa->spa_state_dirty_list); | ||||
for (int t = 0; t < ZIO_TYPES; t++) { | for (int t = 0; t < ZIO_TYPES; t++) { | ||||
for (int q = 0; q < ZIO_TASKQ_TYPES; q++) { | for (int q = 0; q < ZIO_TASKQ_TYPES; q++) { | ||||
▲ Show 20 Lines • Show All 3,275 Lines • ▼ Show 20 Lines | spa_open_common(const char *pool, spa_t **spapp, void *tag, nvlist_t *nvpolicy, | ||||
if (locked) { | if (locked) { | ||||
spa->spa_last_open_failed = 0; | spa->spa_last_open_failed = 0; | ||||
spa->spa_last_ubsync_txg = 0; | spa->spa_last_ubsync_txg = 0; | ||||
spa->spa_load_txg = 0; | spa->spa_load_txg = 0; | ||||
mutex_exit(&spa_namespace_lock); | mutex_exit(&spa_namespace_lock); | ||||
#ifdef __FreeBSD__ | #ifdef __FreeBSD__ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
if (firstopen) | if (firstopen) | ||||
zvol_create_minors(spa->spa_name); | zvol_create_minors(spa, spa->spa_name); | ||||
#endif | #endif | ||||
#endif | #endif | ||||
} | } | ||||
*spapp = spa; | *spapp = spa; | ||||
return (0); | return (0); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,339 Lines • ▼ Show 20 Lines | spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags) | ||||
spa_history_log_version(spa, "import"); | spa_history_log_version(spa, "import"); | ||||
spa_event_notify(spa, NULL, NULL, ESC_ZFS_POOL_IMPORT); | spa_event_notify(spa, NULL, NULL, ESC_ZFS_POOL_IMPORT); | ||||
mutex_exit(&spa_namespace_lock); | mutex_exit(&spa_namespace_lock); | ||||
#ifdef __FreeBSD__ | #ifdef __FreeBSD__ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
zvol_create_minors(pool); | zvol_create_minors(spa, pool); | ||||
#endif | #endif | ||||
#endif | #endif | ||||
return (0); | return (0); | ||||
} | } | ||||
nvlist_t * | nvlist_t * | ||||
spa_tryimport(nvlist_t *tryconfig) | spa_tryimport(nvlist_t *tryconfig) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | spa_export_common(char *pool, int new_state, nvlist_t **oldconfig, | ||||
/* | /* | ||||
* Put a hold on the pool, drop the namespace lock, stop async tasks, | * Put a hold on the pool, drop the namespace lock, stop async tasks, | ||||
* reacquire the namespace lock, and see if we can export. | * reacquire the namespace lock, and see if we can export. | ||||
*/ | */ | ||||
spa_open_ref(spa, FTAG); | spa_open_ref(spa, FTAG); | ||||
mutex_exit(&spa_namespace_lock); | mutex_exit(&spa_namespace_lock); | ||||
spa_async_suspend(spa); | spa_async_suspend(spa); | ||||
if (spa->spa_zvol_taskq) { | |||||
zvol_remove_minors(spa, spa_name(spa)); | |||||
taskq_wait(spa->spa_zvol_taskq); | |||||
} | |||||
mutex_enter(&spa_namespace_lock); | mutex_enter(&spa_namespace_lock); | ||||
spa_close(spa, FTAG); | spa_close(spa, FTAG); | ||||
/* | /* | ||||
* The pool will be in core if it's openable, | * The pool will be in core if it's openable, | ||||
* in which case we can modify its state. | * in which case we can modify its state. | ||||
*/ | */ | ||||
if (spa->spa_state != POOL_STATE_UNINITIALIZED && spa->spa_sync_on) { | if (spa->spa_state != POOL_STATE_UNINITIALIZED && spa->spa_sync_on) { | ||||
▲ Show 20 Lines • Show All 2,810 Lines • Show Last 20 Lines |