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>

@@ -16,16 +16,21 @@
  * fields enclosed by brackets "[]" replaced with your own identifying
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
 /*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
  * The pool configuration repository is stored in /etc/zfs/zpool.cache as a
  * single packed nvlist.  While it would be nice to just read in this
  * file from userland, this wouldn't work from a local zone.  So we have to have
  * a zpool ioctl to return the complete configuration for all pools.  In the
  * global zone, this will be identical to reading the file and unpacking it in

@@ -215,10 +220,40 @@
         if (oldconfig)
                 *oldconfig = zhp->zpool_old_config;
         return (zhp->zpool_config);
 }
 
+/*
+ * Retrieves a list of enabled features and their refcounts and caches it in
+ * the pool handle.
+ */
+nvlist_t *
+zpool_get_features(zpool_handle_t *zhp)
+{
+        nvlist_t *config, *features;
+
+        config = zpool_get_config(zhp, NULL);
+
+        if (config == NULL || !nvlist_exists(config,
+            ZPOOL_CONFIG_FEATURE_STATS)) {
+                int error;
+                boolean_t missing = B_FALSE;
+
+                error = zpool_refresh_stats(zhp, &missing);
+
+                if (error != 0 || missing)
+                        return (NULL);
+
+                config = zpool_get_config(zhp, NULL);
+        }
+
+        verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
+            &features) == 0);
+
+        return (features);
+}
+
 /*
  * Refresh the vdev statistics associated with the given pool.  This is used in
  * iostat to show configuration changes and determine the delta from the last
  * time the function was called.  This function can fail, in case the pool has
  * been destroyed.