d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER START
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# The contents of this file are subject to the terms of the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Common Development and Distribution License (the "License").
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You may not use this file except in compliance with the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# or http://www.opensolaris.org/os/licensing.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# See the License for the specific language governing permissions
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# and limitations under the License.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# When distributing Covered Code, include this CDDL HEADER in each
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# If applicable, add the following below this CDDL HEADER, with the
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# fields enclosed by brackets "[]" replaced with your own identifying
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# information: Portions Copyright [yyyy] [name of copyright owner]
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# CDDL HEADER END
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Use is subject to license terms.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy. $STF_SUITE/tests/functional/cli_root/zpool_clear/zpool_clear.cfg
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# Verify 'zpool clear' can clear pool errors.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 1. Create various configuration pools
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 2. Make errors to pool
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 3. Use zpool clear to clear errors
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy# 4. Verify the errors has been cleared.
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_assert "Verify 'zpool clear' can clear errors of a storage pool."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy#make raw files to create various configuration pools
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy log_must mkfile $FILESIZE $TESTDIR/file.$i
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedyset -A poolconf "mirror $fbase.0 $fbase.1 $fbase.2" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy "raidz1 $fbase.0 $fbase.1 $fbase.2" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset healthstr="pool '$pool' is healthy"
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy [[ "$output" == "$healthstr" ]] && return $errnum
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy zpool status -x $pool | grep -v "^$" | grep -v "pool:" \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy while read line; do
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [[ -n $checkvdev ]]; then
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy echo $line | grep $checkvdev >/dev/null 2>&1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [ $c_read != 0 ] || [ $c_write != 0 ] || \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy if [ $c_read != 0 ] || [ $c_write != 0 ] || \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset type=$1
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Fully fill up the zfs filesystem in order to make data block errors
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy typeset -i i=0
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy while true ; do
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy file_write -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy (( $ret != 28 )) && log_fail "file_write fails to fully fill up the $FS."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy #Make errors to the testing pool by overwrite the vdev device with
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy #/usr/bin/dd command. We donot want to have a full overwrite. That
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy #may cause the system panic. So, we should skip the vdev label space.
1d32ba663e202c24a5a1f2e5aef83fffb447cb7fJohn Wren Kennedy dd if=/dev/zero of=$fbase.$i seek=512 bs=1024 count=$wcount conv=notrunc \
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy # Wait for the completion of scrub operation
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zpool clear' fails to clear error for $fbase.$i device."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedy log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "'zpool clear' clears leaf-device error."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_note "'zpool clear' clears top-level pool error."
d583b39bfb4e2571d3e41097c5c357ffe353ad45John Wren Kennedylog_pass "'zpool clear' clears pool errors as expected."