Print this page
2619 asynchronous destruction of ZFS file systems
2747 SPA versioning with zfs feature flags
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <gwilson@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Reviewed by: Dan Kruchinin <dan.kruchinin@gmail.com>
Approved by: Dan McDonald <danmcd@nexenta.com>


   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2011 by Delphix. All rights reserved.
  26  */
  27 
  28 #include <sys/spa.h>
  29 #include <sys/spa_impl.h>
  30 #include <sys/nvpair.h>
  31 #include <sys/uio.h>
  32 #include <sys/fs/zfs.h>
  33 #include <sys/vdev_impl.h>
  34 #include <sys/zfs_ioctl.h>
  35 #include <sys/utsname.h>
  36 #include <sys/systeminfo.h>
  37 #include <sys/sunddi.h>

  38 #ifdef _KERNEL
  39 #include <sys/kobj.h>
  40 #include <sys/zone.h>
  41 #endif
  42 
  43 /*
  44  * Pool configuration repository.
  45  *
  46  * Pool configuration is stored as a packed nvlist on the filesystem.  By
  47  * default, all pools are stored in /etc/zfs/zpool.cache and loaded on boot
  48  * (when the ZFS module is loaded).  Pools can also have the 'cachefile'
  49  * property set that allows them to be stored in an alternate location until
  50  * the control of external software.
  51  *
  52  * For each cache file, we have a single nvlist which holds all the
  53  * configuration information.  When the module loads, we read this information
  54  * from /etc/zfs/zpool.cache and populate the SPA namespace.  This namespace is
  55  * maintained independently in spa.c.  Whenever the namespace is modified, or
  56  * the configuration of a pool is changed, we call spa_config_sync(), which
  57  * walks through all the active pools and writes the configuration to disk.


 392         /*
 393          * Add the top-level config.  We even add this on pools which
 394          * don't support holes in the namespace.
 395          */
 396         vdev_top_config_generate(spa, config);
 397 
 398         /*
 399          * If we're splitting, record the original pool's guid.
 400          */
 401         if (spa->spa_config_splitting != NULL &&
 402             nvlist_lookup_uint64(spa->spa_config_splitting,
 403             ZPOOL_CONFIG_SPLIT_GUID, &split_guid) == 0) {
 404                 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_SPLIT_GUID,
 405                     split_guid) == 0);
 406         }
 407 
 408         nvroot = vdev_config_generate(spa, vd, getstats, 0);
 409         VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
 410         nvlist_free(nvroot);
 411 






 412         if (getstats && spa_load_state(spa) == SPA_LOAD_NONE) {
 413                 ddt_histogram_t *ddh;
 414                 ddt_stat_t *dds;
 415                 ddt_object_t *ddo;
 416 
 417                 ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
 418                 ddt_get_dedup_histogram(spa, ddh);
 419                 VERIFY(nvlist_add_uint64_array(config,
 420                     ZPOOL_CONFIG_DDT_HISTOGRAM,
 421                     (uint64_t *)ddh, sizeof (*ddh) / sizeof (uint64_t)) == 0);
 422                 kmem_free(ddh, sizeof (ddt_histogram_t));
 423 
 424                 ddo = kmem_zalloc(sizeof (ddt_object_t), KM_SLEEP);
 425                 ddt_get_dedup_object_stats(spa, ddo);
 426                 VERIFY(nvlist_add_uint64_array(config,
 427                     ZPOOL_CONFIG_DDT_OBJ_STATS,
 428                     (uint64_t *)ddo, sizeof (*ddo) / sizeof (uint64_t)) == 0);
 429                 kmem_free(ddo, sizeof (ddt_object_t));
 430 
 431                 dds = kmem_zalloc(sizeof (ddt_stat_t), KM_SLEEP);




   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
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2012 by Delphix. All rights reserved.
  26  */
  27 
  28 #include <sys/spa.h>
  29 #include <sys/spa_impl.h>
  30 #include <sys/nvpair.h>
  31 #include <sys/uio.h>
  32 #include <sys/fs/zfs.h>
  33 #include <sys/vdev_impl.h>
  34 #include <sys/zfs_ioctl.h>
  35 #include <sys/utsname.h>
  36 #include <sys/systeminfo.h>
  37 #include <sys/sunddi.h>
  38 #include <sys/zfeature.h>
  39 #ifdef _KERNEL
  40 #include <sys/kobj.h>
  41 #include <sys/zone.h>
  42 #endif
  43 
  44 /*
  45  * Pool configuration repository.
  46  *
  47  * Pool configuration is stored as a packed nvlist on the filesystem.  By
  48  * default, all pools are stored in /etc/zfs/zpool.cache and loaded on boot
  49  * (when the ZFS module is loaded).  Pools can also have the 'cachefile'
  50  * property set that allows them to be stored in an alternate location until
  51  * the control of external software.
  52  *
  53  * For each cache file, we have a single nvlist which holds all the
  54  * configuration information.  When the module loads, we read this information
  55  * from /etc/zfs/zpool.cache and populate the SPA namespace.  This namespace is
  56  * maintained independently in spa.c.  Whenever the namespace is modified, or
  57  * the configuration of a pool is changed, we call spa_config_sync(), which
  58  * walks through all the active pools and writes the configuration to disk.


 393         /*
 394          * Add the top-level config.  We even add this on pools which
 395          * don't support holes in the namespace.
 396          */
 397         vdev_top_config_generate(spa, config);
 398 
 399         /*
 400          * If we're splitting, record the original pool's guid.
 401          */
 402         if (spa->spa_config_splitting != NULL &&
 403             nvlist_lookup_uint64(spa->spa_config_splitting,
 404             ZPOOL_CONFIG_SPLIT_GUID, &split_guid) == 0) {
 405                 VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_SPLIT_GUID,
 406                     split_guid) == 0);
 407         }
 408 
 409         nvroot = vdev_config_generate(spa, vd, getstats, 0);
 410         VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
 411         nvlist_free(nvroot);
 412 
 413         /*
 414          * Store what's necessary for reading the MOS in the label.
 415          */
 416         VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_FEATURES_FOR_READ,
 417             spa->spa_label_features) == 0);
 418 
 419         if (getstats && spa_load_state(spa) == SPA_LOAD_NONE) {
 420                 ddt_histogram_t *ddh;
 421                 ddt_stat_t *dds;
 422                 ddt_object_t *ddo;
 423 
 424                 ddh = kmem_zalloc(sizeof (ddt_histogram_t), KM_SLEEP);
 425                 ddt_get_dedup_histogram(spa, ddh);
 426                 VERIFY(nvlist_add_uint64_array(config,
 427                     ZPOOL_CONFIG_DDT_HISTOGRAM,
 428                     (uint64_t *)ddh, sizeof (*ddh) / sizeof (uint64_t)) == 0);
 429                 kmem_free(ddh, sizeof (ddt_histogram_t));
 430 
 431                 ddo = kmem_zalloc(sizeof (ddt_object_t), KM_SLEEP);
 432                 ddt_get_dedup_object_stats(spa, ddo);
 433                 VERIFY(nvlist_add_uint64_array(config,
 434                     ZPOOL_CONFIG_DDT_OBJ_STATS,
 435                     (uint64_t *)ddo, sizeof (*ddo) / sizeof (uint64_t)) == 0);
 436                 kmem_free(ddo, sizeof (ddt_object_t));
 437 
 438                 dds = kmem_zalloc(sizeof (ddt_stat_t), KM_SLEEP);