xref: /freebsd/sys/contrib/openzfs/module/zcommon/zfeature_common.c (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
24  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
26  * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
27  * Copyright (c) 2017, Intel Corporation.
28  * Copyright (c) 2019, Klara Inc.
29  * Copyright (c) 2019, Allan Jude
30  */
31 
32 #ifndef _KERNEL
33 #include <errno.h>
34 #include <string.h>
35 #include <sys/stat.h>
36 #endif
37 #include <sys/debug.h>
38 #include <sys/fs/zfs.h>
39 #include <sys/inttypes.h>
40 #include <sys/types.h>
41 #include <sys/param.h>
42 #include <sys/zfs_sysfs.h>
43 #include "zfeature_common.h"
44 
45 /*
46  * Set to disable all feature checks while opening pools, allowing pools with
47  * unsupported features to be opened. Set for testing only.
48  */
49 boolean_t zfeature_checks_disable = B_FALSE;
50 
51 zfeature_info_t spa_feature_table[SPA_FEATURES];
52 
53 /*
54  * Valid characters for feature guids. This list is mainly for aesthetic
55  * purposes and could be expanded in the future. There are different allowed
56  * characters in the guids reverse dns portion (before the colon) and its
57  * short name (after the colon).
58  */
59 static int
60 valid_char(char c, boolean_t after_colon)
61 {
62 	return ((c >= 'a' && c <= 'z') ||
63 	    (c >= '0' && c <= '9') ||
64 	    (after_colon && c == '_') ||
65 	    (!after_colon && (c == '.' || c == '-')));
66 }
67 
68 /*
69  * Every feature guid must contain exactly one colon which separates a reverse
70  * dns organization name from the feature's "short" name (e.g.
71  * "com.company:feature_name").
72  */
73 boolean_t
74 zfeature_is_valid_guid(const char *name)
75 {
76 	int i;
77 	boolean_t has_colon = B_FALSE;
78 
79 	i = 0;
80 	while (name[i] != '\0') {
81 		char c = name[i++];
82 		if (c == ':') {
83 			if (has_colon)
84 				return (B_FALSE);
85 			has_colon = B_TRUE;
86 			continue;
87 		}
88 		if (!valid_char(c, has_colon))
89 			return (B_FALSE);
90 	}
91 
92 	return (has_colon);
93 }
94 
95 boolean_t
96 zfeature_is_supported(const char *guid)
97 {
98 	if (zfeature_checks_disable)
99 		return (B_TRUE);
100 
101 	for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
102 		zfeature_info_t *feature = &spa_feature_table[i];
103 		if (!feature->fi_zfs_mod_supported)
104 			continue;
105 		if (strcmp(guid, feature->fi_guid) == 0)
106 			return (B_TRUE);
107 	}
108 	return (B_FALSE);
109 }
110 
111 int
112 zfeature_lookup_guid(const char *guid, spa_feature_t *res)
113 {
114 	for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
115 		zfeature_info_t *feature = &spa_feature_table[i];
116 		if (!feature->fi_zfs_mod_supported)
117 			continue;
118 		if (strcmp(guid, feature->fi_guid) == 0) {
119 			if (res != NULL)
120 				*res = i;
121 			return (0);
122 		}
123 	}
124 
125 	return (ENOENT);
126 }
127 
128 int
129 zfeature_lookup_name(const char *name, spa_feature_t *res)
130 {
131 	for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
132 		zfeature_info_t *feature = &spa_feature_table[i];
133 		if (!feature->fi_zfs_mod_supported)
134 			continue;
135 		if (strcmp(name, feature->fi_uname) == 0) {
136 			if (res != NULL)
137 				*res = i;
138 			return (0);
139 		}
140 	}
141 
142 	return (ENOENT);
143 }
144 
145 boolean_t
146 zfeature_depends_on(spa_feature_t fid, spa_feature_t check)
147 {
148 	zfeature_info_t *feature = &spa_feature_table[fid];
149 
150 	for (int i = 0; feature->fi_depends[i] != SPA_FEATURE_NONE; i++) {
151 		if (feature->fi_depends[i] == check)
152 			return (B_TRUE);
153 	}
154 	return (B_FALSE);
155 }
156 
157 static boolean_t
158 deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature)
159 {
160 	for (int i = 0; deps[i] != SPA_FEATURE_NONE; i++)
161 		if (deps[i] == feature)
162 			return (B_TRUE);
163 
164 	return (B_FALSE);
165 }
166 
167 #if !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD)
168 static boolean_t
169 zfs_mod_supported_impl(const char *scope, const char *name, const char *sysfs)
170 {
171 	boolean_t supported = B_FALSE;
172 	char *path;
173 
174 	int len = asprintf(&path, "%s%s%s%s%s", sysfs,
175 	    scope == NULL ? "" : "/", scope == NULL ? "" : scope,
176 	    name == NULL ? "" : "/", name == NULL ? "" : name);
177 	if (len > 0) {
178 		struct stat64 statbuf;
179 		supported = !!(stat64(path, &statbuf) == 0);
180 		free(path);
181 	}
182 
183 	return (supported);
184 }
185 
186 boolean_t
187 zfs_mod_supported(const char *scope, const char *name)
188 {
189 	boolean_t supported;
190 
191 	/*
192 	 * Check both the primary and alternate sysfs locations to determine
193 	 * if the required functionality is supported.
194 	 */
195 	supported = (zfs_mod_supported_impl(scope, name, ZFS_SYSFS_DIR) ||
196 	    zfs_mod_supported_impl(scope, name, ZFS_SYSFS_ALT_DIR));
197 
198 	/*
199 	 * For backwards compatibility with kernel modules that predate
200 	 * supported feature/property checking.  Report the feature/property
201 	 * as supported if the kernel module is loaded but the requested
202 	 * scope directory does not exist.
203 	 */
204 	if (supported == B_FALSE) {
205 		struct stat64 statbuf;
206 		if ((stat64(ZFS_SYSFS_DIR, &statbuf) == 0) &&
207 		    !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_DIR) &&
208 		    !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_ALT_DIR)) {
209 			supported = B_TRUE;
210 		}
211 	}
212 
213 	return (supported);
214 }
215 #endif
216 
217 static boolean_t
218 zfs_mod_supported_feature(const char *name)
219 {
220 	/*
221 	 * The zfs module spa_feature_table[], whether in-kernel or in
222 	 * libzpool, always supports all the features. libzfs needs to
223 	 * query the running module, via sysfs, to determine which
224 	 * features are supported.
225 	 *
226 	 * The equivalent _can_ be done on FreeBSD by way of the sysctl
227 	 * tree, but this has not been done yet.  Therefore, we return
228 	 * that all features except edonr are supported.
229 	 */
230 #if defined(__FreeBSD__)
231 	if (strcmp(name, "org.illumos:edonr") == 0)
232 		return (B_FALSE);
233 	else
234 		return (B_TRUE);
235 #elif defined(_KERNEL) || defined(LIB_ZPOOL_BUILD)
236 	return (B_TRUE);
237 #else
238 	return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name));
239 #endif
240 }
241 
242 static void
243 zfeature_register(spa_feature_t fid, const char *guid, const char *name,
244     const char *desc, zfeature_flags_t flags, zfeature_type_t type,
245     const spa_feature_t *deps)
246 {
247 	zfeature_info_t *feature = &spa_feature_table[fid];
248 	static spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
249 
250 	ASSERT(name != NULL);
251 	ASSERT(desc != NULL);
252 	ASSERT((flags & ZFEATURE_FLAG_READONLY_COMPAT) == 0 ||
253 	    (flags & ZFEATURE_FLAG_MOS) == 0);
254 	ASSERT3U(fid, <, SPA_FEATURES);
255 	ASSERT(zfeature_is_valid_guid(guid));
256 
257 	if (deps == NULL)
258 		deps = nodeps;
259 
260 	VERIFY(((flags & ZFEATURE_FLAG_PER_DATASET) == 0) ||
261 	    (deps_contains_feature(deps, SPA_FEATURE_EXTENSIBLE_DATASET)));
262 
263 	feature->fi_feature = fid;
264 	feature->fi_guid = guid;
265 	feature->fi_uname = name;
266 	feature->fi_desc = desc;
267 	feature->fi_flags = flags;
268 	feature->fi_type = type;
269 	feature->fi_depends = deps;
270 	feature->fi_zfs_mod_supported = zfs_mod_supported_feature(guid);
271 }
272 
273 /*
274  * Every feature has a GUID of the form com.example:feature_name.  The
275  * reversed DNS name ensures that the feature's GUID is unique across all ZFS
276  * implementations.  This allows companies to independently develop and
277  * release features.  Examples include org.delphix and org.datto.  Previously,
278  * features developed on one implementation have used that implementation's
279  * domain name (e.g. org.illumos and org.zfsonlinux).  Use of the org.openzfs
280  * domain name is recommended for new features which are developed by the
281  * OpenZFS community and its platforms.  This domain may optionally be used by
282  * companies developing features for initial release through an OpenZFS
283  * implementation.  Use of the org.openzfs domain requires reserving the
284  * feature name in advance with the OpenZFS project.
285  */
286 void
287 zpool_feature_init(void)
288 {
289 	zfeature_register(SPA_FEATURE_ASYNC_DESTROY,
290 	    "com.delphix:async_destroy", "async_destroy",
291 	    "Destroy filesystems asynchronously.",
292 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
293 
294 	zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
295 	    "com.delphix:empty_bpobj", "empty_bpobj",
296 	    "Snapshots use less space.",
297 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
298 
299 	zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
300 	    "org.illumos:lz4_compress", "lz4_compress",
301 	    "LZ4 compression algorithm support.",
302 	    ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL);
303 
304 	zfeature_register(SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
305 	    "com.joyent:multi_vdev_crash_dump", "multi_vdev_crash_dump",
306 	    "Crash dumps to multiple vdev pools.",
307 	    0, ZFEATURE_TYPE_BOOLEAN, NULL);
308 
309 	zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM,
310 	    "com.delphix:spacemap_histogram", "spacemap_histogram",
311 	    "Spacemaps maintain space histograms.",
312 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
313 
314 	zfeature_register(SPA_FEATURE_ENABLED_TXG,
315 	    "com.delphix:enabled_txg", "enabled_txg",
316 	    "Record txg at which a feature is enabled",
317 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
318 
319 	{
320 	static const spa_feature_t hole_birth_deps[] = {
321 		SPA_FEATURE_ENABLED_TXG,
322 		SPA_FEATURE_NONE
323 	};
324 	zfeature_register(SPA_FEATURE_HOLE_BIRTH,
325 	    "com.delphix:hole_birth", "hole_birth",
326 	    "Retain hole birth txg for more precise zfs send",
327 	    ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
328 	    ZFEATURE_TYPE_BOOLEAN, hole_birth_deps);
329 	}
330 
331 	zfeature_register(SPA_FEATURE_POOL_CHECKPOINT,
332 	    "com.delphix:zpool_checkpoint", "zpool_checkpoint",
333 	    "Pool state can be checkpointed, allowing rewind later.",
334 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
335 
336 	zfeature_register(SPA_FEATURE_SPACEMAP_V2,
337 	    "com.delphix:spacemap_v2", "spacemap_v2",
338 	    "Space maps representing large segments are more efficient.",
339 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
340 	    ZFEATURE_TYPE_BOOLEAN, NULL);
341 
342 	zfeature_register(SPA_FEATURE_EXTENSIBLE_DATASET,
343 	    "com.delphix:extensible_dataset", "extensible_dataset",
344 	    "Enhanced dataset functionality, used by other features.",
345 	    0, ZFEATURE_TYPE_BOOLEAN, NULL);
346 
347 	{
348 	static const spa_feature_t bookmarks_deps[] = {
349 		SPA_FEATURE_EXTENSIBLE_DATASET,
350 		SPA_FEATURE_NONE
351 	};
352 
353 	zfeature_register(SPA_FEATURE_BOOKMARKS,
354 	    "com.delphix:bookmarks", "bookmarks",
355 	    "\"zfs bookmark\" command",
356 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
357 	    bookmarks_deps);
358 	}
359 
360 	{
361 	static const spa_feature_t filesystem_limits_deps[] = {
362 		SPA_FEATURE_EXTENSIBLE_DATASET,
363 		SPA_FEATURE_NONE
364 	};
365 	zfeature_register(SPA_FEATURE_FS_SS_LIMIT,
366 	    "com.joyent:filesystem_limits", "filesystem_limits",
367 	    "Filesystem and snapshot limits.",
368 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
369 	    filesystem_limits_deps);
370 	}
371 
372 	zfeature_register(SPA_FEATURE_EMBEDDED_DATA,
373 	    "com.delphix:embedded_data", "embedded_data",
374 	    "Blocks which compress very well use even less space.",
375 	    ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
376 	    ZFEATURE_TYPE_BOOLEAN, NULL);
377 
378 	{
379 	static const spa_feature_t livelist_deps[] = {
380 		SPA_FEATURE_EXTENSIBLE_DATASET,
381 		SPA_FEATURE_NONE
382 	};
383 	zfeature_register(SPA_FEATURE_LIVELIST,
384 	    "com.delphix:livelist", "livelist",
385 	    "Improved clone deletion performance.",
386 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
387 	    livelist_deps);
388 	}
389 
390 	{
391 	static const spa_feature_t log_spacemap_deps[] = {
392 		SPA_FEATURE_SPACEMAP_V2,
393 		SPA_FEATURE_NONE
394 	};
395 	zfeature_register(SPA_FEATURE_LOG_SPACEMAP,
396 	    "com.delphix:log_spacemap", "log_spacemap",
397 	    "Log metaslab changes on a single spacemap and "
398 	    "flush them periodically.",
399 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
400 	    log_spacemap_deps);
401 	}
402 
403 	{
404 	static const spa_feature_t large_blocks_deps[] = {
405 		SPA_FEATURE_EXTENSIBLE_DATASET,
406 		SPA_FEATURE_NONE
407 	};
408 	zfeature_register(SPA_FEATURE_LARGE_BLOCKS,
409 	    "org.open-zfs:large_blocks", "large_blocks",
410 	    "Support for blocks larger than 128KB.",
411 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
412 	    large_blocks_deps);
413 	}
414 
415 	{
416 	static const spa_feature_t large_dnode_deps[] = {
417 		SPA_FEATURE_EXTENSIBLE_DATASET,
418 		SPA_FEATURE_NONE
419 	};
420 	zfeature_register(SPA_FEATURE_LARGE_DNODE,
421 	    "org.zfsonlinux:large_dnode", "large_dnode",
422 	    "Variable on-disk size of dnodes.",
423 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
424 	    large_dnode_deps);
425 	}
426 
427 	{
428 	static const spa_feature_t sha512_deps[] = {
429 		SPA_FEATURE_EXTENSIBLE_DATASET,
430 		SPA_FEATURE_NONE
431 	};
432 	zfeature_register(SPA_FEATURE_SHA512,
433 	    "org.illumos:sha512", "sha512",
434 	    "SHA-512/256 hash algorithm.",
435 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
436 	    sha512_deps);
437 	}
438 
439 	{
440 	static const spa_feature_t skein_deps[] = {
441 		SPA_FEATURE_EXTENSIBLE_DATASET,
442 		SPA_FEATURE_NONE
443 	};
444 	zfeature_register(SPA_FEATURE_SKEIN,
445 	    "org.illumos:skein", "skein",
446 	    "Skein hash algorithm.",
447 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
448 	    skein_deps);
449 	}
450 
451 	{
452 	static const spa_feature_t edonr_deps[] = {
453 		SPA_FEATURE_EXTENSIBLE_DATASET,
454 		SPA_FEATURE_NONE
455 	};
456 	zfeature_register(SPA_FEATURE_EDONR,
457 	    "org.illumos:edonr", "edonr",
458 	    "Edon-R hash algorithm.",
459 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
460 	    edonr_deps);
461 	}
462 
463 	{
464 	static const spa_feature_t redact_books_deps[] = {
465 		SPA_FEATURE_BOOKMARK_V2,
466 		SPA_FEATURE_EXTENSIBLE_DATASET,
467 		SPA_FEATURE_BOOKMARKS,
468 		SPA_FEATURE_NONE
469 	};
470 	zfeature_register(SPA_FEATURE_REDACTION_BOOKMARKS,
471 	    "com.delphix:redaction_bookmarks", "redaction_bookmarks",
472 	    "Support for bookmarks which store redaction lists for zfs "
473 	    "redacted send/recv.", 0, ZFEATURE_TYPE_BOOLEAN,
474 	    redact_books_deps);
475 	}
476 
477 	{
478 	static const spa_feature_t redact_datasets_deps[] = {
479 		SPA_FEATURE_EXTENSIBLE_DATASET,
480 		SPA_FEATURE_NONE
481 	};
482 	zfeature_register(SPA_FEATURE_REDACTED_DATASETS,
483 	    "com.delphix:redacted_datasets", "redacted_datasets", "Support for "
484 	    "redacted datasets, produced by receiving a redacted zfs send "
485 	    "stream.", ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_UINT64_ARRAY,
486 	    redact_datasets_deps);
487 	}
488 
489 	{
490 	static const spa_feature_t bookmark_written_deps[] = {
491 		SPA_FEATURE_BOOKMARK_V2,
492 		SPA_FEATURE_EXTENSIBLE_DATASET,
493 		SPA_FEATURE_BOOKMARKS,
494 		SPA_FEATURE_NONE
495 	};
496 	zfeature_register(SPA_FEATURE_BOOKMARK_WRITTEN,
497 	    "com.delphix:bookmark_written", "bookmark_written",
498 	    "Additional accounting, enabling the written#<bookmark> property"
499 	    "(space written since a bookmark), and estimates of send stream "
500 	    "sizes for incrementals from bookmarks.",
501 	    0, ZFEATURE_TYPE_BOOLEAN, bookmark_written_deps);
502 	}
503 
504 	zfeature_register(SPA_FEATURE_DEVICE_REMOVAL,
505 	    "com.delphix:device_removal", "device_removal",
506 	    "Top-level vdevs can be removed, reducing logical pool size.",
507 	    ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL);
508 
509 	{
510 	static const spa_feature_t obsolete_counts_deps[] = {
511 		SPA_FEATURE_EXTENSIBLE_DATASET,
512 		SPA_FEATURE_DEVICE_REMOVAL,
513 		SPA_FEATURE_NONE
514 	};
515 	zfeature_register(SPA_FEATURE_OBSOLETE_COUNTS,
516 	    "com.delphix:obsolete_counts", "obsolete_counts",
517 	    "Reduce memory used by removed devices when their blocks are "
518 	    "freed or remapped.",
519 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
520 	    obsolete_counts_deps);
521 	}
522 
523 	{
524 	static const spa_feature_t userobj_accounting_deps[] = {
525 		SPA_FEATURE_EXTENSIBLE_DATASET,
526 		SPA_FEATURE_NONE
527 	};
528 	zfeature_register(SPA_FEATURE_USEROBJ_ACCOUNTING,
529 	    "org.zfsonlinux:userobj_accounting", "userobj_accounting",
530 	    "User/Group object accounting.",
531 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
532 	    ZFEATURE_TYPE_BOOLEAN, userobj_accounting_deps);
533 	}
534 
535 	{
536 	static const spa_feature_t bookmark_v2_deps[] = {
537 		SPA_FEATURE_EXTENSIBLE_DATASET,
538 		SPA_FEATURE_BOOKMARKS,
539 		SPA_FEATURE_NONE
540 	};
541 	zfeature_register(SPA_FEATURE_BOOKMARK_V2,
542 	    "com.datto:bookmark_v2", "bookmark_v2",
543 	    "Support for larger bookmarks",
544 	    0, ZFEATURE_TYPE_BOOLEAN, bookmark_v2_deps);
545 	}
546 
547 	{
548 	static const spa_feature_t encryption_deps[] = {
549 		SPA_FEATURE_EXTENSIBLE_DATASET,
550 		SPA_FEATURE_BOOKMARK_V2,
551 		SPA_FEATURE_NONE
552 	};
553 	zfeature_register(SPA_FEATURE_ENCRYPTION,
554 	    "com.datto:encryption", "encryption",
555 	    "Support for dataset level encryption",
556 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
557 	    encryption_deps);
558 	}
559 
560 	{
561 	static const spa_feature_t project_quota_deps[] = {
562 		SPA_FEATURE_EXTENSIBLE_DATASET,
563 		SPA_FEATURE_NONE
564 	};
565 	zfeature_register(SPA_FEATURE_PROJECT_QUOTA,
566 	    "org.zfsonlinux:project_quota", "project_quota",
567 	    "space/object accounting based on project ID.",
568 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
569 	    ZFEATURE_TYPE_BOOLEAN, project_quota_deps);
570 	}
571 
572 	zfeature_register(SPA_FEATURE_ALLOCATION_CLASSES,
573 	    "org.zfsonlinux:allocation_classes", "allocation_classes",
574 	    "Support for separate allocation classes.",
575 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
576 
577 	zfeature_register(SPA_FEATURE_RESILVER_DEFER,
578 	    "com.datto:resilver_defer", "resilver_defer",
579 	    "Support for deferring new resilvers when one is already running.",
580 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
581 
582 	zfeature_register(SPA_FEATURE_DEVICE_REBUILD,
583 	    "org.openzfs:device_rebuild", "device_rebuild",
584 	    "Support for sequential mirror/dRAID device rebuilds",
585 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
586 
587 	{
588 	static const spa_feature_t zstd_deps[] = {
589 		SPA_FEATURE_EXTENSIBLE_DATASET,
590 		SPA_FEATURE_NONE
591 	};
592 	zfeature_register(SPA_FEATURE_ZSTD_COMPRESS,
593 	    "org.freebsd:zstd_compress", "zstd_compress",
594 	    "zstd compression algorithm support.",
595 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, zstd_deps);
596 	}
597 
598 	zfeature_register(SPA_FEATURE_DRAID,
599 	    "org.openzfs:draid", "draid", "Support for distributed spare RAID",
600 	    ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL);
601 }
602 
603 #if defined(_KERNEL)
604 EXPORT_SYMBOL(zfeature_lookup_guid);
605 EXPORT_SYMBOL(zfeature_lookup_name);
606 EXPORT_SYMBOL(zfeature_is_supported);
607 EXPORT_SYMBOL(zfeature_is_valid_guid);
608 EXPORT_SYMBOL(zfeature_depends_on);
609 EXPORT_SYMBOL(zpool_feature_init);
610 EXPORT_SYMBOL(spa_feature_table);
611 #endif
612