Path: blob/main/sys/contrib/openzfs/module/zcommon/zpool_prop.c
48383 views
// SPDX-License-Identifier: CDDL-1.01/*2* CDDL HEADER START3*4* The contents of this file are subject to the terms of the5* Common Development and Distribution License (the "License").6* You may not use this file except in compliance with the License.7*8* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE9* or https://opensource.org/licenses/CDDL-1.0.10* See the License for the specific language governing permissions11* and limitations under the License.12*13* When distributing Covered Code, include this CDDL HEADER in each14* file and include the License file at usr/src/OPENSOLARIS.LICENSE.15* If applicable, add the following below this CDDL HEADER, with the16* fields enclosed by brackets "[]" replaced with your own identifying17* information: Portions Copyright [yyyy] [name of copyright owner]18*19* CDDL HEADER END20*/21/*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 <[email protected]>26* Copyright (c) 2021, 2023, Klara Inc.27*/2829#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>3435#include "zfs_prop.h"3637#if !defined(_KERNEL)38#include <stdlib.h>39#include <string.h>40#include <ctype.h>41#endif4243static zprop_desc_t zpool_prop_table[ZPOOL_NUM_PROPS];44static zprop_desc_t vdev_prop_table[VDEV_NUM_PROPS];4546zprop_desc_t *47zpool_prop_get_table(void)48{49return (zpool_prop_table);50}5152void53zpool_prop_init(void)54{55static const zprop_index_t boolean_table[] = {56{ "off", 0},57{ "on", 1},58{ NULL }59};6061static 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 }66};6768struct zfs_mod_supported_features *sfeatures =69zfs_mod_list_supported(ZFS_SYSFS_POOL_PROPERTIES);7071/* string properties */72zprop_register_string(ZPOOL_PROP_ALTROOT, "altroot", NULL, PROP_DEFAULT,73ZFS_TYPE_POOL, "<path>", "ALTROOT", sfeatures);74zprop_register_string(ZPOOL_PROP_BOOTFS, "bootfs", NULL, PROP_DEFAULT,75ZFS_TYPE_POOL, "<filesystem>", "BOOTFS", sfeatures);76zprop_register_string(ZPOOL_PROP_CACHEFILE, "cachefile", NULL,77PROP_DEFAULT, ZFS_TYPE_POOL, "<file> | none", "CACHEFILE",78sfeatures);79zprop_register_string(ZPOOL_PROP_COMMENT, "comment", NULL,80PROP_DEFAULT, ZFS_TYPE_POOL, "<comment-string>", "COMMENT",81sfeatures);82zprop_register_string(ZPOOL_PROP_COMPATIBILITY, "compatibility",83"off", PROP_DEFAULT, ZFS_TYPE_POOL,84"<file[,file...]> | off | legacy", "COMPATIBILITY", sfeatures);8586/* readonly number properties */87zprop_register_number(ZPOOL_PROP_SIZE, "size", 0, PROP_READONLY,88ZFS_TYPE_POOL, "<size>", "SIZE", B_FALSE, sfeatures);89zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY,90ZFS_TYPE_POOL, "<size>", "FREE", B_FALSE, sfeatures);91zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY,92ZFS_TYPE_POOL, "<size>", "FREEING", B_FALSE, sfeatures);93zprop_register_number(ZPOOL_PROP_CHECKPOINT, "checkpoint", 0,94PROP_READONLY, ZFS_TYPE_POOL, "<size>", "CKPOINT", B_FALSE,95sfeatures);96zprop_register_number(ZPOOL_PROP_LEAKED, "leaked", 0, PROP_READONLY,97ZFS_TYPE_POOL, "<size>", "LEAKED", B_FALSE, sfeatures);98zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,99PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC", B_FALSE,100sfeatures);101zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,102PROP_READONLY, ZFS_TYPE_POOL, "<size>", "EXPANDSZ", B_FALSE,103sfeatures);104zprop_register_number(ZPOOL_PROP_FRAGMENTATION, "fragmentation", 0,105PROP_READONLY, ZFS_TYPE_POOL, "<percent>", "FRAG", B_FALSE,106sfeatures);107zprop_register_number(ZPOOL_PROP_CAPACITY, "capacity", 0, PROP_READONLY,108ZFS_TYPE_POOL, "<percent>", "CAP", B_FALSE, sfeatures);109zprop_register_number(ZPOOL_PROP_GUID, "guid", 0, PROP_READONLY,110ZFS_TYPE_POOL, "<guid>", "GUID", B_TRUE, sfeatures);111zprop_register_number(ZPOOL_PROP_LOAD_GUID, "load_guid", 0,112PROP_READONLY, ZFS_TYPE_POOL, "<load_guid>", "LOAD_GUID",113B_TRUE, sfeatures);114zprop_register_number(ZPOOL_PROP_HEALTH, "health", 0, PROP_READONLY,115ZFS_TYPE_POOL, "<state>", "HEALTH", B_FALSE, sfeatures);116zprop_register_number(ZPOOL_PROP_DEDUPRATIO, "dedupratio", 0,117PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>",118"DEDUP", B_FALSE, sfeatures);119zprop_register_number(ZPOOL_PROP_BCLONEUSED, "bcloneused", 0,120PROP_READONLY, ZFS_TYPE_POOL, "<size>",121"BCLONE_USED", B_FALSE, sfeatures);122zprop_register_number(ZPOOL_PROP_BCLONESAVED, "bclonesaved", 0,123PROP_READONLY, ZFS_TYPE_POOL, "<size>",124"BCLONE_SAVED", B_FALSE, sfeatures);125zprop_register_number(ZPOOL_PROP_BCLONERATIO, "bcloneratio", 0,126PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if cloned>",127"BCLONE_RATIO", B_FALSE, sfeatures);128zprop_register_number(ZPOOL_PROP_DEDUP_TABLE_SIZE, "dedup_table_size",1290, PROP_READONLY, ZFS_TYPE_POOL, "<size>", "DDTSIZE", B_FALSE,130sfeatures);131zprop_register_number(ZPOOL_PROP_LAST_SCRUBBED_TXG,132"last_scrubbed_txg", 0, PROP_READONLY, ZFS_TYPE_POOL, "<txg>",133"LAST_SCRUBBED_TXG", B_FALSE, sfeatures);134135/* default number properties */136zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,137PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION", B_FALSE,138sfeatures);139zprop_register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_DEFAULT,140ZFS_TYPE_POOL, "<ashift, 9-16, or 0=default>", "ASHIFT", B_FALSE,141sfeatures);142zprop_register_number(ZPOOL_PROP_DEDUP_TABLE_QUOTA, "dedup_table_quota",143UINT64_MAX, PROP_DEFAULT, ZFS_TYPE_POOL, "<size>", "DDTQUOTA",144B_FALSE, sfeatures);145146/* default index (boolean) properties */147zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1,148PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION",149boolean_table, sfeatures);150zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0,151PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table,152sfeatures);153zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0,154PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS",155boolean_table, sfeatures);156zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0,157PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table,158sfeatures);159zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0,160PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table,161sfeatures);162zprop_register_index(ZPOOL_PROP_MULTIHOST, "multihost", 0,163PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "MULTIHOST",164boolean_table, sfeatures);165166/* default index properties */167zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode",168ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL,169"wait | continue | panic", "FAILMODE", failuremode_table,170sfeatures);171zprop_register_index(ZPOOL_PROP_AUTOTRIM, "autotrim",172SPA_AUTOTRIM_OFF, PROP_DEFAULT, ZFS_TYPE_POOL,173"on | off", "AUTOTRIM", boolean_table, sfeatures);174175/* hidden properties */176zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,177PROP_READONLY, ZFS_TYPE_POOL, "NAME", B_TRUE, sfeatures);178zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE, "maxblocksize",179PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE",180B_FALSE, sfeatures);181zprop_register_hidden(ZPOOL_PROP_TNAME, "tname", PROP_TYPE_STRING,182PROP_ONETIME, ZFS_TYPE_POOL, "TNAME", B_TRUE, sfeatures);183zprop_register_hidden(ZPOOL_PROP_MAXDNODESIZE, "maxdnodesize",184PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXDNODESIZE",185B_FALSE, sfeatures);186zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO, "dedupditto",187PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO",188B_FALSE, sfeatures);189zprop_register_hidden(ZPOOL_PROP_DEDUPCACHED,190ZPOOL_DEDUPCACHED_PROP_NAME, PROP_TYPE_NUMBER, PROP_READONLY,191ZFS_TYPE_POOL, "DEDUPCACHED", B_FALSE, sfeatures);192193zfs_mod_list_supported_free(sfeatures);194}195196/*197* Given a property name and its type, returns the corresponding property ID.198*/199zpool_prop_t200zpool_name_to_prop(const char *propname)201{202return (zprop_name_to_prop(propname, ZFS_TYPE_POOL));203}204205/*206* Given a pool property ID, returns the corresponding name.207* Assuming the pool property ID is valid.208*/209const char *210zpool_prop_to_name(zpool_prop_t prop)211{212return (zpool_prop_table[prop].pd_name);213}214215zprop_type_t216zpool_prop_get_type(zpool_prop_t prop)217{218return (zpool_prop_table[prop].pd_proptype);219}220221boolean_t222zpool_prop_readonly(zpool_prop_t prop)223{224return (zpool_prop_table[prop].pd_attr == PROP_READONLY);225}226227boolean_t228zpool_prop_setonce(zpool_prop_t prop)229{230return (zpool_prop_table[prop].pd_attr == PROP_ONETIME);231}232233const char *234zpool_prop_default_string(zpool_prop_t prop)235{236return (zpool_prop_table[prop].pd_strdefault);237}238239uint64_t240zpool_prop_default_numeric(zpool_prop_t prop)241{242return (zpool_prop_table[prop].pd_numdefault);243}244245/*246* Returns true if this is a valid feature@ property.247*/248boolean_t249zpool_prop_feature(const char *name)250{251static const char *prefix = "feature@";252return (strncmp(name, prefix, strlen(prefix)) == 0);253}254255/*256* Returns true if this is a valid unsupported@ property.257*/258boolean_t259zpool_prop_unsupported(const char *name)260{261static const char *prefix = "unsupported@";262return (strncmp(name, prefix, strlen(prefix)) == 0);263}264265int266zpool_prop_string_to_index(zpool_prop_t prop, const char *string,267uint64_t *index)268{269return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL));270}271272int273zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index,274const char **string)275{276return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));277}278279uint64_t280zpool_prop_random_value(zpool_prop_t prop, uint64_t seed)281{282return (zprop_random_value(prop, seed, ZFS_TYPE_POOL));283}284285#ifndef _KERNEL286#include <libzfs.h>287288const char *289zpool_prop_values(zpool_prop_t prop)290{291return (zpool_prop_table[prop].pd_values);292}293294const char *295zpool_prop_column_name(zpool_prop_t prop)296{297return (zpool_prop_table[prop].pd_colname);298}299300boolean_t301zpool_prop_align_right(zpool_prop_t prop)302{303return (zpool_prop_table[prop].pd_rightalign);304}305#endif306307zprop_desc_t *308vdev_prop_get_table(void)309{310return (vdev_prop_table);311}312313void314vdev_prop_init(void)315{316static const zprop_index_t boolean_table[] = {317{ "off", 0},318{ "on", 1},319{ NULL }320};321static const zprop_index_t boolean_na_table[] = {322{ "off", 0},323{ "on", 1},324{ "-", 2}, /* ZPROP_BOOLEAN_NA */325{ NULL }326};327328struct zfs_mod_supported_features *sfeatures =329zfs_mod_list_supported(ZFS_SYSFS_VDEV_PROPERTIES);330331/* string properties */332zprop_register_string(VDEV_PROP_COMMENT, "comment", NULL,333PROP_DEFAULT, ZFS_TYPE_VDEV, "<comment-string>", "COMMENT",334sfeatures);335zprop_register_string(VDEV_PROP_PATH, "path", NULL,336PROP_DEFAULT, ZFS_TYPE_VDEV, "<device-path>", "PATH", sfeatures);337zprop_register_string(VDEV_PROP_DEVID, "devid", NULL,338PROP_READONLY, ZFS_TYPE_VDEV, "<devid>", "DEVID", sfeatures);339zprop_register_string(VDEV_PROP_PHYS_PATH, "physpath", NULL,340PROP_READONLY, ZFS_TYPE_VDEV, "<physpath>", "PHYSPATH", sfeatures);341zprop_register_string(VDEV_PROP_ENC_PATH, "encpath", NULL,342PROP_READONLY, ZFS_TYPE_VDEV, "<encpath>", "ENCPATH", sfeatures);343zprop_register_string(VDEV_PROP_FRU, "fru", NULL,344PROP_READONLY, ZFS_TYPE_VDEV, "<fru>", "FRU", sfeatures);345zprop_register_string(VDEV_PROP_PARENT, "parent", NULL,346PROP_READONLY, ZFS_TYPE_VDEV, "<parent>", "PARENT", sfeatures);347zprop_register_string(VDEV_PROP_CHILDREN, "children", NULL,348PROP_READONLY, ZFS_TYPE_VDEV, "<child[,...]>", "CHILDREN",349sfeatures);350351/* readonly number properties */352zprop_register_number(VDEV_PROP_SIZE, "size", 0, PROP_READONLY,353ZFS_TYPE_VDEV, "<size>", "SIZE", B_FALSE, sfeatures);354zprop_register_number(VDEV_PROP_FREE, "free", 0, PROP_READONLY,355ZFS_TYPE_VDEV, "<size>", "FREE", B_FALSE, sfeatures);356zprop_register_number(VDEV_PROP_ALLOCATED, "allocated", 0,357PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "ALLOC", B_FALSE,358sfeatures);359zprop_register_number(VDEV_PROP_EXPANDSZ, "expandsize", 0,360PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "EXPANDSZ", B_FALSE,361sfeatures);362zprop_register_number(VDEV_PROP_FRAGMENTATION, "fragmentation", 0,363PROP_READONLY, ZFS_TYPE_VDEV, "<percent>", "FRAG", B_FALSE,364sfeatures);365zprop_register_number(VDEV_PROP_CAPACITY, "capacity", 0, PROP_READONLY,366ZFS_TYPE_VDEV, "<size>", "CAP", B_FALSE, sfeatures);367zprop_register_number(VDEV_PROP_GUID, "guid", 0, PROP_READONLY,368ZFS_TYPE_VDEV, "<guid>", "GUID", B_TRUE, sfeatures);369zprop_register_number(VDEV_PROP_STATE, "state", 0, PROP_READONLY,370ZFS_TYPE_VDEV, "<state>", "STATE", B_FALSE, sfeatures);371zprop_register_number(VDEV_PROP_BOOTSIZE, "bootsize", 0, PROP_READONLY,372ZFS_TYPE_VDEV, "<size>", "BOOTSIZE", B_FALSE, sfeatures);373zprop_register_number(VDEV_PROP_ASIZE, "asize", 0, PROP_READONLY,374ZFS_TYPE_VDEV, "<asize>", "ASIZE", B_FALSE, sfeatures);375zprop_register_number(VDEV_PROP_PSIZE, "psize", 0, PROP_READONLY,376ZFS_TYPE_VDEV, "<psize>", "PSIZE", B_FALSE, sfeatures);377zprop_register_number(VDEV_PROP_ASHIFT, "ashift", 0, PROP_READONLY,378ZFS_TYPE_VDEV, "<ashift>", "ASHIFT", B_FALSE, sfeatures);379zprop_register_number(VDEV_PROP_PARITY, "parity", 0, PROP_READONLY,380ZFS_TYPE_VDEV, "<parity>", "PARITY", B_FALSE, sfeatures);381zprop_register_number(VDEV_PROP_NUMCHILDREN, "numchildren", 0,382PROP_READONLY, ZFS_TYPE_VDEV, "<number-of-children>", "NUMCHILD",383B_FALSE, sfeatures);384zprop_register_number(VDEV_PROP_READ_ERRORS, "read_errors", 0,385PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "RDERR", B_FALSE,386sfeatures);387zprop_register_number(VDEV_PROP_WRITE_ERRORS, "write_errors", 0,388PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "WRERR", B_FALSE,389sfeatures);390zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS, "checksum_errors", 0,391PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "CKERR", B_FALSE,392sfeatures);393zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS,394"initialize_errors", 0, PROP_READONLY, ZFS_TYPE_VDEV, "<errors>",395"INITERR", B_FALSE, sfeatures);396zprop_register_number(VDEV_PROP_TRIM_ERRORS, "trim_errors", 0,397PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "TRIMERR", B_FALSE,398sfeatures);399zprop_register_number(VDEV_PROP_SLOW_IOS, "slow_ios", 0,400PROP_READONLY, ZFS_TYPE_VDEV, "<slowios>", "SLOW", B_FALSE,401sfeatures);402zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0,403PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "NULLOP", B_FALSE,404sfeatures);405zprop_register_number(VDEV_PROP_OPS_READ, "read_ops", 0,406PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "READOP", B_FALSE,407sfeatures);408zprop_register_number(VDEV_PROP_OPS_WRITE, "write_ops", 0,409PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "WRITEOP", B_FALSE,410sfeatures);411zprop_register_number(VDEV_PROP_OPS_FREE, "free_ops", 0,412PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "FREEOP", B_FALSE,413sfeatures);414zprop_register_number(VDEV_PROP_OPS_CLAIM, "claim_ops", 0,415PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "CLAIMOP", B_FALSE,416sfeatures);417zprop_register_number(VDEV_PROP_OPS_TRIM, "trim_ops", 0,418PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "TRIMOP", B_FALSE,419sfeatures);420zprop_register_number(VDEV_PROP_BYTES_NULL, "null_bytes", 0,421PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "NULLBYTE", B_FALSE,422sfeatures);423zprop_register_number(VDEV_PROP_BYTES_READ, "read_bytes", 0,424PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "READBYTE", B_FALSE,425sfeatures);426zprop_register_number(VDEV_PROP_BYTES_WRITE, "write_bytes", 0,427PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "WRITEBYTE", B_FALSE,428sfeatures);429zprop_register_number(VDEV_PROP_BYTES_FREE, "free_bytes", 0,430PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "FREEBYTE", B_FALSE,431sfeatures);432zprop_register_number(VDEV_PROP_BYTES_CLAIM, "claim_bytes", 0,433PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "CLAIMBYTE", B_FALSE,434sfeatures);435zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0,436PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "TRIMBYTE", B_FALSE,437sfeatures);438439/* default numeric properties */440zprop_register_number(VDEV_PROP_CHECKSUM_N, "checksum_n", UINT64_MAX,441PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "CKSUM_N", B_FALSE,442sfeatures);443zprop_register_number(VDEV_PROP_CHECKSUM_T, "checksum_t", UINT64_MAX,444PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "CKSUM_T", B_FALSE,445sfeatures);446zprop_register_number(VDEV_PROP_IO_N, "io_n", UINT64_MAX,447PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "IO_N", B_FALSE,448sfeatures);449zprop_register_number(VDEV_PROP_IO_T, "io_t", UINT64_MAX,450PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "IO_T", B_FALSE,451sfeatures);452zprop_register_number(VDEV_PROP_SLOW_IO_N, "slow_io_n", UINT64_MAX,453PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "SLOW_IO_N", B_FALSE,454sfeatures);455zprop_register_number(VDEV_PROP_SLOW_IO_T, "slow_io_t", UINT64_MAX,456PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "SLOW_IO_T", B_FALSE,457sfeatures);458459/* default index (boolean) properties */460zprop_register_index(VDEV_PROP_REMOVING, "removing", 0,461PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "REMOVING",462boolean_table, sfeatures);463zprop_register_index(VDEV_PROP_ALLOCATING, "allocating", 1,464PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "ALLOCATING",465boolean_na_table, sfeatures);466zprop_register_index(VDEV_PROP_RAIDZ_EXPANDING, "raidz_expanding", 0,467PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "RAIDZ_EXPANDING",468boolean_table, sfeatures);469zprop_register_index(VDEV_PROP_SIT_OUT, "sit_out", 0,470PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "SIT_OUT", boolean_table,471sfeatures);472zprop_register_index(VDEV_PROP_TRIM_SUPPORT, "trim_support", 0,473PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "TRIMSUP",474boolean_table, sfeatures);475zprop_register_index(VDEV_PROP_AUTOSIT, "autosit", 0,476PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "AUTOSIT", boolean_table,477sfeatures);478479/* default index properties */480zprop_register_index(VDEV_PROP_FAILFAST, "failfast", B_TRUE,481PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "FAILFAST", boolean_table,482sfeatures);483484/* hidden properties */485zprop_register_hidden(VDEV_PROP_NAME, "name", PROP_TYPE_STRING,486PROP_READONLY, ZFS_TYPE_VDEV, "NAME", B_TRUE, sfeatures);487488zfs_mod_list_supported_free(sfeatures);489}490491/*492* Given a property name and its type, returns the corresponding property ID.493*/494vdev_prop_t495vdev_name_to_prop(const char *propname)496{497return (zprop_name_to_prop(propname, ZFS_TYPE_VDEV));498}499500/*501* Returns true if this is a valid user-defined property (one with a ':').502*/503boolean_t504vdev_prop_user(const char *name)505{506int i, len;507char c;508boolean_t foundsep = B_FALSE;509510len = strlen(name);511for (i = 0; i < len; i++) {512c = name[i];513if (!zprop_valid_char(c))514return (B_FALSE);515if (c == ':')516foundsep = B_TRUE;517}518519return (foundsep);520}521522/*523* Given a pool property ID, returns the corresponding name.524* Assuming the pool property ID is valid.525*/526const char *527vdev_prop_to_name(vdev_prop_t prop)528{529return (vdev_prop_table[prop].pd_name);530}531532zprop_type_t533vdev_prop_get_type(vdev_prop_t prop)534{535return (vdev_prop_table[prop].pd_proptype);536}537538boolean_t539vdev_prop_readonly(vdev_prop_t prop)540{541return (vdev_prop_table[prop].pd_attr == PROP_READONLY);542}543544const char *545vdev_prop_default_string(vdev_prop_t prop)546{547return (vdev_prop_table[prop].pd_strdefault);548}549550uint64_t551vdev_prop_default_numeric(vdev_prop_t prop)552{553return (vdev_prop_table[prop].pd_numdefault);554}555556int557vdev_prop_string_to_index(vdev_prop_t prop, const char *string,558uint64_t *index)559{560return (zprop_string_to_index(prop, string, index, ZFS_TYPE_VDEV));561}562563int564vdev_prop_index_to_string(vdev_prop_t prop, uint64_t index,565const char **string)566{567return (zprop_index_to_string(prop, index, string, ZFS_TYPE_VDEV));568}569570/*571* Returns true if this is a valid vdev property.572*/573boolean_t574zpool_prop_vdev(const char *name)575{576return (vdev_name_to_prop(name) != VDEV_PROP_INVAL);577}578579uint64_t580vdev_prop_random_value(vdev_prop_t prop, uint64_t seed)581{582return (zprop_random_value(prop, seed, ZFS_TYPE_VDEV));583}584585#ifndef _KERNEL586const char *587vdev_prop_values(vdev_prop_t prop)588{589return (vdev_prop_table[prop].pd_values);590}591592const char *593vdev_prop_column_name(vdev_prop_t prop)594{595return (vdev_prop_table[prop].pd_colname);596}597598boolean_t599vdev_prop_align_right(vdev_prop_t prop)600{601return (vdev_prop_table[prop].pd_rightalign);602}603#endif604605#if defined(_KERNEL)606/* zpool property functions */607EXPORT_SYMBOL(zpool_prop_init);608EXPORT_SYMBOL(zpool_prop_get_type);609EXPORT_SYMBOL(zpool_prop_get_table);610611/* vdev property functions */612EXPORT_SYMBOL(vdev_prop_init);613EXPORT_SYMBOL(vdev_prop_get_type);614EXPORT_SYMBOL(vdev_prop_get_table);615616/* Pool property functions shared between libzfs and kernel. */617EXPORT_SYMBOL(zpool_name_to_prop);618EXPORT_SYMBOL(zpool_prop_to_name);619EXPORT_SYMBOL(zpool_prop_default_string);620EXPORT_SYMBOL(zpool_prop_default_numeric);621EXPORT_SYMBOL(zpool_prop_readonly);622EXPORT_SYMBOL(zpool_prop_feature);623EXPORT_SYMBOL(zpool_prop_unsupported);624EXPORT_SYMBOL(zpool_prop_index_to_string);625EXPORT_SYMBOL(zpool_prop_string_to_index);626EXPORT_SYMBOL(zpool_prop_vdev);627628/* vdev property functions shared between libzfs and kernel. */629EXPORT_SYMBOL(vdev_name_to_prop);630EXPORT_SYMBOL(vdev_prop_user);631EXPORT_SYMBOL(vdev_prop_to_name);632EXPORT_SYMBOL(vdev_prop_default_string);633EXPORT_SYMBOL(vdev_prop_default_numeric);634EXPORT_SYMBOL(vdev_prop_readonly);635EXPORT_SYMBOL(vdev_prop_index_to_string);636EXPORT_SYMBOL(vdev_prop_string_to_index);637#endif638639640