2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:shiftwidth=4:softtabstop=4:tabstop=4:
7 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
10 . $LUSTRE/tests/test-framework.sh
12 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
15 # While we do not use OSTCOUNT=1 setup anymore,
16 # ost1failover_HOST is used
17 #ostfailover_HOST=${ostfailover_HOST:-$ost_HOST}
18 #failover= must be defined in OST_MKFS_OPTIONS if ostfailover_HOST != ost_HOST
20 require_dsh_ost || exit 0
22 # Tests that fail on uml
23 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
24 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 6"
28 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
31 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
35 check_and_setup_lustre
37 rm -rf $DIR/[df][0-9]*
39 TDIR=$DIR/d0.${TESTSUITE}
41 $LFS setstripe $TDIR -i 0 -c 1
45 zconf_umount `hostname` $MOUNT -f
46 # needs to run during initial client->OST connection
47 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
48 do_facet ost1 "lctl set_param fail_loc=0x80000211"
49 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
51 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
55 cp /etc/profile $TDIR/$tfile
57 diff /etc/profile $TDIR/$tfile
60 run_test 0b "empty replay"
63 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
65 $CHECKSTAT -t file $TDIR/$tfile || return 1
72 echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
76 grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
80 run_test 2 "|x| 10 open(O_CREAT)s"
83 verify=$ROOT/tmp/verify-$$
84 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
88 wait $ddpid || return 1
89 cmp $verify $TDIR/$tfile || return 2
90 rm -f $verify $TDIR/$tfile
92 run_test 3 "Fail OST during write, with verification"
95 verify=$ROOT/tmp/verify-$$
96 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
97 # invalidate cache, so that we're reading over the wire
99 cmp $verify $TDIR/$tfile &
102 wait $cmppid || return 1
103 rm -f $verify $TDIR/$tfile
105 run_test 4 "Fail OST during read, with verification"
110 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
113 echo "+ iozone $args"
114 iozone $args > $tmppipe &
118 echo "tmppipe=$tmppipe"
121 # iozone exit code is 0 even if iozone is not completed
122 # need to check iozone output on "complete"
123 local iozonelog=$TMP/${TESTSUITE}.iozone.log
125 cat $tmppipe | while read line ; do
127 echo "$line" >>$iozonelog
133 if ! $(tail -1 $iozonelog | grep -q complete); then
143 [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
145 # striping is -c 1, get min of available
146 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
147 local size=$(( minavail * 3/4 ))
148 local GB=1048576 # 1048576KB == 1GB
150 if (( size > GB )); then
153 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
155 iozone_bg $iozone_opts &
158 echo iozone bg pid=$pid
167 [ $rc -eq 0 ] || error "iozone failed"
170 run_test 5 "Fail OST during iozone"
173 calc_osc_kbytes kbytesfree
177 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
181 sync && sleep 2 && sync # wait for delete thread
183 # wait till space is returned, following
184 # (( $before > $after_dd)) test counting on that
185 wait_mds_ost_sync || return 4
186 wait_destroy_complete || return 5
189 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
191 stripe_index=$(lfs getstripe -i $f)
194 sleep 2 # ensure we have a fresh statfs
197 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
198 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
199 after_dd=`kbytesfree`
200 log "before: $before after_dd: $after_dd"
201 (( $before > $after_dd )) || return 1
203 fail ost$((stripe_index + 1))
204 wait_recovery_complete ost$((stripe_index + 1)) ||
205 error "OST$((stripe_index + 1)) recovery not completed"
206 $CHECKSTAT -t file $f && return 2 || true
208 # let the delete happen
209 wait_mds_ost_sync || return 4
210 wait_delete_completed || return 5
212 log "before: $before after: $after"
213 (( $before <= $after + 40 )) || return 3 # take OST logs into account
215 run_test 6 "Fail OST before obd_destroy"
220 sync && sleep 5 && sync # wait for delete thread
222 # wait till space is returned, following
223 # (( $before > $after_dd)) test counting on that
224 wait_mds_ost_sync || return 4
225 wait_destroy_complete || return 5
228 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 4
230 sleep 2 # ensure we have a fresh statfs
232 after_dd=`kbytesfree`
233 log "before: $before after_dd: $after_dd"
234 (( $before > $after_dd )) || return 1
238 wait_recovery_complete ost1 || error "OST recovery not done"
239 $CHECKSTAT -t file $f && return 2 || true
241 # let the delete happen
242 wait_mds_ost_sync || return 4
243 wait_delete_completed || return 5
245 log "before: $before after: $after"
246 (( $before <= $after + 40 )) || return 3 # take OST logs into account
248 run_test 7 "Fail OST before obd_destroy"
251 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
252 { skip "Need MDS version at least 2.3.0"; return; }
253 verify=$ROOT/tmp/verify-$$
254 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
255 error "Create verify file failed"
256 #define OBD_FAIL_OST_DQACQ_NET 0x230
257 do_facet ost1 "lctl set_param fail_loc=0x230"
258 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
260 sleep $TIMEOUT # wait for the io to become redo io
261 if ! ps -p $ddpid > /dev/null 2>&1; then
262 error "redo io finished incorrectly"
265 do_facet ost1 "lctl set_param fail_loc=0"
268 cmp $verify $TDIR/$tfile || return 2
269 rm -f $verify $TDIR/$tfile
270 message=`dmesg | grep "redo for recoverable error -115"`
271 [ -z "$message" ] || error "redo error messages found in dmesg"
273 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
276 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
277 { skip "Need MDS version at least 2.3.0"; return; }
278 verify=$ROOT/tmp/verify-$$
279 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
280 error "Create verify file failed"
281 #define OBD_FAIL_OST_DQACQ_NET 0x230
282 do_facet ost1 "lctl set_param fail_loc=0x230"
283 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
285 sleep $TIMEOUT # wait for the io to become redo io
287 do_facet ost1 "lctl set_param fail_loc=0"
288 wait $ddpid || return 1
290 cmp $verify $TDIR/$tfile || return 2
291 rm -f $verify $TDIR/$tfile
293 run_test 8b "Verify redo io: redo io should success after recovery"
296 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
297 { skip "Need MDS version at least 2.3.0"; return; }
298 verify=$ROOT/tmp/verify-$$
299 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
300 error "Create verify file failed"
301 #define OBD_FAIL_OST_DQACQ_NET 0x230
302 do_facet ost1 "lctl set_param fail_loc=0x230"
303 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
305 sleep $TIMEOUT # wait for the io to become redo io
307 # allow recovery to complete
308 sleep $((TIMEOUT + 2))
309 do_facet ost1 "lctl set_param fail_loc=0"
312 cmp $verify $TDIR/$tfile && return 2
313 rm -f $verify $TDIR/$tfile
315 run_test 8c "Verify redo io: redo io should fail after eviction"
318 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
319 { skip "Need MDS version at least 2.3.0"; return; }
320 #define OBD_FAIL_MDS_DQACQ_NET 0x187
321 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
322 # test the non-intent create path
323 mcreate $TDIR/$tfile &
326 if ! ps -p $cpid > /dev/null 2>&1; then
327 error "mknod finished incorrectly"
330 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
331 wait $cpid || return 2
332 stat $TDIR/$tfile || error "mknod failed"
336 #define OBD_FAIL_MDS_DQACQ_NET 0x187
337 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
338 # test the intent create path
339 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
342 if ! ps -p $cpid > /dev/null 2>&1; then
343 error "open finished incorrectly"
346 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
347 wait $cpid || return 4
348 stat $TDIR/$tfile || error "open failed"
350 run_test 8d "Verify redo creation on -EINPROGRESS"
353 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
354 { skip "Need MDS version at least 2.3.0"; return; }
355 sleep 1 # ensure we have a fresh statfs
356 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
357 do_facet ost1 "lctl set_param fail_loc=0x231"
361 if ! ps -p $dfpid > /dev/null 2>&1; then
362 do_facet ost1 "lctl set_param fail_loc=0"
363 error "df shouldn't have completed!"
366 do_facet ost1 "lctl set_param fail_loc=0"
368 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
371 check_and_cleanup_lustre