xref: /illumos-gate/usr/src/common/zfs/zfeature_common.h (revision eb633035c80613ec93d62f90482837adaaf21a0a)
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 /*
2386714001SSerapheim Dimitropoulos  * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
24a6f561b4SSašo Kiselkov  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25810e43b2SBill Pijewski  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26c3d26abcSMatthew Ahrens  * Copyright (c) 2014 Integros [integros.com]
27663207adSDon Brady  * Copyright (c) 2017, Intel Corporation.
2853089ab7Seschrock  */
2953089ab7Seschrock 
3053089ab7Seschrock #ifndef _ZFEATURE_COMMON_H
3153089ab7Seschrock #define	_ZFEATURE_COMMON_H
3253089ab7Seschrock 
3353089ab7Seschrock #include <sys/fs/zfs.h>
3453089ab7Seschrock #include <sys/inttypes.h>
3553089ab7Seschrock #include <sys/types.h>
3653089ab7Seschrock 
3753089ab7Seschrock #ifdef	__cplusplus
3853089ab7Seschrock extern "C" {
3953089ab7Seschrock #endif
4053089ab7Seschrock 
4153089ab7Seschrock struct zfeature_info;
4253089ab7Seschrock 
432acef22dSMatthew Ahrens typedef enum spa_feature {
442acef22dSMatthew Ahrens 	SPA_FEATURE_NONE = -1,
452acef22dSMatthew Ahrens 	SPA_FEATURE_ASYNC_DESTROY,
462acef22dSMatthew Ahrens 	SPA_FEATURE_EMPTY_BPOBJ,
472acef22dSMatthew Ahrens 	SPA_FEATURE_LZ4_COMPRESS,
482acef22dSMatthew Ahrens 	SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
492acef22dSMatthew Ahrens 	SPA_FEATURE_SPACEMAP_HISTOGRAM,
5043466aaeSMax Grossman 	SPA_FEATURE_ENABLED_TXG,
5143466aaeSMax Grossman 	SPA_FEATURE_HOLE_BIRTH,
522acef22dSMatthew Ahrens 	SPA_FEATURE_EXTENSIBLE_DATASET,
535d7b4d43SMatthew Ahrens 	SPA_FEATURE_EMBEDDED_DATA,
5478f17100SMatthew Ahrens 	SPA_FEATURE_BOOKMARKS,
55a2afb611SJerry Jelinek 	SPA_FEATURE_FS_SS_LIMIT,
56b5152584SMatthew Ahrens 	SPA_FEATURE_LARGE_BLOCKS,
5754811da5SToomas Soome 	SPA_FEATURE_LARGE_DNODE,
5845818ee1SMatthew Ahrens 	SPA_FEATURE_SHA512,
5945818ee1SMatthew Ahrens 	SPA_FEATURE_SKEIN,
6045818ee1SMatthew Ahrens 	SPA_FEATURE_EDONR,
615cabbc6bSPrashanth Sreenivasa 	SPA_FEATURE_DEVICE_REMOVAL,
625cabbc6bSPrashanth Sreenivasa 	SPA_FEATURE_OBSOLETE_COUNTS,
6386714001SSerapheim Dimitropoulos 	SPA_FEATURE_POOL_CHECKPOINT,
6417f11284SSerapheim Dimitropoulos 	SPA_FEATURE_SPACEMAP_V2,
65663207adSDon Brady 	SPA_FEATURE_ALLOCATION_CLASSES,
66e4c795beSTom Caputi 	SPA_FEATURE_RESILVER_DEFER,
67*eb633035STom Caputi 	SPA_FEATURE_ENCRYPTION,
68*eb633035STom Caputi 	SPA_FEATURE_BOOKMARK_V2,
692acef22dSMatthew Ahrens 	SPA_FEATURES
702acef22dSMatthew Ahrens } spa_feature_t;
712acef22dSMatthew Ahrens 
7243466aaeSMax Grossman #define	SPA_FEATURE_DISABLED	(-1ULL)
7343466aaeSMax Grossman 
74ca0cc391SMatthew Ahrens typedef enum zfeature_flags {
75ca0cc391SMatthew Ahrens 	/* Can open pool readonly even if this feature is not supported. */
76ca0cc391SMatthew Ahrens 	ZFEATURE_FLAG_READONLY_COMPAT =		(1 << 0),
77ca0cc391SMatthew Ahrens 	/* Is this feature necessary to read the MOS? */
78ca0cc391SMatthew Ahrens 	ZFEATURE_FLAG_MOS =			(1 << 1),
79ca0cc391SMatthew Ahrens 	/* Activate this feature at the same time it is enabled. */
80ca0cc391SMatthew Ahrens 	ZFEATURE_FLAG_ACTIVATE_ON_ENABLE =	(1 << 2),
81ca0cc391SMatthew Ahrens 	/* Each dataset has a field set if it has ever used this feature. */
82ca0cc391SMatthew Ahrens 	ZFEATURE_FLAG_PER_DATASET =		(1 << 3)
83ca0cc391SMatthew Ahrens } zfeature_flags_t;
84ca0cc391SMatthew Ahrens 
8553089ab7Seschrock typedef struct zfeature_info {
862acef22dSMatthew Ahrens 	spa_feature_t fi_feature;
8753089ab7Seschrock 	const char *fi_uname;	/* User-facing feature name */
8853089ab7Seschrock 	const char *fi_guid;	/* On-disk feature identifier */
8953089ab7Seschrock 	const char *fi_desc;	/* Feature description */
90ca0cc391SMatthew Ahrens 	zfeature_flags_t fi_flags;
912acef22dSMatthew Ahrens 	/* array of dependencies, terminated by SPA_FEATURE_NONE */
922acef22dSMatthew Ahrens 	const spa_feature_t *fi_depends;
9353089ab7Seschrock } zfeature_info_t;
9453089ab7Seschrock 
955d7b4d43SMatthew Ahrens typedef int (zfeature_func_t)(zfeature_info_t *, void *);
9653089ab7Seschrock 
9753089ab7Seschrock #define	ZFS_FEATURE_DEBUG
9853089ab7Seschrock 
9953089ab7Seschrock extern zfeature_info_t spa_feature_table[SPA_FEATURES];
10053089ab7Seschrock 
10153089ab7Seschrock extern boolean_t zfeature_is_valid_guid(const char *);
10253089ab7Seschrock 
10353089ab7Seschrock extern boolean_t zfeature_is_supported(const char *);
1045d7b4d43SMatthew Ahrens extern int zfeature_lookup_name(const char *, spa_feature_t *);
1055d7b4d43SMatthew Ahrens extern boolean_t zfeature_depends_on(spa_feature_t, spa_feature_t);
10653089ab7Seschrock 
10753089ab7Seschrock extern void zpool_feature_init(void);
10853089ab7Seschrock 
10953089ab7Seschrock #ifdef	__cplusplus
11053089ab7Seschrock }
11153089ab7Seschrock #endif
11253089ab7Seschrock 
11353089ab7Seschrock #endif	/* _ZFEATURE_COMMON_H */
114