zpool_clear_001_pos.ksh revision d583b39bfb4e2571d3e41097c5c357ffe353ad45
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
# DESCRIPTION:
# Verify 'zpool clear' can clear pool errors.
#
# STRATEGY:
# 1. Create various configuration pools
# 2. Make errors to pool
# 3. Use zpool clear to clear errors
# 4. Verify the errors has been cleared.
#
verify_runnable "global"
function cleanup
{
poolexists $TESTPOOL1 && \
done
}
log_assert "Verify 'zpool clear' can clear errors of a storage pool."
#make raw files to create various configuration pools
typeset -i i=0
while (( i < 3 )); do
(( i = i + 1 ))
done
function check_err # <pool> [<vdev>]
{
typeset pool=$1
shift
if (( $# > 0 )); then
typeset checkvdev=$1
else
typeset checkvdev=""
fi
typeset -i errnum=0
typeset c_read=0
typeset c_write=0
typeset c_cksum=0
typeset line
typeset -i fetchbegin=1
while read line; do
continue
fi
if [[ -n $checkvdev ]]; then
(( $? != 0 )) && continue
[ $c_cksum != 0 ]
then
fi
break
fi
[ $c_cksum != 0 ]
then
fi
done <$tmpfile
return $errnum
}
function do_testing #<clear type> <vdevs>
{
typeset FS=$TESTPOOL1/fs
typeset type=$1
shift
typeset vdev="$@"
#
# Fully fill up the zfs filesystem in order to make data block errors
# zfs filesystem
#
typeset -i ret=0
typeset -i i=0
while $TRUE ; do
$FILE_WRITE -o create -f $file.$i -b $BLOCKSZ -c $NUM_WRITES
ret=$?
(( i = i + 1 ))
done
#
#Make errors to the testing pool by overwrite the vdev device with
#may cause the system panic. So, we should skip the vdev label space.
#
typeset -i wcount=0
typeset -i size
*g|*G)
;;
*m|*M)
;;
*k|*K)
;;
*)
;;
esac
# Wait for the completion of scrub operation
while is_pool_scrubbing $TESTPOOL1; do
$SLEEP 1
done
check_err $TESTPOOL1 && \
log_fail "No error generated."
! check_err $TESTPOOL1 $fbase.$i && \
fi
! check_err $TESTPOOL1 && \
log_fail "'zpool clear' fails to clear error for pool $TESTPOOL1."
fi
}
log_note "'zpool clear' clears leaf-device error."
done
log_note "'zpool clear' clears top-level pool error."
done
log_pass "'zpool clear' clears pool errors as expected."