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.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
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]
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/slog/slog.cfg
36 if datasetexists $TESTPOOL ; then
37 log_must zpool destroy -f $TESTPOOL
39 if datasetexists $TESTPOOL2 ; then
40 log_must zpool destroy -f $TESTPOOL2
45 # Try zpool status/iostat for given pool
49 function display_status
54 zpool status -xv $pool > /dev/null 2>&1
57 zpool iostat > /dev/null 2>&1
60 typeset mntpnt=$(get_prop mountpoint $pool)
61 dd if=/dev/random of=$mntpnt/testfile.$$ &
64 zpool iostat -v 1 3 > /dev/null
73 # Verify the give slog device have correct type and status
80 function verify_slog_device
87 if [[ -z $pool || -z $device || -z $status ]]; then
88 log_fail "Usage: verify_slog_device <pool> <device> " \
93 # Get all the slog devices and status table like below
95 # mirror:/disks/d ONLINE mirror:/disks/e ONLINE stripe:/disks/f ONLINE
97 set -A dev_stat_tab $(zpool status -v $pool | nawk 'BEGIN {start=0} \
99 /\tmirror/ || /\tspares/ || /^$/ {start=0}
100 (start==1) && /\t (\/|[a-zA-Z])/ \
101 {print "stripe:" $1 " " $2}
102 (start==1) && /\t (\/|[a-zA-Z])/ \
103 {print "mirror:" $1 " " $2}
104 # When hotspare is replacing
105 (start==1) && /\t (\/|[a-zA-Z])/ \
106 {print "mirror:" $1 " " $2}'
111 while (( i < ${#dev_stat_tab[@]} )); do
112 typeset dev=${dev_stat_tab[$i]}
113 typeset stat=${dev_stat_tab[((i+1))]}
117 if [[ "$type" == 'mirror' ]]; then
118 log_note "Unexpected type: mirror"
121 if [[ $stat != $status ]]; then
122 log_note "Status($stat) " \
123 "!= Expected stat($status)"
130 if [[ -z "$type" || $type == 'stripe' ]]; then
131 log_note "Unexpected type: stripe"
134 if [[ $stat != $status ]]; then
135 log_note "Status($stat) " \
136 "!= Expected stat($status)"
147 log_note "Can not find device: $device"