5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 # Copyright (c) 2012, 2016 by Delphix. All rights reserved.
27 # Copyright 2016 Nexenta Systems, Inc.
28 # Copyright (c) 2017 Lawrence Livermore National Security, LLC.
31 .
${STF_TOOLS}/include
/logapi.shlib
32 .
${STF_SUITE}/include
/math.shlib
35 # Apply constrained path when available. This is required since the
36 # PATH may have been modified by sudo's secure_path behavior.
38 if [ -n "$STF_PATH" ]; then
42 # Determine if this is a Linux test system
44 # Return 0 if platform Linux, 1 if otherwise
48 if [[ $
(uname
-o) == "GNU/Linux" ]]; then
55 # Determine if this is a 32-bit system
57 # Return 0 if platform is 32-bit, 1 if otherwise
61 if [[ $
(getconf LONG_BIT
) == "32" ]]; then
68 # Determine if kmemleak is enabled
70 # Return 0 if kmemleak is enabled, 1 if otherwise
74 if is_linux
&& [[ -e /sys
/kernel
/debug
/kmemleak
]]; then
81 # Determine whether a dataset is mounted
84 # $2 filesystem type; optional - defaulted to zfs
86 # Return 0 if dataset is mounted; 1 if unmounted; 2 on error
91 [[ -z $fstype ]] && fstype
=zfs
92 typeset out dir name ret
96 if [[ "$1" == "/"* ]] ; then
97 for out
in $
(zfs mount |
awk '{print $2}'); do
98 [[ $1 == $out ]] && return 0
101 for out
in $
(zfs mount |
awk '{print $1}'); do
102 [[ $1 == $out ]] && return 0
107 out
=$
(df
-F $fstype $1 2>/dev
/null
)
109 (($ret != 0)) && return $ret
117 [[ "$1" == "$dir" ||
"$1" == "$name" ]] && return 0
120 out
=$
(df
-t $fstype $1 2>/dev
/null
)
124 if [[ -L "$ZVOL_DEVDIR/$1" ]]; then
125 link
=$
(readlink
-f $ZVOL_DEVDIR/$1)
126 [[ -n "$link" ]] && \
127 mount |
grep -q "^$link" && \
136 # Return 0 if a dataset is mounted; 1 otherwise
139 # $2 filesystem type; optional - defaulted to zfs
144 (($?
== 0)) && return 0
148 # Return 0 if a dataset is unmounted; 1 otherwise
151 # $2 filesystem type; optional - defaulted to zfs
156 (($?
== 1)) && return 0
166 echo $1 |
sed "s/,/ /g"
169 function default_setup
171 default_setup_noexit
"$@"
177 # Given a list of disks, setup storage pools and datasets.
179 function default_setup_noexit
184 log_note begin default_setup_noexit
186 if is_global_zone
; then
187 if poolexists
$TESTPOOL ; then
188 destroy_pool
$TESTPOOL
190 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
191 log_must zpool create
-f $TESTPOOL $disklist
196 rm -rf $TESTDIR || log_unresolved Could not remove
$TESTDIR
197 mkdir
-p $TESTDIR || log_unresolved Could not create
$TESTDIR
199 log_must zfs create
$TESTPOOL/$TESTFS
200 log_must zfs
set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
202 if [[ -n $container ]]; then
203 rm -rf $TESTDIR1 || \
204 log_unresolved Could not remove
$TESTDIR1
205 mkdir
-p $TESTDIR1 || \
206 log_unresolved Could not create
$TESTDIR1
208 log_must zfs create
$TESTPOOL/$TESTCTR
209 log_must zfs
set canmount
=off
$TESTPOOL/$TESTCTR
210 log_must zfs create
$TESTPOOL/$TESTCTR/$TESTFS1
211 log_must zfs
set mountpoint
=$TESTDIR1 \
212 $TESTPOOL/$TESTCTR/$TESTFS1
215 if [[ -n $volume ]]; then
216 if is_global_zone
; then
217 log_must zfs create
-V $VOLSIZE $TESTPOOL/$TESTVOL
220 log_must zfs create
$TESTPOOL/$TESTVOL
226 # Given a list of disks, setup a storage pool, file system and
229 function default_container_setup
233 default_setup
"$disklist" "true"
237 # Given a list of disks, setup a storage pool,file system
240 function default_volume_setup
244 default_setup
"$disklist" "" "true"
248 # Given a list of disks, setup a storage pool,file system,
249 # a container and a volume.
251 function default_container_volume_setup
255 default_setup
"$disklist" "true" "true"
259 # Create a snapshot on a filesystem or volume. Defaultly create a snapshot on
262 # $1 Existing filesystem or volume name. Default, $TESTFS
263 # $2 snapshot name. Default, $TESTSNAP
265 function create_snapshot
267 typeset fs_vol
=${1:-$TESTFS}
268 typeset snap
=${2:-$TESTSNAP}
270 [[ -z $fs_vol ]] && log_fail
"Filesystem or volume's name is undefined."
271 [[ -z $snap ]] && log_fail
"Snapshot's name is undefined."
273 if snapexists
$fs_vol@
$snap; then
274 log_fail
"$fs_vol@$snap already exists."
276 datasetexists
$fs_vol || \
277 log_fail
"$fs_vol must exist."
279 log_must zfs snapshot
$fs_vol@
$snap
283 # Create a clone from a snapshot, default clone name is $TESTCLONE.
285 # $1 Existing snapshot, $TESTPOOL/$TESTFS@$TESTSNAP is default.
286 # $2 Clone name, $TESTPOOL/$TESTCLONE is default.
288 function create_clone
# snapshot clone
290 typeset snap
=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
291 typeset clone
=${2:-$TESTPOOL/$TESTCLONE}
294 log_fail
"Snapshot name is undefined."
296 log_fail
"Clone name is undefined."
298 log_must zfs clone
$snap $clone
302 # Create a bookmark of the given snapshot. Defaultly create a bookmark on
305 # $1 Existing filesystem or volume name. Default, $TESTFS
306 # $2 Existing snapshot name. Default, $TESTSNAP
307 # $3 bookmark name. Default, $TESTBKMARK
309 function create_bookmark
311 typeset fs_vol
=${1:-$TESTFS}
312 typeset snap
=${2:-$TESTSNAP}
313 typeset bkmark
=${3:-$TESTBKMARK}
315 [[ -z $fs_vol ]] && log_fail
"Filesystem or volume's name is undefined."
316 [[ -z $snap ]] && log_fail
"Snapshot's name is undefined."
317 [[ -z $bkmark ]] && log_fail
"Bookmark's name is undefined."
319 if bkmarkexists
$fs_vol#$bkmark; then
320 log_fail
"$fs_vol#$bkmark already exists."
322 datasetexists
$fs_vol || \
323 log_fail
"$fs_vol must exist."
324 snapexists
$fs_vol@
$snap || \
325 log_fail
"$fs_vol@$snap must exist."
327 log_must zfs bookmark
$fs_vol@
$snap $fs_vol#$bkmark
330 function default_mirror_setup
332 default_mirror_setup_noexit
$1 $2 $3
338 # Given a pair of disks, set up a storage pool and dataset for the mirror
339 # @parameters: $1 the primary side of the mirror
340 # $2 the secondary side of the mirror
341 # @uses: ZPOOL ZFS TESTPOOL TESTFS
342 function default_mirror_setup_noexit
344 readonly func
="default_mirror_setup_noexit"
348 [[ -z $primary ]] && \
349 log_fail
"$func: No parameters passed"
350 [[ -z $secondary ]] && \
351 log_fail
"$func: No secondary partition passed"
352 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
353 log_must zpool create
-f $TESTPOOL mirror $@
354 log_must zfs create
$TESTPOOL/$TESTFS
355 log_must zfs
set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
359 # create a number of mirrors.
360 # We create a number($1) of 2 way mirrors using the pairs of disks named
361 # on the command line. These mirrors are *not* mounted
362 # @parameters: $1 the number of mirrors to create
363 # $... the devices to use to create the mirrors on
364 # @uses: ZPOOL ZFS TESTPOOL
365 function setup_mirrors
367 typeset
-i nmirrors
=$1
370 while ((nmirrors
> 0)); do
371 log_must
test -n "$1" -a -n "$2"
372 [[ -d /$TESTPOOL$nmirrors ]] && rm -rf /$TESTPOOL$nmirrors
373 log_must zpool create
-f $TESTPOOL$nmirrors mirror
$1 $2
375 ((nmirrors
= nmirrors
- 1))
380 # create a number of raidz pools.
381 # We create a number($1) of 2 raidz pools using the pairs of disks named
382 # on the command line. These pools are *not* mounted
383 # @parameters: $1 the number of pools to create
384 # $... the devices to use to create the pools on
385 # @uses: ZPOOL ZFS TESTPOOL
386 function setup_raidzs
388 typeset
-i nraidzs
=$1
391 while ((nraidzs
> 0)); do
392 log_must
test -n "$1" -a -n "$2"
393 [[ -d /$TESTPOOL$nraidzs ]] && rm -rf /$TESTPOOL$nraidzs
394 log_must zpool create
-f $TESTPOOL$nraidzs raidz
$1 $2
396 ((nraidzs
= nraidzs
- 1))
401 # Destroy the configured testpool mirrors.
402 # the mirrors are of the form ${TESTPOOL}{number}
403 # @uses: ZPOOL ZFS TESTPOOL
404 function destroy_mirrors
406 default_cleanup_noexit
412 # Given a minimum of two disks, set up a storage pool and dataset for the raid-z
413 # $1 the list of disks
415 function default_raidz_setup
417 typeset disklist
="$*"
418 disks
=(${disklist[*]})
420 if [[ ${#disks[*]} -lt 2 ]]; then
421 log_fail
"A raid-z requires a minimum of two disks."
424 [[ -d /$TESTPOOL ]] && rm -rf /$TESTPOOL
425 log_must zpool create
-f $TESTPOOL raidz
$1 $2 $3
426 log_must zfs create
$TESTPOOL/$TESTFS
427 log_must zfs
set mountpoint
=$TESTDIR $TESTPOOL/$TESTFS
433 # Common function used to cleanup storage pools and datasets.
435 # Invoked at the start of the test suite to ensure the system
436 # is in a known state, and also at the end of each set of
437 # sub-tests to ensure errors from one set of tests doesn't
438 # impact the execution of the next set.
440 function default_cleanup
442 default_cleanup_noexit
447 function default_cleanup_noexit
452 # Destroying the pool will also destroy any
453 # filesystems it contains.
455 if is_global_zone
; then
456 zfs unmount
-a > /dev
/null
2>&1
457 exclude
=`eval echo \"'(${KEEP})'\"`
458 ALL_POOLS
=$
(zpool list
-H -o name \
459 |
grep -v "$NO_POOLS" |
egrep -v "$exclude")
460 # Here, we loop through the pools we're allowed to
461 # destroy, only destroying them if it's safe to do
463 while [ ! -z ${ALL_POOLS} ]
465 for pool
in ${ALL_POOLS}
467 if safe_to_destroy_pool
$pool ;
471 ALL_POOLS
=$
(zpool list
-H -o name \
472 |
grep -v "$NO_POOLS" \
473 |
egrep -v "$exclude")
480 for fs
in $
(zfs list
-H -o name \
481 |
grep "^$ZONE_POOL/$ZONE_CTR[01234]/"); do
482 datasetexists
$fs && \
483 log_must zfs destroy
-Rf $fs
486 # Need cleanup here to avoid garbage dir left.
487 for fs
in $
(zfs list
-H -o name
); do
488 [[ $fs == /$ZONE_POOL ]] && continue
489 [[ -d $fs ]] && log_must
rm -rf $fs/*
493 # Reset the $ZONE_POOL/$ZONE_CTR[01234] file systems property to
496 for fs
in $
(zfs list
-H -o name
); do
497 if [[ $fs == $ZONE_POOL/$ZONE_CTR[01234] ]]; then
498 log_must zfs
set reservation
=none
$fs
499 log_must zfs
set recordsize
=128K
$fs
500 log_must zfs
set mountpoint
=/$fs $fs
502 enc
=$
(get_prop encryption
$fs)
503 if [[ $?
-ne 0 ]] ||
[[ -z "$enc" ]] || \
504 [[ "$enc" == "off" ]]; then
505 log_must zfs
set checksum
=on
$fs
507 log_must zfs
set compression
=off
$fs
508 log_must zfs
set atime
=on
$fs
509 log_must zfs
set devices
=off
$fs
510 log_must zfs
set exec=on
$fs
511 log_must zfs
set setuid
=on
$fs
512 log_must zfs
set readonly=off
$fs
513 log_must zfs
set snapdir
=hidden
$fs
514 log_must zfs
set aclmode
=groupmask
$fs
515 log_must zfs
set aclinherit
=secure
$fs
520 [[ -d $TESTDIR ]] && \
521 log_must
rm -rf $TESTDIR
524 if is_mpath_device
$disk1; then
531 # Common function used to cleanup storage pools, file systems
534 function default_container_cleanup
536 if ! is_global_zone
; then
540 ismounted
$TESTPOOL/$TESTCTR/$TESTFS1
542 log_must zfs unmount
$TESTPOOL/$TESTCTR/$TESTFS1
544 datasetexists
$TESTPOOL/$TESTCTR/$TESTFS1 && \
545 log_must zfs destroy
-R $TESTPOOL/$TESTCTR/$TESTFS1
547 datasetexists
$TESTPOOL/$TESTCTR && \
548 log_must zfs destroy
-Rf $TESTPOOL/$TESTCTR
550 [[ -e $TESTDIR1 ]] && \
551 log_must
rm -rf $TESTDIR1 > /dev
/null
2>&1
557 # Common function used to cleanup snapshot of file system or volume. Default to
558 # delete the file system's snapshot
562 function destroy_snapshot
564 typeset snap
=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
566 if ! snapexists
$snap; then
567 log_fail
"'$snap' does not existed."
571 # For the sake of the value which come from 'get_prop' is not equal
572 # to the really mountpoint when the snapshot is unmounted. So, firstly
573 # check and make sure this snapshot's been mounted in current system.
576 if ismounted
$snap; then
577 mtpt
=$
(get_prop mountpoint
$snap)
579 log_fail
"get_prop mountpoint $snap failed."
582 log_must zfs destroy
$snap
583 [[ $mtpt != "" && -d $mtpt ]] && \
584 log_must
rm -rf $mtpt
588 # Common function used to cleanup clone.
592 function destroy_clone
594 typeset clone
=${1:-$TESTPOOL/$TESTCLONE}
596 if ! datasetexists
$clone; then
597 log_fail
"'$clone' does not existed."
600 # With the same reason in destroy_snapshot
602 if ismounted
$clone; then
603 mtpt
=$
(get_prop mountpoint
$clone)
605 log_fail
"get_prop mountpoint $clone failed."
608 log_must zfs destroy
$clone
609 [[ $mtpt != "" && -d $mtpt ]] && \
610 log_must
rm -rf $mtpt
614 # Common function used to cleanup bookmark of file system or volume. Default
615 # to delete the file system's bookmark.
619 function destroy_bookmark
621 typeset bkmark
=${1:-$TESTPOOL/$TESTFS#$TESTBKMARK}
623 if ! bkmarkexists
$bkmark; then
624 log_fail
"'$bkmarkp' does not existed."
627 log_must zfs destroy
$bkmark
630 # Return 0 if a snapshot exists; $? otherwise
636 zfs list
-H -t snapshot
"$1" > /dev
/null
2>&1
641 # Return 0 if a bookmark exists; $? otherwise
645 function bkmarkexists
647 zfs list
-H -t bookmark
"$1" > /dev
/null
2>&1
652 # Set a property to a certain value on a dataset.
653 # Sets a property of the dataset to the value as passed in.
655 # $1 dataset who's property is being set
657 # $3 value to set property to
659 # 0 if the property could be set.
660 # non-zero otherwise.
663 function dataset_setprop
665 typeset fn
=dataset_setprop
668 log_note
"$fn: Insufficient parameters (need 3, had $#)"
672 output
=$
(zfs
set $2=$3 $1 2>&1)
675 log_note
"Setting property on $1 failed."
676 log_note
"property $2=$3"
677 log_note
"Return Code: $rv"
678 log_note
"Output: $output"
685 # Assign suite defined dataset properties.
686 # This function is used to apply the suite's defined default set of
687 # properties to a dataset.
688 # @parameters: $1 dataset to use
689 # @uses: ZFS COMPRESSION_PROP CHECKSUM_PROP
691 # 0 if the dataset has been altered.
692 # 1 if no pool name was passed in.
693 # 2 if the dataset could not be found.
694 # 3 if the dataset could not have it's properties set.
696 function dataset_set_defaultproperties
700 [[ -z $dataset ]] && return 1
704 for confset
in $
(zfs list
); do
705 if [[ $dataset = $confset ]]; then
710 [[ $found -eq 0 ]] && return 2
711 if [[ -n $COMPRESSION_PROP ]]; then
712 dataset_setprop
$dataset compression
$COMPRESSION_PROP || \
714 log_note
"Compression set to '$COMPRESSION_PROP' on $dataset"
716 if [[ -n $CHECKSUM_PROP ]]; then
717 dataset_setprop
$dataset checksum
$CHECKSUM_PROP || \
719 log_note
"Checksum set to '$CHECKSUM_PROP' on $dataset"
725 # Check a numeric assertion
726 # @parameter: $@ the assertion to check
727 # @output: big loud notice if assertion failed
732 (($@
)) || log_fail
"$@"
736 # Function to format partition size of a disk
737 # Given a disk cxtxdx reduces all partitions
740 function zero_partitions
#<whole_disk_name>
746 log_must parted
$DEV_DSKDIR/$diskname -s -- mklabel gpt
748 for i
in 0 1 3 4 5 6 7
750 set_partition
$i "" 0mb
$diskname
756 # Given a slice, size and disk, this function
757 # formats the slice to the specified size.
758 # Size should be specified with units as per
759 # the `format` command requirements eg. 100mb 3gb
761 # NOTE: This entire interface is problematic for the Linux parted utilty
762 # which requires the end of the partition to be specified. It would be
763 # best to retire this interface and replace it with something more flexible.
764 # At the moment a best effort is made.
766 function set_partition
#<slice_num> <slice_start> <size_plus_units> <whole_disk_name>
768 typeset
-i slicenum
=$1
772 [[ -z $slicenum ||
-z $size ||
-z $disk ]] && \
773 log_fail
"The slice, size or disk name is unspecified."
776 typeset size_mb
=${size%%[mMgG]}
778 size_mb
=${size_mb%%[mMgG][bB]}
779 if [[ ${size:1:1} == 'g' ]]; then
780 ((size_mb
= size_mb
* 1024))
783 # Create GPT partition table when setting slice 0 or
784 # when the device doesn't already contain a GPT label.
785 parted
$DEV_DSKDIR/$disk -s -- print
1 >/dev
/null
787 if [[ $slicenum -eq 0 ||
$ret_val -ne 0 ]]; then
788 log_must parted
$DEV_DSKDIR/$disk -s -- mklabel gpt
791 # When no start is given align on the first cylinder.
792 if [[ -z "$start" ]]; then
796 # Determine the cylinder size for the device and using
797 # that calculate the end offset in cylinders.
798 typeset
-i cly_size_kb
=0
799 cly_size_kb
=$
(parted
-m $DEV_DSKDIR/$disk -s -- \
800 unit cyl print |
head -3 |
tail -1 | \
801 awk -F '[:k.]' '{print $4}')
802 ((end
= (size_mb
* 1024 / cly_size_kb
) + start
))
804 log_must parted
$DEV_DSKDIR/$disk -s -- \
805 mkpart part
$slicenum ${start}cyl
${end}cyl
807 blockdev
--rereadpt $DEV_DSKDIR/$disk 2>/dev
/null
810 typeset format_file
=/var
/tmp
/format_in.$$
812 echo "partition" >$format_file
813 echo "$slicenum" >> $format_file
814 echo "" >> $format_file
815 echo "" >> $format_file
816 echo "$start" >> $format_file
817 echo "$size" >> $format_file
818 echo "label" >> $format_file
819 echo "" >> $format_file
820 echo "q" >> $format_file
821 echo "q" >> $format_file
823 format
-e -s -d $disk -f $format_file
828 [[ $ret_val -ne 0 ]] && \
829 log_fail
"Unable to format $disk slice $slicenum to $size"
834 # Delete all partitions on all disks - this is specifically for the use of multipath
835 # devices which currently can only be used in the test suite as raw/un-partitioned
836 # devices (ie a zpool cannot be created on a whole mpath device that has partitions)
838 function delete_partitions
842 if [[ -z $DISK_ARRAY_NUM ]]; then
843 DISK_ARRAY_NUM
=$
(echo ${DISKS} | nawk
'{print NF}')
845 if [[ -z $DISKSARRAY ]]; then
850 if (( $DISK_ARRAY_NUM == 1 )); then
851 while ((j
< MAX_PARTITIONS
)); do
852 parted
$DEV_DSKDIR/$DISK -s rm $j \
854 if (( $?
== 1 )); then
855 lsblk |
egrep ${DISK}${SLICE_PREFIX}${j} > /dev
/null
856 if (( $?
== 1 )); then
857 log_note
"Partitions for $DISK should be deleted"
859 log_fail
"Partition for ${DISK}${SLICE_PREFIX}${j} not deleted"
863 lsblk |
egrep ${DISK}${SLICE_PREFIX}${j} > /dev
/null
864 if (( $?
== 0 )); then
865 log_fail
"Partition for ${DISK}${SLICE_PREFIX}${j} not deleted"
871 for disk
in `echo $DISKSARRAY`; do
872 while ((j
< MAX_PARTITIONS
)); do
873 parted
$DEV_DSKDIR/$disk -s rm $j > /dev
/null
2>&1
874 if (( $?
== 1 )); then
875 lsblk |
egrep ${disk}${SLICE_PREFIX}${j} > /dev
/null
876 if (( $?
== 1 )); then
877 log_note
"Partitions for $disk should be deleted"
879 log_fail
"Partition for ${disk}${SLICE_PREFIX}${j} not deleted"
883 lsblk |
egrep ${disk}${SLICE_PREFIX}${j} > /dev
/null
884 if (( $?
== 0 )); then
885 log_fail
"Partition for ${disk}${SLICE_PREFIX}${j} not deleted"
898 # Get the end cyl of the given slice
900 function get_endslice
#<disk> <slice>
904 if [[ -z $disk ||
-z $slice ]] ; then
905 log_fail
"The disk name or slice number is unspecified."
909 endcyl
=$
(parted
-s $DEV_DSKDIR/$disk -- unit cyl print | \
910 grep "part${slice}" | \
913 ((endcyl
= (endcyl
+ 1)))
915 disk
=${disk#/dev/dsk/}
916 disk
=${disk#/dev/rdsk/}
920 ratio
=$
(prtvtoc
/dev
/rdsk
/${disk}s2 | \
921 grep "sectors\/cylinder" | \
924 if ((ratio
== 0)); then
928 typeset
-i endcyl
=$
(prtvtoc
-h /dev
/rdsk
/${disk}s2 |
929 nawk
-v token
="$slice" '{if ($1==token) print $6}')
931 ((endcyl
= (endcyl
+ 1) / ratio
))
939 # Given a size,disk and total slice number, this function formats the
940 # disk slices from 0 to the total slice number with the same specified
943 function partition_disk
#<slice_size> <whole_disk_name> <total_slices>
946 typeset slice_size
=$1
948 typeset total_slices
=$3
951 zero_partitions
$disk_name
952 while ((i
< $total_slices)); do
959 set_partition
$i "$cyl" $slice_size $disk_name
960 cyl
=$
(get_endslice
$disk_name $i)
966 # This function continues to write to a filenum number of files into dirnum
967 # number of directories until either file_write returns an error or the
968 # maximum number of files per directory have been written.
971 # fill_fs [destdir] [dirnum] [filenum] [bytes] [num_writes] [data]
973 # Return value: 0 on success
977 # destdir: is the directory where everything is to be created under
978 # dirnum: the maximum number of subdirectories to use, -1 no limit
979 # filenum: the maximum number of files per subdirectory
980 # bytes: number of bytes to write
981 # num_writes: numer of types to write out bytes
982 # data: the data that will be written
985 # file_fs /testdir 20 25 1024 256 0
987 # Note: bytes * num_writes equals the size of the testfile
989 function fill_fs
# destdir dirnum filenum bytes num_writes data
991 typeset destdir
=${1:-$TESTDIR}
992 typeset
-i dirnum
=${2:-50}
993 typeset
-i filenum
=${3:-50}
994 typeset
-i bytes
=${4:-8192}
995 typeset
-i num_writes
=${5:-10240}
996 typeset
-i data
=${6:-0}
1003 log_must mkdir
-p $destdir/$idirnum
1004 while (($odirnum > 0)); do
1005 if ((dirnum
>= 0 && idirnum
>= dirnum
)); then
1009 file_write
-o create
-f $destdir/$idirnum/$TESTFILE.
$fn \
1010 -b $bytes -c $num_writes -d $data
1012 if (($retval != 0)); then
1016 if (($fn >= $filenum)); then
1018 ((idirnum
= idirnum
+ 1))
1019 log_must mkdir
-p $destdir/$idirnum
1028 # Simple function to get the specified property. If unable to
1029 # get the property then exits.
1031 # Note property is in 'parsable' format (-p)
1033 function get_prop
# property dataset
1039 prop_val
=$
(zfs get
-pH -o value
$prop $dataset 2>/dev
/null
)
1040 if [[ $?
-ne 0 ]]; then
1041 log_note
"Unable to get $prop property for dataset " \
1051 # Simple function to get the specified property of pool. If unable to
1052 # get the property then exits.
1054 # Note property is in 'parsable' format (-p)
1056 function get_pool_prop
# property pool
1062 if poolexists
$pool ; then
1063 prop_val
=$
(zpool get
-pH $prop $pool 2>/dev
/null |
tail -1 | \
1065 if [[ $?
-ne 0 ]]; then
1066 log_note
"Unable to get $prop property for pool " \
1071 log_note
"Pool $pool not exists."
1079 # Return 0 if a pool exists; $? otherwise
1087 if [[ -z $pool ]]; then
1088 log_note
"No pool name given."
1092 zpool get name
"$pool" > /dev
/null
2>&1
1096 # Return 0 if all the specified datasets exist; $? otherwise
1099 function datasetexists
1101 if (($# == 0)); then
1102 log_note
"No dataset name given."
1106 while (($# > 0)); do
1107 zfs get name
$1 > /dev
/null
2>&1 || \
1115 # return 0 if none of the specified datasets exists, otherwise return 1.
1118 function datasetnonexists
1120 if (($# == 0)); then
1121 log_note
"No dataset name given."
1125 while (($# > 0)); do
1126 zfs list
-H -t filesystem
,snapshot
,volume
$1 > /dev
/null
2>&1 \
1135 # Given a mountpoint, or a dataset name, determine if it is shared via NFS.
1137 # Returns 0 if shared, 1 otherwise.
1144 if [[ $fs != "/"* ]] ; then
1145 if datasetnonexists
"$fs" ; then
1148 mtpt
=$
(get_prop mountpoint
"$fs")
1150 none|legacy|
-) return 1
1159 for mtpt
in `share | awk '{print $1}'` ; do
1160 if [[ $mtpt == $fs ]] ; then
1167 for mtpt
in `share | awk '{print $2}'` ; do
1168 if [[ $mtpt == $fs ]] ; then
1173 typeset stat
=$
(svcs
-H -o STA nfs
/server
:default
)
1174 if [[ $stat != "ON" ]]; then
1175 log_note
"Current nfs/server status: $stat"
1182 # Given a dataset name determine if it is shared via SMB.
1184 # Returns 0 if shared, 1 otherwise.
1186 function is_shared_smb
1191 if datasetnonexists
"$fs" ; then
1194 fs
=$
(echo $fs |
sed 's@/@_@g')
1198 for mtpt
in `net usershare list | awk '{print $1}'` ; do
1199 if [[ $mtpt == $fs ]] ; then
1205 log_unsupported
"Currently unsupported by the test framework"
1211 # Given a mountpoint, determine if it is not shared via NFS.
1213 # Returns 0 if not shared, 1 otherwise.
1220 if (($?
== 0)); then
1228 # Given a dataset determine if it is not shared via SMB.
1230 # Returns 0 if not shared, 1 otherwise.
1232 function not_shared_smb
1237 if (($?
== 0)); then
1245 # Helper function to unshare a mountpoint.
1247 function unshare_fs
#fs
1251 is_shared
$fs || is_shared_smb
$fs
1252 if (($?
== 0)); then
1253 log_must zfs unshare
$fs
1260 # Helper function to share a NFS mountpoint.
1262 function share_nfs
#fs
1268 if (($?
!= 0)); then
1269 log_must share
"*:$fs"
1273 if (($?
!= 0)); then
1274 log_must share
-F nfs
$fs
1282 # Helper function to unshare a NFS mountpoint.
1284 function unshare_nfs
#fs
1290 if (($?
== 0)); then
1291 log_must unshare
-u "*:$fs"
1295 if (($?
== 0)); then
1296 log_must unshare
-F nfs
$fs
1304 # Helper function to show NFS shares.
1306 function showshares_nfs
1318 # Helper function to show SMB shares.
1320 function showshares_smb
1332 # Check NFS server status and trigger it online.
1334 function setup_nfs_server
1336 # Cannot share directory in non-global zone.
1338 if ! is_global_zone
; then
1339 log_note
"Cannot trigger NFS server by sharing in LZ."
1344 log_note
"NFS server must started prior to running test framework."
1348 typeset nfs_fmri
="svc:/network/nfs/server:default"
1349 if [[ $
(svcs
-Ho STA
$nfs_fmri) != "ON" ]]; then
1351 # Only really sharing operation can enable NFS server
1352 # to online permanently.
1354 typeset dummy
=/tmp
/dummy
1356 if [[ -d $dummy ]]; then
1357 log_must
rm -rf $dummy
1360 log_must mkdir
$dummy
1361 log_must share
$dummy
1364 # Waiting for fmri's status to be the final status.
1365 # Otherwise, in transition, an asterisk (*) is appended for
1366 # instances, unshare will reverse status to 'DIS' again.
1368 # Waiting for 1's at least.
1372 while [[ timeout
-ne 0 && $
(svcs
-Ho STA
$nfs_fmri) == *'*' ]]
1379 log_must unshare
$dummy
1380 log_must
rm -rf $dummy
1383 log_note
"Current NFS status: '$(svcs -Ho STA,FMRI $nfs_fmri)'"
1387 # To verify whether calling process is in global zone
1389 # Return 0 if in global zone, 1 in non-global zone
1391 function is_global_zone
1396 typeset cur_zone
=$
(zonename
2>/dev
/null
)
1397 if [[ $cur_zone != "global" ]]; then
1405 # Verify whether test is permitted to run from
1406 # global zone, local zone, or both
1408 # $1 zone limit, could be "global", "local", or "both"(no limit)
1410 # Return 0 if permitted, otherwise exit with log_unsupported
1412 function verify_runnable
# zone limit
1416 [[ -z $limit ]] && return 0
1418 if is_global_zone
; then
1422 local) log_unsupported
"Test is unable to run from "\
1425 *) log_note
"Warning: unknown limit $limit - " \
1433 global
) log_unsupported
"Test is unable to run from "\
1436 *) log_note
"Warning: unknown limit $limit - " \
1447 # Return 0 if create successfully or the pool exists; $? otherwise
1448 # Note: In local zones, this function should return 0 silently.
1451 # $2-n - [keyword] devs_list
1453 function create_pool
#pool devs_list
1455 typeset pool
=${1%%/*}
1459 if [[ -z $pool ]]; then
1460 log_note
"Missing pool name."
1464 if poolexists
$pool ; then
1468 if is_global_zone
; then
1469 [[ -d /$pool ]] && rm -rf /$pool
1470 log_must zpool create
-f $pool $@
1476 # Return 0 if destroy successfully or the pool exists; $? otherwise
1477 # Note: In local zones, this function should return 0 silently.
1480 # Destroy pool with the given parameters.
1482 function destroy_pool
#pool
1484 typeset pool
=${1%%/*}
1487 if [[ -z $pool ]]; then
1488 log_note
"No pool name given."
1492 if is_global_zone
; then
1493 if poolexists
"$pool" ; then
1494 mtpt
=$
(get_prop mountpoint
"$pool")
1496 # At times, syseventd activity can cause attempts to
1497 # destroy a pool to fail with EBUSY. We retry a few
1498 # times allowing failures before requiring the destroy
1500 typeset
-i wait_time
=10 ret
=1 count
=0
1502 while [[ $ret -ne 0 ]]; do
1503 $must zpool destroy
-f $pool
1505 [[ $ret -eq 0 ]] && break
1506 log_note
"zpool destroy failed with $ret"
1507 [[ count
++ -ge 7 ]] && must
=log_must
1512 log_must
rm -rf $mtpt
1514 log_note
"Pool does not exist. ($pool)"
1523 # Firstly, create a pool with 5 datasets. Then, create a single zone and
1524 # export the 5 datasets to it. In addition, we also add a ZFS filesystem
1525 # and a zvol device to the zone.
1528 # $2 zone root directory prefix
1531 function zfs_zones_setup
#zone_name zone_root zone_ip
1533 typeset zone_name
=${1:-$(hostname)-z}
1534 typeset zone_root
=${2:-"/zone_root"}
1535 typeset zone_ip
=${3:-"10.1.1.10"}
1536 typeset prefix_ctr
=$ZONE_CTR
1537 typeset pool_name
=$ZONE_POOL
1541 # Create pool and 5 container within it
1543 [[ -d /$pool_name ]] && rm -rf /$pool_name
1544 log_must zpool create
-f $pool_name $DISKS
1545 while ((i
< cntctr
)); do
1546 log_must zfs create
$pool_name/$prefix_ctr$i
1551 log_must zfs create
-V 1g
$pool_name/zone_zvol
1555 # If current system support slog, add slog device for pool
1557 if verify_slog_support
; then
1558 typeset sdevs
="/var/tmp/sdev1 /var/tmp/sdev2"
1559 log_must mkfile
$MINVDEVSIZE $sdevs
1560 log_must zpool add
$pool_name log mirror
$sdevs
1563 # this isn't supported just yet.
1564 # Create a filesystem. In order to add this to
1565 # the zone, it must have it's mountpoint set to 'legacy'
1566 # log_must zfs create $pool_name/zfs_filesystem
1567 # log_must zfs set mountpoint=legacy $pool_name/zfs_filesystem
1569 [[ -d $zone_root ]] && \
1570 log_must
rm -rf $zone_root/$zone_name
1571 [[ ! -d $zone_root ]] && \
1572 log_must mkdir
-p -m 0700 $zone_root/$zone_name
1574 # Create zone configure file and configure the zone
1576 typeset zone_conf
=/tmp
/zone_conf.$$
1577 echo "create" > $zone_conf
1578 echo "set zonepath=$zone_root/$zone_name" >> $zone_conf
1579 echo "set autoboot=true" >> $zone_conf
1581 while ((i
< cntctr
)); do
1582 echo "add dataset" >> $zone_conf
1583 echo "set name=$pool_name/$prefix_ctr$i" >> \
1585 echo "end" >> $zone_conf
1589 # add our zvol to the zone
1590 echo "add device" >> $zone_conf
1591 echo "set match=/dev/zvol/dsk/$pool_name/zone_zvol" >> $zone_conf
1592 echo "end" >> $zone_conf
1594 # add a corresponding zvol rdsk to the zone
1595 echo "add device" >> $zone_conf
1596 echo "set match=$ZVOL_RDEVDIR/$pool_name/zone_zvol" >> $zone_conf
1597 echo "end" >> $zone_conf
1599 # once it's supported, we'll add our filesystem to the zone
1600 # echo "add fs" >> $zone_conf
1601 # echo "set type=zfs" >> $zone_conf
1602 # echo "set special=$pool_name/zfs_filesystem" >> $zone_conf
1603 # echo "set dir=/export/zfs_filesystem" >> $zone_conf
1604 # echo "end" >> $zone_conf
1606 echo "verify" >> $zone_conf
1607 echo "commit" >> $zone_conf
1608 log_must zonecfg
-z $zone_name -f $zone_conf
1609 log_must
rm -f $zone_conf
1612 zoneadm
-z $zone_name install
1613 if (($?
== 0)); then
1614 log_note
"SUCCESS: zoneadm -z $zone_name install"
1616 log_fail
"FAIL: zoneadm -z $zone_name install"
1619 # Install sysidcfg file
1621 typeset sysidcfg
=$zone_root/$zone_name/root
/etc
/sysidcfg
1622 echo "system_locale=C" > $sysidcfg
1623 echo "terminal=dtterm" >> $sysidcfg
1624 echo "network_interface=primary {" >> $sysidcfg
1625 echo "hostname=$zone_name" >> $sysidcfg
1626 echo "}" >> $sysidcfg
1627 echo "name_service=NONE" >> $sysidcfg
1628 echo "root_password=mo791xfZ/SFiw" >> $sysidcfg
1629 echo "security_policy=NONE" >> $sysidcfg
1630 echo "timezone=US/Eastern" >> $sysidcfg
1633 log_must zoneadm
-z $zone_name boot
1637 # Reexport TESTPOOL & TESTPOOL(1-4)
1639 function reexport_pool
1644 while ((i
< cntctr
)); do
1646 TESTPOOL
=$ZONE_POOL/$ZONE_CTR$i
1647 if ! ismounted
$TESTPOOL; then
1648 log_must zfs mount
$TESTPOOL
1651 eval TESTPOOL
$i=$ZONE_POOL/$ZONE_CTR$i
1652 if eval ! ismounted \
$TESTPOOL$i; then
1653 log_must
eval zfs mount \
$TESTPOOL$i
1661 # Verify a given disk or pool state
1663 # Return 0 is pool/disk matches expected state, 1 otherwise
1665 function check_state
# pool disk state{online,offline,degraded}
1668 typeset disk
=${2#$DEV_DSKDIR/}
1671 [[ -z $pool ]] ||
[[ -z $state ]] \
1672 && log_fail
"Arguments invalid or missing"
1674 if [[ -z $disk ]]; then
1675 #check pool state only
1676 zpool get
-H -o value health
$pool \
1677 |
grep -i "$state" > /dev
/null
2>&1
1679 zpool status
-v $pool |
grep "$disk" \
1680 |
grep -i "$state" > /dev
/null
2>&1
1687 # Cause a scan of all scsi host adapters by default
1689 # $1 optional host number
1691 function scan_scsi_hosts
1693 typeset hostnum
=${1}
1696 if [[ -z $hostnum ]]; then
1697 for host in /sys
/class
/scsi_host
/host*; do
1698 log_must
eval "echo '- - -' > $host/scan"
1702 "echo /sys/class/scsi_host/host$hostnum/scan" \
1705 "echo '- - -' > /sys/class/scsi_host/host$hostnum/scan"
1710 # Wait for newly created block devices to have their minors created.
1712 function block_device_wait
1721 # Online or offline a disk on the system
1723 # First checks state of disk. Test will fail if disk is not properly onlined
1724 # or offlined. Online is a full rescan of SCSI disks by echoing to every
1727 function on_off_disk
# disk state{online,offline} host
1733 [[ -z $disk ]] ||
[[ -z $state ]] && \
1734 log_fail
"Arguments invalid or missing"
1737 if [[ $state == "offline" ]] && ( is_mpath_device
$disk ); then
1738 dm_name
="$(readlink $DEV_DSKDIR/$disk \
1739 | nawk -F / '{print $2}')"
1740 slave
="$(ls /sys/block/${dm_name}/slaves \
1741 | nawk '{print $1}')"
1742 while [[ -n $slave ]]; do
1743 #check if disk is online
1744 lsscsi |
egrep $slave > /dev
/null
1745 if (($?
== 0)); then
1746 slave_dir
="/sys/block/${dm_name}"
1747 slave_dir
+="/slaves/${slave}/device"
1748 ss
="${slave_dir}/state"
1749 sd
="${slave_dir}/delete"
1750 log_must
eval "echo 'offline' > ${ss}"
1751 log_must
eval "echo '1' > ${sd}"
1752 lsscsi |
egrep $slave > /dev
/null
1753 if (($?
== 0)); then
1754 log_fail
"Offlining" \
1758 slave
="$(ls /sys/block/$dm_name/slaves \
1759 2>/dev/null | nawk '{print $1}')"
1761 elif [[ $state == "offline" ]] && ( is_real_device
$disk ); then
1762 #check if disk is online
1763 lsscsi |
egrep $disk > /dev
/null
1764 if (($?
== 0)); then
1765 dev_state
="/sys/block/$disk/device/state"
1766 dev_delete
="/sys/block/$disk/device/delete"
1767 log_must
eval "echo 'offline' > ${dev_state}"
1768 log_must
eval "echo '1' > ${dev_delete}"
1769 lsscsi |
egrep $disk > /dev
/null
1770 if (($?
== 0)); then
1771 log_fail
"Offlining $disk" \
1775 log_note
"$disk is already offline"
1777 elif [[ $state == "online" ]]; then
1778 #force a full rescan
1779 scan_scsi_hosts
$host
1781 if is_mpath_device
$disk; then
1782 dm_name
="$(readlink $DEV_DSKDIR/$disk \
1783 | nawk -F / '{print $2}')"
1784 slave
="$(ls /sys/block/$dm_name/slaves \
1785 | nawk '{print $1}')"
1786 lsscsi |
egrep $slave > /dev
/null
1787 if (($?
!= 0)); then
1788 log_fail
"Onlining $disk failed"
1790 elif is_real_device
$disk; then
1791 lsscsi |
egrep $disk > /dev
/null
1792 if (($?
!= 0)); then
1793 log_fail
"Onlining $disk failed"
1796 log_fail
"$disk is not a real dev"
1799 log_fail
"$disk failed to $state"
1805 # Get the mountpoint of snapshot
1806 # For the snapshot use <mp_filesystem>/.zfs/snapshot/<snap>
1809 function snapshot_mountpoint
1811 typeset dataset
=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
1813 if [[ $dataset != *@
* ]]; then
1814 log_fail
"Error name of snapshot '$dataset'."
1817 typeset fs
=${dataset%@*}
1818 typeset snap
=${dataset#*@}
1820 if [[ -z $fs ||
-z $snap ]]; then
1821 log_fail
"Error name of snapshot '$dataset'."
1824 echo $
(get_prop mountpoint
$fs)/.zfs
/snapshot
/$snap
1828 # Given a pool and file system, this function will verify the file system
1829 # using the zdb internal tool. Note that the pool is exported and imported
1830 # to ensure it has consistent state.
1832 function verify_filesys
# pool filesystem dir
1835 typeset filesys
="$2"
1836 typeset zdbout
="/tmp/zdbout.$$"
1841 typeset search_path
=""
1843 log_note
"Calling zdb to verify filesystem '$filesys'"
1844 zfs unmount
-a > /dev
/null
2>&1
1845 log_must zpool
export $pool
1847 if [[ -n $dirs ]] ; then
1848 for dir
in $dirs ; do
1849 search_path
="$search_path -d $dir"
1853 log_must zpool import
$search_path $pool
1855 zdb
-cudi $filesys > $zdbout 2>&1
1856 if [[ $?
!= 0 ]]; then
1857 log_note
"Output: zdb -cudi $filesys"
1859 log_fail
"zdb detected errors with: '$filesys'"
1862 log_must zfs mount
-a
1863 log_must
rm -rf $zdbout
1867 # Given a pool, and this function list all disks in the pool
1869 function get_disklist
# pool
1873 disklist
=$
(zpool iostat
-v $1 | nawk
'(NR >4) {print $1}' | \
1874 grep -v "\-\-\-\-\-" | \
1875 egrep -v -e "^(mirror|raidz1|raidz2|spare|log|cache)$")
1881 # Given a pool, and this function list all disks in the pool with their full
1882 # path (like "/dev/sda" instead of "sda").
1884 function get_disklist_fullpath
# pool
1893 # This function kills a given list of processes after a time period. We use
1894 # this in the stress tests instead of STF_TIMEOUT so that we can have processes
1895 # run for a fixed amount of time, yet still pass. Tests that hit STF_TIMEOUT
1896 # would be listed as FAIL, which we don't want : we're happy with stress tests
1897 # running for a certain amount of time, then finishing.
1899 # @param $1 the time in seconds after which we should terminate these processes
1900 # @param $2..$n the processes we wish to terminate.
1902 function stress_timeout
1904 typeset
-i TIMEOUT
=$1
1908 log_note
"Waiting for child processes($cpids). " \
1909 "It could last dozens of minutes, please be patient ..."
1910 log_must
sleep $TIMEOUT
1912 log_note
"Killing child processes after ${TIMEOUT} stress timeout."
1914 for pid
in $cpids; do
1915 ps
-p $pid > /dev
/null
2>&1
1916 if (($?
== 0)); then
1917 log_must
kill -USR1 $pid
1923 # Verify a given hotspare disk is inuse or avail
1925 # Return 0 is pool/disk matches expected state, 1 otherwise
1927 function check_hotspare_state
# pool disk state{inuse,avail}
1930 typeset disk
=${2#$DEV_DSKDIR/}
1933 cur_state
=$
(get_device_state
$pool $disk "spares")
1935 if [[ $state != ${cur_state} ]]; then
1942 # Verify a given slog disk is inuse or avail
1944 # Return 0 is pool/disk matches expected state, 1 otherwise
1946 function check_slog_state
# pool disk state{online,offline,unavail}
1949 typeset disk
=${2#$DEV_DSKDIR/}
1952 cur_state
=$
(get_device_state
$pool $disk "logs")
1954 if [[ $state != ${cur_state} ]]; then
1961 # Verify a given vdev disk is inuse or avail
1963 # Return 0 is pool/disk matches expected state, 1 otherwise
1965 function check_vdev_state
# pool disk state{online,offline,unavail}
1968 typeset disk
=${2#$/DEV_DSKDIR/}
1971 cur_state
=$
(get_device_state
$pool $disk)
1973 if [[ $state != ${cur_state} ]]; then
1980 # Check the output of 'zpool status -v <pool>',
1981 # and to see if the content of <token> contain the <keyword> specified.
1983 # Return 0 is contain, 1 otherwise
1985 function check_pool_status
# pool token keyword
1991 zpool status
-v "$pool" 2>/dev
/null | nawk
-v token
="$token:" '
1992 ($1==token) {print $0}' \
1993 |
grep -i "$keyword" > /dev
/null
2>&1
1999 # These 5 following functions are instance of check_pool_status()
2000 # is_pool_resilvering - to check if the pool is resilver in progress
2001 # is_pool_resilvered - to check if the pool is resilver completed
2002 # is_pool_scrubbing - to check if the pool is scrub in progress
2003 # is_pool_scrubbed - to check if the pool is scrub completed
2004 # is_pool_scrub_stopped - to check if the pool is scrub stopped
2006 function is_pool_resilvering
#pool
2008 check_pool_status
"$1" "scan" "resilver in progress since "
2012 function is_pool_resilvered
#pool
2014 check_pool_status
"$1" "scan" "resilvered "
2018 function is_pool_scrubbing
#pool
2020 check_pool_status
"$1" "scan" "scrub in progress since "
2024 function is_pool_scrubbed
#pool
2026 check_pool_status
"$1" "scan" "scrub repaired"
2030 function is_pool_scrub_stopped
#pool
2032 check_pool_status
"$1" "scan" "scrub canceled"
2037 # Use create_pool()/destroy_pool() to clean up the information in
2038 # in the given disk to avoid slice overlapping.
2040 function cleanup_devices
#vdevs
2042 typeset pool
="foopool$$"
2044 if poolexists
$pool ; then
2048 create_pool
$pool $@
2055 # A function to find and locate free disks on a system or from given
2056 # disks as the parameter. It works by locating disks that are in use
2057 # as swap devices and dump devices, and also disks listed in /etc/vfstab
2059 # $@ given disks to find which are free, default is all disks in
2062 # @return a string containing the list of available disks
2066 # Trust provided list, no attempt is made to locate unused devices.
2073 sfi
=/tmp
/swaplist.$$
2074 dmpi
=/tmp
/dumpdev.$$
2075 max_finddisksnum
=${MAX_FINDDISKSNUM:-6}
2078 dumpadm
> $dmpi 2>/dev
/null
2080 # write an awk script that can process the output of format
2081 # to produce a list of disks we know about. Note that we have
2082 # to escape "$2" so that the shell doesn't interpret it while
2083 # we're creating the awk script.
2084 # -------------------
2085 cat > /tmp
/find_disks.
awk <<EOF
2094 if (searchdisks && \$2 !~ "^$"){
2100 /^AVAILABLE DISK SELECTIONS:/{
2104 #---------------------
2106 chmod 755 /tmp
/find_disks.
awk
2107 disks
=${@:-$(echo "" | format -e 2>/dev/null | /tmp/find_disks.awk)}
2108 rm /tmp
/find_disks.
awk
2111 for disk
in $disks; do
2113 grep "${disk}[sp]" /etc
/mnttab
>/dev
/null
2114 (($?
== 0)) && continue
2116 grep "${disk}[sp]" $sfi >/dev
/null
2117 (($?
== 0)) && continue
2118 # check for dump device
2119 grep "${disk}[sp]" $dmpi >/dev
/null
2120 (($?
== 0)) && continue
2121 # check to see if this disk hasn't been explicitly excluded
2122 # by a user-set environment variable
2123 echo "${ZFS_HOST_DEVICES_IGNORE}" |
grep "${disk}" > /dev
/null
2124 (($?
== 0)) && continue
2125 unused_candidates
="$unused_candidates $disk"
2130 # now just check to see if those disks do actually exist
2131 # by looking for a device pointing to the first slice in
2132 # each case. limit the number to max_finddisksnum
2134 for disk
in $unused_candidates; do
2135 if [ -b $DEV_DSKDIR/${disk}s0
]; then
2136 if [ $count -lt $max_finddisksnum ]; then
2137 unused
="$unused $disk"
2138 # do not impose limit if $@ is provided
2139 [[ -z $@
]] && ((count
= count
+ 1))
2144 # finally, return our disk list
2149 # Add specified user to specified group
2153 # $3 base of the homedir (optional)
2155 function add_user
#<group_name> <user_name> <basedir>
2159 typeset basedir
=${3:-"/var/tmp"}
2161 if ((${#gname} == 0 ||
${#uname} == 0)); then
2162 log_fail
"group name or user name are not defined."
2165 log_must useradd
-g $gname -d $basedir/$uname -m $uname
2166 echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.profile
2167 echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.bash_profile
2168 echo "export PATH=\"$STF_PATH\"" >>$basedir/$uname/.login
2170 # Add new users to the same group and the command line utils.
2171 # This allows them to be run out of the original users home
2172 # directory as long as it permissioned to be group readable.
2174 cmd_group
=$
(stat
--format="%G" $
(which zfs
))
2175 log_must usermod
-a -G $cmd_group $uname
2182 # Delete the specified user.
2185 # $2 base of the homedir (optional)
2187 function del_user
#<logname> <basedir>
2190 typeset basedir
=${2:-"/var/tmp"}
2192 if ((${#user} == 0)); then
2193 log_fail
"login name is necessary."
2196 if id
$user > /dev
/null
2>&1; then
2197 log_must userdel
$user
2200 [[ -d $basedir/$user ]] && rm -fr $basedir/$user
2206 # Select valid gid and create specified group.
2210 function add_group
#<group_name>
2214 if ((${#group} == 0)); then
2215 log_fail
"group name is necessary."
2218 # Assign 100 as the base gid, a larger value is selected for
2219 # Linux because for many distributions 1000 and under are reserved.
2222 groupadd
$group > /dev
/null
2>&1
2232 groupadd
-g $gid $group > /dev
/null
2>&1
2236 # The gid is not unique
2245 # Delete the specified group.
2249 function del_group
#<group_name>
2252 if ((${#grp} == 0)); then
2253 log_fail
"group name is necessary."
2257 getent group
$grp > /dev
/null
2>&1
2260 # Group does not exist.
2262 # Name already exists as a group name
2263 0) log_must groupdel
$grp ;;
2267 groupmod
-n $grp $grp > /dev
/null
2>&1
2270 # Group does not exist.
2272 # Name already exists as a group name
2273 9) log_must groupdel
$grp ;;
2282 # This function will return true if it's safe to destroy the pool passed
2283 # as argument 1. It checks for pools based on zvols and files, and also
2284 # files contained in a pool that may have a different mountpoint.
2286 function safe_to_destroy_pool
{ # $1 the pool name
2289 typeset DONT_DESTROY
=""
2291 # We check that by deleting the $1 pool, we're not
2292 # going to pull the rug out from other pools. Do this
2293 # by looking at all other pools, ensuring that they
2294 # aren't built from files or zvols contained in this pool.
2296 for pool
in $
(zpool list
-H -o name
)
2300 # this is a list of the top-level directories in each of the
2301 # files that make up the path to the files the pool is based on
2302 FILEPOOL
=$
(zpool status
-v $pool |
grep /$1/ | \
2305 # this is a list of the zvols that make up the pool
2306 ZVOLPOOL
=$
(zpool status
-v $pool |
grep "$ZVOL_DEVDIR/$1$" \
2309 # also want to determine if it's a file-based pool using an
2310 # alternate mountpoint...
2311 POOL_FILE_DIRS
=$
(zpool status
-v $pool | \
2312 grep / |
awk '{print $1}' | \
2313 awk -F/ '{print $2}' |
grep -v "dev")
2315 for pooldir
in $POOL_FILE_DIRS
2317 OUTPUT
=$
(zfs list
-H -r -o mountpoint
$1 | \
2318 grep "${pooldir}$" |
awk '{print $1}')
2320 ALTMOUNTPOOL
="${ALTMOUNTPOOL}${OUTPUT}"
2324 if [ ! -z "$ZVOLPOOL" ]
2327 log_note
"Pool $pool is built from $ZVOLPOOL on $1"
2330 if [ ! -z "$FILEPOOL" ]
2333 log_note
"Pool $pool is built from $FILEPOOL on $1"
2336 if [ ! -z "$ALTMOUNTPOOL" ]
2339 log_note
"Pool $pool is built from $ALTMOUNTPOOL on $1"
2343 if [ -z "${DONT_DESTROY}" ]
2347 log_note
"Warning: it is not safe to destroy $1!"
2353 # Get the available ZFS compression options
2354 # $1 option type zfs_set|zfs_compress
2356 function get_compress_opts
2358 typeset COMPRESS_OPTS
2359 typeset GZIP_OPTS
="gzip gzip-1 gzip-2 gzip-3 gzip-4 gzip-5 \
2360 gzip-6 gzip-7 gzip-8 gzip-9"
2362 if [[ $1 == "zfs_compress" ]] ; then
2363 COMPRESS_OPTS
="on lzjb"
2364 elif [[ $1 == "zfs_set" ]] ; then
2365 COMPRESS_OPTS
="on off lzjb"
2367 typeset valid_opts
="$COMPRESS_OPTS"
2368 zfs get
2>&1 |
grep gzip >/dev
/null
2>&1
2369 if [[ $?
-eq 0 ]]; then
2370 valid_opts
="$valid_opts $GZIP_OPTS"
2376 # Verify zfs operation with -p option work as expected
2377 # $1 operation, value could be create, clone or rename
2378 # $2 dataset type, value could be fs or vol
2380 # $4 new dataset name
2382 function verify_opt_p_ops
2387 typeset newdataset
=$4
2389 if [[ $datatype != "fs" && $datatype != "vol" ]]; then
2390 log_fail
"$datatype is not supported."
2393 # check parameters accordingly
2398 if [[ $datatype == "vol" ]]; then
2399 ops
="create -V $VOLSIZE"
2403 if [[ -z $newdataset ]]; then
2404 log_fail
"newdataset should not be empty" \
2407 log_must datasetexists
$dataset
2408 log_must snapexists
$dataset
2411 if [[ -z $newdataset ]]; then
2412 log_fail
"newdataset should not be empty" \
2415 log_must datasetexists
$dataset
2416 log_mustnot snapexists
$dataset
2419 log_fail
"$ops is not supported."
2423 # make sure the upper level filesystem does not exist
2424 if datasetexists
${newdataset%/*} ; then
2425 log_must zfs destroy
-rRf ${newdataset%/*}
2428 # without -p option, operation will fail
2429 log_mustnot zfs
$ops $dataset $newdataset
2430 log_mustnot datasetexists
$newdataset ${newdataset%/*}
2432 # with -p option, operation should succeed
2433 log_must zfs
$ops -p $dataset $newdataset
2436 if ! datasetexists
$newdataset ; then
2437 log_fail
"-p option does not work for $ops"
2440 # when $ops is create or clone, redo the operation still return zero
2441 if [[ $ops != "rename" ]]; then
2442 log_must zfs
$ops -p $dataset $newdataset
2449 # Get configuration of pool
2459 if ! poolexists
"$pool" ; then
2462 alt_root
=$
(zpool list
-H $pool |
awk '{print $NF}')
2463 if [[ $alt_root == "-" ]]; then
2464 value
=$
(zdb
-C $pool |
grep "$config:" |
awk -F: \
2467 value
=$
(zdb
-e $pool |
grep "$config:" |
awk -F: \
2470 if [[ -n $value ]] ; then
2480 # Privated function. Random select one of items from arguments.
2485 function _random_get
2492 ((ind
= RANDOM
% cnt
+ 1))
2494 typeset ret
=$
(echo "$str" | cut
-f $ind -d ' ')
2499 # Random select one of item from arguments which include NONE string
2501 function random_get_with_non
2506 _random_get
"$cnt" "$@"
2510 # Random select one of item from arguments which doesn't include NONE string
2514 _random_get
"$#" "$@"
2518 # Detect if the current system support slog
2520 function verify_slog_support
2522 typeset dir
=/tmp
/disk.$$
2528 mkfile
$MINVDEVSIZE $vdev $sdev
2531 if ! zpool create
-n $pool $vdev log
$sdev > /dev
/null
2>&1; then
2540 # The function will generate a dataset name with specific length
2541 # $1, the length of the name
2542 # $2, the base string to construct the name
2544 function gen_dataset_name
2547 typeset basestr
="$2"
2548 typeset
-i baselen
=${#basestr}
2552 if ((len
% baselen
== 0)); then
2553 ((iter
= len
/ baselen
))
2555 ((iter
= len
/ baselen
+ 1))
2557 while ((iter
> 0)); do
2558 l_name
="${l_name}$basestr"
2567 # Get cksum tuple of dataset
2570 # sample zdb output:
2571 # Dataset data/test [ZPL], ID 355, cr_txg 2413856, 31.0K, 7 objects, rootbp
2572 # DVA[0]=<0:803046400:200> DVA[1]=<0:81199000:200> [L0 DMU objset] fletcher4
2573 # lzjb LE contiguous unique double size=800L/200P birth=2413856L/2413856P
2574 # fill=7 cksum=11ce125712:643a9c18ee2:125e25238fca0:254a3f74b59744
2575 function datasetcksum
2579 cksum=$
(zdb
-vvv $1 |
grep "^Dataset $1 \[" |
grep "cksum" \
2580 |
awk -F= '{print $7}')
2591 cksum=$
(cksum $1 |
awk '{print $1}')
2596 # Get the given disk/slice state from the specific field of the pool
2598 function get_device_state
#pool disk field("", "spares","logs")
2601 typeset disk
=${2#$DEV_DSKDIR/}
2602 typeset field
=${3:-$pool}
2604 state
=$
(zpool status
-v "$pool" 2>/dev
/null | \
2605 nawk
-v device
=$disk -v pool
=$pool -v field
=$field \
2606 'BEGIN {startconfig=0; startfield=0; }
2607 /config:/ {startconfig=1}
2608 (startconfig==1) && ($1==field) {startfield=1; next;}
2609 (startfield==1) && ($1==device) {print $2; exit;}
2611 ($1==field || $1 ~ "^spares$" || $1 ~ "^logs$") {startfield=0}')
2617 # print the given directory filesystem type
2625 if [[ -z $dir ]]; then
2626 log_fail
"Usage: get_fstype <directory>"
2633 df
-n $dir |
awk '{print $3}'
2637 # Given a disk, label it to VTOC regardless what label was on the disk
2643 if [[ -z $disk ]]; then
2644 log_fail
"The disk name is unspecified."
2646 typeset label_file
=/var
/tmp
/labelvtoc.$$
2647 typeset arch
=$
(uname
-p)
2650 log_note
"Currently unsupported by the test framework"
2654 if [[ $arch == "i386" ]]; then
2655 echo "label" > $label_file
2656 echo "0" >> $label_file
2657 echo "" >> $label_file
2658 echo "q" >> $label_file
2659 echo "q" >> $label_file
2661 fdisk
-B $disk >/dev
/null
2>&1
2662 # wait a while for fdisk finishes
2664 elif [[ $arch == "sparc" ]]; then
2665 echo "label" > $label_file
2666 echo "0" >> $label_file
2667 echo "" >> $label_file
2668 echo "" >> $label_file
2669 echo "" >> $label_file
2670 echo "q" >> $label_file
2672 log_fail
"unknown arch type"
2675 format
-e -s -d $disk -f $label_file
2676 typeset
-i ret_val
=$?
2679 # wait the format to finish
2682 if ((ret_val
!= 0)); then
2683 log_fail
"unable to label $disk as VTOC."
2690 # check if the system was installed as zfsroot or not
2691 # return: 0 ture, otherwise false
2695 df
-n / |
grep zfs
> /dev
/null
2>&1
2700 # get the root filesystem name if it's zfsroot system.
2702 # return: root filesystem name
2708 rootfs
=$
(awk '{if ($2 == "/" && $3 == "zfs") print $1}' \
2711 if [[ -z "$rootfs" ]]; then
2712 log_fail
"Can not get rootfs"
2714 zfs list
$rootfs > /dev
/null
2>&1
2715 if (($?
== 0)); then
2718 log_fail
"This is not a zfsroot system."
2723 # get the rootfs's pool name
2727 function get_rootpool
2733 rootfs
=$
(awk '{if ($2 == "/" && $3 =="zfs") print $1}' \
2736 if [[ -z "$rootfs" ]]; then
2737 log_fail
"Can not get rootpool"
2739 zfs list
$rootfs > /dev
/null
2>&1
2740 if (($?
== 0)); then
2741 rootpool
=`echo $rootfs | awk -F\/ '{print $1}'`
2744 log_fail
"This is not a zfsroot system."
2749 # Check if the given device is physical device
2751 function is_physical_device
#device
2753 typeset device
=${1#$DEV_DSKDIR}
2754 device
=${device#$DEV_RDSKDIR}
2757 [[ -b "$DEV_DSKDIR/$device" ]] && \
2758 [[ -f /sys
/module
/loop
/parameters
/max_part
]]
2761 echo $device |
egrep "^c[0-F]+([td][0-F]+)+$" > /dev
/null
2>&1
2767 # Check if the given device is a real device (ie SCSI device)
2769 function is_real_device
#disk
2772 [[ -z $disk ]] && log_fail
"No argument for disk given."
2775 lsblk
$DEV_RDSKDIR/$disk -o TYPE
2>/dev
/null | \
2776 egrep disk
>/dev
/null
2782 # Check if the given device is a loop device
2784 function is_loop_device
#disk
2787 [[ -z $disk ]] && log_fail
"No argument for disk given."
2790 lsblk
$DEV_RDSKDIR/$disk -o TYPE
2>/dev
/null | \
2791 egrep loop
>/dev
/null
2797 # Check if the given device is a multipath device and if there is a sybolic
2798 # link to a device mapper and to a disk
2799 # Currently no support for dm devices alone without multipath
2801 function is_mpath_device
#disk
2804 [[ -z $disk ]] && log_fail
"No argument for disk given."
2807 lsblk
$DEV_MPATHDIR/$disk -o TYPE
2>/dev
/null | \
2808 egrep mpath
>/dev
/null
2809 if (($?
== 0)); then
2810 readlink
$DEV_MPATHDIR/$disk > /dev
/null
2>&1
2818 # Set the slice prefix for disk partitioning depending
2819 # on whether the device is a real, multipath, or loop device.
2820 # Currently all disks have to be of the same type, so only
2821 # checks first disk to determine slice prefix.
2823 function set_slice_prefix
2829 while (( i
< $DISK_ARRAY_NUM )); do
2830 disk
="$(echo $DISKS | nawk '{print $(i + 1)}')"
2831 if ( is_mpath_device
$disk ) && [[ -z $
(echo $disk |
awk 'substr($1,18,1)\
2832 ~ /^[[:digit:]]+$/') ]] ||
( is_real_device
$disk ); then
2833 export SLICE_PREFIX
=""
2835 elif ( is_mpath_device
$disk || is_loop_device \
2837 export SLICE_PREFIX
="p"
2840 log_fail
"$disk not supported for partitioning."
2848 # Set the directory path of the listed devices in $DISK_ARRAY_NUM
2849 # Currently all disks have to be of the same type, so only
2850 # checks first disk to determine device directory
2851 # default = /dev (linux)
2852 # real disk = /dev (linux)
2853 # multipath device = /dev/mapper (linux)
2855 function set_device_dir
2861 while (( i
< $DISK_ARRAY_NUM )); do
2862 disk
="$(echo $DISKS | nawk '{print $(i + 1)}')"
2863 if is_mpath_device
$disk; then
2864 export DEV_DSKDIR
=$DEV_MPATHDIR
2867 export DEV_DSKDIR
=$DEV_RDSKDIR
2873 export DEV_DSKDIR
=$DEV_RDSKDIR
2878 # Get the directory path of given device
2880 function get_device_dir
#device
2884 if ! $
(is_physical_device
$device) ; then
2885 if [[ $device != "/" ]]; then
2888 if [[ -b "$DEV_DSKDIR/$device" ]]; then
2889 device
="$DEV_DSKDIR"
2898 # Get persistent name for given disk
2900 function get_persistent_disk_name
#device
2906 if is_real_device
$device; then
2907 dev_id
="$(udevadm info -q all -n $DEV_DSKDIR/$device \
2908 | egrep disk/by-id | nawk '{print $2; exit}' \
2909 | nawk -F / '{print $3}')"
2911 elif is_mpath_device
$device; then
2912 dev_id
="$(udevadm info -q all -n $DEV_DSKDIR/$device \
2913 | egrep disk/by-id/dm-uuid \
2914 | nawk '{print $2; exit}' \
2915 | nawk -F / '{print $3}')"
2926 # Load scsi_debug module with specified parameters
2928 function load_scsi_debug
# dev_size_mb add_host num_tgts max_luns
2935 [[ -z $devsize ]] ||
[[ -z $hosts ]] ||
[[ -z $tgts ]] || \
2936 [[ -z $luns ]] && log_fail
"Arguments invalid or missing"
2939 modprobe
-n scsi_debug
2940 if (($?
!= 0)); then
2941 log_unsupported
"Platform does not have scsi_debug"
2944 lsmod |
egrep scsi_debug
> /dev
/null
2945 if (($?
== 0)); then
2946 log_fail
"scsi_debug module already installed"
2948 log_must modprobe scsi_debug dev_size_mb
=$devsize \
2949 add_host
=$hosts num_tgts
=$tgts max_luns
=$luns
2951 lsscsi |
egrep scsi_debug
> /dev
/null
2952 if (($?
== 1)); then
2953 log_fail
"scsi_debug module install failed"
2960 # Get the package name
2962 function get_package_name
2964 typeset dirpath
=${1:-$STC_NAME}
2966 echo "SUNWstc-${dirpath}" |
/usr
/bin
/sed -e "s/\//-/g"
2970 # Get the word numbers from a string separated by white space
2972 function get_word_count
2978 # To verify if the require numbers of disks is given
2980 function verify_disk_count
2982 typeset
-i min
=${2:-1}
2984 typeset
-i count
=$
(get_word_count
"$1")
2986 if ((count
< min
)); then
2987 log_untested
"A minimum of $min disks is required to run." \
2988 " You specified $count disk(s)"
2992 function ds_is_volume
2994 typeset
type=$
(get_prop
type $1)
2995 [[ $type = "volume" ]] && return 0
2999 function ds_is_filesystem
3001 typeset
type=$
(get_prop
type $1)
3002 [[ $type = "filesystem" ]] && return 0
3006 function ds_is_snapshot
3008 typeset
type=$
(get_prop
type $1)
3009 [[ $type = "snapshot" ]] && return 0
3014 # Check if Trusted Extensions are installed and enabled
3016 function is_te_enabled
3018 svcs
-H -o state labeld
2>/dev
/null |
grep "enabled"
3019 if (($?
!= 0)); then
3026 # Utility function to determine if a system has multiple cpus.
3032 (($
(psrinfo |
wc -l) > 1))
3038 function get_cpu_freq
3041 lscpu |
awk '/CPU MHz/ { print $3 }'
3043 psrinfo
-v 0 |
awk '/processor operates at/ {print $6}'
3047 # Run the given command as the user provided.
3053 log_note
"user:$user $@"
3054 eval su
- \
$user -c \"$@
\" > /tmp
/out
2>/tmp
/err
3059 # Check if the pool contains the specified vdevs
3064 # Return 0 if the vdevs are contained in the pool, 1 if any of the specified
3065 # vdevs is not in the pool, and 2 if pool name is missing.
3067 function vdevs_in_pool
3072 if [[ -z $pool ]]; then
3073 log_note
"Missing pool name."
3079 typeset tmpfile
=$
(mktemp
)
3080 zpool list
-Hv "$pool" >$tmpfile
3082 grep -w ${vdev##*/} $tmpfile >/dev
/null
2>&1
3083 [[ $?
-ne 0 ]] && return 1
3097 max
=$
(echo $
((max
> i ? max
: i
)))
3109 min
=$
(echo $
((min
< i ? min
: i
)))
3116 # Generate a random number between 1 and the argument.
3121 echo $
(( ($RANDOM % $max) + 1 ))
3124 # Write data that can be compressed into a directory
3125 function write_compressible
3129 typeset nfiles
=${3:-1}
3130 typeset bs
=${4:-1024k}
3131 typeset fname
=${5:-file}
3133 [[ -d $dir ]] || log_fail
"No directory: $dir"
3135 # Under Linux fio is not currently used since its behavior can
3136 # differ significantly across versions. This includes missing
3137 # command line options and cases where the --buffer_compress_*
3138 # options fail to behave as expected.
3140 typeset file_bytes
=$
(to_bytes
$megs)
3141 typeset bs_bytes
=4096
3142 typeset blocks
=$
(($file_bytes / $bs_bytes))
3144 for (( i
= 0; i
< $nfiles; i
++ )); do
3145 truncate
-s $file_bytes $dir/$fname.
$i
3147 # Write every third block to get 66% compression.
3148 for (( j
= 0; j
< $blocks; j
+= 3 )); do
3149 dd if=/dev
/urandom of
=$dir/$fname.
$i \
3150 seek
=$j bs
=$bs_bytes count
=1 \
3151 conv
=notrunc
>/dev
/null
2>&1
3155 log_must
eval "fio \
3160 --buffer_compress_percentage=66 \
3161 --buffer_compress_chunk=4096 \
3168 --filename_format='$fname.\$jobnum' >/dev/null"
3177 [[ -e $pathname ]] || log_fail
"No such file or directory: $pathname"
3178 objnum
=$
(stat
-c %i
$pathname)
3183 # Synchronize all the data in pool
3187 function sync_pool
#pool
3189 typeset pool
=${1:-$TESTPOOL}
3193 # Flush all the pool data.
3195 zpool scrub
$pool >/dev
/null
2>&1
3197 (( $ret != 0 )) && \
3198 log_fail
"zpool scrub $pool failed."
3200 while ! is_pool_scrubbed
$pool; do
3201 if is_pool_resilvered
$pool ; then
3202 log_fail
"$pool should not be resilver completed."
3209 # Wait for zpool 'freeing' property drops to zero.
3213 function wait_freeing
#pool
3215 typeset pool
=${1:-$TESTPOOL}
3217 [[ "0" == "$(zpool list -Ho freeing $pool)" ]] && break
3223 # Check if ZED is currently running, if not start ZED.
3228 # ZEDLET_DIR=/var/tmp/zed
3229 if [[ ! -d $ZEDLET_DIR ]]; then
3230 log_must mkdir
$ZEDLET_DIR
3233 # Verify the ZED is not already running.
3234 pgrep
-x zed
> /dev
/null
3235 if (($?
== 0)); then
3236 log_fail
"ZED already running"
3239 # ZEDLETDIR=</etc/zfs/zed.d | ${SRCDIR}/cmd/zed/zed.d>
3240 log_must
cp ${ZEDLETDIR}/all-syslog.sh
$ZEDLET_DIR
3242 log_note
"Starting ZED"
3243 # run ZED in the background and redirect foreground logging
3245 log_must
eval "zed -vF -d $ZEDLET_DIR -p $ZEDLET_DIR/zed.pid" \
3246 "-s $ZEDLET_DIR/state 2>${ZEDLET_DIR}/zedlog &"
3256 if [[ -f ${ZEDLET_DIR}/zed.pid
]]; then
3257 zedpid
=$
(cat ${ZEDLET_DIR}/zed.pid
)
3258 log_must
kill $zedpid
3260 log_must
rm -f ${ZEDLET_DIR}/all-syslog.sh
3261 log_must
rm -f ${ZEDLET_DIR}/zed.pid
3262 log_must
rm -f ${ZEDLET_DIR}/zedlog
3263 log_must
rm -f ${ZEDLET_DIR}/state
3264 log_must
rmdir $ZEDLET_DIR