1#! /usr/local/bin/ksh93 -p 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# $FreeBSD$ 24 25# 26# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 27# Use is subject to license terms. 28# 29# ident "@(#)zinject_002_pos.ksh 1.3 09/06/22 SMI" 30# 31 32############################################################################### 33# 34# __stc_assertion_start 35# 36# ID: zinject_002_pos 37# 38# DESCRIPTION: 39# 40# Inject an error into the metadnode in the block 41# corresponding to the dnode for a file or directory 42# Verify fmdump will get the expect ereport 43# 44# STRATEGY: 45# 1) Populate ZFS file system 46# 2) Inject an error into the metadnode in the block. 47# 3) Verify fmdump get the ereport as expect. 48# <Errno> <Expect ereport> <Comments> 49# io ereport.fs.zfs.io 50# ereport.fs.zfs.data 51# checksum ereport.fs.zfs.checksum Non-stripe pool 52# ereport.fs.zfs.data 53# checksum ereport.fs.zfs.data Stripe pool only 54# 55# TESTABILITY: explicit 56# 57# TEST_AUTOMATION_LEVEL: automated 58# 59# CODING_STATUS: COMPLETED (2007-02-01) 60# 61# __stc_assertion_end 62# 63################################################################################ 64 65. $STF_SUITE/tests/zinject/zinject.kshlib 66 67verify_runnable "global" 68 69log_assert "Verify fault inject handle metadnode error successfully." 70log_onexit cleanup_env 71 72set -A types "" "mirror" "raidz" "raidz2" 73 74typeset -i maxnumber=1 75 76function test_zinject_unit 77{ 78 typeset etype=$1 79 typeset object=$2 80 typeset errno=$3 81 typeset ereport=$4 82 typeset now 83 84 typeset otype="file" 85 [[ -d $object ]] && otype="dir" 86 87 now=`date '+%m/%d/%y %H:%M:%S'` 88 inject_fault $etype $object $errno 89 90 trigger_inject $etype $object $otype 91 92 log_must check_ereport "$now" $ereport 93 94 log_must check_status $TESTPOOL "$TESTPOOL/$TESTFS:<0x0>" 95 96 inject_clear 97} 98 99function test_zinject 100{ 101 typeset basedir=$1 102 typeset pooltype=$2 103 typeset -i i=0 104 typeset etype="dnode" 105 106 set -A errset "io" "ereport.fs.zfs.io ereport.fs.zfs.data" 107 108 ((i=${#errset[*]})) 109 if [[ -n $pooltype ]] ; then 110 errset[i]="checksum" 111 errset[((i+1))]="ereport.fs.zfs.checksum ereport.fs.zfs.data" 112 else 113 errset[i]="checksum" 114 errset[((i+1))]="ereport.fs.zfs.data" 115 fi 116 117 i=0 118 while ((i < ${#errset[*]} )); do 119 for object in $basedir/testfile.$maxnumber \ 120 $basedir/testdir.$maxnumber ; do 121 test_zinject_unit $etype $object \ 122 ${errset[i]} "${errset[((i+1))]}" 123 done 124 125 (( i = i + 2 )) 126 done 127} 128 129inject_clear 130for type in "${types[@]}"; do 131 create_pool $TESTPOOL $type $pooldevs spare $sparedevs 132 133 log_must $ZPOOL add -f $TESTPOOL log $logdevs 134 log_must $ZPOOL add -f $TESTPOOL cache $cachedevs 135 136 log_must $ZPOOL replace $TESTPOOL $VDEV0 $sparedevs 137 log_must $ZFS create $TESTPOOL/$TESTFS 138 log_must $ZFS set mountpoint=$TESTDIR $TESTPOOL/$TESTFS 139 140 populate_test_env $TESTDIR/safe_dir 64 141 populate_test_env $TESTDIR/bad_dir $maxnumber 142 143 test_zinject $TESTDIR/bad_dir $type 144 145 cleanup_env 146done 147 148log_pass "Fault inject handle metadnode error successfully." 149