1236884Smm/*
2236884Smm * CDDL HEADER START
3236884Smm *
4236884Smm * The contents of this file are subject to the terms of the
5236884Smm * Common Development and Distribution License (the "License").
6236884Smm * You may not use this file except in compliance with the License.
7236884Smm *
8236884Smm * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9236884Smm * or http://www.opensolaris.org/os/licensing.
10236884Smm * See the License for the specific language governing permissions
11236884Smm * and limitations under the License.
12236884Smm *
13236884Smm * When distributing Covered Code, include this CDDL HEADER in each
14236884Smm * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15236884Smm * If applicable, add the following below this CDDL HEADER, with the
16236884Smm * fields enclosed by brackets "[]" replaced with your own identifying
17236884Smm * information: Portions Copyright [yyyy] [name of copyright owner]
18236884Smm *
19236884Smm * CDDL HEADER END
20236884Smm */
21236884Smm
22236884Smm/*
23288572Smav * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
24246586Sdelphij * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25255750Sdelphij * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26297112Smav * Copyright (c) 2014 Integros [integros.com]
27236884Smm */
28236884Smm
29236884Smm#ifndef _ZFEATURE_COMMON_H
30236884Smm#define	_ZFEATURE_COMMON_H
31236884Smm
32236884Smm#include <sys/fs/zfs.h>
33236884Smm#include <sys/types.h>
34236884Smm
35236884Smm#ifdef	__cplusplus
36236884Smmextern "C" {
37236884Smm#endif
38236884Smm
39236884Smmstruct zfeature_info;
40236884Smm
41263390Sdelphijtypedef enum spa_feature {
42263390Sdelphij	SPA_FEATURE_NONE = -1,
43263390Sdelphij	SPA_FEATURE_ASYNC_DESTROY,
44263390Sdelphij	SPA_FEATURE_EMPTY_BPOBJ,
45263390Sdelphij	SPA_FEATURE_LZ4_COMPRESS,
46263390Sdelphij	SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
47263390Sdelphij	SPA_FEATURE_SPACEMAP_HISTOGRAM,
48263397Sdelphij	SPA_FEATURE_ENABLED_TXG,
49263397Sdelphij	SPA_FEATURE_HOLE_BIRTH,
50263390Sdelphij	SPA_FEATURE_EXTENSIBLE_DATASET,
51268649Sdelphij	SPA_FEATURE_EMBEDDED_DATA,
52263407Sdelphij	SPA_FEATURE_BOOKMARKS,
53265744Sdelphij	SPA_FEATURE_FS_SS_LIMIT,
54276081Sdelphij	SPA_FEATURE_LARGE_BLOCKS,
55290757Smav#ifdef illumos
56290757Smav	SPA_FEATURE_SHA512,
57290757Smav	SPA_FEATURE_SKEIN,
58290757Smav	SPA_FEATURE_EDONR,
59290757Smav#endif
60263390Sdelphij	SPA_FEATURES
61263390Sdelphij} spa_feature_t;
62263390Sdelphij
63263397Sdelphij#define	SPA_FEATURE_DISABLED	(-1ULL)
64263397Sdelphij
65288572Smavtypedef enum zfeature_flags {
66288572Smav	/* Can open pool readonly even if this feature is not supported. */
67288572Smav	ZFEATURE_FLAG_READONLY_COMPAT =		(1 << 0),
68288572Smav	/* Is this feature necessary to read the MOS? */
69288572Smav	ZFEATURE_FLAG_MOS =			(1 << 1),
70288572Smav	/* Activate this feature at the same time it is enabled. */
71288572Smav	ZFEATURE_FLAG_ACTIVATE_ON_ENABLE =	(1 << 2),
72288572Smav	/* Each dataset has a field set if it has ever used this feature. */
73288572Smav	ZFEATURE_FLAG_PER_DATASET =		(1 << 3)
74288572Smav} zfeature_flags_t;
75288572Smav
76236884Smmtypedef struct zfeature_info {
77263390Sdelphij	spa_feature_t fi_feature;
78236884Smm	const char *fi_uname;	/* User-facing feature name */
79236884Smm	const char *fi_guid;	/* On-disk feature identifier */
80236884Smm	const char *fi_desc;	/* Feature description */
81288572Smav	zfeature_flags_t fi_flags;
82263390Sdelphij	/* array of dependencies, terminated by SPA_FEATURE_NONE */
83263390Sdelphij	const spa_feature_t *fi_depends;
84236884Smm} zfeature_info_t;
85236884Smm
86268649Sdelphijtypedef int (zfeature_func_t)(zfeature_info_t *, void *);
87236884Smm
88236884Smm#define	ZFS_FEATURE_DEBUG
89236884Smm
90236884Smmextern zfeature_info_t spa_feature_table[SPA_FEATURES];
91236884Smm
92236884Smmextern boolean_t zfeature_is_valid_guid(const char *);
93236884Smm
94236884Smmextern boolean_t zfeature_is_supported(const char *);
95268649Sdelphijextern int zfeature_lookup_name(const char *, spa_feature_t *);
96268649Sdelphijextern boolean_t zfeature_depends_on(spa_feature_t, spa_feature_t);
97236884Smm
98236884Smmextern void zpool_feature_init(void);
99236884Smm
100236884Smm#ifdef	__cplusplus
101236884Smm}
102236884Smm#endif
103236884Smm
104236884Smm#endif	/* _ZFEATURE_COMMON_H */
105