The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/module/zcommon/zpool_prop.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * CDDL HEADER START
    3  *
    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.
    7  *
    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.
   12  *
   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]
   18  *
   19  * CDDL HEADER END
   20  */
   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 <colm@tuatha.org>
   26  * Copyright (c) 2021, Klara Inc.
   27  */
   28 
   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>
   34 
   35 #include "zfs_prop.h"
   36 
   37 #if !defined(_KERNEL)
   38 #include <stdlib.h>
   39 #include <string.h>
   40 #include <ctype.h>
   41 #endif
   42 
   43 static zprop_desc_t zpool_prop_table[ZPOOL_NUM_PROPS];
   44 static zprop_desc_t vdev_prop_table[VDEV_NUM_PROPS];
   45 
   46 zprop_desc_t *
   47 zpool_prop_get_table(void)
   48 {
   49         return (zpool_prop_table);
   50 }
   51 
   52 void
   53 zpool_prop_init(void)
   54 {
   55         static const zprop_index_t boolean_table[] = {
   56                 { "off",        0},
   57                 { "on",         1},
   58                 { NULL }
   59         };
   60 
   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 }
   66         };
   67 
   68         struct zfs_mod_supported_features *sfeatures =
   69             zfs_mod_list_supported(ZFS_SYSFS_POOL_PROPERTIES);
   70 
   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);
   85 
   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 
  120         /* default number properties */
  121         zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
  122             PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION", B_FALSE,
  123             sfeatures);
  124         zprop_register_number(ZPOOL_PROP_ASHIFT, "ashift", 0, PROP_DEFAULT,
  125             ZFS_TYPE_POOL, "<ashift, 9-16, or 0=default>", "ASHIFT", B_FALSE,
  126             sfeatures);
  127 
  128         /* default index (boolean) properties */
  129         zprop_register_index(ZPOOL_PROP_DELEGATION, "delegation", 1,
  130             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "DELEGATION",
  131             boolean_table, sfeatures);
  132         zprop_register_index(ZPOOL_PROP_AUTOREPLACE, "autoreplace", 0,
  133             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "REPLACE", boolean_table,
  134             sfeatures);
  135         zprop_register_index(ZPOOL_PROP_LISTSNAPS, "listsnapshots", 0,
  136             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "LISTSNAPS",
  137             boolean_table, sfeatures);
  138         zprop_register_index(ZPOOL_PROP_AUTOEXPAND, "autoexpand", 0,
  139             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "EXPAND", boolean_table,
  140             sfeatures);
  141         zprop_register_index(ZPOOL_PROP_READONLY, "readonly", 0,
  142             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "RDONLY", boolean_table,
  143             sfeatures);
  144         zprop_register_index(ZPOOL_PROP_MULTIHOST, "multihost", 0,
  145             PROP_DEFAULT, ZFS_TYPE_POOL, "on | off", "MULTIHOST",
  146             boolean_table, sfeatures);
  147 
  148         /* default index properties */
  149         zprop_register_index(ZPOOL_PROP_FAILUREMODE, "failmode",
  150             ZIO_FAILURE_MODE_WAIT, PROP_DEFAULT, ZFS_TYPE_POOL,
  151             "wait | continue | panic", "FAILMODE", failuremode_table,
  152             sfeatures);
  153         zprop_register_index(ZPOOL_PROP_AUTOTRIM, "autotrim",
  154             SPA_AUTOTRIM_DEFAULT, PROP_DEFAULT, ZFS_TYPE_POOL,
  155             "on | off", "AUTOTRIM", boolean_table, sfeatures);
  156 
  157         /* hidden properties */
  158         zprop_register_hidden(ZPOOL_PROP_NAME, "name", PROP_TYPE_STRING,
  159             PROP_READONLY, ZFS_TYPE_POOL, "NAME", B_TRUE, sfeatures);
  160         zprop_register_hidden(ZPOOL_PROP_MAXBLOCKSIZE, "maxblocksize",
  161             PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXBLOCKSIZE",
  162             B_FALSE, sfeatures);
  163         zprop_register_hidden(ZPOOL_PROP_TNAME, "tname", PROP_TYPE_STRING,
  164             PROP_ONETIME, ZFS_TYPE_POOL, "TNAME", B_TRUE, sfeatures);
  165         zprop_register_hidden(ZPOOL_PROP_MAXDNODESIZE, "maxdnodesize",
  166             PROP_TYPE_NUMBER, PROP_READONLY, ZFS_TYPE_POOL, "MAXDNODESIZE",
  167             B_FALSE, sfeatures);
  168         zprop_register_hidden(ZPOOL_PROP_DEDUPDITTO, "dedupditto",
  169             PROP_TYPE_NUMBER, PROP_DEFAULT, ZFS_TYPE_POOL, "DEDUPDITTO",
  170             B_FALSE, sfeatures);
  171 
  172         zfs_mod_list_supported_free(sfeatures);
  173 }
  174 
  175 /*
  176  * Given a property name and its type, returns the corresponding property ID.
  177  */
  178 zpool_prop_t
  179 zpool_name_to_prop(const char *propname)
  180 {
  181         return (zprop_name_to_prop(propname, ZFS_TYPE_POOL));
  182 }
  183 
  184 /*
  185  * Given a pool property ID, returns the corresponding name.
  186  * Assuming the pool property ID is valid.
  187  */
  188 const char *
  189 zpool_prop_to_name(zpool_prop_t prop)
  190 {
  191         return (zpool_prop_table[prop].pd_name);
  192 }
  193 
  194 zprop_type_t
  195 zpool_prop_get_type(zpool_prop_t prop)
  196 {
  197         return (zpool_prop_table[prop].pd_proptype);
  198 }
  199 
  200 boolean_t
  201 zpool_prop_readonly(zpool_prop_t prop)
  202 {
  203         return (zpool_prop_table[prop].pd_attr == PROP_READONLY);
  204 }
  205 
  206 boolean_t
  207 zpool_prop_setonce(zpool_prop_t prop)
  208 {
  209         return (zpool_prop_table[prop].pd_attr == PROP_ONETIME);
  210 }
  211 
  212 const char *
  213 zpool_prop_default_string(zpool_prop_t prop)
  214 {
  215         return (zpool_prop_table[prop].pd_strdefault);
  216 }
  217 
  218 uint64_t
  219 zpool_prop_default_numeric(zpool_prop_t prop)
  220 {
  221         return (zpool_prop_table[prop].pd_numdefault);
  222 }
  223 
  224 /*
  225  * Returns true if this is a valid feature@ property.
  226  */
  227 boolean_t
  228 zpool_prop_feature(const char *name)
  229 {
  230         static const char *prefix = "feature@";
  231         return (strncmp(name, prefix, strlen(prefix)) == 0);
  232 }
  233 
  234 /*
  235  * Returns true if this is a valid unsupported@ property.
  236  */
  237 boolean_t
  238 zpool_prop_unsupported(const char *name)
  239 {
  240         static const char *prefix = "unsupported@";
  241         return (strncmp(name, prefix, strlen(prefix)) == 0);
  242 }
  243 
  244 int
  245 zpool_prop_string_to_index(zpool_prop_t prop, const char *string,
  246     uint64_t *index)
  247 {
  248         return (zprop_string_to_index(prop, string, index, ZFS_TYPE_POOL));
  249 }
  250 
  251 int
  252 zpool_prop_index_to_string(zpool_prop_t prop, uint64_t index,
  253     const char **string)
  254 {
  255         return (zprop_index_to_string(prop, index, string, ZFS_TYPE_POOL));
  256 }
  257 
  258 uint64_t
  259 zpool_prop_random_value(zpool_prop_t prop, uint64_t seed)
  260 {
  261         return (zprop_random_value(prop, seed, ZFS_TYPE_POOL));
  262 }
  263 
  264 #ifndef _KERNEL
  265 #include <libzfs.h>
  266 
  267 const char *
  268 zpool_prop_values(zpool_prop_t prop)
  269 {
  270         return (zpool_prop_table[prop].pd_values);
  271 }
  272 
  273 const char *
  274 zpool_prop_column_name(zpool_prop_t prop)
  275 {
  276         return (zpool_prop_table[prop].pd_colname);
  277 }
  278 
  279 boolean_t
  280 zpool_prop_align_right(zpool_prop_t prop)
  281 {
  282         return (zpool_prop_table[prop].pd_rightalign);
  283 }
  284 #endif
  285 
  286 zprop_desc_t *
  287 vdev_prop_get_table(void)
  288 {
  289         return (vdev_prop_table);
  290 }
  291 
  292 void
  293 vdev_prop_init(void)
  294 {
  295         static const zprop_index_t boolean_table[] = {
  296                 { "off",        0},
  297                 { "on",         1},
  298                 { NULL }
  299         };
  300         static const zprop_index_t boolean_na_table[] = {
  301                 { "off",        0},
  302                 { "on",         1},
  303                 { "-",          2},     /* ZPROP_BOOLEAN_NA */
  304                 { NULL }
  305         };
  306 
  307         struct zfs_mod_supported_features *sfeatures =
  308             zfs_mod_list_supported(ZFS_SYSFS_VDEV_PROPERTIES);
  309 
  310         /* string properties */
  311         zprop_register_string(VDEV_PROP_COMMENT, "comment", NULL,
  312             PROP_DEFAULT, ZFS_TYPE_VDEV, "<comment-string>", "COMMENT",
  313             sfeatures);
  314         zprop_register_string(VDEV_PROP_PATH, "path", NULL,
  315             PROP_DEFAULT, ZFS_TYPE_VDEV, "<device-path>", "PATH", sfeatures);
  316         zprop_register_string(VDEV_PROP_DEVID, "devid", NULL,
  317             PROP_READONLY, ZFS_TYPE_VDEV, "<devid>", "DEVID", sfeatures);
  318         zprop_register_string(VDEV_PROP_PHYS_PATH, "physpath", NULL,
  319             PROP_READONLY, ZFS_TYPE_VDEV, "<physpath>", "PHYSPATH", sfeatures);
  320         zprop_register_string(VDEV_PROP_ENC_PATH, "encpath", NULL,
  321             PROP_READONLY, ZFS_TYPE_VDEV, "<encpath>", "ENCPATH", sfeatures);
  322         zprop_register_string(VDEV_PROP_FRU, "fru", NULL,
  323             PROP_READONLY, ZFS_TYPE_VDEV, "<fru>", "FRU", sfeatures);
  324         zprop_register_string(VDEV_PROP_PARENT, "parent", NULL,
  325             PROP_READONLY, ZFS_TYPE_VDEV, "<parent>", "PARENT", sfeatures);
  326         zprop_register_string(VDEV_PROP_CHILDREN, "children", NULL,
  327             PROP_READONLY, ZFS_TYPE_VDEV, "<child[,...]>", "CHILDREN",
  328             sfeatures);
  329 
  330         /* readonly number properties */
  331         zprop_register_number(VDEV_PROP_SIZE, "size", 0, PROP_READONLY,
  332             ZFS_TYPE_VDEV, "<size>", "SIZE", B_FALSE, sfeatures);
  333         zprop_register_number(VDEV_PROP_FREE, "free", 0, PROP_READONLY,
  334             ZFS_TYPE_VDEV, "<size>", "FREE", B_FALSE, sfeatures);
  335         zprop_register_number(VDEV_PROP_ALLOCATED, "allocated", 0,
  336             PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "ALLOC", B_FALSE,
  337             sfeatures);
  338         zprop_register_number(VDEV_PROP_EXPANDSZ, "expandsize", 0,
  339             PROP_READONLY, ZFS_TYPE_VDEV, "<size>", "EXPANDSZ", B_FALSE,
  340             sfeatures);
  341         zprop_register_number(VDEV_PROP_FRAGMENTATION, "fragmentation", 0,
  342             PROP_READONLY, ZFS_TYPE_VDEV, "<percent>", "FRAG", B_FALSE,
  343             sfeatures);
  344         zprop_register_number(VDEV_PROP_CAPACITY, "capacity", 0, PROP_READONLY,
  345             ZFS_TYPE_VDEV, "<size>", "CAP", B_FALSE, sfeatures);
  346         zprop_register_number(VDEV_PROP_GUID, "guid", 0, PROP_READONLY,
  347             ZFS_TYPE_VDEV, "<guid>", "GUID", B_TRUE, sfeatures);
  348         zprop_register_number(VDEV_PROP_STATE, "state", 0, PROP_READONLY,
  349             ZFS_TYPE_VDEV, "<state>", "STATE", B_FALSE, sfeatures);
  350         zprop_register_number(VDEV_PROP_BOOTSIZE, "bootsize", 0, PROP_READONLY,
  351             ZFS_TYPE_VDEV, "<size>", "BOOTSIZE", B_FALSE, sfeatures);
  352         zprop_register_number(VDEV_PROP_ASIZE, "asize", 0, PROP_READONLY,
  353             ZFS_TYPE_VDEV, "<asize>", "ASIZE", B_FALSE, sfeatures);
  354         zprop_register_number(VDEV_PROP_PSIZE, "psize", 0, PROP_READONLY,
  355             ZFS_TYPE_VDEV, "<psize>", "PSIZE", B_FALSE, sfeatures);
  356         zprop_register_number(VDEV_PROP_ASHIFT, "ashift", 0, PROP_READONLY,
  357             ZFS_TYPE_VDEV, "<ashift>", "ASHIFT", B_FALSE, sfeatures);
  358         zprop_register_number(VDEV_PROP_PARITY, "parity", 0, PROP_READONLY,
  359             ZFS_TYPE_VDEV, "<parity>", "PARITY", B_FALSE, sfeatures);
  360         zprop_register_number(VDEV_PROP_NUMCHILDREN, "numchildren", 0,
  361             PROP_READONLY, ZFS_TYPE_VDEV, "<number-of-children>", "NUMCHILD",
  362             B_FALSE, sfeatures);
  363         zprop_register_number(VDEV_PROP_READ_ERRORS, "read_errors", 0,
  364             PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "RDERR", B_FALSE,
  365             sfeatures);
  366         zprop_register_number(VDEV_PROP_WRITE_ERRORS, "write_errors", 0,
  367             PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "WRERR", B_FALSE,
  368             sfeatures);
  369         zprop_register_number(VDEV_PROP_CHECKSUM_ERRORS, "checksum_errors", 0,
  370             PROP_READONLY, ZFS_TYPE_VDEV, "<errors>", "CKERR", B_FALSE,
  371             sfeatures);
  372         zprop_register_number(VDEV_PROP_INITIALIZE_ERRORS,
  373             "initialize_errors", 0, PROP_READONLY, ZFS_TYPE_VDEV, "<errors>",
  374             "INITERR", B_FALSE, sfeatures);
  375         zprop_register_number(VDEV_PROP_OPS_NULL, "null_ops", 0,
  376             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "NULLOP", B_FALSE,
  377             sfeatures);
  378         zprop_register_number(VDEV_PROP_OPS_READ, "read_ops", 0,
  379             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "READOP", B_FALSE,
  380             sfeatures);
  381         zprop_register_number(VDEV_PROP_OPS_WRITE, "write_ops", 0,
  382             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "WRITEOP", B_FALSE,
  383             sfeatures);
  384         zprop_register_number(VDEV_PROP_OPS_FREE, "free_ops", 0,
  385             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "FREEOP", B_FALSE,
  386             sfeatures);
  387         zprop_register_number(VDEV_PROP_OPS_CLAIM, "claim_ops", 0,
  388             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "CLAIMOP", B_FALSE,
  389             sfeatures);
  390         zprop_register_number(VDEV_PROP_OPS_TRIM, "trim_ops", 0,
  391             PROP_READONLY, ZFS_TYPE_VDEV, "<operations>", "TRIMOP", B_FALSE,
  392             sfeatures);
  393         zprop_register_number(VDEV_PROP_BYTES_NULL, "null_bytes", 0,
  394             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "NULLBYTE", B_FALSE,
  395             sfeatures);
  396         zprop_register_number(VDEV_PROP_BYTES_READ, "read_bytes", 0,
  397             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "READBYTE", B_FALSE,
  398             sfeatures);
  399         zprop_register_number(VDEV_PROP_BYTES_WRITE, "write_bytes", 0,
  400             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "WRITEBYTE", B_FALSE,
  401             sfeatures);
  402         zprop_register_number(VDEV_PROP_BYTES_FREE, "free_bytes", 0,
  403             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "FREEBYTE", B_FALSE,
  404             sfeatures);
  405         zprop_register_number(VDEV_PROP_BYTES_CLAIM, "claim_bytes", 0,
  406             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "CLAIMBYTE", B_FALSE,
  407             sfeatures);
  408         zprop_register_number(VDEV_PROP_BYTES_TRIM, "trim_bytes", 0,
  409             PROP_READONLY, ZFS_TYPE_VDEV, "<bytes>", "TRIMBYTE", B_FALSE,
  410             sfeatures);
  411 
  412         /* default numeric properties */
  413         zprop_register_number(VDEV_PROP_CHECKSUM_N, "checksum_n", UINT64_MAX,
  414             PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "CKSUM_N", B_FALSE,
  415             sfeatures);
  416         zprop_register_number(VDEV_PROP_CHECKSUM_T, "checksum_t", UINT64_MAX,
  417             PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "CKSUM_T", B_FALSE,
  418             sfeatures);
  419         zprop_register_number(VDEV_PROP_IO_N, "io_n", UINT64_MAX,
  420             PROP_DEFAULT, ZFS_TYPE_VDEV, "<events>", "IO_N", B_FALSE,
  421             sfeatures);
  422         zprop_register_number(VDEV_PROP_IO_T, "io_t", UINT64_MAX,
  423             PROP_DEFAULT, ZFS_TYPE_VDEV, "<seconds>", "IO_T", B_FALSE,
  424             sfeatures);
  425 
  426         /* default index (boolean) properties */
  427         zprop_register_index(VDEV_PROP_REMOVING, "removing", 0,
  428             PROP_READONLY, ZFS_TYPE_VDEV, "on | off", "REMOVING",
  429             boolean_table, sfeatures);
  430         zprop_register_index(VDEV_PROP_ALLOCATING, "allocating", 1,
  431             PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "ALLOCATING",
  432             boolean_na_table, sfeatures);
  433 
  434         /* default index properties */
  435         zprop_register_index(VDEV_PROP_FAILFAST, "failfast", B_TRUE,
  436             PROP_DEFAULT, ZFS_TYPE_VDEV, "on | off", "FAILFAST", boolean_table,
  437             sfeatures);
  438 
  439         /* hidden properties */
  440         zprop_register_hidden(VDEV_PROP_NAME, "name", PROP_TYPE_STRING,
  441             PROP_READONLY, ZFS_TYPE_VDEV, "NAME", B_TRUE, sfeatures);
  442 
  443         zfs_mod_list_supported_free(sfeatures);
  444 }
  445 
  446 /*
  447  * Given a property name and its type, returns the corresponding property ID.
  448  */
  449 vdev_prop_t
  450 vdev_name_to_prop(const char *propname)
  451 {
  452         return (zprop_name_to_prop(propname, ZFS_TYPE_VDEV));
  453 }
  454 
  455 /*
  456  * Returns true if this is a valid user-defined property (one with a ':').
  457  */
  458 boolean_t
  459 vdev_prop_user(const char *name)
  460 {
  461         int i;
  462         char c;
  463         boolean_t foundsep = B_FALSE;
  464 
  465         for (i = 0; i < strlen(name); i++) {
  466                 c = name[i];
  467                 if (!zprop_valid_char(c))
  468                         return (B_FALSE);
  469                 if (c == ':')
  470                         foundsep = B_TRUE;
  471         }
  472 
  473         return (foundsep);
  474 }
  475 
  476 /*
  477  * Given a pool property ID, returns the corresponding name.
  478  * Assuming the pool property ID is valid.
  479  */
  480 const char *
  481 vdev_prop_to_name(vdev_prop_t prop)
  482 {
  483         return (vdev_prop_table[prop].pd_name);
  484 }
  485 
  486 zprop_type_t
  487 vdev_prop_get_type(vdev_prop_t prop)
  488 {
  489         return (vdev_prop_table[prop].pd_proptype);
  490 }
  491 
  492 boolean_t
  493 vdev_prop_readonly(vdev_prop_t prop)
  494 {
  495         return (vdev_prop_table[prop].pd_attr == PROP_READONLY);
  496 }
  497 
  498 const char *
  499 vdev_prop_default_string(vdev_prop_t prop)
  500 {
  501         return (vdev_prop_table[prop].pd_strdefault);
  502 }
  503 
  504 uint64_t
  505 vdev_prop_default_numeric(vdev_prop_t prop)
  506 {
  507         return (vdev_prop_table[prop].pd_numdefault);
  508 }
  509 
  510 int
  511 vdev_prop_string_to_index(vdev_prop_t prop, const char *string,
  512     uint64_t *index)
  513 {
  514         return (zprop_string_to_index(prop, string, index, ZFS_TYPE_VDEV));
  515 }
  516 
  517 int
  518 vdev_prop_index_to_string(vdev_prop_t prop, uint64_t index,
  519     const char **string)
  520 {
  521         return (zprop_index_to_string(prop, index, string, ZFS_TYPE_VDEV));
  522 }
  523 
  524 /*
  525  * Returns true if this is a valid vdev property.
  526  */
  527 boolean_t
  528 zpool_prop_vdev(const char *name)
  529 {
  530         return (vdev_name_to_prop(name) != VDEV_PROP_INVAL);
  531 }
  532 
  533 uint64_t
  534 vdev_prop_random_value(vdev_prop_t prop, uint64_t seed)
  535 {
  536         return (zprop_random_value(prop, seed, ZFS_TYPE_VDEV));
  537 }
  538 
  539 #ifndef _KERNEL
  540 const char *
  541 vdev_prop_values(vdev_prop_t prop)
  542 {
  543         return (vdev_prop_table[prop].pd_values);
  544 }
  545 
  546 const char *
  547 vdev_prop_column_name(vdev_prop_t prop)
  548 {
  549         return (vdev_prop_table[prop].pd_colname);
  550 }
  551 
  552 boolean_t
  553 vdev_prop_align_right(vdev_prop_t prop)
  554 {
  555         return (vdev_prop_table[prop].pd_rightalign);
  556 }
  557 #endif
  558 
  559 #if defined(_KERNEL)
  560 /* zpool property functions */
  561 EXPORT_SYMBOL(zpool_prop_init);
  562 EXPORT_SYMBOL(zpool_prop_get_type);
  563 EXPORT_SYMBOL(zpool_prop_get_table);
  564 
  565 /* vdev property functions */
  566 EXPORT_SYMBOL(vdev_prop_init);
  567 EXPORT_SYMBOL(vdev_prop_get_type);
  568 EXPORT_SYMBOL(vdev_prop_get_table);
  569 
  570 /* Pool property functions shared between libzfs and kernel. */
  571 EXPORT_SYMBOL(zpool_name_to_prop);
  572 EXPORT_SYMBOL(zpool_prop_to_name);
  573 EXPORT_SYMBOL(zpool_prop_default_string);
  574 EXPORT_SYMBOL(zpool_prop_default_numeric);
  575 EXPORT_SYMBOL(zpool_prop_readonly);
  576 EXPORT_SYMBOL(zpool_prop_feature);
  577 EXPORT_SYMBOL(zpool_prop_unsupported);
  578 EXPORT_SYMBOL(zpool_prop_index_to_string);
  579 EXPORT_SYMBOL(zpool_prop_string_to_index);
  580 EXPORT_SYMBOL(zpool_prop_vdev);
  581 
  582 /* vdev property functions shared between libzfs and kernel. */
  583 EXPORT_SYMBOL(vdev_name_to_prop);
  584 EXPORT_SYMBOL(vdev_prop_user);
  585 EXPORT_SYMBOL(vdev_prop_to_name);
  586 EXPORT_SYMBOL(vdev_prop_default_string);
  587 EXPORT_SYMBOL(vdev_prop_default_numeric);
  588 EXPORT_SYMBOL(vdev_prop_readonly);
  589 EXPORT_SYMBOL(vdev_prop_index_to_string);
  590 EXPORT_SYMBOL(vdev_prop_string_to_index);
  591 #endif

Cache object: 39a326fa16db8dd33e576a48967ed4a5


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.