Lines Matching +full:per +full:- +full:slice

1 # SPDX-License-Identifier: CDDL-1.0
10 # or https://opensource.org/licenses/CDDL-1.0.
30 # Copyright (c) 2017, Open-E Inc. All rights reserved.
46 PWD="$(readlink -f $PWD)"
53 if [ -n "$STF_PATH" ]; then
64 [ "$(printf "$1\n$2" | sort -V | tail -n1)" = "$1" ]
74 [ -z "$ver" ] && case "$UNAME" in
78 # RHEL7: 3.10.0-1160.108.1.el7.x86_64
79 # Fedora 37: 6.5.12-100.fc37.x86_64
80 # Debian 12.6: 6.1.0-22-amd64
81 ver=$(uname -r | grep -Eo "^[0-9]+\.[0-9]+\.[0-9]+")
84 # FreeBSD version numbers are X.Y-BRANCH-pZ. Depending on
85 # branch, -pZ may not be present, but this is typically only
86 # on pre-release or true .0 releases, so can be assumed 0
89 # 13.2-RELEASE-p4
90 # 14.1-RELEASE
91 # 15.0-CURRENT
92 ver=$(uname -r | \
93 grep -Eo "[0-9]+\.[0-9]+(-[A-Z0-9]+-p[0-9]+)?" | \
94 sed -E "s/-[^-]+-p/./")
103 IFS='.' read -r version major minor _ <<<"$ver"
105 [ -z "$version" ] && version=0
106 [ -z "$major" ] && major=0
107 [ -z "$minor" ] && minor=0
116 # Used for comparison: if [ $(linux_version) -ge $(linux_version "2.6.32") ]
125 # Used for comparison: if [ $(freebsd_version) -ge $(freebsd_version "13.2") ]
156 # Determine if this is a 32-bit system
158 # Return 0 if platform is 32-bit, 1 if otherwise
171 is_linux && [ -e /sys/kernel/debug/kmemleak ]
177 # $2 filesystem type; optional - defaulted to zfs
184 [[ -z $fstype ]] && fstype=zfs
190 ! zfs mount | awk -v fs="$1" '$2 == fs {exit 1}'
192 ! zfs mount | awk -v ds="$1" '$1 == ds {exit 1}'
197 mount -pt $fstype | while read dev dir _t _flags; do
201 out=$(df -F $fstype $1 2>/dev/null) || return
213 df -t $fstype $1 > /dev/null 2>&1
216 if [[ -L "$ZVOL_DEVDIR/$1" ]]; then
217 link=$(readlink -f $ZVOL_DEVDIR/$1)
218 [[ -n "$link" ]] && \
219 mount | grep -q "^$link" && \
232 # $2 filesystem type; optional - defaulted to zfs
242 # $2 filesystem type; optional - defaulted to zfs
278 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
279 log_must zpool create -f $TESTPOOL $disklist
284 rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
285 mkdir -p $TESTDIR || log_unresolved Could not create $TESTDIR
288 if [[ -z $no_mountpoint ]]; then
292 if [[ -n $container ]]; then
293 rm -rf $TESTDIR1 || \
295 mkdir -p $TESTDIR1 || \
301 if [[ -z $no_mountpoint ]]; then
307 if [[ -n $volume ]]; then
309 log_must zfs create -V $VOLSIZE $TESTPOOL/$TESTVOL
359 typeset fs_vol=${1:-$TESTPOOL/$TESTFS}
360 typeset snap=${2:-$TESTSNAP}
362 [[ -z $fs_vol ]] && log_fail "Filesystem or volume's name is undefined."
363 [[ -z $snap ]] && log_fail "Snapshot's name is undefined."
382 typeset snap=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
383 typeset clone=${2:-$TESTPOOL/$TESTCLONE}
385 [[ -z $snap ]] && \
387 [[ -z $clone ]] && \
403 typeset fs_vol=${1:-$TESTFS}
404 typeset snap=${2:-$TESTSNAP}
405 typeset bkmark=${3:-$TESTBKMARK}
407 [[ -z $fs_vol ]] && log_fail "Filesystem or volume's name is undefined."
408 [[ -z $snap ]] && log_fail "Snapshot's name is undefined."
409 [[ -z $bkmark ]] && log_fail "Bookmark's name is undefined."
431 typeset sendfs="${2:-$TESTPOOL/create_recv_clone}"
437 [[ -z $recvfs ]] && log_fail "Recv filesystem's name is undefined."
442 log_must zfs create -o compression=off -o mountpoint="$mountpoint" $sendfs
444 log_must eval "zfs send $snap | zfs recv -u $recvfs"
447 log_must eval "zfs send -i $snap $incr | dd bs=10K count=1 \
449 log_mustnot eval "zfs recv -su $recvfs < $sendfile"
450 destroy_dataset "$sendfs" "-r"
451 log_must rm -f "$sendfile"
453 if [[ $(get_prop 'inconsistent' "$recvfs/%recv") -ne 1 ]]; then
476 [[ -z $primary ]] && \
478 [[ -z $secondary ]] && \
480 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
481 log_must zpool create -f $TESTPOOL mirror $@
505 # Given a minimum of two disks, set up a storage pool and dataset for the raid-z
513 if [[ ${#disks[*]} -lt 2 ]]; then
514 log_fail "A raid-z requires a minimum of two disks."
517 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
518 log_must zpool create -f $TESTPOOL raidz $disklist
528 # sub-tests to ensure errors from one set of tests doesn't
546 zpool list -H -o name | grep -Fvx "$KEEP" | grep -v "$NO_POOLS"
557 zfs unmount -a > /dev/null 2>&1
562 while [ ! -z ${ALL_POOLS} ]
574 zfs mount -a
577 for fs in $(zfs list -H -o name \
579 destroy_dataset "$fs" "-Rf"
583 for fs in $(zfs list -H -o name); do
585 [[ -d $fs ]] && log_must rm -rf $fs/*
592 for fs in $(zfs list -H -o name); do
598 if [ -z "$enc" ] || [ "$enc" = "off" ]; then
614 [[ -d $TESTDIR ]] && \
615 log_must rm -rf $TESTDIR
622 rm -f $TEST_BASE_DIR/{err,out}
639 destroy_dataset "$TESTPOOL/$TESTCTR/$TESTFS1" "-R"
640 destroy_dataset "$TESTPOOL/$TESTCTR" "-Rf"
642 [[ -e $TESTDIR1 ]] && \
643 log_must rm -rf $TESTDIR1
656 typeset snap=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
673 [[ $mtpt != "" && -d $mtpt ]] && \
674 log_must rm -rf $mtpt
684 typeset clone=${1:-$TESTPOOL/$TESTCLONE}
697 [[ $mtpt != "" && -d $mtpt ]] && \
698 log_must rm -rf $mtpt
709 typeset bkmark=${1:-$TESTPOOL/$TESTFS#$TESTBKMARK}
720 # $1 - snapshot name
724 zfs list -H -t snapshot "$1" > /dev/null 2>&1
730 # $1 - bookmark name
734 zfs list -H -t bookmark "$1" > /dev/null 2>&1
740 # $1 - hold tag
741 # $2 - snapshot name
745 ! zfs holds "$2" | awk -v t="$1" '$2 ~ t { exit 1 }'
757 # non-zero otherwise.
803 gpart destroy -F $diskname
806 DSK=$(echo $DSK | sed -e "s|//|/|g")
807 log_must parted $DSK -s -- mklabel gpt
808 blockdev --rereadpt $DSK 2>/dev/null
821 # Given a slice, size and disk, this function
822 # formats the slice to the specified size.
823 # Size should be specified with units as per
834 typeset -i slicenum=$1
842 if [[ -z $size || -z $disk ]]; then
853 # Create GPT partition table when setting slice 0 or
855 parted $disk -s -- print 1 >/dev/null
857 if [[ $slicenum -eq 0 || $ret_val -ne 0 ]]; then
858 if ! parted $disk -s -- mklabel gpt; then
865 if [[ -z "$start" ]]; then
871 typeset -i cly_size_kb=0
872 cly_size_kb=$(parted -m $disk -s -- unit cyl print |
873 awk -F '[:k.]' 'NR == 3 {print $4}')
876 parted $disk -s -- \
879 if [[ $ret_val -ne 0 ]]; then
884 blockdev --rereadpt $disk 2>/dev/null
888 if [[ -z $size || -z $disk ]]; then
893 if [[ $slicenum -eq 0 ]] || ! gpart show $disk >/dev/null 2>&1; then
894 gpart destroy -F $disk >/dev/null 2>&1
895 if ! gpart create -s GPT $disk; then
903 if [[ -n $start ]]; then
904 start="-b $start"
906 gpart add -t freebsd-zfs $start -s $size -i $index $disk
907 if [[ $ret_val -ne 0 ]]; then
915 if [[ -z $slicenum || -z $size || -z $disk ]]; then
916 log_fail "The slice, size or disk name is unspecified."
932 format -e -s -d $disk -f $format_file
934 rm -f $format_file
938 if [[ $ret_val -ne 0 ]]; then
939 log_note "Unable to format $disk slice $slicenum to $size"
946 # Delete all partitions on all disks - this is specifically for the use of multipath
947 # devices which currently can only be used in the test suite as raw/un-partitioned
954 if [[ -z $DISKSARRAY ]]; then
959 typeset -i part
963 parted $DEV_DSKDIR/$disk -s rm $part > /dev/null 2>&1
964 if lsblk | grep -qF ${partition}; then
973 if gpart destroy -F $disk; then
983 # Get the end cyl of the given slice
985 function get_endslice #<disk> <slice>
988 typeset slice=$2
989 if [[ -z $disk || -z $slice ]] ; then
990 log_fail "The disk name or slice number is unspecified."
995 endcyl=$(parted -s $DEV_DSKDIR/$disk -- unit cyl print | \
996 awk "/part${slice}/"' {sub(/cyl/, "", $3); print $3}')
1002 slice=$((slice + 1))
1004 awk -v slice=$slice '$3 == slice { print $1 + $2 }')
1011 typeset -i ratio=0
1019 typeset -i endcyl=$(prtvtoc -h /dev/rdsk/${disk}s2 |
1020 awk -v token="$slice" '$1 == token {print $6}')
1031 # Given a size,disk and total slice number, this function formats the
1032 # disk slices from 0 to the total slice number with the same specified
1037 typeset -i i=0
1060 # maximum number of files per directory have been written.
1070 # dirnum: the maximum number of subdirectories to use, -1 no limit
1071 # filenum: the maximum number of files per subdirectory
1083 typeset destdir=${1:-$TESTDIR}
1084 typeset -i dirnum=${2:-50}
1085 typeset -i filenum=${3:-50}
1086 typeset -i bytes=${4:-8192}
1087 typeset -i num_writes=${5:-10240}
1088 typeset data=${6:-"R"}
1090 mkdir -p $destdir/{1..$dirnum}
1092 file_write -o create -f $f -b $bytes -c $num_writes -d $data \
1103 zfs get -Hpo value "$prop" "$dataset" || log_fail "zfs get $prop $dataset"
1112 zpool get -Hpo value "$prop" "$pool" || log_fail "zpool get $prop $pool"
1122 zpool get -Hpo value "$prop" "$pool" "$vdev" || log_fail "zpool get $prop $pool $vdev"
1127 # $1 - pool name
1133 if [[ -z $pool ]]; then
1143 # $1-n dataset name
1156 # $1-n dataset name
1165 zfs list -H -t filesystem,snapshot,volume $1 > /dev/null 2>&1 \
1176 # cf. https://github.com/openzfs/zfs/pull/13165#issuecomment-1059845807
1178 # Linux can have spaces (which are \OOO-escaped),
1189 pgrep -q mountd && showmount -E | grep -qx "$fs"
1203 typeset stat=$(svcs -H -o STA nfs/server:default)
1214 ! exportfs -s | awk -v fs="${fs//\\/\\\\}" '/^\// && $1 == fs {exit 1}'
1233 none|legacy|-) return 1
1253 while read -r mtpt _; do
1265 while read -r mtpt _; do
1277 while read -r mtpt _; do
1286 # the os-specific NFS exports file.
1301 none|legacy|-) return 1
1328 net usershare list | grep -xFq "${fs//[-\/]/_}"
1382 read -r mountd < /var/run/mountd.pid
1384 log_must kill -s HUP "$mountd"
1387 log_must share -F nfs "$fs"
1405 log_must exportfs -u "*:$fs"
1409 read -r mountd < /var/run/mountd.pid
1410 awk -v fs="${fs//\\/\\\\}" '$1 != fs' /etc/zfs/exports > /etc/zfs/exports.$$
1412 log_must kill -s HUP "$mountd"
1415 log_must unshare -F nfs $fs
1429 exportfs -v
1435 share -F nfs
1444 exportfs -s
1447 showmount -e
1460 # Cannot share directory in non-global zone.
1469 # Re-synchronize /var/lib/nfs/etab with /etc/exports and
1472 log_must exportfs -r
1477 log_must kill -s HUP $(</var/run/mountd.pid)
1484 if [[ $(svcs -Ho STA $nfs_fmri) != "ON" ]]; then
1491 if [[ -d $dummy ]]; then
1492 log_must rm -rf $dummy
1507 while [[ timeout -ne 0 && $(svcs -Ho STA $nfs_fmri) == *'*' ]]
1511 ((timeout -= 1))
1515 log_must rm -rf $dummy
1518 log_note "Current NFS status: '$(svcs -Ho STA,FMRI $nfs_fmri)'"
1524 # Return 0 if in global zone, 1 in non-global zone
1548 [[ -z $limit ]] && return 0
1557 *) log_note "Warning: unknown limit $limit - " \
1568 *) log_note "Warning: unknown limit $limit - " \
1582 # $1 - pool name
1583 # $2-n - [keyword] devs_list
1591 if [[ -z $pool ]]; then
1601 [[ -d /$pool ]] && rm -rf /$pool
1602 log_must zpool create -f $pool $@
1611 # $1 - pool name
1619 if [[ -z $pool ]]; then
1632 log_must_busy zpool destroy -f $pool
1634 [[ -d $mtpt ]] && \
1635 log_must rm -rf $mtpt
1647 # $1 - dataset name
1648 # $2-n - dataset options
1656 if [[ -z $dataset ]]; then
1673 # $1 - dataset name
1674 # $2 - custom arguments for zfs destroy
1681 typeset args=${2:-""}
1683 if [[ -z $dataset ]]; then
1693 [ -d $mtpt ] && log_must rm -rf $mtpt
1704 # Reexport TESTPOOL & TESTPOOL(1-4)
1708 typeset -i cntctr=5
1709 typeset -i i=0
1738 [[ -z $pool ]] || [[ -z $state ]] \
1741 if [[ -z $disk ]]; then
1743 zpool get -H -o value health $pool | grep -qi "$state"
1745 zpool status -v $pool | grep "$disk" | grep -qi "$state"
1756 typeset dataset=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
1765 if [[ -z $fs || -z $snap ]]; then
1780 zdb -e -lll $device | awk -v ashift=$ashift '
1809 zfs unmount -a > /dev/null 2>&1
1812 if [[ -n $dirs ]] ; then
1814 search_path="$search_path -d $dir"
1820 if ! zdb -cudi $filesys > $zdbout 2>&1; then
1821 log_note "Output: zdb -cudi $filesys"
1823 rm -f $zdbout
1827 log_must zfs mount -a
1828 log_must rm -rf $zdbout
1836 typeset pool=${1:-$TESTPOOL}
1841 typeset -i cksum=$(zpool status $pool | awk '
1848 log_must zpool status -v
1858 echo $(zpool iostat -v $1 | awk '(NR > 4) {print $1}' | \
1859 grep -vEe '^-----' -e "^(mirror|raidz[1-3]|draid[1-3]|spare|log|cache|special|dedup)|\-[0-9]$")
1868 get_disklist "-P $1"
1885 typeset -i TIMEOUT=$1
1896 ps -p $pid > /dev/null 2>&1 &&
1897 log_must kill -USR1 $pid
1927 typeset timeout=${4:-60}
1928 typeset -i i=0
1930 while [[ $i -lt $timeout ]]; do
1968 typeset timeout=${4:-60}
1969 typeset -i i=0
1971 while [[ $i -lt $timeout ]]; do
1992 typeset pool=${1:-$TESTPOOL}
1994 typeset timeout=${3:-300}
2006 # Check the output of 'zpool status -v <pool>',
2016 typeset verbose=${4:-false}
2018 scan=$(zpool status -v "$pool" 2>/dev/null | awk -v token="$token:" '$1==token')
2022 echo $scan | grep -qi "$keyword"
2027 # is_pool_resilvering - to check if the pool resilver is in progress
2028 # is_pool_resilvered - to check if the pool resilver is completed
2029 # is_pool_scrubbing - to check if the pool scrub is in progress
2030 # is_pool_scrubbed - to check if the pool scrub is completed
2031 # is_pool_scrub_stopped - to check if the pool scrub is stopped
2032 # is_pool_scrub_paused - to check if the pool scrub has paused
2033 # is_pool_removing - to check if the pool removing is a vdev
2034 # is_pool_removed - to check if the pool remove is completed
2035 # is_pool_discarding - to check if the pool checkpoint is being discarded
2036 # is_pool_replacing - to check if the pool is performing a replacement
2041 "resilver[ ()0-9A-Za-z:_-]* in progress since" $2
2103 zpool status "$1" | grep -qE 'replacing-[0-9]+'
2109 typeset timeout=${2:-30}
2116 if ((SECONDS - t0 > $timeout)); then
2127 # in the given disk to avoid slice overlapping.
2165 max_finddisksnum=${MAX_FINDDISKSNUM:-6}
2167 swap -l > $sfi
2170 disks=${@:-$(echo "" | format -e 2>/dev/null | awk '
2192 grep -q "${disk}[sp]" /etc/mnttab && continue
2194 grep -q "${disk}[sp]" $sfi && continue
2196 grep -q "${disk}[sp]" $dmpi && continue
2198 # by a user-set environment variable
2199 echo "${ZFS_HOST_DEVICES_IGNORE}" | grep -q "${disk}" && continue
2205 # by looking for a device pointing to the first slice in
2210 [ $count -lt $max_finddisksnum ]; then
2213 [[ -z $@ ]] && ((count = count + 1))
2233 typeset -i uid=1000
2235 pw useradd -u $uid -g $group -d $basedir/$user -m -n $user
2284 typeset -i gid=1000
2286 pw groupadd -g $gid -n $group > /dev/null 2>&1
2308 pw groupdel -n $group > /dev/null 2>&1
2326 log_must useradd -g $group -d $basedir/$user -m $user
2346 typeset -i gid=100
2348 groupadd -g $gid $group > /dev/null 2>&1
2362 groupmod -n $grp $grp > /dev/null 2>&1
2378 log_must useradd -g $group -d $basedir/$user -m $user
2383 cmd_group=$(stat --format="%G" $(command -v zfs))
2384 log_must usermod -a -G $cmd_group $user
2440 typeset basedir=${3:-"$TEST_BASE_DIR"}
2470 typeset basedir=${2:-"$TEST_BASE_DIR"}
2488 [[ -d $basedir/$user ]] && rm -fr $basedir/$user
2564 for pool in $(zpool list -H -o name)
2568 # this is a list of the top-level directories in each of the
2570 FILEPOOL=$(zpool status -v $pool | awk -v pool="/$1/" '$0 ~ pool {print $1}')
2573 ZVOLPOOL=$(zpool status -v $pool | awk -v zvols="$ZVOL_DEVDIR/$1$" '$0 ~ zvols {print $1}')
2575 # also want to determine if it's a file-based pool using an
2577 POOL_FILE_DIRS=$(zpool status -v $pool | \
2579 awk -F/ '!/dev/ {print $2}')
2583 OUTPUT=$(zfs list -H -r -o mountpoint $1 | \
2584 awk -v pd="${pooldir}$" '$0 ~ pd {print $1}')
2590 if [ ! -z "$ZVOLPOOL" ]
2596 if [ ! -z "$FILEPOOL" ]
2602 if [ ! -z "$ALTMOUNTPOOL" ]
2609 if [ -z "${DONT_DESTROY}" ]
2619 # Verify zfs operation with -p option work as expected
2642 ops="create -V $VOLSIZE"
2646 if [[ -z $newdataset ]]; then
2654 if [[ -z $newdataset ]]; then
2666 destroy_dataset "${newdataset%/*}" "-rRf"
2668 # without -p option, operation will fail
2672 # with -p option, operation should succeed
2673 log_must zfs $ops -p $dataset $newdataset
2677 log_fail "-p option does not work for $ops"
2682 log_must zfs $ops -p $dataset $newdataset
2702 zdb -e $pool
2704 zdb -C $pool
2705 fi | awk -F: -v cfg="$config:" '$0 ~ cfg {sub(/^'\''/, $2); sub(/'\''$/, $2); print $2}'
2712 # $2-n string
2720 typeset -i ind
2723 echo "$str" | cut -f $ind -d ' '
2731 typeset -i cnt=$#
2752 typeset -i len=$1
2754 typeset -i baselen=${#basestr}
2755 typeset -i iter=0
2766 ((iter -= 1))
2786 zdb -vvv $1 | awk -F= -v ds="^Dataset $1 "'\\[' '$0 ~ ds && /cksum/ {print $7}'
2790 # Get the given disk/slice state from the specific field of the pool
2796 typeset field=${3:-$pool}
2798 zpool status -v "$pool" 2>/dev/null | \
2799 awk -v device=$disk -v pool=$pool -v field=$field \
2817 rootfs=$(mount -p | awk '$2 == "/" && $3 == "zfs" {print $1}')
2822 if [[ -z "$rootfs" ]]; then
2848 typeset -i min=${2:-1}
2850 typeset -i count=$(echo "$1" | wc -w)
2875 svcs -H -o state labeld 2>/dev/null | grep -q "enabled"
2878 # Return the number of CPUs (cross-platform)
2882 grep -c '^processor' /proc/cpuinfo
2884 sysctl -n kern.smp.cpus
2886 psrinfo | wc -l
2893 [[ $(get_num_cpus) -gt 1 ]]
2901 sysctl -n hw.clockrate
2903 psrinfo -v 0 | awk '/processor operates at/ {print $6}'
2916 if ! sudo -Eu $user test -x $PATH ; then
2917 log_note "-------------------------------------------------"
2928 log_note "to a world-accessible location (like /tmp), and "
2935 log_note "-------------------------------------------------"
2941 sudo -Eu $user \
2964 if [[ -z $pool ]]; then
2972 # can't reference a mirror/raidz vdev using its ID (i.e mirror-0),
2975 zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile
2977 grep -wq ${vdev##*/} $tmpfile || return 1
2980 rm -f $tmpfile
2986 typeset -l i max=$1
3001 typeset nfiles=${3:-1}
3002 typeset bs=${4:-1024k}
3003 typeset fname=${5:-file}
3005 [[ -d $dir ]] || log_fail "No directory: $dir"
3009 # command line options and cases where the --buffer_compress_*
3017 truncate -s $file_bytes $dir/$fname.$i
3027 command -v fio > /dev/null || log_unsupported "fio missing"
3029 --name=job \
3030 --fallocate=0 \
3031 --minimal \
3032 --randrepeat=0 \
3033 --buffer_compress_percentage=66 \
3034 --buffer_compress_chunk=4096 \
3035 --directory="$dir" \
3036 --numjobs="$nfiles" \
3037 --nrfiles="$nfiles" \
3038 --rw=write \
3039 --bs="$bs" \
3040 --filesize="$megs" \
3041 "--filename_format='$fname.\$jobnum' >/dev/null"
3050 [[ -e $pathname ]] || log_fail "No such file or directory: $pathname"
3052 objnum=$(stat -f "%i" $pathname)
3054 objnum=$(stat -c %i $pathname)
3067 typeset pool=${1:-$TESTPOOL}
3068 typeset force=${2:-false}
3071 log_must zpool sync -f $pool
3086 typeset force=${1:-false}
3089 log_must zpool sync -f
3104 typeset pool=${1:-$TESTPOOL}
3106 [[ "0" == "$(zpool list -Ho freeing $pool)" ]] && break
3119 typeset timeout=${2:-300}
3120 typeset pool=${1:-$TESTPOOL}
3134 typeset timeout=${2:-300}
3135 typeset pool=${1:-$TESTPOOL}
3167 if [[ ! -d $ZEDLET_DIR ]]; then
3171 if [[ ! -e $VDEVID_CONF ]]; then
3175 if [[ -e $VDEVID_CONF_ETC ]]; then
3181 log_must ln -s $VDEVID_CONF $VDEVID_CONF_ETC
3186 log_must cp ${ZEDLET_ETC_DIR}/zed-functions.sh $ZEDLET_DIR
3189 if [[ -n "$EXTRA_ZEDLETS" ]] ; then
3199 log_must sed -i '/\#ZED_DEBUG_LOG=.*/d' $ZEDLET_DIR/zed.rc
3215 log_must rm -f ${ZEDLET_DIR}/$extra_zedlet
3217 …log_must rm -fd ${ZEDLET_DIR}/zed.rc ${ZEDLET_DIR}/zed-functions.sh ${ZEDLET_DIR}/all-syslog.sh ${…
3230 zedpids="$(pgrep -x zed)"
3231 zedpids2="$(pgrep -x lt-zed)"
3245 if [[ ! -d $ZEDLET_DIR ]]; then
3251 if [ -n "$zedpids" ]; then
3253 # is already running - usually this implies our test cases
3257 log_fail "ZED already running - ${zedpids}"
3262 log_must truncate -s 0 $ZED_DEBUG_LOG
3263 log_must eval "zed -vF -d $ZEDLET_DIR -P $PATH" \
3264 "-s $ZEDLET_DIR/state -j 1 2>$ZED_LOG &"
3282 [ ! -n "$zedpids" ] && break
3295 while [ $(zpool events -H | wc -l) -ne 0 ]; do
3297 zpool events -c >/dev/null
3301 # Set a variable in zed.rc to something, un-commenting it in the process.
3311 eval sed -i $cmd $ZEDLET_DIR/zed.rc
3325 if [[ -z $device ]] ; then
3332 swapon -s | grep -wq $(readlink -f $device)
3335 swapctl -l | grep -wq $device
3338 swap -l | grep -wq $device
3356 log_must swapctl -a $swapdev
3359 log_must swap -a $swapdev
3379 log_must swap -d $swapdev
3387 # Set a global system tunable (64-bit value)
3398 # Set a global system tunable (32-bit value)
3426 [[ -z "$value" ]] && return 1
3427 [[ -z "$mdb_cmd" ]] && return 1
3438 echo "${tunable}/${mdb_cmd}0t${value}" | mdb -kw
3446 [[ ! -d $TEST_BASE_DIR ]] && return 1
3447 [[ -e $TEST_BASE_DIR/tunable-$1 ]] && return 2
3448 echo "$(get_tunable """$1""")" > "$TEST_BASE_DIR"/tunable-"$1"
3455 [[ ! -e $TEST_BASE_DIR/tunable-$1 ]] && return 1
3456 val="$(cat $TEST_BASE_DIR/tunable-"""$1""")"
3458 rm $TEST_BASE_DIR/tunable-$1
3475 typeset module="${2:-zfs}"
3481 if [ -z "$check_only" ] ; then
3488 if [ -z "$check_only" ] ; then
3504 sysctl -n vfs.zfs.$tunable
3507 [[ "$module" -eq "zfs" ]] || return 1
3548 echo y | newfs -v "$@"
3559 stat -f %z "$path"
3562 stat -c %s "$path"
3573 stat -f %m "$path"
3576 stat -c %Y "$path"
3587 stat -f %c "$path"
3590 stat -c %Z "$path"
3601 stat -f %B "$path"
3604 stat -c %W "$path"
3618 stat -f %v "${path}"
3632 script -q /dev/null env "$@"
3634 script --return --quiet -c "$*" /dev/null
3643 typeset -i begin=$1
3644 typeset -i end=$2
3646 seq ${begin} ${end} | sort -R
3650 # Cross-platform xattr helpers
3660 getextattr -qq user "${name}" "${path}"
3663 attr -qg "${name}" "${path}"
3679 attr -qs "${name}" -V "${value}" "${path}"
3691 setextattr -i user "${name}" "${path}"
3694 attr -qs "${name}" "${path}"
3706 rmextattr -q user "${name}" "${path}"
3709 attr -qr "${name}" "${path}"
3720 lsextattr -qq user "${path}"
3723 attr -ql "${path}"
3736 truncate -d -o $offset -l $length "$file"
3739 fallocate --punch-hole --offset $offset --length $length "$file"
3755 fallocate --zero-range --offset $offset --length $length "$file"
3764 # Wait for the specified arcstat to reach non-zero quiescence.
3774 if [[ $echo -eq 0 ]]; then
3778 while $do_once || [ $stat1 -ne $stat2 ] || [ $stat2 -eq 0 ]; do
3785 if [[ $echo -eq 1 ]]; then
3814 if [ $child_exit -ne 0 ]; then
3825 # output and a non-zero error is returned.
3836 zil_replay="${LIBTEST_DIFF_ZIL_REPLAY:-0}"
3840 if ! [ -d "$dir_a" -a -d "$dir_b" ]; then
3844 # Run rsync with --dry-run --itemize-changes to get something akin to diff
3848 # Also make sure to filter out non-user.* xattrs when comparing. On
3849 # SELinux-enabled systems the copied tree will probably have different
3851 args=("-nicaAHX" '--filter=-x! user.*' "--delete")
3853 # NOTE: Quite a few rsync builds do not support --crtimes which would be
3862 if rsync --version | grep -q "[, ] crtimes"; then
3863 args+=("--crtimes")
3865 log_note "This rsync package does not support --crtimes (-N)."
3869 # Unfortunately --no-times doesn't do what we want -- it will still tell
3873 if [ "$zil_replay" -eq 0 ]; then
3879 filter=("grep" "-v" '^\..[.Tt]\+ ')
3884 if [ -n "$diff" ]; then
3911 ulimit -c unlimited
3919 sysctl -n kern.corefile
3924 coreadm -p "$1/core.%f"
3934 [ -s "$1" ] || return 0
3938 { read -r pat; read -r pid; } < "$1"