Deleted Added
full compact
spa.c (307113) spa.c (307277)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 1318 unchanged lines hidden (view full) ---

1327 if (spa->spa_dsl_pool) {
1328 dsl_pool_close(spa->spa_dsl_pool);
1329 spa->spa_dsl_pool = NULL;
1330 spa->spa_meta_objset = NULL;
1331 }
1332
1333 ddt_unload(spa);
1334
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 1318 unchanged lines hidden (view full) ---

1327 if (spa->spa_dsl_pool) {
1328 dsl_pool_close(spa->spa_dsl_pool);
1329 spa->spa_dsl_pool = NULL;
1330 spa->spa_meta_objset = NULL;
1331 }
1332
1333 ddt_unload(spa);
1334
1335
1336 /*
1337 * Drop and purge level 2 cache
1338 */
1339 spa_l2cache_drop(spa);
1340
1341 for (i = 0; i < spa->spa_spares.sav_count; i++)
1342 vdev_free(spa->spa_spares.sav_vdevs[i]);
1343 if (spa->spa_spares.sav_vdevs) {

--- 2371 unchanged lines hidden (view full) ---

3715 version = SPA_VERSION;
3716 }
3717 ASSERT(SPA_VERSION_IS_SUPPORTED(version));
3718
3719 spa->spa_first_txg = txg;
3720 spa->spa_uberblock.ub_txg = txg - 1;
3721 spa->spa_uberblock.ub_version = version;
3722 spa->spa_ubsync = spa->spa_uberblock;
1335 /*
1336 * Drop and purge level 2 cache
1337 */
1338 spa_l2cache_drop(spa);
1339
1340 for (i = 0; i < spa->spa_spares.sav_count; i++)
1341 vdev_free(spa->spa_spares.sav_vdevs[i]);
1342 if (spa->spa_spares.sav_vdevs) {

--- 2371 unchanged lines hidden (view full) ---

3714 version = SPA_VERSION;
3715 }
3716 ASSERT(SPA_VERSION_IS_SUPPORTED(version));
3717
3718 spa->spa_first_txg = txg;
3719 spa->spa_uberblock.ub_txg = txg - 1;
3720 spa->spa_uberblock.ub_version = version;
3721 spa->spa_ubsync = spa->spa_uberblock;
3722 spa->spa_load_state = SPA_LOAD_CREATE;
3723
3724 /*
3725 * Create "The Godfather" zio to hold all async IOs
3726 */
3727 spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),
3728 KM_SLEEP);
3729 for (int i = 0; i < max_ncpus; i++) {
3730 spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,

--- 169 unchanged lines hidden (view full) ---

3900 spa_history_log_version(spa, "create");
3901
3902 /*
3903 * Don't count references from objsets that are already closed
3904 * and are making their way through the eviction process.
3905 */
3906 spa_evicting_os_wait(spa);
3907 spa->spa_minref = refcount_count(&spa->spa_refcount);
3723
3724 /*
3725 * Create "The Godfather" zio to hold all async IOs
3726 */
3727 spa->spa_async_zio_root = kmem_alloc(max_ncpus * sizeof (void *),
3728 KM_SLEEP);
3729 for (int i = 0; i < max_ncpus; i++) {
3730 spa->spa_async_zio_root[i] = zio_root(spa, NULL, NULL,

--- 169 unchanged lines hidden (view full) ---

3900 spa_history_log_version(spa, "create");
3901
3902 /*
3903 * Don't count references from objsets that are already closed
3904 * and are making their way through the eviction process.
3905 */
3906 spa_evicting_os_wait(spa);
3907 spa->spa_minref = refcount_count(&spa->spa_refcount);
3908 spa->spa_load_state = SPA_LOAD_NONE;
3908
3909 mutex_exit(&spa_namespace_lock);
3910
3911 return (0);
3912}
3913
3914#ifdef _KERNEL
3915#ifdef illumos

--- 1694 unchanged lines hidden (view full) ---

5610 return (nvpp[i]);
5611 }
5612
5613 return (NULL);
5614}
5615
5616static void
5617spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count,
3909
3910 mutex_exit(&spa_namespace_lock);
3911
3912 return (0);
3913}
3914
3915#ifdef _KERNEL
3916#ifdef illumos

