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>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_config.c
          +++ new/usr/src/lib/libzfs/common/libzfs_config.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
       21 +
  21   22  /*
  22   23   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   24   * Use is subject to license terms.
  24   25   */
  25   26  
  26   27  /*
       28 + * Copyright (c) 2012 by Delphix. All rights reserved.
       29 + */
       30 +
       31 +/*
  27   32   * The pool configuration repository is stored in /etc/zfs/zpool.cache as a
  28   33   * single packed nvlist.  While it would be nice to just read in this
  29   34   * file from userland, this wouldn't work from a local zone.  So we have to have
  30   35   * a zpool ioctl to return the complete configuration for all pools.  In the
  31   36   * global zone, this will be identical to reading the file and unpacking it in
  32   37   * userland.
  33   38   */
  34   39  
  35   40  #include <errno.h>
  36   41  #include <sys/stat.h>
↓ open down ↓ 173 lines elided ↑ open up ↑
 210  215   * describing the vdevs, as well as the statistics associated with each one.
 211  216   */
 212  217  nvlist_t *
 213  218  zpool_get_config(zpool_handle_t *zhp, nvlist_t **oldconfig)
 214  219  {
 215  220          if (oldconfig)
 216  221                  *oldconfig = zhp->zpool_old_config;
 217  222          return (zhp->zpool_config);
 218  223  }
 219  224  
      225 +/*
      226 + * Retrieves a list of enabled features and their refcounts and caches it in
      227 + * the pool handle.
      228 + */
      229 +nvlist_t *
      230 +zpool_get_features(zpool_handle_t *zhp)
      231 +{
      232 +        nvlist_t *config, *features;
      233 +
      234 +        config = zpool_get_config(zhp, NULL);
      235 +
      236 +        if (config == NULL || !nvlist_exists(config,
      237 +            ZPOOL_CONFIG_FEATURE_STATS)) {
      238 +                int error;
      239 +                boolean_t missing = B_FALSE;
      240 +
      241 +                error = zpool_refresh_stats(zhp, &missing);
      242 +
      243 +                if (error != 0 || missing)
      244 +                        return (NULL);
      245 +
      246 +                config = zpool_get_config(zhp, NULL);
      247 +        }
      248 +
      249 +        verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
      250 +            &features) == 0);
      251 +
      252 +        return (features);
      253 +}
      254 +
 220  255  /*
 221  256   * Refresh the vdev statistics associated with the given pool.  This is used in
 222  257   * iostat to show configuration changes and determine the delta from the last
 223  258   * time the function was called.  This function can fail, in case the pool has
 224  259   * been destroyed.
 225  260   */
 226  261  int
 227  262  zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
 228  263  {
 229  264          zfs_cmd_t zc = { 0 };
↓ open down ↓ 141 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX