5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-`dirname $0`/..}
7 . $LUSTRE/tests/test-framework.sh
9 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
11 ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
12 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
14 # Tests that fail on uml
15 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
16 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
20 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
22 # It is replay-ost-single, after all
33 if [ "$ONLY" == "cleanup" ]; then
40 SETUP=${SETUP:-"setup"}
41 CLEANUP=${CLEANUP:-"cleanup"}
44 # needs to run during initial client->OST connection
45 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
46 do_facet ost "sysctl -w lustre.fail_loc=0x80000211"
47 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
52 start mds1 `mdsdevname 1` $MDS_MOUNT_OPTS
53 start ost1 `ostdevname 1` $OST_MOUNT_OPTS
54 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
56 # this might not mount if we aren't running test 0a
57 [ -z "`grep " $MOUNT " /proc/mounts`" ] && \
58 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
60 if [ -z "`grep " $MOUNT " /proc/mounts`" ]; then
61 zconf_mount `hostname` $MOUNT || error "mount fail"
65 do_facet ost1 "sysctl -w lustre.fail_loc=0"
74 cp /etc/profile $DIR/$tfile
76 diff /etc/profile $DIR/$tfile
79 run_test 0b "empty replay"
84 $CHECKSTAT -t file $DIR/$tfile || return 1
91 echo "tag-$i" > $DIR/$tfile-$i
95 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
99 run_test 2 "|x| 10 open(O_CREAT)s"
102 verify=$ROOT/tmp/verify-$$
103 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile &
107 wait $ddpid || return 1
108 cmp $verify $DIR/$tfile || return 2
109 rm -f $verify $DIR/$tfile
111 run_test 3 "Fail OST during write, with verification"
114 verify=$ROOT/tmp/verify-$$
115 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $DIR/$tfile
116 # invalidate cache, so that we're reading over the wire
117 for i in /proc/fs/lustre/ldlm/namespaces/*-osc-*; do
118 echo -n clear > $i/lru_size
120 cmp $verify $DIR/$tfile &
123 wait $cmppid || return 1
124 rm -f $verify $DIR/$tfile
126 run_test 4 "Fail OST during read, with verification"
129 [ -z "`which iozone 2> /dev/null`" ] && log "iozone missing" && return
130 FREE=`df -P -h $DIR | tail -n 1 | awk '{ print $3 }'`
134 IOZONE_OPTS="-i 0 -i 1 -i 2 -+d -r 4 -s $FREE"
135 iozone $IOZONE_OPTS -f $DIR/$tfile &
144 [ $RC -ne 0 ] && return $RC || true
146 run_test 5 "Fail OST during iozone"
149 awk '{total+=$1} END {print total}' /proc/fs/lustre/osc/*-osc-*/kbytesfree
155 sync && sleep 2 && sync # wait for delete thread
157 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
160 sleep 2 # ensure we have a fresh statfs
162 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
163 do_facet mds "sysctl -w lustre.fail_loc=0x80000119"
164 after_dd=`kbytesfree`
165 log "before: $before after_dd: $after_dd"
166 (( $before > $after_dd )) || return 1
169 $CHECKSTAT -t file $f && return 2 || true
171 # let the delete happen
174 log "before: $before after: $after"
175 (( $before <= $after + 40 )) || return 3 # take OST logs into account
177 run_test 6 "Fail OST before obd_destroy"
182 sync && sleep 5 && sync # wait for delete thread
184 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
186 sleep 2 # ensure we have a fresh statfs
188 after_dd=`kbytesfree`
189 log "before: $before after_dd: $after_dd"
190 (( $before > $after_dd )) || return 1
194 $CHECKSTAT -t file $f && return 2 || true
196 # let the delete happen
199 log "before: $before after: $after"
200 (( $before <= $after + 40 )) || return 3 # take OST logs into account
202 run_test 7 "Fail OST before obd_destroy"
204 equals_msg test complete, cleaning up