153089ab7Seschrock /* 253089ab7Seschrock * CDDL HEADER START 353089ab7Seschrock * 453089ab7Seschrock * The contents of this file are subject to the terms of the 553089ab7Seschrock * Common Development and Distribution License (the "License"). 653089ab7Seschrock * You may not use this file except in compliance with the License. 753089ab7Seschrock * 853089ab7Seschrock * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 953089ab7Seschrock * or http://www.opensolaris.org/os/licensing. 1053089ab7Seschrock * See the License for the specific language governing permissions 1153089ab7Seschrock * and limitations under the License. 1253089ab7Seschrock * 1353089ab7Seschrock * When distributing Covered Code, include this CDDL HEADER in each 1453089ab7Seschrock * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1553089ab7Seschrock * If applicable, add the following below this CDDL HEADER, with the 1653089ab7Seschrock * fields enclosed by brackets "[]" replaced with your own identifying 1753089ab7Seschrock * information: Portions Copyright [yyyy] [name of copyright owner] 1853089ab7Seschrock * 1953089ab7Seschrock * CDDL HEADER END 2053089ab7Seschrock */ 2153089ab7Seschrock 2253089ab7Seschrock /* 2353089ab7Seschrock * Copyright (c) 2012 by Delphix. All rights reserved. 2453089ab7Seschrock */ 2553089ab7Seschrock 2653089ab7Seschrock #include <sys/zfs_context.h> 2753089ab7Seschrock #include <sys/zfeature.h> 2853089ab7Seschrock #include <sys/dmu.h> 2953089ab7Seschrock #include <sys/nvpair.h> 3053089ab7Seschrock #include <sys/zap.h> 3153089ab7Seschrock #include <sys/dmu_tx.h> 3253089ab7Seschrock #include "zfeature_common.h" 3353089ab7Seschrock #include <sys/spa_impl.h> 3453089ab7Seschrock 3553089ab7Seschrock /* 3653089ab7Seschrock * ZFS Feature Flags 3753089ab7Seschrock * ----------------- 3853089ab7Seschrock * 3953089ab7Seschrock * ZFS feature flags are used to provide fine-grained versioning to the ZFS 4053089ab7Seschrock * on-disk format. Once enabled on a pool feature flags replace the old 4153089ab7Seschrock * spa_version() number. 4253089ab7Seschrock * 4353089ab7Seschrock * Each new on-disk format change will be given a uniquely identifying string 4453089ab7Seschrock * guid rather than a version number. This avoids the problem of different 4553089ab7Seschrock * organizations creating new on-disk formats with the same version number. To 4653089ab7Seschrock * keep feature guids unique they should consist of the reverse dns name of the 4753089ab7Seschrock * organization which implemented the feature and a short name for the feature, 4853089ab7Seschrock * separated by a colon (e.g. com.delphix:async_destroy). 4953089ab7Seschrock * 5053089ab7Seschrock * Reference Counts 5153089ab7Seschrock * ---------------- 5253089ab7Seschrock * 5353089ab7Seschrock * Within each pool features can be in one of three states: disabled, enabled, 5453089ab7Seschrock * or active. These states are differentiated by a reference count stored on 5553089ab7Seschrock * disk for each feature: 5653089ab7Seschrock * 5753089ab7Seschrock * 1) If there is no reference count stored on disk the feature is disabled. 5853089ab7Seschrock * 2) If the reference count is 0 a system administrator has enabled the 5953089ab7Seschrock * feature, but the feature has not been used yet, so no on-disk 6053089ab7Seschrock * format changes have been made. 6153089ab7Seschrock * 3) If the reference count is greater than 0 the feature is active. 6253089ab7Seschrock * The format changes required by the feature are currently on disk. 6353089ab7Seschrock * Note that if the feature's format changes are reversed the feature 6453089ab7Seschrock * may choose to set its reference count back to 0. 6553089ab7Seschrock * 6653089ab7Seschrock * Feature flags makes no differentiation between non-zero reference counts 6753089ab7Seschrock * for an active feature (e.g. a reference count of 1 means the same thing as a 6853089ab7Seschrock * reference count of 27834721), but feature implementations may choose to use 6953089ab7Seschrock * the reference count to store meaningful information. For example, a new RAID 7053089ab7Seschrock * implementation might set the reference count to the number of vdevs using 7153089ab7Seschrock * it. If all those disks are removed from the pool the feature goes back to 7253089ab7Seschrock * having a reference count of 0. 7353089ab7Seschrock * 7453089ab7Seschrock * It is the responsibility of the individual features to maintain a non-zero 7553089ab7Seschrock * reference count as long as the feature's format changes are present on disk. 7653089ab7Seschrock * 7753089ab7Seschrock * Dependencies 7853089ab7Seschrock * ------------ 7953089ab7Seschrock * 8053089ab7Seschrock * Each feature may depend on other features. The only effect of this 8153089ab7Seschrock * relationship is that when a feature is enabled all of its dependencies are 8253089ab7Seschrock * automatically enabled as well. Any future work to support disabling of 8353089ab7Seschrock * features would need to ensure that features cannot be disabled if other 8453089ab7Seschrock * enabled features depend on them. 8553089ab7Seschrock * 8653089ab7Seschrock * On-disk Format 8753089ab7Seschrock * -------------- 8853089ab7Seschrock * 8953089ab7Seschrock * When feature flags are enabled spa_version() is set to SPA_VERSION_FEATURES 9053089ab7Seschrock * (5000). In order for this to work the pool is automatically upgraded to 9153089ab7Seschrock * SPA_VERSION_BEFORE_FEATURES (28) first, so all pre-feature flags on disk 9253089ab7Seschrock * format changes will be in use. 9353089ab7Seschrock * 9453089ab7Seschrock * Information about features is stored in 3 ZAP objects in the pool's MOS. 9553089ab7Seschrock * These objects are linked to by the following names in the pool directory 9653089ab7Seschrock * object: 9753089ab7Seschrock * 9853089ab7Seschrock * 1) features_for_read: feature guid -> reference count 9953089ab7Seschrock * Features needed to open the pool for reading. 10053089ab7Seschrock * 2) features_for_write: feature guid -> reference count 10153089ab7Seschrock * Features needed to open the pool for writing. 10253089ab7Seschrock * 3) feature_descriptions: feature guid -> descriptive string 10353089ab7Seschrock * A human readable string. 10453089ab7Seschrock * 10553089ab7Seschrock * All enabled features appear in either features_for_read or 10653089ab7Seschrock * features_for_write, but not both. 10753089ab7Seschrock * 10853089ab7Seschrock * To open a pool in read-only mode only the features listed in 10953089ab7Seschrock * features_for_read need to be supported. 11053089ab7Seschrock * 11153089ab7Seschrock * To open the pool in read-write mode features in both features_for_read and 11253089ab7Seschrock * features_for_write need to be supported. 11353089ab7Seschrock * 11453089ab7Seschrock * Some features may be required to read the ZAP objects containing feature 11553089ab7Seschrock * information. To allow software to check for compatibility with these features 11653089ab7Seschrock * before the pool is opened their names must be stored in the label in a 11753089ab7Seschrock * new "features_for_read" entry (note that features that are only required 11853089ab7Seschrock * to write to a pool never need to be stored in the label since the 11953089ab7Seschrock * features_for_write ZAP object can be read before the pool is written to). 12053089ab7Seschrock * To save space in the label features must be explicitly marked as needing to 12153089ab7Seschrock * be written to the label. Also, reference counts are not stored in the label, 12253089ab7Seschrock * instead any feature whose reference count drops to 0 is removed from the 12353089ab7Seschrock * label. 12453089ab7Seschrock * 12553089ab7Seschrock * Adding New Features 12653089ab7Seschrock * ------------------- 12753089ab7Seschrock * 12853089ab7Seschrock * Features must be registered in zpool_feature_init() function in 12953089ab7Seschrock * zfeature_common.c using the zfeature_register() function. This function 13053089ab7Seschrock * has arguments to specify if the feature should be stored in the 13153089ab7Seschrock * features_for_read or features_for_write ZAP object and if it needs to be 13253089ab7Seschrock * written to the label when active. 13353089ab7Seschrock * 13453089ab7Seschrock * Once a feature is registered it will appear as a "feature@<feature name>" 13553089ab7Seschrock * property which can be set by an administrator. Feature implementors should 13653089ab7Seschrock * use the spa_feature_is_enabled() and spa_feature_is_active() functions to 13753089ab7Seschrock * query the state of a feature and the spa_feature_incr() and 13853089ab7Seschrock * spa_feature_decr() functions to change an enabled feature's reference count. 13953089ab7Seschrock * Reference counts may only be updated in the syncing context. 14053089ab7Seschrock * 14153089ab7Seschrock * Features may not perform enable-time initialization. Instead, any such 14253089ab7Seschrock * initialization should occur when the feature is first used. This design 14353089ab7Seschrock * enforces that on-disk changes be made only when features are used. Code 14453089ab7Seschrock * should only check if a feature is enabled using spa_feature_is_enabled(), 14553089ab7Seschrock * not by relying on any feature specific metadata existing. If a feature is 14653089ab7Seschrock * enabled, but the feature's metadata is not on disk yet then it should be 14753089ab7Seschrock * created as needed. 14853089ab7Seschrock * 14953089ab7Seschrock * As an example, consider the com.delphix:async_destroy feature. This feature 15053089ab7Seschrock * relies on the existence of a bptree in the MOS that store blocks for 15153089ab7Seschrock * asynchronous freeing. This bptree is not created when async_destroy is 15253089ab7Seschrock * enabled. Instead, when a dataset is destroyed spa_feature_is_enabled() is 15353089ab7Seschrock * called to check if async_destroy is enabled. If it is and the bptree object 15453089ab7Seschrock * does not exist yet, the bptree object is created as part of the dataset 15553089ab7Seschrock * destroy and async_destroy's reference count is incremented to indicate it 15653089ab7Seschrock * has made an on-disk format change. Later, after the destroyed dataset's 15753089ab7Seschrock * blocks have all been asynchronously freed there is no longer any use for the 15853089ab7Seschrock * bptree object, so it is destroyed and async_destroy's reference count is 15953089ab7Seschrock * decremented back to 0 to indicate that it has undone its on-disk format 16053089ab7Seschrock * changes. 16153089ab7Seschrock */ 16253089ab7Seschrock 16353089ab7Seschrock typedef enum { 16453089ab7Seschrock FEATURE_ACTION_ENABLE, 16553089ab7Seschrock FEATURE_ACTION_INCR, 16653089ab7Seschrock FEATURE_ACTION_DECR, 16753089ab7Seschrock } feature_action_t; 16853089ab7Seschrock 16953089ab7Seschrock /* 17053089ab7Seschrock * Checks that the features active in the specified object are supported by 17153089ab7Seschrock * this software. Adds each unsupported feature (name -> description) to 17253089ab7Seschrock * the supplied nvlist. 17353089ab7Seschrock */ 17453089ab7Seschrock boolean_t 17553089ab7Seschrock feature_is_supported(objset_t *os, uint64_t obj, uint64_t desc_obj, 176*57221772SChristopher Siden nvlist_t *unsup_feat, nvlist_t *enabled_feat) 17753089ab7Seschrock { 17853089ab7Seschrock boolean_t supported; 17953089ab7Seschrock zap_cursor_t zc; 18053089ab7Seschrock zap_attribute_t za; 18153089ab7Seschrock 18253089ab7Seschrock supported = B_TRUE; 18353089ab7Seschrock for (zap_cursor_init(&zc, os, obj); 18453089ab7Seschrock zap_cursor_retrieve(&zc, &za) == 0; 18553089ab7Seschrock zap_cursor_advance(&zc)) { 18653089ab7Seschrock ASSERT(za.za_integer_length == sizeof (uint64_t) && 18753089ab7Seschrock za.za_num_integers == 1); 18853089ab7Seschrock 189*57221772SChristopher Siden if (NULL != enabled_feat) { 190*57221772SChristopher Siden fnvlist_add_uint64(enabled_feat, za.za_name, 191*57221772SChristopher Siden za.za_first_integer); 192*57221772SChristopher Siden } 193*57221772SChristopher Siden 19453089ab7Seschrock if (za.za_first_integer != 0 && 19553089ab7Seschrock !zfeature_is_supported(za.za_name)) { 19653089ab7Seschrock supported = B_FALSE; 19753089ab7Seschrock 198*57221772SChristopher Siden if (NULL != unsup_feat) { 19953089ab7Seschrock char *desc = ""; 20053089ab7Seschrock char buf[MAXPATHLEN]; 20153089ab7Seschrock 20253089ab7Seschrock if (zap_lookup(os, desc_obj, za.za_name, 20353089ab7Seschrock 1, sizeof (buf), buf) == 0) 20453089ab7Seschrock desc = buf; 20553089ab7Seschrock 20653089ab7Seschrock VERIFY(nvlist_add_string(unsup_feat, za.za_name, 20753089ab7Seschrock desc) == 0); 20853089ab7Seschrock } 20953089ab7Seschrock } 21053089ab7Seschrock } 21153089ab7Seschrock zap_cursor_fini(&zc); 21253089ab7Seschrock 21353089ab7Seschrock return (supported); 21453089ab7Seschrock } 21553089ab7Seschrock 21653089ab7Seschrock static int 21753089ab7Seschrock feature_get_refcount(objset_t *os, uint64_t read_obj, uint64_t write_obj, 21853089ab7Seschrock zfeature_info_t *feature, uint64_t *res) 21953089ab7Seschrock { 22053089ab7Seschrock int err; 22153089ab7Seschrock uint64_t refcount; 22253089ab7Seschrock uint64_t zapobj = feature->fi_can_readonly ? write_obj : read_obj; 22353089ab7Seschrock 22453089ab7Seschrock ASSERT(0 != zapobj); 22553089ab7Seschrock 22653089ab7Seschrock err = zap_lookup(os, zapobj, feature->fi_guid, sizeof (uint64_t), 1, 22753089ab7Seschrock &refcount); 22853089ab7Seschrock if (err != 0) { 22953089ab7Seschrock if (err == ENOENT) 23053089ab7Seschrock return (ENOTSUP); 23153089ab7Seschrock else 23253089ab7Seschrock return (err); 23353089ab7Seschrock } 23453089ab7Seschrock *res = refcount; 23553089ab7Seschrock return (0); 23653089ab7Seschrock } 23753089ab7Seschrock 23853089ab7Seschrock static int 23953089ab7Seschrock feature_do_action(objset_t *os, uint64_t read_obj, uint64_t write_obj, 24053089ab7Seschrock uint64_t desc_obj, zfeature_info_t *feature, feature_action_t action, 24153089ab7Seschrock dmu_tx_t *tx) 24253089ab7Seschrock { 24353089ab7Seschrock int error; 24453089ab7Seschrock uint64_t refcount; 24553089ab7Seschrock uint64_t zapobj = feature->fi_can_readonly ? write_obj : read_obj; 24653089ab7Seschrock 24753089ab7Seschrock ASSERT(0 != zapobj); 24853089ab7Seschrock ASSERT(zfeature_is_valid_guid(feature->fi_guid)); 24953089ab7Seschrock 25053089ab7Seschrock error = zap_lookup(os, zapobj, feature->fi_guid, 25153089ab7Seschrock sizeof (uint64_t), 1, &refcount); 25253089ab7Seschrock 25353089ab7Seschrock /* 25453089ab7Seschrock * If we can't ascertain the status of the specified feature, an I/O 25553089ab7Seschrock * error occurred. 25653089ab7Seschrock */ 25753089ab7Seschrock if (error != 0 && error != ENOENT) 25853089ab7Seschrock return (error); 25953089ab7Seschrock 26053089ab7Seschrock switch (action) { 26153089ab7Seschrock case FEATURE_ACTION_ENABLE: 26253089ab7Seschrock /* 26353089ab7Seschrock * If the feature is already enabled, ignore the request. 26453089ab7Seschrock */ 26553089ab7Seschrock if (error == 0) 26653089ab7Seschrock return (0); 26753089ab7Seschrock refcount = 0; 26853089ab7Seschrock break; 26953089ab7Seschrock case FEATURE_ACTION_INCR: 27053089ab7Seschrock if (error == ENOENT) 27153089ab7Seschrock return (ENOTSUP); 27253089ab7Seschrock if (refcount == UINT64_MAX) 27353089ab7Seschrock return (EOVERFLOW); 27453089ab7Seschrock refcount++; 27553089ab7Seschrock break; 27653089ab7Seschrock case FEATURE_ACTION_DECR: 27753089ab7Seschrock if (error == ENOENT) 27853089ab7Seschrock return (ENOTSUP); 27953089ab7Seschrock if (refcount == 0) 28053089ab7Seschrock return (EOVERFLOW); 28153089ab7Seschrock refcount--; 28253089ab7Seschrock break; 28353089ab7Seschrock default: 28453089ab7Seschrock ASSERT(0); 28553089ab7Seschrock break; 28653089ab7Seschrock } 28753089ab7Seschrock 28853089ab7Seschrock if (action == FEATURE_ACTION_ENABLE) { 28953089ab7Seschrock int i; 29053089ab7Seschrock 29153089ab7Seschrock for (i = 0; feature->fi_depends[i] != NULL; i++) { 29253089ab7Seschrock zfeature_info_t *dep = feature->fi_depends[i]; 29353089ab7Seschrock 29453089ab7Seschrock error = feature_do_action(os, read_obj, write_obj, 29553089ab7Seschrock desc_obj, dep, FEATURE_ACTION_ENABLE, tx); 29653089ab7Seschrock if (error != 0) 29753089ab7Seschrock return (error); 29853089ab7Seschrock } 29953089ab7Seschrock } 30053089ab7Seschrock 30153089ab7Seschrock error = zap_update(os, zapobj, feature->fi_guid, 30253089ab7Seschrock sizeof (uint64_t), 1, &refcount, tx); 30353089ab7Seschrock if (error != 0) 30453089ab7Seschrock return (error); 30553089ab7Seschrock 30653089ab7Seschrock if (action == FEATURE_ACTION_ENABLE) { 30753089ab7Seschrock error = zap_update(os, desc_obj, 30853089ab7Seschrock feature->fi_guid, 1, strlen(feature->fi_desc) + 1, 30953089ab7Seschrock feature->fi_desc, tx); 31053089ab7Seschrock if (error != 0) 31153089ab7Seschrock return (error); 31253089ab7Seschrock } 31353089ab7Seschrock 31453089ab7Seschrock if (action == FEATURE_ACTION_INCR && refcount == 1 && feature->fi_mos) { 31553089ab7Seschrock spa_activate_mos_feature(dmu_objset_spa(os), feature->fi_guid); 31653089ab7Seschrock } 31753089ab7Seschrock 31853089ab7Seschrock if (action == FEATURE_ACTION_DECR && refcount == 0) { 31953089ab7Seschrock spa_deactivate_mos_feature(dmu_objset_spa(os), 32053089ab7Seschrock feature->fi_guid); 32153089ab7Seschrock } 32253089ab7Seschrock 32353089ab7Seschrock return (0); 32453089ab7Seschrock } 32553089ab7Seschrock 32653089ab7Seschrock void 32753089ab7Seschrock spa_feature_create_zap_objects(spa_t *spa, dmu_tx_t *tx) 32853089ab7Seschrock { 32953089ab7Seschrock /* 33053089ab7Seschrock * We create feature flags ZAP objects in two instances: during pool 33153089ab7Seschrock * creation and during pool upgrade. 33253089ab7Seschrock */ 33353089ab7Seschrock ASSERT(dsl_pool_sync_context(spa_get_dsl(spa)) || (!spa->spa_sync_on && 33453089ab7Seschrock tx->tx_txg == TXG_INITIAL)); 33553089ab7Seschrock 33653089ab7Seschrock spa->spa_feat_for_read_obj = zap_create_link(spa->spa_meta_objset, 33753089ab7Seschrock DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT, 33853089ab7Seschrock DMU_POOL_FEATURES_FOR_READ, tx); 33953089ab7Seschrock spa->spa_feat_for_write_obj = zap_create_link(spa->spa_meta_objset, 34053089ab7Seschrock DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT, 34153089ab7Seschrock DMU_POOL_FEATURES_FOR_WRITE, tx); 34253089ab7Seschrock spa->spa_feat_desc_obj = zap_create_link(spa->spa_meta_objset, 34353089ab7Seschrock DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT, 34453089ab7Seschrock DMU_POOL_FEATURE_DESCRIPTIONS, tx); 34553089ab7Seschrock } 34653089ab7Seschrock 34753089ab7Seschrock /* 34853089ab7Seschrock * Enable any required dependencies, then enable the requested feature. 34953089ab7Seschrock */ 35053089ab7Seschrock void 35153089ab7Seschrock spa_feature_enable(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx) 35253089ab7Seschrock { 35353089ab7Seschrock ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES); 35453089ab7Seschrock VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset, 35553089ab7Seschrock spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj, 35653089ab7Seschrock spa->spa_feat_desc_obj, feature, FEATURE_ACTION_ENABLE, tx)); 35753089ab7Seschrock } 35853089ab7Seschrock 35953089ab7Seschrock /* 36053089ab7Seschrock * If the specified feature has not yet been enabled, this function returns 36153089ab7Seschrock * ENOTSUP; otherwise, this function increments the feature's refcount (or 36253089ab7Seschrock * returns EOVERFLOW if the refcount cannot be incremented). This function must 36353089ab7Seschrock * be called from syncing context. 36453089ab7Seschrock */ 36553089ab7Seschrock void 36653089ab7Seschrock spa_feature_incr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx) 36753089ab7Seschrock { 36853089ab7Seschrock ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES); 36953089ab7Seschrock VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset, 37053089ab7Seschrock spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj, 37153089ab7Seschrock spa->spa_feat_desc_obj, feature, FEATURE_ACTION_INCR, tx)); 37253089ab7Seschrock } 37353089ab7Seschrock 37453089ab7Seschrock /* 37553089ab7Seschrock * If the specified feature has not yet been enabled, this function returns 37653089ab7Seschrock * ENOTSUP; otherwise, this function decrements the feature's refcount (or 37753089ab7Seschrock * returns EOVERFLOW if the refcount is already 0). This function must 37853089ab7Seschrock * be called from syncing context. 37953089ab7Seschrock */ 38053089ab7Seschrock void 38153089ab7Seschrock spa_feature_decr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx) 38253089ab7Seschrock { 38353089ab7Seschrock ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES); 38453089ab7Seschrock VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset, 38553089ab7Seschrock spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj, 38653089ab7Seschrock spa->spa_feat_desc_obj, feature, FEATURE_ACTION_DECR, tx)); 38753089ab7Seschrock } 38853089ab7Seschrock 38953089ab7Seschrock boolean_t 39053089ab7Seschrock spa_feature_is_enabled(spa_t *spa, zfeature_info_t *feature) 39153089ab7Seschrock { 39253089ab7Seschrock int err; 39353089ab7Seschrock uint64_t refcount; 39453089ab7Seschrock 39553089ab7Seschrock if (spa_version(spa) < SPA_VERSION_FEATURES) 39653089ab7Seschrock return (B_FALSE); 39753089ab7Seschrock 39853089ab7Seschrock err = feature_get_refcount(spa->spa_meta_objset, 39953089ab7Seschrock spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj, 40053089ab7Seschrock feature, &refcount); 40153089ab7Seschrock ASSERT(err == 0 || err == ENOTSUP); 40253089ab7Seschrock return (err == 0); 40353089ab7Seschrock } 40453089ab7Seschrock 40553089ab7Seschrock boolean_t 40653089ab7Seschrock spa_feature_is_active(spa_t *spa, zfeature_info_t *feature) 40753089ab7Seschrock { 40853089ab7Seschrock int err; 40953089ab7Seschrock uint64_t refcount; 41053089ab7Seschrock 41153089ab7Seschrock if (spa_version(spa) < SPA_VERSION_FEATURES) 41253089ab7Seschrock return (B_FALSE); 41353089ab7Seschrock 41453089ab7Seschrock err = feature_get_refcount(spa->spa_meta_objset, 41553089ab7Seschrock spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj, 41653089ab7Seschrock feature, &refcount); 41753089ab7Seschrock ASSERT(err == 0 || err == ENOTSUP); 41853089ab7Seschrock return (err == 0 && refcount > 0); 41953089ab7Seschrock } 420