1*2fae26bdSAlan Somers#! /usr/local/bin/ksh93 -p 2*2fae26bdSAlan Somers# 3*2fae26bdSAlan Somers# CDDL HEADER START 4*2fae26bdSAlan Somers# 5*2fae26bdSAlan Somers# The contents of this file are subject to the terms of the 6*2fae26bdSAlan Somers# Common Development and Distribution License (the "License"). 7*2fae26bdSAlan Somers# You may not use this file except in compliance with the License. 8*2fae26bdSAlan Somers# 9*2fae26bdSAlan Somers# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*2fae26bdSAlan Somers# or http://www.opensolaris.org/os/licensing. 11*2fae26bdSAlan Somers# See the License for the specific language governing permissions 12*2fae26bdSAlan Somers# and limitations under the License. 13*2fae26bdSAlan Somers# 14*2fae26bdSAlan Somers# When distributing Covered Code, include this CDDL HEADER in each 15*2fae26bdSAlan Somers# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*2fae26bdSAlan Somers# If applicable, add the following below this CDDL HEADER, with the 17*2fae26bdSAlan Somers# fields enclosed by brackets "[]" replaced with your own identifying 18*2fae26bdSAlan Somers# information: Portions Copyright [yyyy] [name of copyright owner] 19*2fae26bdSAlan Somers# 20*2fae26bdSAlan Somers# CDDL HEADER END 21*2fae26bdSAlan Somers# 22*2fae26bdSAlan Somers 23*2fae26bdSAlan Somers# 24*2fae26bdSAlan Somers# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25*2fae26bdSAlan Somers# Use is subject to license terms. 26*2fae26bdSAlan Somers 27*2fae26bdSAlan Somers############################################################################### 28*2fae26bdSAlan Somers# 29*2fae26bdSAlan Somers# __stc_assertion_start 30*2fae26bdSAlan Somers# 31*2fae26bdSAlan Somers# ID: zinject_003_pos 32*2fae26bdSAlan Somers# 33*2fae26bdSAlan Somers# DESCRIPTION: 34*2fae26bdSAlan Somers# 35*2fae26bdSAlan Somers# Inject an error into the first metadnode in the block 36*2fae26bdSAlan Somers# Verify the filesystem unmountable since dnode be injected. 37*2fae26bdSAlan Somers# 38*2fae26bdSAlan Somers# STRATEGY: 39*2fae26bdSAlan Somers# 1) Populate ZFS file system 40*2fae26bdSAlan Somers# 2) Inject an error into the first metadnode in the block. 41*2fae26bdSAlan Somers# 3) Verify the filesystem unmountable, 42*2fae26bdSAlan Somers# and 'zpool status -v' will display the error as expect. 43*2fae26bdSAlan Somers# 44*2fae26bdSAlan Somers# TESTABILITY: explicit 45*2fae26bdSAlan Somers# 46*2fae26bdSAlan Somers# TEST_AUTOMATION_LEVEL: automated 47*2fae26bdSAlan Somers# 48*2fae26bdSAlan Somers# CODING_STATUS: COMPLETED (2007-02-01) 49*2fae26bdSAlan Somers# 50*2fae26bdSAlan Somers# __stc_assertion_end 51*2fae26bdSAlan Somers# 52*2fae26bdSAlan Somers################################################################################ 53*2fae26bdSAlan Somers 54*2fae26bdSAlan Somers. $STF_SUITE/tests/zinject/zinject.kshlib 55*2fae26bdSAlan Somers 56*2fae26bdSAlan Somersverify_runnable "global" 57*2fae26bdSAlan Somers 58*2fae26bdSAlan Somerslog_assert "Verify fault inject handle into first metadnode " \ 59*2fae26bdSAlan Somers "cause filesystem unmountable." 60*2fae26bdSAlan Somerslog_onexit cleanup_env 61*2fae26bdSAlan Somers 62*2fae26bdSAlan Somersset -A types "" "mirror" "raidz" "raidz2" 63*2fae26bdSAlan Somers 64*2fae26bdSAlan Somerstypeset -i maxnumber=1 65*2fae26bdSAlan Somers 66*2fae26bdSAlan Somersfunction test_zinject_unit 67*2fae26bdSAlan Somers{ 68*2fae26bdSAlan Somers typeset etype=$1 69*2fae26bdSAlan Somers typeset object=$2 70*2fae26bdSAlan Somers typeset errno=$3 71*2fae26bdSAlan Somers typeset ereport=$4 72*2fae26bdSAlan Somers typeset now 73*2fae26bdSAlan Somers 74*2fae26bdSAlan Somers typeset otype="file" 75*2fae26bdSAlan Somers [[ -d $object ]] && otype="dir" 76*2fae26bdSAlan Somers 77*2fae26bdSAlan Somers now=`date '+%m/%d/%y %H:%M:%S'` 78*2fae26bdSAlan Somers inject_fault $etype $object $errno 1 79*2fae26bdSAlan Somers 80*2fae26bdSAlan Somers unmounted $TESTPOOL/$TESTFS || \ 81*2fae26bdSAlan Somers log_fail "$TESTPOOL/$TESTFS mount unexpected." 82*2fae26bdSAlan Somers 83*2fae26bdSAlan Somers log_must check_status $TESTPOOL "$TESTPOOL/$TESTFS:<0x0>" 84*2fae26bdSAlan Somers 85*2fae26bdSAlan Somers inject_clear 86*2fae26bdSAlan Somers 87*2fae26bdSAlan Somers log_must $ZFS mount -a 88*2fae26bdSAlan Somers} 89*2fae26bdSAlan Somers 90*2fae26bdSAlan Somersfunction test_zinject 91*2fae26bdSAlan Somers{ 92*2fae26bdSAlan Somers typeset basedir=$1 93*2fae26bdSAlan Somers typeset pooltype=$2 94*2fae26bdSAlan Somers typeset -i i=0 95*2fae26bdSAlan Somers typeset etype="dnode" 96*2fae26bdSAlan Somers 97*2fae26bdSAlan Somers set -A errset "io" "ereport.fs.zfs.io ereport.fs.zfs.data" 98*2fae26bdSAlan Somers 99*2fae26bdSAlan Somers ((i=${#errset[*]})) 100*2fae26bdSAlan Somers if [[ -n $pooltype ]] ; then 101*2fae26bdSAlan Somers errset[i]="checksum" 102*2fae26bdSAlan Somers errset[((i+1))]="ereport.fs.zfs.checksum ereport.fs.zfs.data" 103*2fae26bdSAlan Somers else 104*2fae26bdSAlan Somers errset[i]="checksum" 105*2fae26bdSAlan Somers errset[((i+1))]="ereport.fs.zfs.data" 106*2fae26bdSAlan Somers fi 107*2fae26bdSAlan Somers 108*2fae26bdSAlan Somers i=0 109*2fae26bdSAlan Somers while ((i < ${#errset[*]} )); do 110*2fae26bdSAlan Somers for object in $basedir/testfile.$maxnumber \ 111*2fae26bdSAlan Somers $basedir/testdir.$maxnumber ; do 112*2fae26bdSAlan Somers test_zinject_unit $etype $object \ 113*2fae26bdSAlan Somers ${errset[i]} "${errset[((i+1))]}" 114*2fae26bdSAlan Somers done 115*2fae26bdSAlan Somers 116*2fae26bdSAlan Somers (( i = i + 2 )) 117*2fae26bdSAlan Somers done 118*2fae26bdSAlan Somers} 119*2fae26bdSAlan Somers 120*2fae26bdSAlan Somersinject_clear 121*2fae26bdSAlan Somersfor type in "${types[@]}"; do 122*2fae26bdSAlan Somers create_pool $TESTPOOL $type $pooldevs spare $sparedevs 123*2fae26bdSAlan Somers 124*2fae26bdSAlan Somers log_must $ZPOOL add -f $TESTPOOL log $logdevs 125*2fae26bdSAlan Somers log_must $ZPOOL add -f $TESTPOOL cache $cachedevs 126*2fae26bdSAlan Somers 127*2fae26bdSAlan Somers log_must $ZPOOL replace $TESTPOOL $VDEV0 $sparedevs 128*2fae26bdSAlan Somers log_must $ZFS create $TESTPOOL/$TESTFS 129*2fae26bdSAlan Somers log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 130*2fae26bdSAlan Somers 131*2fae26bdSAlan Somers populate_test_env $TESTDIR/bad_dir $maxnumber 132*2fae26bdSAlan Somers 133*2fae26bdSAlan Somers test_zinject $TESTDIR/bad_dir $type 134*2fae26bdSAlan Somers 135*2fae26bdSAlan Somers cleanup_env 136*2fae26bdSAlan Somersdone 137*2fae26bdSAlan Somers 138*2fae26bdSAlan Somerslog_pass "Fault inject handle into first metadnode " \ 139*2fae26bdSAlan Somers "cause filesystem unmountable." 140