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/tests/zfs-tests/include/properties.shlib

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 # This file and its contents are supplied under the terms of the
    3 # Common Development and Distribution License ("CDDL"), version 1.0.
    4 # You may only use this file in accordance with the terms of version
    5 # 1.0 of the CDDL.
    6 #
    7 # A full copy of the text of the CDDL should have accompanied this
    8 # source.  A copy of the CDDL is also available via the Internet at
    9 # http://www.illumos.org/license/CDDL.
   10 #
   11 
   12 #
   13 # Copyright (c) 2012, 2016, Delphix. All rights reserved.
   14 # Copyright (c) 2022 Hewlett Packard Enterprise Development LP.
   15 #
   16 
   17 . $STF_SUITE/include/libtest.shlib
   18 
   19 typeset -a compress_prop_vals=('off' 'lzjb' 'lz4' 'gzip' 'zle' 'zstd')
   20 typeset -a checksum_prop_vals=('on' 'off' 'fletcher2' 'fletcher4' 'sha256'
   21     'noparity' 'sha512' 'skein' 'blake3')
   22 if ! is_freebsd; then
   23         checksum_prop_vals+=('edonr')
   24 fi
   25 typeset -a recsize_prop_vals=('512' '1024' '2048' '4096' '8192' '16384'
   26     '32768' '65536' '131072' '262144' '524288' '1048576')
   27 typeset -a canmount_prop_vals=('on' 'off' 'noauto')
   28 typeset -a copies_prop_vals=('1' '2' '3')
   29 typeset -a logbias_prop_vals=('latency' 'throughput')
   30 typeset -a primarycache_prop_vals=('all' 'none' 'metadata')
   31 typeset -a redundant_metadata_prop_vals=('all' 'most' 'some' 'none')
   32 typeset -a secondarycache_prop_vals=('all' 'none' 'metadata')
   33 typeset -a snapdir_prop_vals=('hidden' 'visible')
   34 typeset -a sync_prop_vals=('standard' 'always' 'disabled')
   35 
   36 typeset -a fs_props=('compress' 'checksum' 'recsize'
   37     'canmount' 'copies' 'logbias' 'primarycache' 'redundant_metadata'
   38     'secondarycache' 'snapdir' 'sync')
   39 typeset -a vol_props=('compress' 'checksum' 'copies' 'logbias' 'primarycache'
   40     'secondarycache' 'redundant_metadata' 'sync')
   41 
   42 #
   43 # Given the 'prop' passed in, return 'num_vals' elements of the corresponding
   44 # values array to the user, excluding any elements below 'first.' This allows
   45 # us to exclude 'off' and 'on' which can be either unwanted, or a duplicate of
   46 # another property respectively.
   47 #
   48 function get_rand_prop_vals
   49 {
   50         typeset prop=$1
   51         typeset -i num_vals=$2
   52         typeset -i first=$3
   53 
   54         [[ -z $prop || -z $num_vals || -z $first ]] && \
   55             log_fail "get_rand_prop_vals: bad arguments"
   56 
   57         typeset retstr=""
   58 
   59         typeset prop_vals_var=${prop}_prop_vals
   60         typeset -a prop_vals=($(eval echo \${${prop_vals_var}[@]}))
   61 
   62         [[ -z $prop_vals ]] && \
   63             log_fail "get_rand_prop_vals: bad prop $prop"
   64 
   65         typeset -i last=$((${#prop_vals[@]} - 1))
   66         typeset -i i
   67         for i in $(range_shuffle $first $last | head -n $num_vals); do
   68                 retstr="${prop_vals[$i]} $retstr"
   69         done
   70         echo $retstr
   71 }
   72 
   73 #
   74 # Functions to toggle on/off properties
   75 #
   76 typeset -a binary_props=('atime' 'devices' 'exec' 'readonly' 'setuid' 'xattr')
   77 
   78 if is_freebsd; then
   79         binary_props+=('jailed')
   80 else
   81         binary_props+=('zoned')
   82 fi
   83 
   84 # Newer Linuxes dropped non-blocking mandatory locks
   85 if ! is_linux || [ $(linux_version) -lt $(linux_version "4.4") ]; then
   86         binary_props+=('nbmand')
   87 fi
   88 
   89 function toggle_prop
   90 {
   91         typeset ds=$1
   92         typeset prop=$2
   93 
   94         typeset val=$(get_prop $prop $ds)
   95         typeset newval='off'
   96 
   97         [[ $val = $newval ]] && newval='on'
   98         log_must zfs set $prop=$newval $ds
   99 }
  100 
  101 function toggle_binary_props
  102 {
  103         typeset ds=$1
  104         typeset prop
  105 
  106         for prop in "${binary_props[@]}"; do
  107                 toggle_prop $ds $prop
  108         done
  109 }
  110 
  111 function randomize_ds_props
  112 {
  113         typeset ds=$1
  114         typeset prop proplist val
  115 
  116         if ds_is_volume $ds; then
  117                 toggle_prop $ds readonly
  118                 proplist="${vol_props[@]}"
  119         elif ds_is_filesystem $ds; then
  120                 toggle_binary_props $ds
  121                 proplist="${fs_props[@]}"
  122         else
  123                 log_fail "$ds is neither a volume nor a file system"
  124         fi
  125 
  126         for prop in $proplist; do
  127                 typeset val=$(get_rand_prop_vals $prop 1 0)
  128                 log_must zfs set $prop=$val $ds
  129         done
  130 }

Cache object: f24e35f01fb6b82dc658a99d56bb86ab


[ 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.