zpool/zfs: restore -V & --version options
[zfs.git] / module / zcommon / zfeature_common.c
blob96f0086d785813e39bc97fcf468766ea4e0a4dd5
1 /*
2 * CDDL HEADER START
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.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
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]
19 * CDDL HEADER END
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, 2024, Klara, Inc.
29 * Copyright (c) 2019, Allan Jude
32 #ifndef _KERNEL
33 #include <errno.h>
34 #include <string.h>
35 #include <dirent.h>
36 #include <search.h>
37 #include <sys/stat.h>
38 #endif
39 #include <sys/debug.h>
40 #include <sys/fs/zfs.h>
41 #include <sys/inttypes.h>
42 #include <sys/types.h>
43 #include <sys/param.h>
44 #include <sys/zfs_sysfs.h>
45 #include "zfeature_common.h"
48 * Set to disable all feature checks while opening pools, allowing pools with
49 * unsupported features to be opened. Set for testing only.
51 boolean_t zfeature_checks_disable = B_FALSE;
53 zfeature_info_t spa_feature_table[SPA_FEATURES];
56 * Valid characters for feature guids. This list is mainly for aesthetic
57 * purposes and could be expanded in the future. There are different allowed
58 * characters in the guids reverse dns portion (before the colon) and its
59 * short name (after the colon).
61 static int
62 valid_char(char c, boolean_t after_colon)
64 return ((c >= 'a' && c <= 'z') ||
65 (c >= '0' && c <= '9') ||
66 (after_colon && c == '_') ||
67 (!after_colon && (c == '.' || c == '-')));
71 * Every feature guid must contain exactly one colon which separates a reverse
72 * dns organization name from the feature's "short" name (e.g.
73 * "com.company:feature_name").
75 boolean_t
76 zfeature_is_valid_guid(const char *name)
78 int i;
79 boolean_t has_colon = B_FALSE;
81 i = 0;
82 while (name[i] != '\0') {
83 char c = name[i++];
84 if (c == ':') {
85 if (has_colon)
86 return (B_FALSE);
87 has_colon = B_TRUE;
88 continue;
90 if (!valid_char(c, has_colon))
91 return (B_FALSE);
94 return (has_colon);
97 boolean_t
98 zfeature_is_supported(const char *guid)
100 if (zfeature_checks_disable)
101 return (B_TRUE);
103 for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
104 zfeature_info_t *feature = &spa_feature_table[i];
105 if (!feature->fi_zfs_mod_supported)
106 continue;
107 if (strcmp(guid, feature->fi_guid) == 0)
108 return (B_TRUE);
110 return (B_FALSE);
114 zfeature_lookup_guid(const char *guid, spa_feature_t *res)
116 for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
117 zfeature_info_t *feature = &spa_feature_table[i];
118 if (!feature->fi_zfs_mod_supported)
119 continue;
120 if (strcmp(guid, feature->fi_guid) == 0) {
121 if (res != NULL)
122 *res = i;
123 return (0);
127 return (ENOENT);
131 zfeature_lookup_name(const char *name, spa_feature_t *res)
133 for (spa_feature_t i = 0; i < SPA_FEATURES; i++) {
134 zfeature_info_t *feature = &spa_feature_table[i];
135 if (!feature->fi_zfs_mod_supported)
136 continue;
137 if (strcmp(name, feature->fi_uname) == 0) {
138 if (res != NULL)
139 *res = i;
140 return (0);
144 return (ENOENT);
147 boolean_t
148 zfeature_depends_on(spa_feature_t fid, spa_feature_t check)
150 zfeature_info_t *feature = &spa_feature_table[fid];
152 for (int i = 0; feature->fi_depends[i] != SPA_FEATURE_NONE; i++) {
153 if (feature->fi_depends[i] == check)
154 return (B_TRUE);
156 return (B_FALSE);
159 static boolean_t
160 deps_contains_feature(const spa_feature_t *deps, const spa_feature_t feature)
162 for (int i = 0; deps[i] != SPA_FEATURE_NONE; i++)
163 if (deps[i] == feature)
164 return (B_TRUE);
166 return (B_FALSE);
169 #define STRCMP ((int(*)(const void *, const void *))&strcmp)
170 struct zfs_mod_supported_features {
171 void *tree;
172 boolean_t all_features;
175 struct zfs_mod_supported_features *
176 zfs_mod_list_supported(const char *scope)
178 #if defined(__FreeBSD__) || defined(_KERNEL) || defined(LIB_ZPOOL_BUILD)
179 (void) scope;
180 return (NULL);
181 #else
182 struct zfs_mod_supported_features *ret = calloc(1, sizeof (*ret));
183 if (ret == NULL)
184 return (NULL);
186 DIR *sysfs_dir = NULL;
187 char path[128];
189 if (snprintf(path, sizeof (path), "%s/%s",
190 ZFS_SYSFS_DIR, scope) < sizeof (path))
191 sysfs_dir = opendir(path);
192 if (sysfs_dir == NULL && errno == ENOENT) {
193 if (snprintf(path, sizeof (path), "%s/%s",
194 ZFS_SYSFS_ALT_DIR, scope) < sizeof (path))
195 sysfs_dir = opendir(path);
197 if (sysfs_dir == NULL) {
198 ret->all_features = errno == ENOENT &&
199 (access(ZFS_SYSFS_DIR, F_OK) == 0 ||
200 access(ZFS_SYSFS_ALT_DIR, F_OK) == 0);
201 return (ret);
204 struct dirent *node;
205 while ((node = readdir(sysfs_dir)) != NULL) {
206 if (strcmp(node->d_name, ".") == 0 ||
207 strcmp(node->d_name, "..") == 0)
208 continue;
210 char *name = strdup(node->d_name);
211 if (name == NULL) {
212 goto nomem;
215 if (tsearch(name, &ret->tree, STRCMP) == NULL) {
217 * Don't bother checking for duplicate entries:
218 * we're iterating a single directory.
220 free(name);
221 goto nomem;
225 end:
226 closedir(sysfs_dir);
227 return (ret);
229 nomem:
230 zfs_mod_list_supported_free(ret);
231 ret = NULL;
232 goto end;
233 #endif
236 void
237 zfs_mod_list_supported_free(struct zfs_mod_supported_features *list)
239 #if !defined(__FreeBSD__) && !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD)
240 if (list) {
241 tdestroy(list->tree, free);
242 free(list);
244 #else
245 (void) list;
246 #endif
249 #if !defined(_KERNEL) && !defined(LIB_ZPOOL_BUILD)
250 static boolean_t
251 zfs_mod_supported_impl(const char *scope, const char *name, const char *sysfs)
253 char path[128];
254 if (snprintf(path, sizeof (path), "%s%s%s%s%s", sysfs,
255 scope == NULL ? "" : "/", scope ?: "",
256 name == NULL ? "" : "/", name ?: "") < sizeof (path))
257 return (access(path, F_OK) == 0);
258 else
259 return (B_FALSE);
262 boolean_t
263 zfs_mod_supported(const char *scope, const char *name,
264 const struct zfs_mod_supported_features *sfeatures)
266 boolean_t supported;
268 if (sfeatures != NULL)
269 return (sfeatures->all_features ||
270 tfind(name, &sfeatures->tree, STRCMP));
273 * Check both the primary and alternate sysfs locations to determine
274 * if the required functionality is supported.
276 supported = (zfs_mod_supported_impl(scope, name, ZFS_SYSFS_DIR) ||
277 zfs_mod_supported_impl(scope, name, ZFS_SYSFS_ALT_DIR));
280 * For backwards compatibility with kernel modules that predate
281 * supported feature/property checking. Report the feature/property
282 * as supported if the kernel module is loaded but the requested
283 * scope directory does not exist.
285 if (supported == B_FALSE) {
286 if ((access(ZFS_SYSFS_DIR, F_OK) == 0 &&
287 !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_DIR)) ||
288 (access(ZFS_SYSFS_ALT_DIR, F_OK) == 0 &&
289 !zfs_mod_supported_impl(scope, NULL, ZFS_SYSFS_ALT_DIR))) {
290 supported = B_TRUE;
294 return (supported);
296 #endif
298 static boolean_t
299 zfs_mod_supported_feature(const char *name,
300 const struct zfs_mod_supported_features *sfeatures)
303 * The zfs module spa_feature_table[], whether in-kernel or in
304 * libzpool, always supports all the features. libzfs needs to
305 * query the running module, via sysfs, to determine which
306 * features are supported.
308 * The equivalent _can_ be done on FreeBSD by way of the sysctl
309 * tree, but this has not been done yet. Therefore, we return
310 * that all features are supported.
313 #if defined(_KERNEL) || defined(LIB_ZPOOL_BUILD) || defined(__FreeBSD__)
314 (void) name, (void) sfeatures;
315 return (B_TRUE);
316 #else
317 return (zfs_mod_supported(ZFS_SYSFS_POOL_FEATURES, name, sfeatures));
318 #endif
321 static void
322 zfeature_register(spa_feature_t fid, const char *guid, const char *name,
323 const char *desc, zfeature_flags_t flags, zfeature_type_t type,
324 const spa_feature_t *deps,
325 const struct zfs_mod_supported_features *sfeatures)
327 zfeature_info_t *feature = &spa_feature_table[fid];
328 static const spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
330 ASSERT(name != NULL);
331 ASSERT(desc != NULL);
332 ASSERT((flags & ZFEATURE_FLAG_READONLY_COMPAT) == 0 ||
333 (flags & ZFEATURE_FLAG_MOS) == 0);
334 ASSERT3U(fid, <, SPA_FEATURES);
335 ASSERT(zfeature_is_valid_guid(guid));
337 if (deps == NULL)
338 deps = nodeps;
340 VERIFY(((flags & ZFEATURE_FLAG_PER_DATASET) == 0) ||
341 (deps_contains_feature(deps, SPA_FEATURE_EXTENSIBLE_DATASET)));
343 feature->fi_feature = fid;
344 feature->fi_guid = guid;
345 feature->fi_uname = name;
346 feature->fi_desc = desc;
347 feature->fi_flags = flags;
348 feature->fi_type = type;
349 feature->fi_depends = deps;
350 feature->fi_zfs_mod_supported =
351 zfs_mod_supported_feature(guid, sfeatures);
355 * Every feature has a GUID of the form com.example:feature_name. The
356 * reversed DNS name ensures that the feature's GUID is unique across all ZFS
357 * implementations. This allows companies to independently develop and
358 * release features. Examples include org.delphix and org.datto. Previously,
359 * features developed on one implementation have used that implementation's
360 * domain name (e.g. org.illumos and org.zfsonlinux). Use of the org.openzfs
361 * domain name is recommended for new features which are developed by the
362 * OpenZFS community and its platforms. This domain may optionally be used by
363 * companies developing features for initial release through an OpenZFS
364 * implementation. Use of the org.openzfs domain requires reserving the
365 * feature name in advance with the OpenZFS project.
367 void
368 zpool_feature_init(void)
370 struct zfs_mod_supported_features *sfeatures =
371 zfs_mod_list_supported(ZFS_SYSFS_POOL_FEATURES);
373 zfeature_register(SPA_FEATURE_ASYNC_DESTROY,
374 "com.delphix:async_destroy", "async_destroy",
375 "Destroy filesystems asynchronously.",
376 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
377 sfeatures);
379 zfeature_register(SPA_FEATURE_EMPTY_BPOBJ,
380 "com.delphix:empty_bpobj", "empty_bpobj",
381 "Snapshots use less space.",
382 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
383 sfeatures);
385 zfeature_register(SPA_FEATURE_LZ4_COMPRESS,
386 "org.illumos:lz4_compress", "lz4_compress",
387 "LZ4 compression algorithm support.",
388 ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL,
389 sfeatures);
391 zfeature_register(SPA_FEATURE_MULTI_VDEV_CRASH_DUMP,
392 "com.joyent:multi_vdev_crash_dump", "multi_vdev_crash_dump",
393 "Crash dumps to multiple vdev pools.",
394 0, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
396 zfeature_register(SPA_FEATURE_SPACEMAP_HISTOGRAM,
397 "com.delphix:spacemap_histogram", "spacemap_histogram",
398 "Spacemaps maintain space histograms.",
399 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
400 sfeatures);
402 zfeature_register(SPA_FEATURE_ENABLED_TXG,
403 "com.delphix:enabled_txg", "enabled_txg",
404 "Record txg at which a feature is enabled",
405 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
406 sfeatures);
409 static const spa_feature_t hole_birth_deps[] = {
410 SPA_FEATURE_ENABLED_TXG,
411 SPA_FEATURE_NONE
413 zfeature_register(SPA_FEATURE_HOLE_BIRTH,
414 "com.delphix:hole_birth", "hole_birth",
415 "Retain hole birth txg for more precise zfs send",
416 ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
417 ZFEATURE_TYPE_BOOLEAN, hole_birth_deps, sfeatures);
420 zfeature_register(SPA_FEATURE_POOL_CHECKPOINT,
421 "com.delphix:zpool_checkpoint", "zpool_checkpoint",
422 "Pool state can be checkpointed, allowing rewind later.",
423 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
424 sfeatures);
426 zfeature_register(SPA_FEATURE_SPACEMAP_V2,
427 "com.delphix:spacemap_v2", "spacemap_v2",
428 "Space maps representing large segments are more efficient.",
429 ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
430 ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
432 zfeature_register(SPA_FEATURE_EXTENSIBLE_DATASET,
433 "com.delphix:extensible_dataset", "extensible_dataset",
434 "Enhanced dataset functionality, used by other features.",
435 0, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
438 static const spa_feature_t bookmarks_deps[] = {
439 SPA_FEATURE_EXTENSIBLE_DATASET,
440 SPA_FEATURE_NONE
443 zfeature_register(SPA_FEATURE_BOOKMARKS,
444 "com.delphix:bookmarks", "bookmarks",
445 "\"zfs bookmark\" command",
446 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
447 bookmarks_deps, sfeatures);
451 static const spa_feature_t filesystem_limits_deps[] = {
452 SPA_FEATURE_EXTENSIBLE_DATASET,
453 SPA_FEATURE_NONE
455 zfeature_register(SPA_FEATURE_FS_SS_LIMIT,
456 "com.joyent:filesystem_limits", "filesystem_limits",
457 "Filesystem and snapshot limits.",
458 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
459 filesystem_limits_deps, sfeatures);
462 zfeature_register(SPA_FEATURE_EMBEDDED_DATA,
463 "com.delphix:embedded_data", "embedded_data",
464 "Blocks which compress very well use even less space.",
465 ZFEATURE_FLAG_MOS | ZFEATURE_FLAG_ACTIVATE_ON_ENABLE,
466 ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
469 static const spa_feature_t livelist_deps[] = {
470 SPA_FEATURE_EXTENSIBLE_DATASET,
471 SPA_FEATURE_NONE
473 zfeature_register(SPA_FEATURE_LIVELIST,
474 "com.delphix:livelist", "livelist",
475 "Improved clone deletion performance.",
476 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
477 livelist_deps, sfeatures);
481 static const spa_feature_t log_spacemap_deps[] = {
482 SPA_FEATURE_SPACEMAP_V2,
483 SPA_FEATURE_NONE
485 zfeature_register(SPA_FEATURE_LOG_SPACEMAP,
486 "com.delphix:log_spacemap", "log_spacemap",
487 "Log metaslab changes on a single spacemap and "
488 "flush them periodically.",
489 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
490 log_spacemap_deps, sfeatures);
494 static const spa_feature_t large_blocks_deps[] = {
495 SPA_FEATURE_EXTENSIBLE_DATASET,
496 SPA_FEATURE_NONE
498 zfeature_register(SPA_FEATURE_LARGE_BLOCKS,
499 "org.open-zfs:large_blocks", "large_blocks",
500 "Support for blocks larger than 128KB.",
501 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
502 large_blocks_deps, sfeatures);
506 static const spa_feature_t large_dnode_deps[] = {
507 SPA_FEATURE_EXTENSIBLE_DATASET,
508 SPA_FEATURE_NONE
510 zfeature_register(SPA_FEATURE_LARGE_DNODE,
511 "org.zfsonlinux:large_dnode", "large_dnode",
512 "Variable on-disk size of dnodes.",
513 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
514 large_dnode_deps, sfeatures);
518 static const spa_feature_t sha512_deps[] = {
519 SPA_FEATURE_EXTENSIBLE_DATASET,
520 SPA_FEATURE_NONE
522 zfeature_register(SPA_FEATURE_SHA512,
523 "org.illumos:sha512", "sha512",
524 "SHA-512/256 hash algorithm.",
525 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
526 sha512_deps, sfeatures);
530 static const spa_feature_t skein_deps[] = {
531 SPA_FEATURE_EXTENSIBLE_DATASET,
532 SPA_FEATURE_NONE
534 zfeature_register(SPA_FEATURE_SKEIN,
535 "org.illumos:skein", "skein",
536 "Skein hash algorithm.",
537 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
538 skein_deps, sfeatures);
542 static const spa_feature_t edonr_deps[] = {
543 SPA_FEATURE_EXTENSIBLE_DATASET,
544 SPA_FEATURE_NONE
546 zfeature_register(SPA_FEATURE_EDONR,
547 "org.illumos:edonr", "edonr",
548 "Edon-R hash algorithm.",
549 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
550 edonr_deps, sfeatures);
554 static const spa_feature_t redact_books_deps[] = {
555 SPA_FEATURE_BOOKMARK_V2,
556 SPA_FEATURE_EXTENSIBLE_DATASET,
557 SPA_FEATURE_BOOKMARKS,
558 SPA_FEATURE_NONE
560 zfeature_register(SPA_FEATURE_REDACTION_BOOKMARKS,
561 "com.delphix:redaction_bookmarks", "redaction_bookmarks",
562 "Support for bookmarks which store redaction lists for zfs "
563 "redacted send/recv.", 0, ZFEATURE_TYPE_BOOLEAN,
564 redact_books_deps, sfeatures);
568 static const spa_feature_t redact_datasets_deps[] = {
569 SPA_FEATURE_EXTENSIBLE_DATASET,
570 SPA_FEATURE_NONE
572 zfeature_register(SPA_FEATURE_REDACTED_DATASETS,
573 "com.delphix:redacted_datasets", "redacted_datasets",
574 "Support for redacted datasets, produced by receiving "
575 "a redacted zfs send stream.",
576 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_UINT64_ARRAY,
577 redact_datasets_deps, sfeatures);
581 static const spa_feature_t bookmark_written_deps[] = {
582 SPA_FEATURE_BOOKMARK_V2,
583 SPA_FEATURE_EXTENSIBLE_DATASET,
584 SPA_FEATURE_BOOKMARKS,
585 SPA_FEATURE_NONE
587 zfeature_register(SPA_FEATURE_BOOKMARK_WRITTEN,
588 "com.delphix:bookmark_written", "bookmark_written",
589 "Additional accounting, enabling the written#<bookmark> "
590 "property (space written since a bookmark), "
591 "and estimates of send stream sizes for incrementals from "
592 "bookmarks.",
593 0, ZFEATURE_TYPE_BOOLEAN, bookmark_written_deps, sfeatures);
596 zfeature_register(SPA_FEATURE_DEVICE_REMOVAL,
597 "com.delphix:device_removal", "device_removal",
598 "Top-level vdevs can be removed, reducing logical pool size.",
599 ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
602 static const spa_feature_t obsolete_counts_deps[] = {
603 SPA_FEATURE_EXTENSIBLE_DATASET,
604 SPA_FEATURE_DEVICE_REMOVAL,
605 SPA_FEATURE_NONE
607 zfeature_register(SPA_FEATURE_OBSOLETE_COUNTS,
608 "com.delphix:obsolete_counts", "obsolete_counts",
609 "Reduce memory used by removed devices when their blocks "
610 "are freed or remapped.",
611 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN,
612 obsolete_counts_deps, sfeatures);
616 static const spa_feature_t userobj_accounting_deps[] = {
617 SPA_FEATURE_EXTENSIBLE_DATASET,
618 SPA_FEATURE_NONE
620 zfeature_register(SPA_FEATURE_USEROBJ_ACCOUNTING,
621 "org.zfsonlinux:userobj_accounting", "userobj_accounting",
622 "User/Group object accounting.",
623 ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
624 ZFEATURE_TYPE_BOOLEAN, userobj_accounting_deps, sfeatures);
628 static const spa_feature_t bookmark_v2_deps[] = {
629 SPA_FEATURE_EXTENSIBLE_DATASET,
630 SPA_FEATURE_BOOKMARKS,
631 SPA_FEATURE_NONE
633 zfeature_register(SPA_FEATURE_BOOKMARK_V2,
634 "com.datto:bookmark_v2", "bookmark_v2",
635 "Support for larger bookmarks",
636 0, ZFEATURE_TYPE_BOOLEAN, bookmark_v2_deps, sfeatures);
640 static const spa_feature_t encryption_deps[] = {
641 SPA_FEATURE_EXTENSIBLE_DATASET,
642 SPA_FEATURE_BOOKMARK_V2,
643 SPA_FEATURE_NONE
645 zfeature_register(SPA_FEATURE_ENCRYPTION,
646 "com.datto:encryption", "encryption",
647 "Support for dataset level encryption",
648 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
649 encryption_deps, sfeatures);
653 static const spa_feature_t project_quota_deps[] = {
654 SPA_FEATURE_EXTENSIBLE_DATASET,
655 SPA_FEATURE_NONE
657 zfeature_register(SPA_FEATURE_PROJECT_QUOTA,
658 "org.zfsonlinux:project_quota", "project_quota",
659 "space/object accounting based on project ID.",
660 ZFEATURE_FLAG_READONLY_COMPAT | ZFEATURE_FLAG_PER_DATASET,
661 ZFEATURE_TYPE_BOOLEAN, project_quota_deps, sfeatures);
664 zfeature_register(SPA_FEATURE_ALLOCATION_CLASSES,
665 "org.zfsonlinux:allocation_classes", "allocation_classes",
666 "Support for separate allocation classes.",
667 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
668 sfeatures);
670 zfeature_register(SPA_FEATURE_RESILVER_DEFER,
671 "com.datto:resilver_defer", "resilver_defer",
672 "Support for deferring new resilvers when one is already running.",
673 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
674 sfeatures);
676 zfeature_register(SPA_FEATURE_DEVICE_REBUILD,
677 "org.openzfs:device_rebuild", "device_rebuild",
678 "Support for sequential mirror/dRAID device rebuilds",
679 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
680 sfeatures);
683 static const spa_feature_t zstd_deps[] = {
684 SPA_FEATURE_EXTENSIBLE_DATASET,
685 SPA_FEATURE_NONE
687 zfeature_register(SPA_FEATURE_ZSTD_COMPRESS,
688 "org.freebsd:zstd_compress", "zstd_compress",
689 "zstd compression algorithm support.",
690 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN, zstd_deps,
691 sfeatures);
694 zfeature_register(SPA_FEATURE_DRAID,
695 "org.openzfs:draid", "draid", "Support for distributed spare RAID",
696 ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
699 static const spa_feature_t zilsaxattr_deps[] = {
700 SPA_FEATURE_EXTENSIBLE_DATASET,
701 SPA_FEATURE_NONE
703 zfeature_register(SPA_FEATURE_ZILSAXATTR,
704 "org.openzfs:zilsaxattr", "zilsaxattr",
705 "Support for xattr=sa extended attribute logging in ZIL.",
706 ZFEATURE_FLAG_PER_DATASET | ZFEATURE_FLAG_READONLY_COMPAT,
707 ZFEATURE_TYPE_BOOLEAN, zilsaxattr_deps, sfeatures);
710 zfeature_register(SPA_FEATURE_HEAD_ERRLOG,
711 "com.delphix:head_errlog", "head_errlog",
712 "Support for per-dataset on-disk error logs.",
713 ZFEATURE_FLAG_ACTIVATE_ON_ENABLE, ZFEATURE_TYPE_BOOLEAN, NULL,
714 sfeatures);
717 static const spa_feature_t blake3_deps[] = {
718 SPA_FEATURE_EXTENSIBLE_DATASET,
719 SPA_FEATURE_NONE
721 zfeature_register(SPA_FEATURE_BLAKE3,
722 "org.openzfs:blake3", "blake3",
723 "BLAKE3 hash algorithm.",
724 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
725 blake3_deps, sfeatures);
728 zfeature_register(SPA_FEATURE_BLOCK_CLONING,
729 "com.fudosecurity:block_cloning", "block_cloning",
730 "Support for block cloning via Block Reference Table.",
731 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
732 sfeatures);
734 zfeature_register(SPA_FEATURE_AVZ_V2,
735 "com.klarasystems:vdev_zaps_v2", "vdev_zaps_v2",
736 "Support for root vdev ZAP.",
737 ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL,
738 sfeatures);
741 static const spa_feature_t redact_list_spill_deps[] = {
742 SPA_FEATURE_REDACTION_BOOKMARKS,
743 SPA_FEATURE_NONE
745 zfeature_register(SPA_FEATURE_REDACTION_LIST_SPILL,
746 "com.delphix:redaction_list_spill", "redaction_list_spill",
747 "Support for increased number of redaction_snapshot "
748 "arguments in zfs redact.", 0, ZFEATURE_TYPE_BOOLEAN,
749 redact_list_spill_deps, sfeatures);
752 zfeature_register(SPA_FEATURE_RAIDZ_EXPANSION,
753 "org.openzfs:raidz_expansion", "raidz_expansion",
754 "Support for raidz expansion",
755 ZFEATURE_FLAG_MOS, ZFEATURE_TYPE_BOOLEAN, NULL, sfeatures);
757 zfeature_register(SPA_FEATURE_FAST_DEDUP,
758 "com.klarasystems:fast_dedup", "fast_dedup",
759 "Support for advanced deduplication",
760 ZFEATURE_FLAG_READONLY_COMPAT, ZFEATURE_TYPE_BOOLEAN, NULL,
761 sfeatures);
764 static const spa_feature_t longname_deps[] = {
765 SPA_FEATURE_EXTENSIBLE_DATASET,
766 SPA_FEATURE_NONE
768 zfeature_register(SPA_FEATURE_LONGNAME,
769 "org.zfsonlinux:longname", "longname",
770 "support filename up to 1024 bytes",
771 ZFEATURE_FLAG_PER_DATASET, ZFEATURE_TYPE_BOOLEAN,
772 longname_deps, sfeatures);
776 static const spa_feature_t large_microzap_deps[] = {
777 SPA_FEATURE_EXTENSIBLE_DATASET,
778 SPA_FEATURE_LARGE_BLOCKS,
779 SPA_FEATURE_NONE
781 zfeature_register(SPA_FEATURE_LARGE_MICROZAP,
782 "com.klarasystems:large_microzap", "large_microzap",
783 "Support for microzaps larger than 128KB.",
784 ZFEATURE_FLAG_PER_DATASET | ZFEATURE_FLAG_READONLY_COMPAT,
785 ZFEATURE_TYPE_BOOLEAN, large_microzap_deps, sfeatures);
788 zfs_mod_list_supported_free(sfeatures);
791 #if defined(_KERNEL)
792 EXPORT_SYMBOL(zfeature_lookup_guid);
793 EXPORT_SYMBOL(zfeature_lookup_name);
794 EXPORT_SYMBOL(zfeature_is_supported);
795 EXPORT_SYMBOL(zfeature_is_valid_guid);
796 EXPORT_SYMBOL(zfeature_depends_on);
797 EXPORT_SYMBOL(zpool_feature_init);
798 EXPORT_SYMBOL(spa_feature_table);
799 #endif