Print this page
4101 metaslab_debug should allow for fine-grained control
4102 space_maps should store more information about themselves
4103 space map object blocksize should be increased
4104 ::spa_space no longer works
4105 removing a mirrored log device results in a leaked object
4106 asynchronously load metaslab
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Sebastien Roy <seb@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/spa.c
          +++ new/usr/src/uts/common/fs/zfs/spa.c
↓ open down ↓ 1219 lines elided ↑ open up ↑
1220 1220          /*
1221 1221           * Wait for any outstanding async I/O to complete.
1222 1222           */
1223 1223          if (spa->spa_async_zio_root != NULL) {
1224 1224                  (void) zio_wait(spa->spa_async_zio_root);
1225 1225                  spa->spa_async_zio_root = NULL;
1226 1226          }
1227 1227  
1228 1228          bpobj_close(&spa->spa_deferred_bpobj);
1229 1229  
     1230 +        spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
     1231 +
1230 1232          /*
     1233 +         * Close all vdevs.
     1234 +         */
     1235 +        if (spa->spa_root_vdev)
     1236 +                vdev_free(spa->spa_root_vdev);
     1237 +        ASSERT(spa->spa_root_vdev == NULL);
     1238 +
     1239 +        /*
1231 1240           * Close the dsl pool.
1232 1241           */
1233 1242          if (spa->spa_dsl_pool) {
1234 1243                  dsl_pool_close(spa->spa_dsl_pool);
1235 1244                  spa->spa_dsl_pool = NULL;
1236 1245                  spa->spa_meta_objset = NULL;
1237 1246          }
1238 1247  
1239 1248          ddt_unload(spa);
1240 1249  
1241      -        spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
1242 1250  
1243 1251          /*
1244 1252           * Drop and purge level 2 cache
1245 1253           */
1246 1254          spa_l2cache_drop(spa);
1247 1255  
1248      -        /*
1249      -         * Close all vdevs.
1250      -         */
1251      -        if (spa->spa_root_vdev)
1252      -                vdev_free(spa->spa_root_vdev);
1253      -        ASSERT(spa->spa_root_vdev == NULL);
1254      -
1255 1256          for (i = 0; i < spa->spa_spares.sav_count; i++)
1256 1257                  vdev_free(spa->spa_spares.sav_vdevs[i]);
1257 1258          if (spa->spa_spares.sav_vdevs) {
1258 1259                  kmem_free(spa->spa_spares.sav_vdevs,
1259 1260                      spa->spa_spares.sav_count * sizeof (void *));
1260 1261                  spa->spa_spares.sav_vdevs = NULL;
1261 1262          }
1262 1263          if (spa->spa_spares.sav_config) {
1263 1264                  nvlist_free(spa->spa_spares.sav_config);
1264 1265                  spa->spa_spares.sav_config = NULL;
↓ open down ↓ 3229 lines elided ↑ open up ↑
4494 4495          oldvdpath = spa_strdup(oldvd->vdev_path);
4495 4496          newvdpath = spa_strdup(newvd->vdev_path);
4496 4497          newvd_isspare = newvd->vdev_isspare;
4497 4498  
4498 4499          /*
4499 4500           * Mark newvd's DTL dirty in this txg.
4500 4501           */
4501 4502          vdev_dirty(tvd, VDD_DTL, newvd, txg);
4502 4503  
4503 4504          /*
4504      -         * Restart the resilver
     4505 +         * Schedule the resilver to restart in the future. We do this to
     4506 +         * ensure that dmu_sync-ed blocks have been stitched into the
     4507 +         * respective datasets.
4505 4508           */
4506 4509          dsl_resilver_restart(spa->spa_dsl_pool, dtl_max_txg);
4507 4510  
4508 4511          /*
4509 4512           * Commit the config
4510 4513           */
4511 4514          (void) spa_vdev_exit(spa, newrootvd, dtl_max_txg, 0);
4512 4515  
4513 4516          spa_history_log_internal(spa, "vdev attach", NULL,
4514 4517              "%s vdev=%s %s vdev=%s",
↓ open down ↓ 601 lines elided ↑ open up ↑
5116 5119          if (error)
5117 5120                  return (error);
5118 5121  
5119 5122          /*
5120 5123           * The evacuation succeeded.  Remove any remaining MOS metadata
5121 5124           * associated with this vdev, and wait for these changes to sync.
5122 5125           */
5123 5126          ASSERT0(vd->vdev_stat.vs_alloc);
5124 5127          txg = spa_vdev_config_enter(spa);
5125 5128          vd->vdev_removing = B_TRUE;
5126      -        vdev_dirty(vd, 0, NULL, txg);
     5129 +        vdev_dirty_leaves(vd, VDD_DTL, txg);
5127 5130          vdev_config_dirty(vd);
5128 5131          spa_vdev_config_exit(spa, NULL, txg, 0, FTAG);
5129 5132  
5130 5133          return (0);
5131 5134  }
5132 5135  
5133 5136  /*
5134 5137   * Complete the removal by cleaning up the namespace.
5135 5138   */
5136 5139  static void
↓ open down ↓ 779 lines elided ↑ open up ↑
5916 5919                  zfeature_info_t *feature;
5917 5920  
5918 5921                  switch (prop = zpool_name_to_prop(nvpair_name(elem))) {
5919 5922                  case ZPROP_INVAL:
5920 5923                          /*
5921 5924                           * We checked this earlier in spa_prop_validate().
5922 5925                           */
5923 5926                          ASSERT(zpool_prop_feature(nvpair_name(elem)));
5924 5927  
5925 5928                          fname = strchr(nvpair_name(elem), '@') + 1;
5926      -                        VERIFY3U(0, ==, zfeature_lookup_name(fname, &feature));
     5929 +                        VERIFY0(zfeature_lookup_name(fname, &feature));
5927 5930  
5928 5931                          spa_feature_enable(spa, feature, tx);
5929 5932                          spa_history_log_internal(spa, "set", tx,
5930 5933                              "%s=enabled", nvpair_name(elem));
5931 5934                          break;
5932 5935  
5933 5936                  case ZPOOL_PROP_VERSION:
5934      -                        VERIFY(nvpair_value_uint64(elem, &intval) == 0);
     5937 +                        intval = fnvpair_value_uint64(elem);
5935 5938                          /*
5936 5939                           * The version is synced seperatly before other
5937 5940                           * properties and should be correct by now.
5938 5941                           */
5939 5942                          ASSERT3U(spa_version(spa), >=, intval);
5940 5943                          break;
5941 5944  
5942 5945                  case ZPOOL_PROP_ALTROOT:
5943 5946                          /*
5944 5947                           * 'altroot' is a non-persistent property. It should
↓ open down ↓ 3 lines elided ↑ open up ↑
5948 5951                          break;
5949 5952  
5950 5953                  case ZPOOL_PROP_READONLY:
5951 5954                  case ZPOOL_PROP_CACHEFILE:
5952 5955                          /*
5953 5956                           * 'readonly' and 'cachefile' are also non-persisitent
5954 5957                           * properties.
5955 5958                           */
5956 5959                          break;
5957 5960                  case ZPOOL_PROP_COMMENT:
5958      -                        VERIFY(nvpair_value_string(elem, &strval) == 0);
     5961 +                        strval = fnvpair_value_string(elem);
5959 5962                          if (spa->spa_comment != NULL)
5960 5963                                  spa_strfree(spa->spa_comment);
5961 5964                          spa->spa_comment = spa_strdup(strval);
5962 5965                          /*
5963 5966                           * We need to dirty the configuration on all the vdevs
5964 5967                           * so that their labels get updated.  It's unnecessary
5965 5968                           * to do this for pool creation since the vdev's
5966 5969                           * configuratoin has already been dirtied.
5967 5970                           */
5968 5971                          if (tx->tx_txg != TXG_INITIAL)
↓ open down ↓ 11 lines elided ↑ open up ↑
5980 5983                                      DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_PROPS,
5981 5984                                      tx);
5982 5985                          }
5983 5986  
5984 5987                          /* normalize the property name */
5985 5988                          propname = zpool_prop_to_name(prop);
5986 5989                          proptype = zpool_prop_get_type(prop);
5987 5990  
5988 5991                          if (nvpair_type(elem) == DATA_TYPE_STRING) {
5989 5992                                  ASSERT(proptype == PROP_TYPE_STRING);
5990      -                                VERIFY(nvpair_value_string(elem, &strval) == 0);
5991      -                                VERIFY(zap_update(mos,
     5993 +                                strval = fnvpair_value_string(elem);
     5994 +                                VERIFY0(zap_update(mos,
5992 5995                                      spa->spa_pool_props_object, propname,
5993      -                                    1, strlen(strval) + 1, strval, tx) == 0);
     5996 +                                    1, strlen(strval) + 1, strval, tx));
5994 5997                                  spa_history_log_internal(spa, "set", tx,
5995 5998                                      "%s=%s", nvpair_name(elem), strval);
5996 5999                          } else if (nvpair_type(elem) == DATA_TYPE_UINT64) {
5997      -                                VERIFY(nvpair_value_uint64(elem, &intval) == 0);
     6000 +                                intval = fnvpair_value_uint64(elem);
5998 6001  
5999 6002                                  if (proptype == PROP_TYPE_INDEX) {
6000 6003                                          const char *unused;
6001      -                                        VERIFY(zpool_prop_index_to_string(
6002      -                                            prop, intval, &unused) == 0);
     6004 +                                        VERIFY0(zpool_prop_index_to_string(
     6005 +                                            prop, intval, &unused));
6003 6006                                  }
6004      -                                VERIFY(zap_update(mos,
     6007 +                                VERIFY0(zap_update(mos,
6005 6008                                      spa->spa_pool_props_object, propname,
6006      -                                    8, 1, &intval, tx) == 0);
     6009 +                                    8, 1, &intval, tx));
6007 6010                                  spa_history_log_internal(spa, "set", tx,
6008 6011                                      "%s=%lld", nvpair_name(elem), intval);
6009 6012                          } else {
6010 6013                                  ASSERT(0); /* not allowed */
6011 6014                          }
6012 6015  
6013 6016                          switch (prop) {
6014 6017                          case ZPOOL_PROP_DELEGATION:
6015 6018                                  spa->spa_delegation = intval;
6016 6019                                  break;
↓ open down ↓ 506 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX