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]
22 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 * Copyright (c) 2012, 2018 by Delphix. All rights reserved.
25 * Copyright (c) 2021, Colm Buckley <colm@tuatha.org>
26 * Copyright (c) 2021, 2023, Klara Inc.
31 #include <sys/zfs_acl.h>
32 #include <sys/zfs_ioctl.h>
33 #include <sys/fs/zfs.h>
43 static zprop_desc_t zpool_prop_table
[ZPOOL_NUM_PROPS
];
44 static zprop_desc_t vdev_prop_table
[VDEV_NUM_PROPS
];
47 zpool_prop_get_table(void)
49 return (zpool_prop_table
);
55 static const zprop_index_t boolean_table
[] = {
61 static const zprop_index_t failuremode_table
[] = {
62 { "wait", ZIO_FAILURE_MODE_WAIT
},
63 { "continue", ZIO_FAILURE_MODE_CONTINUE
},
64 { "panic", ZIO_FAILURE_MODE_PANIC
},
68 struct zfs_mod_supported_features
*sfeatures
=
69 zfs_mod_list_supported(ZFS_SYSFS_POOL_PROPERTIES
);
71 /* string properties */
72 zprop_register_string(ZPOOL_PROP_ALTROOT
, "altroot", NULL
, PROP_DEFAULT
,
73 ZFS_TYPE_POOL
, "<path>", "ALTROOT", sfeatures
);
74 zprop_register_string(ZPOOL_PROP_BOOTFS
, "bootfs", NULL
, PROP_DEFAULT
,
75 ZFS_TYPE_POOL
, "<filesystem>", "BOOTFS", sfeatures
);
76 zprop_register_string(ZPOOL_PROP_CACHEFILE
, "cachefile", NULL
,
77 PROP_DEFAULT
, ZFS_TYPE_POOL
, "<file> | none", "CACHEFILE",
79 zprop_register_string(ZPOOL_PROP_COMMENT
, "comment", NULL
,
80 PROP_DEFAULT
, ZFS_TYPE_POOL
, "<comment-string>", "COMMENT",
82 zprop_register_string(ZPOOL_PROP_COMPATIBILITY
, "compatibility",
83 "off", PROP_DEFAULT
, ZFS_TYPE_POOL
,
84 "<file[,file...]> | off | legacy", "COMPATIBILITY", sfeatures
);
86 /* readonly number properties */
87 zprop_register_number(ZPOOL_PROP_SIZE
, "size", 0, PROP_READONLY
,
88 ZFS_TYPE_POOL
, "<size>", "SIZE", B_FALSE
, sfeatures
);
89 zprop_register_number(ZPOOL_PROP_FREE
, "free", 0, PROP_READONLY
,
90 ZFS_TYPE_POOL
, "<size>", "FREE", B_FALSE
, sfeatures
);
91 zprop_register_number(ZPOOL_PROP_FREEING
, "freeing", 0, PROP_READONLY
,
92 ZFS_TYPE_POOL
, "<size>", "FREEING", B_FALSE
, sfeatures
);
93 zprop_register_number(ZPOOL_PROP_CHECKPOINT
, "checkpoint", 0,
94 PROP_READONLY
, ZFS_TYPE_POOL
, "<size>", "CKPOINT", B_FALSE
,
96 zprop_register_number(ZPOOL_PROP_LEAKED
, "leaked", 0, PROP_READONLY
,
97 ZFS_TYPE_POOL
, "<size>", "LEAKED", B_FALSE
, sfeatures
);
98 zprop_register_number(ZPOOL_PROP_ALLOCATED
, "allocated", 0,
99 PROP_READONLY
, ZFS_TYPE_POOL
, "<size>", "ALLOC", B_FALSE
,
101 zprop_register_number(ZPOOL_PROP_EXPANDSZ
, "expandsize", 0,
102 PROP_READONLY
, ZFS_TYPE_POOL
, "<size>", "EXPANDSZ", B_FALSE
,
104 zprop_register_number(ZPOOL_PROP_FRAGMENTATION
, "fragmentation", 0,
105 PROP_READONLY
, ZFS_TYPE_POOL
, "<percent>", "FRAG", B_FALSE
,
107 zprop_register_number(ZPOOL_PROP_CAPACITY
, "capacity", 0, PROP_READONLY
,
108 ZFS_TYPE_POOL
, "<size>", "CAP", B_FALSE
, sfeatures
);
109 zprop_register_number(ZPOOL_PROP_GUID
, "guid", 0, PROP_READONLY
,
110 ZFS_TYPE_POOL
, "<guid>", "GUID", B_TRUE
, sfeatures
);
111 zprop_register_number(ZPOOL_PROP_LOAD_GUID
, "load_guid", 0,
112 PROP_READONLY
, ZFS_TYPE_POOL
, "<load_guid>", "LOAD_GUID",
114 zprop_register_number(ZPOOL_PROP_HEALTH
, "health", 0, PROP_READONLY
,
115 ZFS_TYPE_POOL
, "<state>", "HEALTH", B_FALSE
, sfeatures
);
116 zprop_register_number(ZPOOL_PROP_DEDUPRATIO
, "dedupratio", 0,
117 PROP_READONLY
, ZFS_TYPE_POOL
, "<1.00x or higher if deduped>",
118 "DEDUP", B_FALSE
, sfeatures
);
119 zprop_register_number(ZPOOL_PROP_BCLONEUSED
, "bcloneused", 0,
120 PROP_READONLY
, ZFS_TYPE_POOL
, "<size>",
121 "BCLONE_USED", B_FALSE
, sfeatures
);
122 zprop_register_number(ZPOOL_PROP_BCLONESAVED
, "bclonesaved", 0,
123 PROP_READONLY
, ZFS_TYPE_POOL
, "<size>",
124 "BCLONE_SAVED", B_FALSE
, sfeatures
);
125 zprop_register_number(ZPOOL_PROP_BCLONERATIO
, "bcloneratio", 0,
126 PROP_READONLY
, ZFS_TYPE_POOL
, "<1.00x or higher if cloned>",
127 "BCLONE_RATIO", B_FALSE
, sfeatures
);
128 zprop_register_number(ZPOOL_PROP_DEDUP_TABLE_SIZE
, "dedup_table_size",
129 0, PROP_READONLY
, ZFS_TYPE_POOL
, "<size>", "DDTSIZE", B_FALSE
,
132 /* default number properties */
133 zprop_register_number(ZPOOL_PROP_VERSION
, "version", SPA_VERSION
,
134 PROP_DEFAULT
, ZFS_TYPE_POOL
, "<version>", "VERSION", B_FALSE
,
136 zprop_register_number(ZPOOL_PROP_ASHIFT
, "ashift", 0, PROP_DEFAULT
,
137 ZFS_TYPE_POOL
, "<ashift, 9-16, or 0=default>", "ASHIFT", B_FALSE
,
139 zprop_register_number(ZPOOL_PROP_DEDUP_TABLE_QUOTA
, "dedup_table_quota",
140 UINT64_MAX
, PROP_DEFAULT
, ZFS_TYPE_POOL
, "<size>", "DDTQUOTA",
143 /* default index (boolean) properties */
144 zprop_register_index(ZPOOL_PROP_DELEGATION
, "delegation", 1,
145 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "DELEGATION",
146 boolean_table
, sfeatures
);
147 zprop_register_index(ZPOOL_PROP_AUTOREPLACE
, "autoreplace", 0,
148 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "REPLACE", boolean_table
,
150 zprop_register_index(ZPOOL_PROP_LISTSNAPS
, "listsnapshots", 0,
151 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "LISTSNAPS",
152 boolean_table
, sfeatures
);
153 zprop_register_index(ZPOOL_PROP_AUTOEXPAND
, "autoexpand", 0,
154 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "EXPAND", boolean_table
,
156 zprop_register_index(ZPOOL_PROP_READONLY
, "readonly", 0,
157 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "RDONLY", boolean_table
,
159 zprop_register_index(ZPOOL_PROP_MULTIHOST
, "multihost", 0,
160 PROP_DEFAULT
, ZFS_TYPE_POOL
, "on | off", "MULTIHOST",
161 boolean_table
, sfeatures
);
163 /* default index properties */
164 zprop_register_index(ZPOOL_PROP_FAILUREMODE
, "failmode",
165 ZIO_FAILURE_MODE_WAIT
, PROP_DEFAULT
, ZFS_TYPE_POOL
,
166 "wait | continue | panic", "FAILMODE", failuremode_table
,
168 zprop_register_index(ZPOOL_PROP_AUTOTRIM
, "autotrim",
169 SPA_AUTOTRIM_OFF
, PROP_DEFAULT
, ZFS_TYPE_POOL
,
170 "on | off", "AUTOTRIM", boolean_table
, sfeatures
);
172 /* hidden properties */
173 zprop_register_hidden(ZPOOL_PROP_NAME
, "name", PROP_TYPE_STRING
,
174 PROP_READONLY
, ZFS_TYPE_POOL
, "NAME", B_TRUE
, sfeatures
);
175 zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE
, "maxblocksize",
176 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_POOL
, "MAXBLOCKSIZE",
178 zprop_register_hidden(ZPOOL_PROP_TNAME
, "tname", PROP_TYPE_STRING
,
179 PROP_ONETIME
, ZFS_TYPE_POOL
, "TNAME", B_TRUE
, sfeatures
);
180 zprop_register_hidden(ZPOOL_PROP_MAXDNODESIZE
, "maxdnodesize",
181 PROP_TYPE_NUMBER
, PROP_READONLY
, ZFS_TYPE_POOL
, "MAXDNODESIZE",
183 zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO
, "dedupditto",
184 PROP_TYPE_NUMBER
, PROP_DEFAULT
, ZFS_TYPE_POOL
, "DEDUPDITTO",
186 zprop_register_hidden(ZPOOL_PROP_DEDUPCACHED
,
187 ZPOOL_DEDUPCACHED_PROP_NAME
, PROP_TYPE_NUMBER
, PROP_READONLY
,
188 ZFS_TYPE_POOL
, "DEDUPCACHED", B_FALSE
, sfeatures
);
190 zfs_mod_list_supported_free(sfeatures
);
194 * Given a property name and its type, returns the corresponding property ID.
197 zpool_name_to_prop(const char *propname
)
199 return (zprop_name_to_prop(propname
, ZFS_TYPE_POOL
));
203 * Given a pool property ID, returns the corresponding name.
204 * Assuming the pool property ID is valid.
207 zpool_prop_to_name(zpool_prop_t prop
)
209 return (zpool_prop_table
[prop
].pd_name
);
213 zpool_prop_get_type(zpool_prop_t prop
)
215 return (zpool_prop_table
[prop
].pd_proptype
);
219 zpool_prop_readonly(zpool_prop_t prop
)
221 return (zpool_prop_table
[prop
].pd_attr
== PROP_READONLY
);
225 zpool_prop_setonce(zpool_prop_t prop
)
227 return (zpool_prop_table
[prop
].pd_attr
== PROP_ONETIME
);
231 zpool_prop_default_string(zpool_prop_t prop
)
233 return (zpool_prop_table
[prop
].pd_strdefault
);
237 zpool_prop_default_numeric(zpool_prop_t prop
)
239 return (zpool_prop_table
[prop
].pd_numdefault
);
243 * Returns true if this is a valid feature@ property.
246 zpool_prop_feature(const char *name
)
248 static const char *prefix
= "feature@";
249 return (strncmp(name
, prefix
, strlen(prefix
)) == 0);
253 * Returns true if this is a valid unsupported@ property.
256 zpool_prop_unsupported(const char *name
)
258 static const char *prefix
= "unsupported@";
259 return (strncmp(name
, prefix
, strlen(prefix
)) == 0);
263 zpool_prop_string_to_index(zpool_prop_t prop
, const char *string
,
266 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_POOL
));
270 zpool_prop_index_to_string(zpool_prop_t prop
, uint64_t index
,
273 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_POOL
));
277 zpool_prop_random_value(zpool_prop_t prop
, uint64_t seed
)
279 return (zprop_random_value(prop
, seed
, ZFS_TYPE_POOL
));
286 zpool_prop_values(zpool_prop_t prop
)
288 return (zpool_prop_table
[prop
].pd_values
);
292 zpool_prop_column_name(zpool_prop_t prop
)
294 return (zpool_prop_table
[prop
].pd_colname
);
298 zpool_prop_align_right(zpool_prop_t prop
)
300 return (zpool_prop_table
[prop
].pd_rightalign
);
305 vdev_prop_get_table(void)
307 return (vdev_prop_table
);
313 static const zprop_index_t boolean_table
[] = {
318 static const zprop_index_t boolean_na_table
[] = {
321 { "-", 2}, /* ZPROP_BOOLEAN_NA */
325 struct zfs_mod_supported_features
*sfeatures
=
326 zfs_mod_list_supported(ZFS_SYSFS_VDEV_PROPERTIES
);
328 /* string properties */
329 zprop_register_string(VDEV_PROP_COMMENT
, "comment", NULL
,
330 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<comment-string>", "COMMENT",
332 zprop_register_string(VDEV_PROP_PATH
, "path", NULL
,
333 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<device-path>", "PATH", sfeatures
);
334 zprop_register_string(VDEV_PROP_DEVID
, "devid", NULL
,
335 PROP_READONLY
, ZFS_TYPE_VDEV
, "<devid>", "DEVID", sfeatures
);
336 zprop_register_string(VDEV_PROP_PHYS_PATH
, "physpath", NULL
,
337 PROP_READONLY
, ZFS_TYPE_VDEV
, "<physpath>", "PHYSPATH", sfeatures
);
338 zprop_register_string(VDEV_PROP_ENC_PATH
, "encpath", NULL
,
339 PROP_READONLY
, ZFS_TYPE_VDEV
, "<encpath>", "ENCPATH", sfeatures
);
340 zprop_register_string(VDEV_PROP_FRU
, "fru", NULL
,
341 PROP_READONLY
, ZFS_TYPE_VDEV
, "<fru>", "FRU", sfeatures
);
342 zprop_register_string(VDEV_PROP_PARENT
, "parent", NULL
,
343 PROP_READONLY
, ZFS_TYPE_VDEV
, "<parent>", "PARENT", sfeatures
);
344 zprop_register_string(VDEV_PROP_CHILDREN
, "children", NULL
,
345 PROP_READONLY
, ZFS_TYPE_VDEV
, "<child[,...]>", "CHILDREN",
348 /* readonly number properties */
349 zprop_register_number(VDEV_PROP_SIZE
, "size", 0, PROP_READONLY
,
350 ZFS_TYPE_VDEV
, "<size>", "SIZE", B_FALSE
, sfeatures
);
351 zprop_register_number(VDEV_PROP_FREE
, "free", 0, PROP_READONLY
,
352 ZFS_TYPE_VDEV
, "<size>", "FREE", B_FALSE
, sfeatures
);
353 zprop_register_number(VDEV_PROP_ALLOCATED
, "allocated", 0,
354 PROP_READONLY
, ZFS_TYPE_VDEV
, "<size>", "ALLOC", B_FALSE
,
356 zprop_register_number(VDEV_PROP_EXPANDSZ
, "expandsize", 0,
357 PROP_READONLY
, ZFS_TYPE_VDEV
, "<size>", "EXPANDSZ", B_FALSE
,
359 zprop_register_number(VDEV_PROP_FRAGMENTATION
, "fragmentation", 0,
360 PROP_READONLY
, ZFS_TYPE_VDEV
, "<percent>", "FRAG", B_FALSE
,
362 zprop_register_number(VDEV_PROP_CAPACITY
, "capacity", 0, PROP_READONLY
,
363 ZFS_TYPE_VDEV
, "<size>", "CAP", B_FALSE
, sfeatures
);
364 zprop_register_number(VDEV_PROP_GUID
, "guid", 0, PROP_READONLY
,
365 ZFS_TYPE_VDEV
, "<guid>", "GUID", B_TRUE
, sfeatures
);
366 zprop_register_number(VDEV_PROP_STATE
, "state", 0, PROP_READONLY
,
367 ZFS_TYPE_VDEV
, "<state>", "STATE", B_FALSE
, sfeatures
);
368 zprop_register_number(VDEV_PROP_BOOTSIZE
, "bootsize", 0, PROP_READONLY
,
369 ZFS_TYPE_VDEV
, "<size>", "BOOTSIZE", B_FALSE
, sfeatures
);
370 zprop_register_number(VDEV_PROP_ASIZE
, "asize", 0, PROP_READONLY
,
371 ZFS_TYPE_VDEV
, "<asize>", "ASIZE", B_FALSE
, sfeatures
);
372 zprop_register_number(VDEV_PROP_PSIZE
, "psize", 0, PROP_READONLY
,
373 ZFS_TYPE_VDEV
, "<psize>", "PSIZE", B_FALSE
, sfeatures
);
374 zprop_register_number(VDEV_PROP_ASHIFT
, "ashift", 0, PROP_READONLY
,
375 ZFS_TYPE_VDEV
, "<ashift>", "ASHIFT", B_FALSE
, sfeatures
);
376 zprop_register_number(VDEV_PROP_PARITY
, "parity", 0, PROP_READONLY
,
377 ZFS_TYPE_VDEV
, "<parity>", "PARITY", B_FALSE
, sfeatures
);
378 zprop_register_number(VDEV_PROP_NUMCHILDREN
, "numchildren", 0,
379 PROP_READONLY
, ZFS_TYPE_VDEV
, "<number-of-children>", "NUMCHILD",
381 zprop_register_number(VDEV_PROP_READ_ERRORS
, "read_errors", 0,
382 PROP_READONLY
, ZFS_TYPE_VDEV
, "<errors>", "RDERR", B_FALSE
,
384 zprop_register_number(VDEV_PROP_WRITE_ERRORS
, "write_errors", 0,
385 PROP_READONLY
, ZFS_TYPE_VDEV
, "<errors>", "WRERR", B_FALSE
,
387 zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS
, "checksum_errors", 0,
388 PROP_READONLY
, ZFS_TYPE_VDEV
, "<errors>", "CKERR", B_FALSE
,
390 zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS
,
391 "initialize_errors", 0, PROP_READONLY
, ZFS_TYPE_VDEV
, "<errors>",
392 "INITERR", B_FALSE
, sfeatures
);
393 zprop_register_number(VDEV_PROP_TRIM_ERRORS
, "trim_errors", 0,
394 PROP_READONLY
, ZFS_TYPE_VDEV
, "<errors>", "TRIMERR", B_FALSE
,
396 zprop_register_number(VDEV_PROP_SLOW_IOS
, "slow_ios", 0,
397 PROP_READONLY
, ZFS_TYPE_VDEV
, "<slowios>", "SLOW", B_FALSE
,
399 zprop_register_number(VDEV_PROP_OPS_NULL
, "null_ops", 0,
400 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "NULLOP", B_FALSE
,
402 zprop_register_number(VDEV_PROP_OPS_READ
, "read_ops", 0,
403 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "READOP", B_FALSE
,
405 zprop_register_number(VDEV_PROP_OPS_WRITE
, "write_ops", 0,
406 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "WRITEOP", B_FALSE
,
408 zprop_register_number(VDEV_PROP_OPS_FREE
, "free_ops", 0,
409 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "FREEOP", B_FALSE
,
411 zprop_register_number(VDEV_PROP_OPS_CLAIM
, "claim_ops", 0,
412 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "CLAIMOP", B_FALSE
,
414 zprop_register_number(VDEV_PROP_OPS_TRIM
, "trim_ops", 0,
415 PROP_READONLY
, ZFS_TYPE_VDEV
, "<operations>", "TRIMOP", B_FALSE
,
417 zprop_register_number(VDEV_PROP_BYTES_NULL
, "null_bytes", 0,
418 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "NULLBYTE", B_FALSE
,
420 zprop_register_number(VDEV_PROP_BYTES_READ
, "read_bytes", 0,
421 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "READBYTE", B_FALSE
,
423 zprop_register_number(VDEV_PROP_BYTES_WRITE
, "write_bytes", 0,
424 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "WRITEBYTE", B_FALSE
,
426 zprop_register_number(VDEV_PROP_BYTES_FREE
, "free_bytes", 0,
427 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "FREEBYTE", B_FALSE
,
429 zprop_register_number(VDEV_PROP_BYTES_CLAIM
, "claim_bytes", 0,
430 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "CLAIMBYTE", B_FALSE
,
432 zprop_register_number(VDEV_PROP_BYTES_TRIM
, "trim_bytes", 0,
433 PROP_READONLY
, ZFS_TYPE_VDEV
, "<bytes>", "TRIMBYTE", B_FALSE
,
436 /* default numeric properties */
437 zprop_register_number(VDEV_PROP_CHECKSUM_N
, "checksum_n", UINT64_MAX
,
438 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<events>", "CKSUM_N", B_FALSE
,
440 zprop_register_number(VDEV_PROP_CHECKSUM_T
, "checksum_t", UINT64_MAX
,
441 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<seconds>", "CKSUM_T", B_FALSE
,
443 zprop_register_number(VDEV_PROP_IO_N
, "io_n", UINT64_MAX
,
444 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<events>", "IO_N", B_FALSE
,
446 zprop_register_number(VDEV_PROP_IO_T
, "io_t", UINT64_MAX
,
447 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<seconds>", "IO_T", B_FALSE
,
449 zprop_register_number(VDEV_PROP_SLOW_IO_N
, "slow_io_n", UINT64_MAX
,
450 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<events>", "SLOW_IO_N", B_FALSE
,
452 zprop_register_number(VDEV_PROP_SLOW_IO_T
, "slow_io_t", UINT64_MAX
,
453 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "<seconds>", "SLOW_IO_T", B_FALSE
,
456 /* default index (boolean) properties */
457 zprop_register_index(VDEV_PROP_REMOVING
, "removing", 0,
458 PROP_READONLY
, ZFS_TYPE_VDEV
, "on | off", "REMOVING",
459 boolean_table
, sfeatures
);
460 zprop_register_index(VDEV_PROP_ALLOCATING
, "allocating", 1,
461 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "on | off", "ALLOCATING",
462 boolean_na_table
, sfeatures
);
463 zprop_register_index(VDEV_PROP_RAIDZ_EXPANDING
, "raidz_expanding", 0,
464 PROP_READONLY
, ZFS_TYPE_VDEV
, "on | off", "RAIDZ_EXPANDING",
465 boolean_table
, sfeatures
);
466 zprop_register_index(VDEV_PROP_TRIM_SUPPORT
, "trim_support", 0,
467 PROP_READONLY
, ZFS_TYPE_VDEV
, "on | off", "TRIMSUP",
468 boolean_table
, sfeatures
);
470 /* default index properties */
471 zprop_register_index(VDEV_PROP_FAILFAST
, "failfast", B_TRUE
,
472 PROP_DEFAULT
, ZFS_TYPE_VDEV
, "on | off", "FAILFAST", boolean_table
,
475 /* hidden properties */
476 zprop_register_hidden(VDEV_PROP_NAME
, "name", PROP_TYPE_STRING
,
477 PROP_READONLY
, ZFS_TYPE_VDEV
, "NAME", B_TRUE
, sfeatures
);
479 zfs_mod_list_supported_free(sfeatures
);
483 * Given a property name and its type, returns the corresponding property ID.
486 vdev_name_to_prop(const char *propname
)
488 return (zprop_name_to_prop(propname
, ZFS_TYPE_VDEV
));
492 * Returns true if this is a valid user-defined property (one with a ':').
495 vdev_prop_user(const char *name
)
499 boolean_t foundsep
= B_FALSE
;
502 for (i
= 0; i
< len
; i
++) {
504 if (!zprop_valid_char(c
))
514 * Given a pool property ID, returns the corresponding name.
515 * Assuming the pool property ID is valid.
518 vdev_prop_to_name(vdev_prop_t prop
)
520 return (vdev_prop_table
[prop
].pd_name
);
524 vdev_prop_get_type(vdev_prop_t prop
)
526 return (vdev_prop_table
[prop
].pd_proptype
);
530 vdev_prop_readonly(vdev_prop_t prop
)
532 return (vdev_prop_table
[prop
].pd_attr
== PROP_READONLY
);
536 vdev_prop_default_string(vdev_prop_t prop
)
538 return (vdev_prop_table
[prop
].pd_strdefault
);
542 vdev_prop_default_numeric(vdev_prop_t prop
)
544 return (vdev_prop_table
[prop
].pd_numdefault
);
548 vdev_prop_string_to_index(vdev_prop_t prop
, const char *string
,
551 return (zprop_string_to_index(prop
, string
, index
, ZFS_TYPE_VDEV
));
555 vdev_prop_index_to_string(vdev_prop_t prop
, uint64_t index
,
558 return (zprop_index_to_string(prop
, index
, string
, ZFS_TYPE_VDEV
));
562 * Returns true if this is a valid vdev property.
565 zpool_prop_vdev(const char *name
)
567 return (vdev_name_to_prop(name
) != VDEV_PROP_INVAL
);
571 vdev_prop_random_value(vdev_prop_t prop
, uint64_t seed
)
573 return (zprop_random_value(prop
, seed
, ZFS_TYPE_VDEV
));
578 vdev_prop_values(vdev_prop_t prop
)
580 return (vdev_prop_table
[prop
].pd_values
);
584 vdev_prop_column_name(vdev_prop_t prop
)
586 return (vdev_prop_table
[prop
].pd_colname
);
590 vdev_prop_align_right(vdev_prop_t prop
)
592 return (vdev_prop_table
[prop
].pd_rightalign
);
597 /* zpool property functions */
598 EXPORT_SYMBOL(zpool_prop_init
);
599 EXPORT_SYMBOL(zpool_prop_get_type
);
600 EXPORT_SYMBOL(zpool_prop_get_table
);
602 /* vdev property functions */
603 EXPORT_SYMBOL(vdev_prop_init
);
604 EXPORT_SYMBOL(vdev_prop_get_type
);
605 EXPORT_SYMBOL(vdev_prop_get_table
);
607 /* Pool property functions shared between libzfs and kernel. */
608 EXPORT_SYMBOL(zpool_name_to_prop
);
609 EXPORT_SYMBOL(zpool_prop_to_name
);
610 EXPORT_SYMBOL(zpool_prop_default_string
);
611 EXPORT_SYMBOL(zpool_prop_default_numeric
);
612 EXPORT_SYMBOL(zpool_prop_readonly
);
613 EXPORT_SYMBOL(zpool_prop_feature
);
614 EXPORT_SYMBOL(zpool_prop_unsupported
);
615 EXPORT_SYMBOL(zpool_prop_index_to_string
);
616 EXPORT_SYMBOL(zpool_prop_string_to_index
);
617 EXPORT_SYMBOL(zpool_prop_vdev
);
619 /* vdev property functions shared between libzfs and kernel. */
620 EXPORT_SYMBOL(vdev_name_to_prop
);
621 EXPORT_SYMBOL(vdev_prop_user
);
622 EXPORT_SYMBOL(vdev_prop_to_name
);
623 EXPORT_SYMBOL(vdev_prop_default_string
);
624 EXPORT_SYMBOL(vdev_prop_default_numeric
);
625 EXPORT_SYMBOL(vdev_prop_readonly
);
626 EXPORT_SYMBOL(vdev_prop_index_to_string
);
627 EXPORT_SYMBOL(vdev_prop_string_to_index
);