zdb: show dedup table and log attributes
[zfs.git] / module / zcommon / zpool_prop.c
blobd3355730ba3d0c10c7649eaba9366fc523e2fa27
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
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.
29 #include <sys/zio.h>
30 #include <sys/spa.h>
31 #include <sys/zfs_acl.h>
32 #include <sys/zfs_ioctl.h>
33 #include <sys/fs/zfs.h>
35 #include "zfs_prop.h"
37 #if !defined(_KERNEL)
38 #include <stdlib.h>
39 #include <string.h>
40 #include <ctype.h>
41 #endif
43 static zprop_desc_t zpool_prop_table[ZPOOL_NUM_PROPS];
44 static zprop_desc_t vdev_prop_table[VDEV_NUM_PROPS];
46 zprop_desc_t *
47 zpool_prop_get_table(void)
49 return (zpool_prop_table);
52 void
53 zpool_prop_init(void)
55 static const zprop_index_t boolean_table[] = {
56 { "off", 0},
57 { "on", 1},
58 { NULL }
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 },
65 { NULL }
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",
78 sfeatures);
79 zprop_register_string(ZPOOL_PROP_COMMENT, "comment", NULL,
80 PROP_DEFAULT, ZFS_TYPE_POOL, "<comment-string>", "COMMENT",
81 sfeatures);
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,
95 sfeatures);
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,
100 sfeatures);
101 zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,
102 PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ", B_FALSE,
103 sfeatures);
104 zprop_register_number(ZPOOL_PROP_FRAGMENTATION, "fragmentation", 0,
105 PROP_READONLY, ZFS_TYPE_POOL, "<percent>", "FRAG", B_FALSE,
106 sfeatures);
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",
113 B_TRUE, sfeatures);
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,
130 sfeatures);
132 /* default number properties */
133 zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
134 PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION", B_FALSE,
135 sfeatures);
136 zprop_register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_DEFAULT,
137 ZFS_TYPE_POOL, "<ashift, 9-16, or 0=default>", "ASHIFT", B_FALSE,
138 sfeatures);
139 zprop_register_number(ZPOOL_PROP_DEDUP_TABLE_QUOTA, "dedup_table_quota",
140 UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_POOL, "<size>", "DDTQUOTA",
141 B_FALSE, sfeatures);
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,
149 sfeatures);
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,
155 sfeatures);
156 zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0,
157 PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table,
158 sfeatures);
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,
167 sfeatures);
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",
177 B_FALSE, sfeatures);
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",
182 B_FALSE, sfeatures);
183 zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO, "dedupditto",
184 PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO",
185 B_FALSE, sfeatures);
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.
196 zpool_prop_t
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.
206 const char *
207 zpool_prop_to_name(zpool_prop_t prop)
209 return (zpool_prop_table[prop].pd_name);
212 zprop_type_t
213 zpool_prop_get_type(zpool_prop_t prop)
215 return (zpool_prop_table[prop].pd_proptype);
218 boolean_t
219 zpool_prop_readonly(zpool_prop_t prop)
221 return (zpool_prop_table[prop].pd_attr == PROP_READONLY);
224 boolean_t
225 zpool_prop_setonce(zpool_prop_t prop)
227 return (zpool_prop_table[prop].pd_attr == PROP_ONETIME);
230 const char *
231 zpool_prop_default_string(zpool_prop_t prop)
233 return (zpool_prop_table[prop].pd_strdefault);
236 uint64_t
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.
245 boolean_t
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.
255 boolean_t
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,
264 uint64_t *index)
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,
271 const char **string)
273 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));
276 uint64_t
277 zpool_prop_random_value(zpool_prop_t prop, uint64_t seed)
279 return (zprop_random_value(prop, seed, ZFS_TYPE_POOL));
282 #ifndef _KERNEL
283 #include <libzfs.h>
285 const char *
286 zpool_prop_values(zpool_prop_t prop)
288 return (zpool_prop_table[prop].pd_values);
291 const char *
292 zpool_prop_column_name(zpool_prop_t prop)
294 return (zpool_prop_table[prop].pd_colname);
297 boolean_t
298 zpool_prop_align_right(zpool_prop_t prop)
300 return (zpool_prop_table[prop].pd_rightalign);
302 #endif
304 zprop_desc_t *
305 vdev_prop_get_table(void)
307 return (vdev_prop_table);
310 void
311 vdev_prop_init(void)
313 static const zprop_index_t boolean_table[] = {
314 { "off", 0},
315 { "on", 1},
316 { NULL }
318 static const zprop_index_t boolean_na_table[] = {
319 { "off", 0},
320 { "on", 1},
321 { "-", 2}, /* ZPROP_BOOLEAN_NA */
322 { NULL }
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",
331 sfeatures);
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",
346 sfeatures);
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,
355 sfeatures);
356 zprop_register_number(VDEV_PROP_EXPANDSZ, "expandsize", 0,
357 PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "EXPANDSZ", B_FALSE,
358 sfeatures);
359 zprop_register_number(VDEV_PROP_FRAGMENTATION, "fragmentation", 0,
360 PROP_READONLY, ZFS_TYPE_VDEV, "<percent>", "FRAG", B_FALSE,
361 sfeatures);
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",
380 B_FALSE, sfeatures);
381 zprop_register_number(VDEV_PROP_READ_ERRORS, "read_errors", 0,
382 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "RDERR", B_FALSE,
383 sfeatures);
384 zprop_register_number(VDEV_PROP_WRITE_ERRORS, "write_errors", 0,
385 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "WRERR", B_FALSE,
386 sfeatures);
387 zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS, "checksum_errors", 0,
388 PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "CKERR", B_FALSE,
389 sfeatures);
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,
395 sfeatures);
396 zprop_register_number(VDEV_PROP_SLOW_IOS, "slow_ios", 0,
397 PROP_READONLY, ZFS_TYPE_VDEV, "<slowios>", "SLOW", B_FALSE,
398 sfeatures);
399 zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0,
400 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "NULLOP", B_FALSE,
401 sfeatures);
402 zprop_register_number(VDEV_PROP_OPS_READ, "read_ops", 0,
403 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "READOP", B_FALSE,
404 sfeatures);
405 zprop_register_number(VDEV_PROP_OPS_WRITE, "write_ops", 0,
406 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "WRITEOP", B_FALSE,
407 sfeatures);
408 zprop_register_number(VDEV_PROP_OPS_FREE, "free_ops", 0,
409 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "FREEOP", B_FALSE,
410 sfeatures);
411 zprop_register_number(VDEV_PROP_OPS_CLAIM, "claim_ops", 0,
412 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "CLAIMOP", B_FALSE,
413 sfeatures);
414 zprop_register_number(VDEV_PROP_OPS_TRIM, "trim_ops", 0,
415 PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "TRIMOP", B_FALSE,
416 sfeatures);
417 zprop_register_number(VDEV_PROP_BYTES_NULL, "null_bytes", 0,
418 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "NULLBYTE", B_FALSE,
419 sfeatures);
420 zprop_register_number(VDEV_PROP_BYTES_READ, "read_bytes", 0,
421 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "READBYTE", B_FALSE,
422 sfeatures);
423 zprop_register_number(VDEV_PROP_BYTES_WRITE, "write_bytes", 0,
424 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "WRITEBYTE", B_FALSE,
425 sfeatures);
426 zprop_register_number(VDEV_PROP_BYTES_FREE, "free_bytes", 0,
427 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "FREEBYTE", B_FALSE,
428 sfeatures);
429 zprop_register_number(VDEV_PROP_BYTES_CLAIM, "claim_bytes", 0,
430 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "CLAIMBYTE", B_FALSE,
431 sfeatures);
432 zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0,
433 PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "TRIMBYTE", B_FALSE,
434 sfeatures);
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,
439 sfeatures);
440 zprop_register_number(VDEV_PROP_CHECKSUM_T, "checksum_t", UINT64_MAX,
441 PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "CKSUM_T", B_FALSE,
442 sfeatures);
443 zprop_register_number(VDEV_PROP_IO_N, "io_n", UINT64_MAX,
444 PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "IO_N", B_FALSE,
445 sfeatures);
446 zprop_register_number(VDEV_PROP_IO_T, "io_t", UINT64_MAX,
447 PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "IO_T", B_FALSE,
448 sfeatures);
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,
451 sfeatures);
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,
454 sfeatures);
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,
473 sfeatures);
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.
485 vdev_prop_t
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 ':').
494 boolean_t
495 vdev_prop_user(const char *name)
497 int i, len;
498 char c;
499 boolean_t foundsep = B_FALSE;
501 len = strlen(name);
502 for (i = 0; i < len; i++) {
503 c = name[i];
504 if (!zprop_valid_char(c))
505 return (B_FALSE);
506 if (c == ':')
507 foundsep = B_TRUE;
510 return (foundsep);
514 * Given a pool property ID, returns the corresponding name.
515 * Assuming the pool property ID is valid.
517 const char *
518 vdev_prop_to_name(vdev_prop_t prop)
520 return (vdev_prop_table[prop].pd_name);
523 zprop_type_t
524 vdev_prop_get_type(vdev_prop_t prop)
526 return (vdev_prop_table[prop].pd_proptype);
529 boolean_t
530 vdev_prop_readonly(vdev_prop_t prop)
532 return (vdev_prop_table[prop].pd_attr == PROP_READONLY);
535 const char *
536 vdev_prop_default_string(vdev_prop_t prop)
538 return (vdev_prop_table[prop].pd_strdefault);
541 uint64_t
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,
549 uint64_t *index)
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,
556 const char **string)
558 return (zprop_index_to_string(prop, index, string, ZFS_TYPE_VDEV));
562 * Returns true if this is a valid vdev property.
564 boolean_t
565 zpool_prop_vdev(const char *name)
567 return (vdev_name_to_prop(name) != VDEV_PROP_INVAL);
570 uint64_t
571 vdev_prop_random_value(vdev_prop_t prop, uint64_t seed)
573 return (zprop_random_value(prop, seed, ZFS_TYPE_VDEV));
576 #ifndef _KERNEL
577 const char *
578 vdev_prop_values(vdev_prop_t prop)
580 return (vdev_prop_table[prop].pd_values);
583 const char *
584 vdev_prop_column_name(vdev_prop_t prop)
586 return (vdev_prop_table[prop].pd_colname);
589 boolean_t
590 vdev_prop_align_right(vdev_prop_t prop)
592 return (vdev_prop_table[prop].pd_rightalign);
594 #endif
596 #if defined(_KERNEL)
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);
628 #endif