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 http://www.opensolaris.org/os/licensing.
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]
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2011, 2018 by Delphix. All rights reserved.
24 * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25 * Copyright 2016, Joyent, Inc.
26 * Copyright (c) 2019, Klara Inc.
27 * Copyright (c) 2019, Allan Jude
30 /* Portions Copyright 2010 Robert Milkowski */
34 #include <sys/u8_textprep.h>
35 #include <sys/zfs_acl.h>
36 #include <sys/zfs_ioctl.h>
37 #include <sys/zfs_znode.h>
38 #include <sys/dsl_crypt.h>
41 #include "zfs_deleg.h"
42 #include "zfs_fletcher.h"
50 static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
52 /* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
53 const char *zfs_userquota_prop_prefixes[] = {
69 zfs_prop_get_table(void)
71 return (zfs_prop_table);
77 static zprop_index_t checksum_table[] = {
78 { "on", ZIO_CHECKSUM_ON },
79 { "off", ZIO_CHECKSUM_OFF },
80 { "fletcher2", ZIO_CHECKSUM_FLETCHER_2 },
81 { "fletcher4", ZIO_CHECKSUM_FLETCHER_4 },
82 { "sha256", ZIO_CHECKSUM_SHA256 },
83 { "noparity", ZIO_CHECKSUM_NOPARITY },
84 { "sha512", ZIO_CHECKSUM_SHA512 },
85 { "skein", ZIO_CHECKSUM_SKEIN },
86 #if !defined(__FreeBSD__)
88 { "edonr", ZIO_CHECKSUM_EDONR },
93 static zprop_index_t dedup_table[] = {
94 { "on", ZIO_CHECKSUM_ON },
95 { "off", ZIO_CHECKSUM_OFF },
96 { "verify", ZIO_CHECKSUM_ON | ZIO_CHECKSUM_VERIFY },
97 { "sha256", ZIO_CHECKSUM_SHA256 },
99 ZIO_CHECKSUM_SHA256 | ZIO_CHECKSUM_VERIFY },
100 { "sha512", ZIO_CHECKSUM_SHA512 },
102 ZIO_CHECKSUM_SHA512 | ZIO_CHECKSUM_VERIFY },
103 { "skein", ZIO_CHECKSUM_SKEIN },
105 ZIO_CHECKSUM_SKEIN | ZIO_CHECKSUM_VERIFY },
106 #if !defined(__FreeBSD__)
109 ZIO_CHECKSUM_EDONR | ZIO_CHECKSUM_VERIFY },
114 static zprop_index_t compress_table[] = {
115 { "on", ZIO_COMPRESS_ON },
116 { "off", ZIO_COMPRESS_OFF },
117 { "lzjb", ZIO_COMPRESS_LZJB },
118 { "gzip", ZIO_COMPRESS_GZIP_6 }, /* gzip default */
119 { "gzip-1", ZIO_COMPRESS_GZIP_1 },
120 { "gzip-2", ZIO_COMPRESS_GZIP_2 },
121 { "gzip-3", ZIO_COMPRESS_GZIP_3 },
122 { "gzip-4", ZIO_COMPRESS_GZIP_4 },
123 { "gzip-5", ZIO_COMPRESS_GZIP_5 },
124 { "gzip-6", ZIO_COMPRESS_GZIP_6 },
125 { "gzip-7", ZIO_COMPRESS_GZIP_7 },
126 { "gzip-8", ZIO_COMPRESS_GZIP_8 },
127 { "gzip-9", ZIO_COMPRESS_GZIP_9 },
128 { "zle", ZIO_COMPRESS_ZLE },
129 { "lz4", ZIO_COMPRESS_LZ4 },
130 { "zstd", ZIO_COMPRESS_ZSTD },
132 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_DEFAULT) },
135 * ZSTD 1-19 are synthetic. We store the compression level in a
136 * separate hidden property to avoid wasting a large amount of
137 * space in the ZIO_COMPRESS enum.
139 * The compression level is also stored within the header of the
140 * compressed block since we may need it for later recompression
141 * to avoid checksum errors (L2ARC).
143 * Note that the level here is defined as bit shifted mask on
146 { "zstd-1", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_1) },
147 { "zstd-2", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_2) },
148 { "zstd-3", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_3) },
149 { "zstd-4", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_4) },
150 { "zstd-5", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_5) },
151 { "zstd-6", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_6) },
152 { "zstd-7", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_7) },
153 { "zstd-8", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_8) },
154 { "zstd-9", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_9) },
155 { "zstd-10", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_10) },
156 { "zstd-11", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_11) },
157 { "zstd-12", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_12) },
158 { "zstd-13", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_13) },
159 { "zstd-14", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_14) },
160 { "zstd-15", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_15) },
161 { "zstd-16", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_16) },
162 { "zstd-17", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_17) },
163 { "zstd-18", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_18) },
164 { "zstd-19", ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_19) },
167 * The ZSTD-Fast levels are also synthetic.
170 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1) },
172 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_2) },
174 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_3) },
176 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_4) },
178 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_5) },
180 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_6) },
182 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_7) },
184 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_8) },
186 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_9) },
188 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_10) },
190 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_20) },
192 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_30) },
194 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_40) },
196 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_50) },
198 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_60) },
200 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_70) },
202 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_80) },
204 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_90) },
206 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_100) },
208 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_500) },
210 ZIO_COMPLEVEL_ZSTD(ZIO_ZSTD_LEVEL_FAST_1000) },
214 static zprop_index_t crypto_table[] = {
215 { "on", ZIO_CRYPT_ON },
216 { "off", ZIO_CRYPT_OFF },
217 { "aes-128-ccm", ZIO_CRYPT_AES_128_CCM },
218 { "aes-192-ccm", ZIO_CRYPT_AES_192_CCM },
219 { "aes-256-ccm", ZIO_CRYPT_AES_256_CCM },
220 { "aes-128-gcm", ZIO_CRYPT_AES_128_GCM },
221 { "aes-192-gcm", ZIO_CRYPT_AES_192_GCM },
222 { "aes-256-gcm", ZIO_CRYPT_AES_256_GCM },
226 static zprop_index_t keyformat_table[] = {
227 { "none", ZFS_KEYFORMAT_NONE },
228 { "raw", ZFS_KEYFORMAT_RAW },
229 { "hex", ZFS_KEYFORMAT_HEX },
230 { "passphrase", ZFS_KEYFORMAT_PASSPHRASE },
234 static zprop_index_t snapdir_table[] = {
235 { "hidden", ZFS_SNAPDIR_HIDDEN },
236 { "visible", ZFS_SNAPDIR_VISIBLE },
240 static zprop_index_t snapdev_table[] = {
241 { "hidden", ZFS_SNAPDEV_HIDDEN },
242 { "visible", ZFS_SNAPDEV_VISIBLE },
246 static zprop_index_t acl_mode_table[] = {
247 { "discard", ZFS_ACL_DISCARD },
248 { "groupmask", ZFS_ACL_GROUPMASK },
249 { "passthrough", ZFS_ACL_PASSTHROUGH },
250 { "restricted", ZFS_ACL_RESTRICTED },
254 static zprop_index_t acltype_table[] = {
255 { "off", ZFS_ACLTYPE_OFF },
256 { "posix", ZFS_ACLTYPE_POSIX },
257 { "nfsv4", ZFS_ACLTYPE_NFSV4 },
258 { "disabled", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
259 { "noacl", ZFS_ACLTYPE_OFF }, /* bkwrd compatibility */
260 { "posixacl", ZFS_ACLTYPE_POSIX }, /* bkwrd compatibility */
264 static zprop_index_t acl_inherit_table[] = {
265 { "discard", ZFS_ACL_DISCARD },
266 { "noallow", ZFS_ACL_NOALLOW },
267 { "restricted", ZFS_ACL_RESTRICTED },
268 { "passthrough", ZFS_ACL_PASSTHROUGH },
269 { "secure", ZFS_ACL_RESTRICTED }, /* bkwrd compatibility */
270 { "passthrough-x", ZFS_ACL_PASSTHROUGH_X },
274 static zprop_index_t case_table[] = {
275 { "sensitive", ZFS_CASE_SENSITIVE },
276 { "insensitive", ZFS_CASE_INSENSITIVE },
277 { "mixed", ZFS_CASE_MIXED },
281 static zprop_index_t copies_table[] = {
289 * Use the unique flags we have to send to u8_strcmp() and/or
290 * u8_textprep() to represent the various normalization property
293 static zprop_index_t normalize_table[] = {
295 { "formD", U8_TEXTPREP_NFD },
296 { "formKC", U8_TEXTPREP_NFKC },
297 { "formC", U8_TEXTPREP_NFC },
298 { "formKD", U8_TEXTPREP_NFKD },
302 static zprop_index_t version_table[] = {
308 { "current", ZPL_VERSION },
312 static zprop_index_t boolean_table[] = {
318 static zprop_index_t keystatus_table[] = {
319 { "none", ZFS_KEYSTATUS_NONE},
320 { "unavailable", ZFS_KEYSTATUS_UNAVAILABLE},
321 { "available", ZFS_KEYSTATUS_AVAILABLE},
325 static zprop_index_t logbias_table[] = {
326 { "latency", ZFS_LOGBIAS_LATENCY },
327 { "throughput", ZFS_LOGBIAS_THROUGHPUT },
331 static zprop_index_t canmount_table[] = {
332 { "off", ZFS_CANMOUNT_OFF },
333 { "on", ZFS_CANMOUNT_ON },
334 { "noauto", ZFS_CANMOUNT_NOAUTO },
338 static zprop_index_t cache_table[] = {
339 { "none", ZFS_CACHE_NONE },
340 { "metadata", ZFS_CACHE_METADATA },
341 { "all", ZFS_CACHE_ALL },
345 static zprop_index_t sync_table[] = {
346 { "standard", ZFS_SYNC_STANDARD },
347 { "always", ZFS_SYNC_ALWAYS },
348 { "disabled", ZFS_SYNC_DISABLED },
352 static zprop_index_t xattr_table[] = {
353 { "off", ZFS_XATTR_OFF },
354 { "on", ZFS_XATTR_DIR },
355 { "sa", ZFS_XATTR_SA },
356 { "dir", ZFS_XATTR_DIR },
360 static zprop_index_t dnsize_table[] = {
361 { "legacy", ZFS_DNSIZE_LEGACY },
362 { "auto", ZFS_DNSIZE_AUTO },
363 { "1k", ZFS_DNSIZE_1K },
364 { "2k", ZFS_DNSIZE_2K },
365 { "4k", ZFS_DNSIZE_4K },
366 { "8k", ZFS_DNSIZE_8K },
367 { "16k", ZFS_DNSIZE_16K },
371 static zprop_index_t redundant_metadata_table[] = {
372 { "all", ZFS_REDUNDANT_METADATA_ALL },
373 { "most", ZFS_REDUNDANT_METADATA_MOST },
377 static zprop_index_t volmode_table[] = {
378 { "default", ZFS_VOLMODE_DEFAULT },
379 { "full", ZFS_VOLMODE_GEOM },
380 { "geom", ZFS_VOLMODE_GEOM },
381 { "dev", ZFS_VOLMODE_DEV },
382 { "none", ZFS_VOLMODE_NONE },
386 /* inherit index properties */
387 zprop_register_index(ZFS_PROP_REDUNDANT_METADATA, "redundant_metadata",
388 ZFS_REDUNDANT_METADATA_ALL,
389 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
390 "all | most", "REDUND_MD",
391 redundant_metadata_table);
392 zprop_register_index(ZFS_PROP_SYNC, "sync", ZFS_SYNC_STANDARD,
393 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
394 "standard | always | disabled", "SYNC",
396 zprop_register_index(ZFS_PROP_CHECKSUM, "checksum",
397 ZIO_CHECKSUM_DEFAULT, PROP_INHERIT, ZFS_TYPE_FILESYSTEM |
399 #if !defined(__FreeBSD__)
400 "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein"
403 "on | off | fletcher2 | fletcher4 | sha256 | sha512 | skein",
405 "CHECKSUM", checksum_table);
406 zprop_register_index(ZFS_PROP_DEDUP, "dedup", ZIO_CHECKSUM_OFF,
407 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
408 "on | off | verify | sha256[,verify] | sha512[,verify] | "
409 #if !defined(__FreeBSD__)
410 "skein[,verify] | edonr,verify",
414 "DEDUP", dedup_table);
415 zprop_register_index(ZFS_PROP_COMPRESSION, "compression",
416 ZIO_COMPRESS_DEFAULT, PROP_INHERIT,
417 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
418 "on | off | lzjb | gzip | gzip-[1-9] | zle | lz4 | "
419 "zstd | zstd-[1-19] | "
420 "zstd-fast | zstd-fast-[1-10,20,30,40,50,60,70,80,90,100,500,1000]",
421 "COMPRESS", compress_table);
422 zprop_register_index(ZFS_PROP_SNAPDIR, "snapdir", ZFS_SNAPDIR_HIDDEN,
423 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
424 "hidden | visible", "SNAPDIR", snapdir_table);
425 zprop_register_index(ZFS_PROP_SNAPDEV, "snapdev", ZFS_SNAPDEV_HIDDEN,
426 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
427 "hidden | visible", "SNAPDEV", snapdev_table);
428 zprop_register_index(ZFS_PROP_ACLMODE, "aclmode", ZFS_ACL_DISCARD,
429 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
430 "discard | groupmask | passthrough | restricted", "ACLMODE",
432 zprop_register_index(ZFS_PROP_ACLTYPE, "acltype",
434 /* Linux doesn't natively support ZFS's NFSv4-style ACLs. */
439 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
440 "off | nfsv4 | posix", "ACLTYPE", acltype_table);
441 zprop_register_index(ZFS_PROP_ACLINHERIT, "aclinherit",
442 ZFS_ACL_RESTRICTED, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
443 "discard | noallow | restricted | passthrough | passthrough-x",
444 "ACLINHERIT", acl_inherit_table);
445 zprop_register_index(ZFS_PROP_COPIES, "copies", 1, PROP_INHERIT,
446 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
447 "1 | 2 | 3", "COPIES", copies_table);
448 zprop_register_index(ZFS_PROP_PRIMARYCACHE, "primarycache",
449 ZFS_CACHE_ALL, PROP_INHERIT,
450 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
451 "all | none | metadata", "PRIMARYCACHE", cache_table);
452 zprop_register_index(ZFS_PROP_SECONDARYCACHE, "secondarycache",
453 ZFS_CACHE_ALL, PROP_INHERIT,
454 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME,
455 "all | none | metadata", "SECONDARYCACHE", cache_table);
456 zprop_register_index(ZFS_PROP_LOGBIAS, "logbias", ZFS_LOGBIAS_LATENCY,
457 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
458 "latency | throughput", "LOGBIAS", logbias_table);
459 zprop_register_index(ZFS_PROP_XATTR, "xattr", ZFS_XATTR_DIR,
460 PROP_INHERIT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
461 "on | off | dir | sa", "XATTR", xattr_table);
462 zprop_register_index(ZFS_PROP_DNODESIZE, "dnodesize",
463 ZFS_DNSIZE_LEGACY, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
464 "legacy | auto | 1k | 2k | 4k | 8k | 16k", "DNSIZE", dnsize_table);
465 zprop_register_index(ZFS_PROP_VOLMODE, "volmode",
466 ZFS_VOLMODE_DEFAULT, PROP_INHERIT,
467 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
468 "default | full | geom | dev | none", "VOLMODE", volmode_table);
470 /* inherit index (boolean) properties */
471 zprop_register_index(ZFS_PROP_ATIME, "atime", 1, PROP_INHERIT,
472 ZFS_TYPE_FILESYSTEM, "on | off", "ATIME", boolean_table);
473 zprop_register_index(ZFS_PROP_RELATIME, "relatime", 0, PROP_INHERIT,
474 ZFS_TYPE_FILESYSTEM, "on | off", "RELATIME", boolean_table);
475 zprop_register_index(ZFS_PROP_DEVICES, "devices", 1, PROP_INHERIT,
476 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "DEVICES",
478 zprop_register_index(ZFS_PROP_EXEC, "exec", 1, PROP_INHERIT,
479 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "EXEC",
481 zprop_register_index(ZFS_PROP_SETUID, "setuid", 1, PROP_INHERIT,
482 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "SETUID",
484 zprop_register_index(ZFS_PROP_READONLY, "readonly", 0, PROP_INHERIT,
485 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "on | off", "RDONLY",
488 zprop_register_index(ZFS_PROP_ZONED, "jailed", 0, PROP_INHERIT,
489 ZFS_TYPE_FILESYSTEM, "on | off", "JAILED", boolean_table);
491 zprop_register_index(ZFS_PROP_ZONED, "zoned", 0, PROP_INHERIT,
492 ZFS_TYPE_FILESYSTEM, "on | off", "ZONED", boolean_table);
494 zprop_register_index(ZFS_PROP_VSCAN, "vscan", 0, PROP_INHERIT,
495 ZFS_TYPE_FILESYSTEM, "on | off", "VSCAN", boolean_table);
496 zprop_register_index(ZFS_PROP_NBMAND, "nbmand", 0, PROP_INHERIT,
497 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT, "on | off", "NBMAND",
499 zprop_register_index(ZFS_PROP_OVERLAY, "overlay", 1, PROP_INHERIT,
500 ZFS_TYPE_FILESYSTEM, "on | off", "OVERLAY", boolean_table);
502 /* default index properties */
503 zprop_register_index(ZFS_PROP_VERSION, "version", 0, PROP_DEFAULT,
504 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
505 "1 | 2 | 3 | 4 | 5 | current", "VERSION", version_table);
506 zprop_register_index(ZFS_PROP_CANMOUNT, "canmount", ZFS_CANMOUNT_ON,
507 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM, "on | off | noauto",
508 "CANMOUNT", canmount_table);
510 /* readonly index properties */
511 zprop_register_index(ZFS_PROP_MOUNTED, "mounted", 0, PROP_READONLY,
512 ZFS_TYPE_FILESYSTEM, "yes | no", "MOUNTED", boolean_table);
513 zprop_register_index(ZFS_PROP_DEFER_DESTROY, "defer_destroy", 0,
514 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "yes | no", "DEFER_DESTROY",
516 zprop_register_index(ZFS_PROP_KEYSTATUS, "keystatus",
517 ZFS_KEYSTATUS_NONE, PROP_READONLY, ZFS_TYPE_DATASET,
518 "none | unavailable | available",
519 "KEYSTATUS", keystatus_table);
521 /* set once index properties */
522 zprop_register_index(ZFS_PROP_NORMALIZE, "normalization", 0,
523 PROP_ONETIME, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
524 "none | formC | formD | formKC | formKD", "NORMALIZATION",
526 zprop_register_index(ZFS_PROP_CASE, "casesensitivity",
527 ZFS_CASE_SENSITIVE, PROP_ONETIME, ZFS_TYPE_FILESYSTEM |
529 "sensitive | insensitive | mixed", "CASE", case_table);
530 zprop_register_index(ZFS_PROP_KEYFORMAT, "keyformat",
531 ZFS_KEYFORMAT_NONE, PROP_ONETIME_DEFAULT,
532 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
533 "none | raw | hex | passphrase", "KEYFORMAT", keyformat_table);
534 zprop_register_index(ZFS_PROP_ENCRYPTION, "encryption",
535 ZIO_CRYPT_DEFAULT, PROP_ONETIME, ZFS_TYPE_DATASET,
536 "on | off | aes-128-ccm | aes-192-ccm | aes-256-ccm | "
537 "aes-128-gcm | aes-192-gcm | aes-256-gcm", "ENCRYPTION",
540 /* set once index (boolean) properties */
541 zprop_register_index(ZFS_PROP_UTF8ONLY, "utf8only", 0, PROP_ONETIME,
542 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_SNAPSHOT,
543 "on | off", "UTF8ONLY", boolean_table);
545 /* string properties */
546 zprop_register_string(ZFS_PROP_ORIGIN, "origin", NULL, PROP_READONLY,
547 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<snapshot>", "ORIGIN");
548 zprop_register_string(ZFS_PROP_CLONES, "clones", NULL, PROP_READONLY,
549 ZFS_TYPE_SNAPSHOT, "<dataset>[,...]", "CLONES");
550 zprop_register_string(ZFS_PROP_MOUNTPOINT, "mountpoint", "/",
551 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "<path> | legacy | none",
553 zprop_register_string(ZFS_PROP_SHARENFS, "sharenfs", "off",
554 PROP_INHERIT, ZFS_TYPE_FILESYSTEM, "on | off | NFS share options",
556 zprop_register_string(ZFS_PROP_TYPE, "type", NULL, PROP_READONLY,
557 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
558 "filesystem | volume | snapshot | bookmark", "TYPE");
559 zprop_register_string(ZFS_PROP_SHARESMB, "sharesmb", "off",
560 PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
561 "on | off | SMB share options", "SHARESMB");
562 zprop_register_string(ZFS_PROP_MLSLABEL, "mlslabel",
563 ZFS_MLSLABEL_DEFAULT, PROP_INHERIT, ZFS_TYPE_DATASET,
564 "<sensitivity label>", "MLSLABEL");
565 zprop_register_string(ZFS_PROP_SELINUX_CONTEXT, "context",
566 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux context>",
568 zprop_register_string(ZFS_PROP_SELINUX_FSCONTEXT, "fscontext",
569 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux fscontext>",
571 zprop_register_string(ZFS_PROP_SELINUX_DEFCONTEXT, "defcontext",
572 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux defcontext>",
574 zprop_register_string(ZFS_PROP_SELINUX_ROOTCONTEXT, "rootcontext",
575 "none", PROP_DEFAULT, ZFS_TYPE_DATASET, "<selinux rootcontext>",
577 zprop_register_string(ZFS_PROP_RECEIVE_RESUME_TOKEN,
578 "receive_resume_token",
579 NULL, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
580 "<string token>", "RESUMETOK");
581 zprop_register_string(ZFS_PROP_ENCRYPTION_ROOT, "encryptionroot", NULL,
582 PROP_READONLY, ZFS_TYPE_DATASET, "<filesystem | volume>",
584 zprop_register_string(ZFS_PROP_KEYLOCATION, "keylocation",
585 "none", PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
586 "prompt | <file URI>", "KEYLOCATION");
587 zprop_register_string(ZFS_PROP_REDACT_SNAPS,
588 "redact_snaps", NULL, PROP_READONLY,
589 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<snapshot>[,...]",
592 /* readonly number properties */
593 zprop_register_number(ZFS_PROP_USED, "used", 0, PROP_READONLY,
594 ZFS_TYPE_DATASET, "<size>", "USED");
595 zprop_register_number(ZFS_PROP_AVAILABLE, "available", 0, PROP_READONLY,
596 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "AVAIL");
597 zprop_register_number(ZFS_PROP_REFERENCED, "referenced", 0,
598 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
600 zprop_register_number(ZFS_PROP_COMPRESSRATIO, "compressratio", 0,
601 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
602 "<1.00x or higher if compressed>", "RATIO");
603 zprop_register_number(ZFS_PROP_REFRATIO, "refcompressratio", 0,
604 PROP_READONLY, ZFS_TYPE_DATASET,
605 "<1.00x or higher if compressed>", "REFRATIO");
606 zprop_register_number(ZFS_PROP_VOLBLOCKSIZE, "volblocksize",
607 ZVOL_DEFAULT_BLOCKSIZE, PROP_ONETIME,
608 ZFS_TYPE_VOLUME, "512 to 128k, power of 2", "VOLBLOCK");
609 zprop_register_number(ZFS_PROP_USEDSNAP, "usedbysnapshots", 0,
610 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
612 zprop_register_number(ZFS_PROP_USEDDS, "usedbydataset", 0,
613 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
615 zprop_register_number(ZFS_PROP_USEDCHILD, "usedbychildren", 0,
616 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
618 zprop_register_number(ZFS_PROP_USEDREFRESERV, "usedbyrefreservation", 0,
620 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>", "USEDREFRESERV");
621 zprop_register_number(ZFS_PROP_USERREFS, "userrefs", 0, PROP_READONLY,
622 ZFS_TYPE_SNAPSHOT, "<count>", "USERREFS");
623 zprop_register_number(ZFS_PROP_WRITTEN, "written", 0, PROP_READONLY,
624 ZFS_TYPE_DATASET, "<size>", "WRITTEN");
625 zprop_register_number(ZFS_PROP_LOGICALUSED, "logicalused", 0,
626 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "<size>",
628 zprop_register_number(ZFS_PROP_LOGICALREFERENCED, "logicalreferenced",
629 0, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<size>",
631 zprop_register_number(ZFS_PROP_FILESYSTEM_COUNT, "filesystem_count",
632 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM,
633 "<count>", "FSCOUNT");
634 zprop_register_number(ZFS_PROP_SNAPSHOT_COUNT, "snapshot_count",
635 UINT64_MAX, PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
636 "<count>", "SSCOUNT");
637 zprop_register_number(ZFS_PROP_GUID, "guid", 0, PROP_READONLY,
638 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "GUID");
639 zprop_register_number(ZFS_PROP_CREATETXG, "createtxg", 0, PROP_READONLY,
640 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "<uint64>", "CREATETXG");
641 zprop_register_number(ZFS_PROP_PBKDF2_ITERS, "pbkdf2iters",
642 0, PROP_ONETIME_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
643 "<iters>", "PBKDF2ITERS");
644 zprop_register_number(ZFS_PROP_OBJSETID, "objsetid", 0,
645 PROP_READONLY, ZFS_TYPE_DATASET, "<uint64>", "OBJSETID");
647 /* default number properties */
648 zprop_register_number(ZFS_PROP_QUOTA, "quota", 0, PROP_DEFAULT,
649 ZFS_TYPE_FILESYSTEM, "<size> | none", "QUOTA");
650 zprop_register_number(ZFS_PROP_RESERVATION, "reservation", 0,
651 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
652 "<size> | none", "RESERV");
653 zprop_register_number(ZFS_PROP_VOLSIZE, "volsize", 0, PROP_DEFAULT,
654 ZFS_TYPE_SNAPSHOT | ZFS_TYPE_VOLUME, "<size>", "VOLSIZE");
655 zprop_register_number(ZFS_PROP_REFQUOTA, "refquota", 0, PROP_DEFAULT,
656 ZFS_TYPE_FILESYSTEM, "<size> | none", "REFQUOTA");
657 zprop_register_number(ZFS_PROP_REFRESERVATION, "refreservation", 0,
658 PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
659 "<size> | none", "REFRESERV");
660 zprop_register_number(ZFS_PROP_FILESYSTEM_LIMIT, "filesystem_limit",
661 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM,
662 "<count> | none", "FSLIMIT");
663 zprop_register_number(ZFS_PROP_SNAPSHOT_LIMIT, "snapshot_limit",
664 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME,
665 "<count> | none", "SSLIMIT");
667 /* inherit number properties */
668 zprop_register_number(ZFS_PROP_RECORDSIZE, "recordsize",
669 SPA_OLD_MAXBLOCKSIZE, PROP_INHERIT,
670 ZFS_TYPE_FILESYSTEM, "512 to 1M, power of 2", "RECSIZE");
671 zprop_register_number(ZFS_PROP_SPECIAL_SMALL_BLOCKS,
672 "special_small_blocks", 0, PROP_INHERIT, ZFS_TYPE_FILESYSTEM,
673 "zero or 512 to 1M, power of 2", "SPECIAL_SMALL_BLOCKS");
675 /* hidden properties */
676 zprop_register_hidden(ZFS_PROP_NUMCLONES, "numclones", PROP_TYPE_NUMBER,
677 PROP_READONLY, ZFS_TYPE_SNAPSHOT, "NUMCLONES");
678 zprop_register_hidden(ZFS_PROP_NAME, "name", PROP_TYPE_STRING,
679 PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "NAME");
680 zprop_register_hidden(ZFS_PROP_ISCSIOPTIONS, "iscsioptions",
681 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME, "ISCSIOPTIONS");
682 zprop_register_hidden(ZFS_PROP_STMF_SHAREINFO, "stmf_sbd_lu",
683 PROP_TYPE_STRING, PROP_INHERIT, ZFS_TYPE_VOLUME,
685 zprop_register_hidden(ZFS_PROP_USERACCOUNTING, "useraccounting",
686 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET,
688 zprop_register_hidden(ZFS_PROP_UNIQUE, "unique", PROP_TYPE_NUMBER,
689 PROP_READONLY, ZFS_TYPE_DATASET, "UNIQUE");
690 zprop_register_hidden(ZFS_PROP_INCONSISTENT, "inconsistent",
691 PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_DATASET, "INCONSISTENT");
692 zprop_register_hidden(ZFS_PROP_IVSET_GUID, "ivsetguid",
693 PROP_TYPE_NUMBER, PROP_READONLY,
694 ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK, "IVSETGUID");
695 zprop_register_hidden(ZFS_PROP_PREV_SNAP, "prevsnap", PROP_TYPE_STRING,
696 PROP_READONLY, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PREVSNAP");
697 zprop_register_hidden(ZFS_PROP_PBKDF2_SALT, "pbkdf2salt",
698 PROP_TYPE_NUMBER, PROP_ONETIME_DEFAULT,
699 ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME, "PBKDF2SALT");
700 zprop_register_hidden(ZFS_PROP_KEY_GUID, "keyguid", PROP_TYPE_NUMBER,
701 PROP_READONLY, ZFS_TYPE_DATASET, "KEYGUID");
702 zprop_register_hidden(ZFS_PROP_REDACTED, "redacted", PROP_TYPE_NUMBER,
703 PROP_READONLY, ZFS_TYPE_DATASET, "REDACTED");
706 * Properties that are obsolete and not used. These are retained so
707 * that we don't have to change the values of the zfs_prop_t enum, or
708 * have NULL pointers in the zfs_prop_table[].
710 zprop_register_hidden(ZFS_PROP_REMAPTXG, "remaptxg", PROP_TYPE_NUMBER,
711 PROP_READONLY, ZFS_TYPE_DATASET, "REMAPTXG");
713 /* oddball properties */
714 zprop_register_impl(ZFS_PROP_CREATION, "creation", PROP_TYPE_NUMBER, 0,
715 NULL, PROP_READONLY, ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK,
716 "<date>", "CREATION", B_FALSE, B_TRUE, NULL);
720 zfs_prop_delegatable(zfs_prop_t prop)
722 zprop_desc_t *pd = &zfs_prop_table[prop];
724 /* The mlslabel property is never delegatable. */
725 if (prop == ZFS_PROP_MLSLABEL)
728 return (pd->pd_attr != PROP_READONLY);
732 * Given a zfs dataset property name, returns the corresponding property ID.
735 zfs_name_to_prop(const char *propname)
737 return (zprop_name_to_prop(propname, ZFS_TYPE_DATASET));
741 * For user property names, we allow all lowercase alphanumeric characters, plus
742 * a few useful punctuation characters.
747 return ((c >= 'a' && c <= 'z') ||
748 (c >= '0' && c <= '9') ||
749 c == '-' || c == '_' || c == '.' || c == ':');
753 * Returns true if this is a valid user-defined property (one with a ':').
756 zfs_prop_user(const char *name)
760 boolean_t foundsep = B_FALSE;
762 for (i = 0; i < strlen(name); i++) {
777 * Returns true if this is a valid userspace-type property (one with a '@').
778 * Note that after the @, any character is valid (eg, another @, for SID
782 zfs_prop_userquota(const char *name)
784 zfs_userquota_prop_t prop;
786 for (prop = 0; prop < ZFS_NUM_USERQUOTA_PROPS; prop++) {
787 if (strncmp(name, zfs_userquota_prop_prefixes[prop],
788 strlen(zfs_userquota_prop_prefixes[prop])) == 0) {
797 * Returns true if this is a valid written@ property.
798 * Note that after the @, any character is valid (eg, another @, for
799 * written@pool/fs@origin).
802 zfs_prop_written(const char *name)
804 static const char *prop_prefix = "written@";
805 static const char *book_prefix = "written#";
806 return (strncmp(name, prop_prefix, strlen(prop_prefix)) == 0 ||
807 strncmp(name, book_prefix, strlen(book_prefix)) == 0);
811 * Tables of index types, plus functions to convert between the user view
812 * (strings) and internal representation (uint64_t).
815 zfs_prop_string_to_index(zfs_prop_t prop, const char *string, uint64_t *index)
817 return (zprop_string_to_index(prop, string, index, ZFS_TYPE_DATASET));
821 zfs_prop_index_to_string(zfs_prop_t prop, uint64_t index, const char **string)
823 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_DATASET));
827 zfs_prop_random_value(zfs_prop_t prop, uint64_t seed)
829 return (zprop_random_value(prop, seed, ZFS_TYPE_DATASET));
833 * Returns TRUE if the property applies to any of the given dataset types.
836 zfs_prop_valid_for_type(int prop, zfs_type_t types, boolean_t headcheck)
838 return (zprop_valid_for_type(prop, types, headcheck));
842 zfs_prop_get_type(zfs_prop_t prop)
844 return (zfs_prop_table[prop].pd_proptype);
848 * Returns TRUE if the property is readonly.
851 zfs_prop_readonly(zfs_prop_t prop)
853 return (zfs_prop_table[prop].pd_attr == PROP_READONLY ||
854 zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
855 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
859 * Returns TRUE if the property is visible (not hidden).
862 zfs_prop_visible(zfs_prop_t prop)
864 return (zfs_prop_table[prop].pd_visible &&
865 zfs_prop_table[prop].pd_zfs_mod_supported);
869 * Returns TRUE if the property is only allowed to be set once.
872 zfs_prop_setonce(zfs_prop_t prop)
874 return (zfs_prop_table[prop].pd_attr == PROP_ONETIME ||
875 zfs_prop_table[prop].pd_attr == PROP_ONETIME_DEFAULT);
879 zfs_prop_default_string(zfs_prop_t prop)
881 return (zfs_prop_table[prop].pd_strdefault);
885 zfs_prop_default_numeric(zfs_prop_t prop)
887 return (zfs_prop_table[prop].pd_numdefault);
891 * Given a dataset property ID, returns the corresponding name.
892 * Assuming the zfs dataset property ID is valid.
895 zfs_prop_to_name(zfs_prop_t prop)
897 return (zfs_prop_table[prop].pd_name);
901 * Returns TRUE if the property is inheritable.
904 zfs_prop_inheritable(zfs_prop_t prop)
906 return (zfs_prop_table[prop].pd_attr == PROP_INHERIT ||
907 zfs_prop_table[prop].pd_attr == PROP_ONETIME);
911 * Returns TRUE if property is one of the encryption properties that requires
912 * a loaded encryption key to modify.
915 zfs_prop_encryption_key_param(zfs_prop_t prop)
918 * keylocation does not count as an encryption property. It can be
919 * changed at will without needing the master keys.
921 return (prop == ZFS_PROP_PBKDF2_SALT || prop == ZFS_PROP_PBKDF2_ITERS ||
922 prop == ZFS_PROP_KEYFORMAT);
926 * Helper function used by both kernelspace and userspace to check the
927 * keylocation property. If encrypted is set, the keylocation must be valid
928 * for an encrypted dataset.
931 zfs_prop_valid_keylocation(const char *str, boolean_t encrypted)
933 if (strcmp("none", str) == 0)
935 else if (strcmp("prompt", str) == 0)
937 else if (strlen(str) > 8 && strncmp("file:///", str, 8) == 0)
948 * Returns a string describing the set of acceptable values for the given
949 * zfs property, or NULL if it cannot be set.
952 zfs_prop_values(zfs_prop_t prop)
954 return (zfs_prop_table[prop].pd_values);
958 * Returns TRUE if this property is a string type. Note that index types
959 * (compression, checksum) are treated as strings in userland, even though they
960 * are stored numerically on disk.
963 zfs_prop_is_string(zfs_prop_t prop)
965 return (zfs_prop_table[prop].pd_proptype == PROP_TYPE_STRING ||
966 zfs_prop_table[prop].pd_proptype == PROP_TYPE_INDEX);
970 * Returns the column header for the given property. Used only in
971 * 'zfs list -o', but centralized here with the other property information.
974 zfs_prop_column_name(zfs_prop_t prop)
976 return (zfs_prop_table[prop].pd_colname);
980 * Returns whether the given property should be displayed right-justified for
984 zfs_prop_align_right(zfs_prop_t prop)
986 return (zfs_prop_table[prop].pd_rightalign);
993 #include <sys/simd.h>
995 #if defined(HAVE_KERNEL_FPU_INTERNAL)
996 union fpregs_state **zfs_kfpu_fpregs;
997 EXPORT_SYMBOL(zfs_kfpu_fpregs);
998 #endif /* HAVE_KERNEL_FPU_INTERNAL */
1003 int error = kfpu_init();
1019 module_init_early(zcommon_init);
1020 module_exit(zcommon_fini);
1024 ZFS_MODULE_DESCRIPTION("Generic ZFS support");
1025 ZFS_MODULE_AUTHOR(ZFS_META_AUTHOR);
1026 ZFS_MODULE_LICENSE(ZFS_META_LICENSE);
1027 ZFS_MODULE_VERSION(ZFS_META_VERSION "-" ZFS_META_RELEASE);
1029 /* zfs dataset property functions */
1030 EXPORT_SYMBOL(zfs_userquota_prop_prefixes);
1031 EXPORT_SYMBOL(zfs_prop_init);
1032 EXPORT_SYMBOL(zfs_prop_get_type);
1033 EXPORT_SYMBOL(zfs_prop_get_table);
1034 EXPORT_SYMBOL(zfs_prop_delegatable);
1035 EXPORT_SYMBOL(zfs_prop_visible);
1037 /* Dataset property functions shared between libzfs and kernel. */
1038 EXPORT_SYMBOL(zfs_prop_default_string);
1039 EXPORT_SYMBOL(zfs_prop_default_numeric);
1040 EXPORT_SYMBOL(zfs_prop_readonly);
1041 EXPORT_SYMBOL(zfs_prop_inheritable);
1042 EXPORT_SYMBOL(zfs_prop_encryption_key_param);
1043 EXPORT_SYMBOL(zfs_prop_valid_keylocation);
1044 EXPORT_SYMBOL(zfs_prop_setonce);
1045 EXPORT_SYMBOL(zfs_prop_to_name);
1046 EXPORT_SYMBOL(zfs_name_to_prop);
1047 EXPORT_SYMBOL(zfs_prop_user);
1048 EXPORT_SYMBOL(zfs_prop_userquota);
1049 EXPORT_SYMBOL(zfs_prop_index_to_string);
1050 EXPORT_SYMBOL(zfs_prop_string_to_index);
1051 EXPORT_SYMBOL(zfs_prop_valid_for_type);
1052 EXPORT_SYMBOL(zfs_prop_written);