--- 1694 unchanged lines hidden (view full) ---

5611 return (nvpp[i]);
5612 }
5613
5614 return (NULL);
5615}
5616
5617static void
5618spa_vdev_remove_aux(nvlist_t *config, char *name, nvlist_t **dev, int count,
5618 nvlist_t *dev_to_remove)
5619 nvlist_t *dev_to_remove)
5619{
5620 nvlist_t **newdev = NULL;
5621
5622 if (count > 1)
5623 newdev = kmem_alloc((count - 1) * sizeof (void *), KM_SLEEP);
5624
5625 for (int i = 0, j = 0; i < count; i++) {
5626 if (dev[i] == dev_to_remove)

--- 1198 unchanged lines hidden (view full) ---

6825{
6826 dsl_pool_t *dp = spa->spa_dsl_pool;
6827 objset_t *mos = spa->spa_meta_objset;
6828 bplist_t *free_bpl = &spa->spa_free_bplist[txg & TXG_MASK];
6829 vdev_t *rvd = spa->spa_root_vdev;
6830 vdev_t *vd;
6831 dmu_tx_t *tx;
6832 int error;
5620{
5621 nvlist_t **newdev = NULL;
5622
5623 if (count > 1)
5624 newdev = kmem_alloc((count - 1) * sizeof (void *), KM_SLEEP);
5625
5626 for (int i = 0, j = 0; i < count; i++) {
5627 if (dev[i] == dev_to_remove)

--- 1198 unchanged lines hidden (view full) ---

6826{
6827 dsl_pool_t *dp = spa->spa_dsl_pool;
6828 objset_t *mos = spa->spa_meta_objset;
6829 bplist_t *free_bpl = &spa->spa_free_bplist[txg & TXG_MASK];
6830 vdev_t *rvd = spa->spa_root_vdev;
6831 vdev_t *vd;
6832 dmu_tx_t *tx;
6833 int error;
6834 uint32_t max_queue_depth = zfs_vdev_async_write_max_active *
6835 zfs_vdev_queue_depth_pct / 100;
6833
6834 VERIFY(spa_writeable(spa));
6835
6836 /*
6837 * Lock out configuration changes.
6838 */
6839 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
6840
6841 spa->spa_syncing_txg = txg;
6842 spa->spa_sync_pass = 0;
6843
6836
6837 VERIFY(spa_writeable(spa));
6838
6839 /*
6840 * Lock out configuration changes.
6841 */
6842 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
6843
6844 spa->spa_syncing_txg = txg;
6845 spa->spa_sync_pass = 0;
6846
6847 mutex_enter(&spa->spa_alloc_lock);
6848 VERIFY0(avl_numnodes(&spa->spa_alloc_tree));
6849 mutex_exit(&spa->spa_alloc_lock);
6850
6844 /*
6845 * If there are any pending vdev state changes, convert them
6846 * into config changes that go out with this transaction group.
6847 */
6848 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
6849 while (list_head(&spa->spa_state_dirty_list) != NULL) {
6850 /*
6851 * We need the write lock here because, for aux vdevs,

--- 43 unchanged lines hidden (view full) ---

6895 spa->spa_deflate = TRUE;
6896 VERIFY(0 == zap_add(spa->spa_meta_objset,
6897 DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_DEFLATE,
6898 sizeof (uint64_t), 1, &spa->spa_deflate, tx));
6899 }
6900 }
6901
6902 /*
6851 /*
6852 * If there are any pending vdev state changes, convert them
6853 * into config changes that go out with this transaction group.
6854 */
6855 spa_config_enter(spa, SCL_STATE, FTAG, RW_READER);
6856 while (list_head(&spa->spa_state_dirty_list) != NULL) {
6857 /*
6858 * We need the write lock here because, for aux vdevs,

--- 43 unchanged lines hidden (view full) ---

6902 spa->spa_deflate = TRUE;
6903 VERIFY(0 == zap_add(spa->spa_meta_objset,
6904 DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_DEFLATE,
6905 sizeof (uint64_t), 1, &spa->spa_deflate, tx));
6906 }
6907 }
6908
6909 /*
6910 * Set the top-level vdev's max queue depth. Evaluate each
6911 * top-level's async write queue depth in case it changed.
6912 * The max queue depth will not change in the middle of syncing
6913 * out this txg.
6914 */
6915 uint64_t queue_depth_total = 0;
6916 for (int c = 0; c < rvd->vdev_children; c++) {
6917 vdev_t *tvd = rvd->vdev_child[c];
6918 metaslab_group_t *mg = tvd->vdev_mg;
6919
6920 if (mg == NULL || mg->mg_class != spa_normal_class(spa) ||
6921 !metaslab_group_initialized(mg))
6922 continue;
6923
6924 /*
6925 * It is safe to do a lock-free check here because only async
6926 * allocations look at mg_max_alloc_queue_depth, and async
6927 * allocations all happen from spa_sync().
6928 */
6929 ASSERT0(refcount_count(&mg->mg_alloc_queue_depth));
6930 mg->mg_max_alloc_queue_depth = max_queue_depth;
6931 queue_depth_total += mg->mg_max_alloc_queue_depth;
6932 }
6933 metaslab_class_t *mc = spa_normal_class(spa);
6934 ASSERT0(refcount_count(&mc->mc_alloc_slots));
6935 mc->mc_alloc_max_slots = queue_depth_total;
6936 mc->mc_alloc_throttle_enabled = zio_dva_throttle_enabled;
6937
6938 ASSERT3U(mc->mc_alloc_max_slots, <=,
6939 max_queue_depth * rvd->vdev_children);
6940
6941 /*
6903 * Iterate to convergence.
6904 */
6905 do {
6906 int pass = ++spa->spa_sync_pass;
6907
6908 spa_sync_config_object(spa, tx);
6909 spa_sync_aux_dev(spa, &spa->spa_spares, tx,
6910 ZPOOL_CONFIG_SPARES, DMU_POOL_SPARES);

--- 140 unchanged lines hidden (view full) ---

7051 spa->spa_config_txg = txg;
7052 spa->spa_config_syncing = NULL;
7053 }
7054
7055 spa->spa_ubsync = spa->spa_uberblock;
7056
7057 dsl_pool_sync_done(dp, txg);
7058
6942 * Iterate to convergence.
6943 */
6944 do {
6945 int pass = ++spa->spa_sync_pass;
6946
6947 spa_sync_config_object(spa, tx);
6948 spa_sync_aux_dev(spa, &spa->spa_spares, tx,
6949 ZPOOL_CONFIG_SPARES, DMU_POOL_SPARES);

--- 140 unchanged lines hidden (view full) ---

7090 spa->spa_config_txg = txg;
7091 spa->spa_config_syncing = NULL;
7092 }
7093
7094 spa->spa_ubsync = spa->spa_uberblock;
7095
7096 dsl_pool_sync_done(dp, txg);
7097
7098 mutex_enter(&spa->spa_alloc_lock);
7099 VERIFY0(avl_numnodes(&spa->spa_alloc_tree));
7100 mutex_exit(&spa->spa_alloc_lock);
7101
7059 /*
7060 * Update usable space statistics.
7061 */
7062 while (vd = txg_list_remove(&spa->spa_vdev_txg_list, TXG_CLEAN(txg)))
7063 vdev_sync_done(vd, txg);
7064
7065 spa_update_dspace(spa);
7066

--- 247 unchanged lines hidden ---
7102 /*
7103 * Update usable space statistics.
7104 */
7105 while (vd = txg_list_remove(&spa->spa_vdev_txg_list, TXG_CLEAN(txg)))
7106 vdev_sync_done(vd, txg);
7107
7108 spa_update_dspace(spa);
7109

--- 247 unchanged lines hidden ---