xref: /illumos-gate/usr/src/uts/common/fs/zfs/sys/zfeature.h (revision 43466aae)
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 /*
230713e232SGeorge Wilson  * Copyright (c) 2013 by Delphix. All rights reserved.
2453089ab7Seschrock  */
2553089ab7Seschrock 
2653089ab7Seschrock #ifndef _SYS_ZFEATURE_H
2753089ab7Seschrock #define	_SYS_ZFEATURE_H
2853089ab7Seschrock 
2953089ab7Seschrock #include <sys/nvpair.h>
302acef22dSMatthew Ahrens #include <sys/txg.h>
3153089ab7Seschrock #include "zfeature_common.h"
3253089ab7Seschrock 
3353089ab7Seschrock #ifdef	__cplusplus
3453089ab7Seschrock extern "C" {
3553089ab7Seschrock #endif
3653089ab7Seschrock 
37*43466aaeSMax Grossman #define	VALID_FEATURE_FID(fid)	((fid) >= 0 && (fid) < SPA_FEATURES)
38*43466aaeSMax Grossman #define	VALID_FEATURE_OR_NONE(fid)	((fid) == SPA_FEATURE_NONE ||	\
39*43466aaeSMax Grossman     VALID_FEATURE_FID(fid))
40*43466aaeSMax Grossman 
413b2aab18SMatthew Ahrens struct spa;
423b2aab18SMatthew Ahrens struct dmu_tx;
433b2aab18SMatthew Ahrens struct objset;
443b2aab18SMatthew Ahrens 
453b2aab18SMatthew Ahrens extern void spa_feature_create_zap_objects(struct spa *, struct dmu_tx *);
462acef22dSMatthew Ahrens extern void spa_feature_enable(struct spa *, spa_feature_t,
472acef22dSMatthew Ahrens     struct dmu_tx *);
482acef22dSMatthew Ahrens extern void spa_feature_incr(struct spa *, spa_feature_t, struct dmu_tx *);
492acef22dSMatthew Ahrens extern void spa_feature_decr(struct spa *, spa_feature_t, struct dmu_tx *);
502acef22dSMatthew Ahrens extern boolean_t spa_feature_is_enabled(struct spa *, spa_feature_t);
512acef22dSMatthew Ahrens extern boolean_t spa_feature_is_active(struct spa *, spa_feature_t);
52*43466aaeSMax Grossman extern boolean_t spa_feature_enabled_txg(spa_t *spa, spa_feature_t fid,
53*43466aaeSMax Grossman     uint64_t *txg);
542acef22dSMatthew Ahrens extern uint64_t spa_feature_refcount(spa_t *, spa_feature_t, uint64_t);
552acef22dSMatthew Ahrens extern boolean_t spa_features_check(spa_t *, boolean_t, nvlist_t *, nvlist_t *);
562acef22dSMatthew Ahrens 
572acef22dSMatthew Ahrens /*
582acef22dSMatthew Ahrens  * These functions are only exported for zhack and zdb; normal callers should
592acef22dSMatthew Ahrens  * use the above interfaces.
602acef22dSMatthew Ahrens  */
612acef22dSMatthew Ahrens extern int feature_get_refcount(struct spa *, zfeature_info_t *, uint64_t *);
62*43466aaeSMax Grossman extern int feature_get_refcount_from_disk(spa_t *spa, zfeature_info_t *feature,
63*43466aaeSMax Grossman     uint64_t *res);
642acef22dSMatthew Ahrens extern void feature_enable_sync(struct spa *, zfeature_info_t *,
652acef22dSMatthew Ahrens     struct dmu_tx *);
662acef22dSMatthew Ahrens extern void feature_sync(struct spa *, zfeature_info_t *, uint64_t,
673b2aab18SMatthew Ahrens     struct dmu_tx *);
6853089ab7Seschrock 
6953089ab7Seschrock #ifdef	__cplusplus
7053089ab7Seschrock }
7153089ab7Seschrock #endif
7253089ab7Seschrock 
7353089ab7Seschrock #endif /* _SYS_ZFEATURE_H */
74