xref: /freebsd/sys/contrib/openzfs/module/zcommon/zfeature_common.c (revision 681ce946f33e75c590e97c53076e86dff1fe8f4a)
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 are supported.
229 	 */
230 
231 #if defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) || defined(__FreeBSD__)
232 	(void) name;
233 	return (B_TRUE);
234 #else
235 	return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name));
236 #endif
237 }
238 
239 static void
240 zfeature_register(spa_feature_t fid, const char *guid, const char *name,
241     const char *desc, zfeature_flags_t flags, zfeature_type_t type,
242     const spa_feature_t *deps)
243 {
244 	zfeature_info_t *feature = &spa_feature_table[fid];
245 	static spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
246 
247 	ASSERT(name != NULL);
248 	ASSERT(desc != NULL);
249 	ASSERT((flags & ZFEATURE_FLAG_READONLY_COMPAT) == 0 ||
250 	    (flags & ZFEATURE_FLAG_MOS) == 0);
251 	ASSERT3U(fid, <, SPA_FEATURES);
252 	ASSERT(zfeature_is_valid_guid(guid));
253 
254 	if (deps == NULL)
255 		deps = nodeps;
256 
257 	VERIFY(((flags & ZFEATURE_FLAG_PER_DATASET) == 0) ||
258 	    (deps_contains_feature(deps, SPA_FEATURE_EXTENSIBLE_DATASET)));
259 
260 	feature->fi_feature = fid;
261 	feature->fi_guid = guid;
262 	feature->fi_uname = name;
263 	feature->fi_desc = desc;
264 	feature->fi_flags = flags;
265 	feature->fi_type = type;
266 	feature->fi_depends = deps;
267 	feature->fi_zfs_mod_supported = zfs_mod_supported_feature(guid);
268 }
269 
270 /*
271  * Every feature has a GUID of the form com.example:feature_name.  The
272  * reversed DNS name ensures that the feature's GUID is unique across all ZFS
273  * implementations.  This allows companies to independently develop and
274  * release features.  Examples include org.delphix and org.datto.  Previously,
275  * features developed on one implementation have used that implementation's
276  * domain name (e.g. org.illumos and org.zfsonlinux).  Use of the org.openzfs
277  * domain name is recommended for new features which are developed by the
278  * OpenZFS community and its platforms.  This domain may optionally be used by
279  * companies developing features for initial release through an OpenZFS
280  * implementation.  Use of the org.openzfs domain requires reserving the
281  * feature name in advance with the OpenZFS project.
282  */
283 void
284 zpool_feature_init(void)
285 {
286 	zfeature_register(SPA_FEATURE_ASYNC_DESTROY,
287 	    "com.delphix:async_destroy", "async_destroy",
288 	    "Destroy filesystems asynchronously.",
289 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
290 
291 	zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
292 	    "com.delphix:empty_bpobj", "empty_bpobj",
293 	    "Snapshots use less space.",
294 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
295 
296 	zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
297 	    "org.illumos:lz4_compress", "lz4_compress",
298 	    "LZ4 compression algorithm support.",
299 	    ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL);
300 
301 	zfeature_register(SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
302 	    "com.joyent:multi_vdev_crash_dump", "multi_vdev_crash_dump",
303 	    "Crash dumps to multiple vdev pools.",
304 	    0, ZFEATURE_TYPE_BOOLEAN, NULL);
305 
306 	zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM,
307 	    "com.delphix:spacemap_histogram", "spacemap_histogram",
308 	    "Spacemaps maintain space histograms.",
309 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
310 
311 	zfeature_register(SPA_FEATURE_ENABLED_TXG,
312 	    "com.delphix:enabled_txg", "enabled_txg",
313 	    "Record txg at which a feature is enabled",
314 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
315 
316 	{
317 	static const spa_feature_t hole_birth_deps[] = {
318 		SPA_FEATURE_ENABLED_TXG,
319 		SPA_FEATURE_NONE
320 	};
321 	zfeature_register(SPA_FEATURE_HOLE_BIRTH,
322 	    "com.delphix:hole_birth", "hole_birth",
323 	    "Retain hole birth txg for more precise zfs send",
324 	    ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
325 	    ZFEATURE_TYPE_BOOLEAN, hole_birth_deps);
326 	}
327 
328 	zfeature_register(SPA_FEATURE_POOL_CHECKPOINT,
329 	    "com.delphix:zpool_checkpoint", "zpool_checkpoint",
330 	    "Pool state can be checkpointed, allowing rewind later.",
331 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
332 
333 	zfeature_register(SPA_FEATURE_SPACEMAP_V2,
334 	    "com.delphix:spacemap_v2", "spacemap_v2",
335 	    "Space maps representing large segments are more efficient.",
336 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
337 	    ZFEATURE_TYPE_BOOLEAN, NULL);
338 
339 	zfeature_register(SPA_FEATURE_EXTENSIBLE_DATASET,
340 	    "com.delphix:extensible_dataset", "extensible_dataset",
341 	    "Enhanced dataset functionality, used by other features.",
342 	    0, ZFEATURE_TYPE_BOOLEAN, NULL);
343 
344 	{
345 	static const spa_feature_t bookmarks_deps[] = {
346 		SPA_FEATURE_EXTENSIBLE_DATASET,
347 		SPA_FEATURE_NONE
348 	};
349 
350 	zfeature_register(SPA_FEATURE_BOOKMARKS,
351 	    "com.delphix:bookmarks", "bookmarks",
352 	    "\"zfs bookmark\" command",
353 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
354 	    bookmarks_deps);
355 	}
356 
357 	{
358 	static const spa_feature_t filesystem_limits_deps[] = {
359 		SPA_FEATURE_EXTENSIBLE_DATASET,
360 		SPA_FEATURE_NONE
361 	};
362 	zfeature_register(SPA_FEATURE_FS_SS_LIMIT,
363 	    "com.joyent:filesystem_limits", "filesystem_limits",
364 	    "Filesystem and snapshot limits.",
365 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
366 	    filesystem_limits_deps);
367 	}
368 
369 	zfeature_register(SPA_FEATURE_EMBEDDED_DATA,
370 	    "com.delphix:embedded_data", "embedded_data",
371 	    "Blocks which compress very well use even less space.",
372 	    ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
373 	    ZFEATURE_TYPE_BOOLEAN, NULL);
374 
375 	{
376 	static const spa_feature_t livelist_deps[] = {
377 		SPA_FEATURE_EXTENSIBLE_DATASET,
378 		SPA_FEATURE_NONE
379 	};
380 	zfeature_register(SPA_FEATURE_LIVELIST,
381 	    "com.delphix:livelist", "livelist",
382 	    "Improved clone deletion performance.",
383 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
384 	    livelist_deps);
385 	}
386 
387 	{
388 	static const spa_feature_t log_spacemap_deps[] = {
389 		SPA_FEATURE_SPACEMAP_V2,
390 		SPA_FEATURE_NONE
391 	};
392 	zfeature_register(SPA_FEATURE_LOG_SPACEMAP,
393 	    "com.delphix:log_spacemap", "log_spacemap",
394 	    "Log metaslab changes on a single spacemap and "
395 	    "flush them periodically.",
396 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
397 	    log_spacemap_deps);
398 	}
399 
400 	{
401 	static const spa_feature_t large_blocks_deps[] = {
402 		SPA_FEATURE_EXTENSIBLE_DATASET,
403 		SPA_FEATURE_NONE
404 	};
405 	zfeature_register(SPA_FEATURE_LARGE_BLOCKS,
406 	    "org.open-zfs:large_blocks", "large_blocks",
407 	    "Support for blocks larger than 128KB.",
408 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
409 	    large_blocks_deps);
410 	}
411 
412 	{
413 	static const spa_feature_t large_dnode_deps[] = {
414 		SPA_FEATURE_EXTENSIBLE_DATASET,
415 		SPA_FEATURE_NONE
416 	};
417 	zfeature_register(SPA_FEATURE_LARGE_DNODE,
418 	    "org.zfsonlinux:large_dnode", "large_dnode",
419 	    "Variable on-disk size of dnodes.",
420 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
421 	    large_dnode_deps);
422 	}
423 
424 	{
425 	static const spa_feature_t sha512_deps[] = {
426 		SPA_FEATURE_EXTENSIBLE_DATASET,
427 		SPA_FEATURE_NONE
428 	};
429 	zfeature_register(SPA_FEATURE_SHA512,
430 	    "org.illumos:sha512", "sha512",
431 	    "SHA-512/256 hash algorithm.",
432 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
433 	    sha512_deps);
434 	}
435 
436 	{
437 	static const spa_feature_t skein_deps[] = {
438 		SPA_FEATURE_EXTENSIBLE_DATASET,
439 		SPA_FEATURE_NONE
440 	};
441 	zfeature_register(SPA_FEATURE_SKEIN,
442 	    "org.illumos:skein", "skein",
443 	    "Skein hash algorithm.",
444 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
445 	    skein_deps);
446 	}
447 
448 	{
449 	static const spa_feature_t edonr_deps[] = {
450 		SPA_FEATURE_EXTENSIBLE_DATASET,
451 		SPA_FEATURE_NONE
452 	};
453 	zfeature_register(SPA_FEATURE_EDONR,
454 	    "org.illumos:edonr", "edonr",
455 	    "Edon-R hash algorithm.",
456 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
457 	    edonr_deps);
458 	}
459 
460 	{
461 	static const spa_feature_t redact_books_deps[] = {
462 		SPA_FEATURE_BOOKMARK_V2,
463 		SPA_FEATURE_EXTENSIBLE_DATASET,
464 		SPA_FEATURE_BOOKMARKS,
465 		SPA_FEATURE_NONE
466 	};
467 	zfeature_register(SPA_FEATURE_REDACTION_BOOKMARKS,
468 	    "com.delphix:redaction_bookmarks", "redaction_bookmarks",
469 	    "Support for bookmarks which store redaction lists for zfs "
470 	    "redacted send/recv.", 0, ZFEATURE_TYPE_BOOLEAN,
471 	    redact_books_deps);
472 	}
473 
474 	{
475 	static const spa_feature_t redact_datasets_deps[] = {
476 		SPA_FEATURE_EXTENSIBLE_DATASET,
477 		SPA_FEATURE_NONE
478 	};
479 	zfeature_register(SPA_FEATURE_REDACTED_DATASETS,
480 	    "com.delphix:redacted_datasets", "redacted_datasets", "Support for "
481 	    "redacted datasets, produced by receiving a redacted zfs send "
482 	    "stream.", ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_UINT64_ARRAY,
483 	    redact_datasets_deps);
484 	}
485 
486 	{
487 	static const spa_feature_t bookmark_written_deps[] = {
488 		SPA_FEATURE_BOOKMARK_V2,
489 		SPA_FEATURE_EXTENSIBLE_DATASET,
490 		SPA_FEATURE_BOOKMARKS,
491 		SPA_FEATURE_NONE
492 	};
493 	zfeature_register(SPA_FEATURE_BOOKMARK_WRITTEN,
494 	    "com.delphix:bookmark_written", "bookmark_written",
495 	    "Additional accounting, enabling the written#<bookmark> property"
496 	    "(space written since a bookmark), and estimates of send stream "
497 	    "sizes for incrementals from bookmarks.",
498 	    0, ZFEATURE_TYPE_BOOLEAN, bookmark_written_deps);
499 	}
500 
501 	zfeature_register(SPA_FEATURE_DEVICE_REMOVAL,
502 	    "com.delphix:device_removal", "device_removal",
503 	    "Top-level vdevs can be removed, reducing logical pool size.",
504 	    ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL);
505 
506 	{
507 	static const spa_feature_t obsolete_counts_deps[] = {
508 		SPA_FEATURE_EXTENSIBLE_DATASET,
509 		SPA_FEATURE_DEVICE_REMOVAL,
510 		SPA_FEATURE_NONE
511 	};
512 	zfeature_register(SPA_FEATURE_OBSOLETE_COUNTS,
513 	    "com.delphix:obsolete_counts", "obsolete_counts",
514 	    "Reduce memory used by removed devices when their blocks are "
515 	    "freed or remapped.",
516 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
517 	    obsolete_counts_deps);
518 	}
519 
520 	{
521 	static const spa_feature_t userobj_accounting_deps[] = {
522 		SPA_FEATURE_EXTENSIBLE_DATASET,
523 		SPA_FEATURE_NONE
524 	};
525 	zfeature_register(SPA_FEATURE_USEROBJ_ACCOUNTING,
526 	    "org.zfsonlinux:userobj_accounting", "userobj_accounting",
527 	    "User/Group object accounting.",
528 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
529 	    ZFEATURE_TYPE_BOOLEAN, userobj_accounting_deps);
530 	}
531 
532 	{
533 	static const spa_feature_t bookmark_v2_deps[] = {
534 		SPA_FEATURE_EXTENSIBLE_DATASET,
535 		SPA_FEATURE_BOOKMARKS,
536 		SPA_FEATURE_NONE
537 	};
538 	zfeature_register(SPA_FEATURE_BOOKMARK_V2,
539 	    "com.datto:bookmark_v2", "bookmark_v2",
540 	    "Support for larger bookmarks",
541 	    0, ZFEATURE_TYPE_BOOLEAN, bookmark_v2_deps);
542 	}
543 
544 	{
545 	static const spa_feature_t encryption_deps[] = {
546 		SPA_FEATURE_EXTENSIBLE_DATASET,
547 		SPA_FEATURE_BOOKMARK_V2,
548 		SPA_FEATURE_NONE
549 	};
550 	zfeature_register(SPA_FEATURE_ENCRYPTION,
551 	    "com.datto:encryption", "encryption",
552 	    "Support for dataset level encryption",
553 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
554 	    encryption_deps);
555 	}
556 
557 	{
558 	static const spa_feature_t project_quota_deps[] = {
559 		SPA_FEATURE_EXTENSIBLE_DATASET,
560 		SPA_FEATURE_NONE
561 	};
562 	zfeature_register(SPA_FEATURE_PROJECT_QUOTA,
563 	    "org.zfsonlinux:project_quota", "project_quota",
564 	    "space/object accounting based on project ID.",
565 	    ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
566 	    ZFEATURE_TYPE_BOOLEAN, project_quota_deps);
567 	}
568 
569 	zfeature_register(SPA_FEATURE_ALLOCATION_CLASSES,
570 	    "org.zfsonlinux:allocation_classes", "allocation_classes",
571 	    "Support for separate allocation classes.",
572 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
573 
574 	zfeature_register(SPA_FEATURE_RESILVER_DEFER,
575 	    "com.datto:resilver_defer", "resilver_defer",
576 	    "Support for deferring new resilvers when one is already running.",
577 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
578 
579 	zfeature_register(SPA_FEATURE_DEVICE_REBUILD,
580 	    "org.openzfs:device_rebuild", "device_rebuild",
581 	    "Support for sequential mirror/dRAID device rebuilds",
582 	    ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL);
583 
584 	{
585 	static const spa_feature_t zstd_deps[] = {
586 		SPA_FEATURE_EXTENSIBLE_DATASET,
587 		SPA_FEATURE_NONE
588 	};
589 	zfeature_register(SPA_FEATURE_ZSTD_COMPRESS,
590 	    "org.freebsd:zstd_compress", "zstd_compress",
591 	    "zstd compression algorithm support.",
592 	    ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, zstd_deps);
593 	}
594 
595 	zfeature_register(SPA_FEATURE_DRAID,
596 	    "org.openzfs:draid", "draid", "Support for distributed spare RAID",
597 	    ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL);
598 }
599 
600 #if defined(_KERNEL)
601 EXPORT_SYMBOL(zfeature_lookup_guid);
602 EXPORT_SYMBOL(zfeature_lookup_name);
603 EXPORT_SYMBOL(zfeature_is_supported);
604 EXPORT_SYMBOL(zfeature_is_valid_guid);
605 EXPORT_SYMBOL(zfeature_depends_on);
606 EXPORT_SYMBOL(zpool_feature_init);
607 EXPORT_SYMBOL(spa_feature_table);
608 #endif
609