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.
26236884Smm */
27236884Smm
28236884Smm#ifndef _ZFEATURE_COMMON_H
29236884Smm#define	_ZFEATURE_COMMON_H
30236884Smm
31236884Smm#include <sys/fs/zfs.h>
32236884Smm#include <sys/types.h>
33236884Smm
34236884Smm#ifdef	__cplusplus
35236884Smmextern "C" {
36236884Smm#endif
37236884Smm
38236884Smmstruct zfeature_info;
39236884Smm
40263390Sdelphijtypedef enum spa_feature {
41263390Sdelphij	SPA_FEATURE_NONE = -1,
42263390Sdelphij	SPA_FEATURE_ASYNC_DESTROY,
43263390Sdelphij	SPA_FEATURE_EMPTY_BPOBJ,
44263390Sdelphij	SPA_FEATURE_LZ4_COMPRESS,
45263390Sdelphij	SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
46263390Sdelphij	SPA_FEATURE_SPACEMAP_HISTOGRAM,
47263397Sdelphij	SPA_FEATURE_ENABLED_TXG,
48263397Sdelphij	SPA_FEATURE_HOLE_BIRTH,
49263390Sdelphij	SPA_FEATURE_EXTENSIBLE_DATASET,
50268649Sdelphij	SPA_FEATURE_EMBEDDED_DATA,
51263407Sdelphij	SPA_FEATURE_BOOKMARKS,
52265744Sdelphij	SPA_FEATURE_FS_SS_LIMIT,
53276081Sdelphij	SPA_FEATURE_LARGE_BLOCKS,
54290757Smav#ifdef illumos
55290757Smav	SPA_FEATURE_SHA512,
56290757Smav	SPA_FEATURE_SKEIN,
57290757Smav	SPA_FEATURE_EDONR,
58290757Smav#endif
59263390Sdelphij	SPA_FEATURES
60263390Sdelphij} spa_feature_t;
61263390Sdelphij
62263397Sdelphij#define	SPA_FEATURE_DISABLED	(-1ULL)
63263397Sdelphij
64288572Smavtypedef enum zfeature_flags {
65288572Smav	/* Can open pool readonly even if this feature is not supported. */
66288572Smav	ZFEATURE_FLAG_READONLY_COMPAT =		(1 << 0),
67288572Smav	/* Is this feature necessary to read the MOS? */
68288572Smav	ZFEATURE_FLAG_MOS =			(1 << 1),
69288572Smav	/* Activate this feature at the same time it is enabled. */
70288572Smav	ZFEATURE_FLAG_ACTIVATE_ON_ENABLE =	(1 << 2),
71288572Smav	/* Each dataset has a field set if it has ever used this feature. */
72288572Smav	ZFEATURE_FLAG_PER_DATASET =		(1 << 3)
73288572Smav} zfeature_flags_t;
74288572Smav
75236884Smmtypedef struct zfeature_info {
76263390Sdelphij	spa_feature_t fi_feature;
77236884Smm	const char *fi_uname;	/* User-facing feature name */
78236884Smm	const char *fi_guid;	/* On-disk feature identifier */
79236884Smm	const char *fi_desc;	/* Feature description */
80288572Smav	zfeature_flags_t fi_flags;
81263390Sdelphij	/* array of dependencies, terminated by SPA_FEATURE_NONE */
82263390Sdelphij	const spa_feature_t *fi_depends;
83236884Smm} zfeature_info_t;
84236884Smm
85268649Sdelphijtypedef int (zfeature_func_t)(zfeature_info_t *, void *);
86236884Smm
87236884Smm#define	ZFS_FEATURE_DEBUG
88236884Smm
89236884Smmextern zfeature_info_t spa_feature_table[SPA_FEATURES];
90236884Smm
91236884Smmextern boolean_t zfeature_is_valid_guid(const char *);
92236884Smm
93236884Smmextern boolean_t zfeature_is_supported(const char *);
94268649Sdelphijextern int zfeature_lookup_name(const char *, spa_feature_t *);
95268649Sdelphijextern boolean_t zfeature_depends_on(spa_feature_t, spa_feature_t);
96236884Smm
97236884Smmextern void zpool_feature_init(void);
98236884Smm
99236884Smm#ifdef	__cplusplus
100236884Smm}
101236884Smm#endif
102236884Smm
103236884Smm#endif	/* _ZFEATURE_COMMON_H */
104