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
24 ALWAYS_EXCEPT="$REPLAY_OST_SINGLE_EXCEPT"
27 [ "$SLOW" = "no" ] && EXCEPT_SLOW="5"
29 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
30 # bug number for skipped test: LU-2285
31 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 3"
32 # bug number for slowed tests: LU-2874
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 8a"
38 check_and_setup_lustre
40 rm -rf $DIR/[df][0-9]*
42 TDIR=$DIR/d0.${TESTSUITE}
44 $LFS setstripe $TDIR -i 0 -c 1
48 zconf_umount `hostname` $MOUNT -f
49 # needs to run during initial client->OST connection
50 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
51 do_facet ost1 "lctl set_param fail_loc=0x80000211"
52 zconf_mount `hostname` $MOUNT && df $MOUNT || error "0a mount fail"
54 run_test 0a "target handle mismatch (bug 5317) `date +%H:%M:%S`"
58 cp /etc/profile $TDIR/$tfile
60 diff /etc/profile $TDIR/$tfile
63 run_test 0b "empty replay"
66 date > $TDIR/$tfile || error "error creating $TDIR/$tfile"
68 $CHECKSTAT -t file $TDIR/$tfile || return 1
75 echo "tag-$i" > $TDIR/$tfile-$i || error "create $TDIR/$tfile-$i"
79 grep -q "tag-$i" $TDIR/$tfile-$i || error "grep $TDIR/$tfile-$i"
83 run_test 2 "|x| 10 open(O_CREAT)s"
86 verify=$ROOT/tmp/verify-$$
87 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile &
91 wait $ddpid || return 1
92 cmp $verify $TDIR/$tfile || return 2
93 rm -f $verify $TDIR/$tfile
95 run_test 3 "Fail OST during write, with verification"
98 verify=$ROOT/tmp/verify-$$
99 dd if=/dev/urandom bs=4096 count=1280 | tee $verify > $TDIR/$tfile
100 # invalidate cache, so that we're reading over the wire
102 cmp $verify $TDIR/$tfile &
105 wait $cmppid || return 1
106 rm -f $verify $TDIR/$tfile
108 run_test 4 "Fail OST during read, with verification"
113 local tmppipe=$TMP/${TESTSUITE}.${TESTNAME}.pipe
116 echo "+ iozone $args"
117 iozone $args > $tmppipe &
121 echo "tmppipe=$tmppipe"
124 # iozone exit code is 0 even if iozone is not completed
125 # need to check iozone output on "complete"
126 local iozonelog=$TMP/${TESTSUITE}.iozone.log
128 cat $tmppipe | while read line ; do
130 echo "$line" >>$iozonelog
136 if ! $(tail -1 $iozonelog | grep -q complete); then
146 [ -z "`which iozone 2> /dev/null`" ] && skip_env "iozone missing" && return 0
148 # striping is -c 1, get min of available
149 local minavail=$(lctl get_param -n osc.*[oO][sS][cC][-_]*.kbytesavail | sort -n | head -1)
150 local size=$(( minavail * 3/4 ))
151 local GB=1048576 # 1048576KB == 1GB
153 if (( size > GB )); then
156 local iozone_opts="-i 0 -i 1 -i 2 -+d -r 4 -s $size -f $TDIR/$tfile"
158 iozone_bg $iozone_opts &
161 echo iozone bg pid=$pid
170 wait_delete_completed_mds
171 [ $rc -eq 0 ] || error "iozone failed"
174 run_test 5 "Fail OST during iozone"
177 calc_osc_kbytes kbytesfree
181 remote_mds_nodsh && skip "remote MDS with nodsh" && return 0
185 sync && sleep 2 && sync # wait for delete thread
187 # wait till space is returned, following
188 # (( $before > $after_dd)) test counting on that
189 wait_mds_ost_sync || return 4
190 wait_destroy_complete || return 5
192 local before=$(kbytesfree)
193 dd if=/dev/urandom bs=4096 count=1280 of=$f || return 28
195 local stripe_index=$(lfs getstripe -i $f)
198 sleep 4 # ensure we have a fresh statfs and changes have stablalized
201 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
202 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
203 local after_dd=$(kbytesfree)
204 log "before: $before after_dd: $after_dd"
205 (( $before > $after_dd )) ||
206 error "space grew after dd: before:$before after_dd:$after_dd"
208 fail ost$((stripe_index + 1))
209 wait_recovery_complete ost$((stripe_index + 1)) ||
210 error "OST$((stripe_index + 1)) recovery not completed"
211 $CHECKSTAT -t file $f && return 2 || true
213 # let the delete happen
214 wait_mds_ost_sync || return 4
215 wait_delete_completed || return 5
216 local after=$(kbytesfree)
217 log "before: $before after: $after"
218 (( $before <= $after + $(fs_log_size) )) ||
219 error "$before > $after + logsize $(fs_log_size)"
221 run_test 6 "Fail OST before obd_destroy"
226 sync && sleep 5 && sync # wait for delete thread
228 # wait till space is returned, following
229 # (( $before > $after_dd)) test counting on that
230 wait_mds_ost_sync || return 4
231 wait_destroy_complete || return 5
233 local before=$(kbytesfree)
234 dd if=/dev/urandom bs=4096 count=1280 of=$f || error "dd to file failed: $?"
237 local after_dd=$(kbytesfree)
238 while (( $before <= $after_dd && $i < 10 )); do
242 after_dd=$(kbytesfree)
245 log "before: $before after_dd: $after_dd took $i seconds"
246 (( $before > $after_dd )) ||
247 error "space grew after dd: before:$before after_dd:$after_dd"
251 wait_recovery_complete ost1 || error "OST recovery not done"
252 $CHECKSTAT -t file $f && return 2 || true
254 # let the delete happen
255 wait_mds_ost_sync || return 4
256 wait_delete_completed || return 5
257 local after=$(kbytesfree)
258 log "before: $before after: $after"
259 (( $before <= $after + $(fs_log_size) )) ||
260 error "$before > $after + logsize $(fs_log_size)"
262 run_test 7 "Fail OST before obd_destroy"
265 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
266 { skip "Need MDS version at least 2.3.0"; return; }
267 verify=$ROOT/tmp/verify-$$
268 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
269 error "Create verify file failed"
270 #define OBD_FAIL_OST_DQACQ_NET 0x230
271 do_facet ost1 "lctl set_param fail_loc=0x230"
272 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
274 sleep $TIMEOUT # wait for the io to become redo io
275 if ! ps -p $ddpid > /dev/null 2>&1; then
276 error "redo io finished incorrectly"
279 do_facet ost1 "lctl set_param fail_loc=0"
282 cmp $verify $TDIR/$tfile || return 2
283 rm -f $verify $TDIR/$tfile
284 message=`dmesg | grep "redo for recoverable error -115"`
285 [ -z "$message" ] || error "redo error messages found in dmesg"
287 run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
290 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
291 { skip "Need MDS version at least 2.3.0"; return; }
292 verify=$ROOT/tmp/verify-$$
293 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
294 error "Create verify file failed"
295 #define OBD_FAIL_OST_DQACQ_NET 0x230
296 do_facet ost1 "lctl set_param fail_loc=0x230"
297 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
299 sleep $TIMEOUT # wait for the io to become redo io
301 do_facet ost1 "lctl set_param fail_loc=0"
302 wait $ddpid || return 1
304 cmp $verify $TDIR/$tfile || return 2
305 rm -f $verify $TDIR/$tfile
307 run_test 8b "Verify redo io: redo io should success after recovery"
310 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
311 { skip "Need MDS version at least 2.3.0"; return; }
312 verify=$ROOT/tmp/verify-$$
313 dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
314 error "Create verify file failed"
315 #define OBD_FAIL_OST_DQACQ_NET 0x230
316 do_facet ost1 "lctl set_param fail_loc=0x230"
317 dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
319 sleep $TIMEOUT # wait for the io to become redo io
321 # allow recovery to complete
322 sleep $((TIMEOUT + 2))
323 do_facet ost1 "lctl set_param fail_loc=0"
326 cmp $verify $TDIR/$tfile && return 2
327 rm -f $verify $TDIR/$tfile
329 run_test 8c "Verify redo io: redo io should fail after eviction"
332 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
333 { skip "Need MDS version at least 2.3.0"; return; }
334 #define OBD_FAIL_MDS_DQACQ_NET 0x187
335 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
336 # test the non-intent create path
337 mcreate $TDIR/$tfile &
340 if ! ps -p $cpid > /dev/null 2>&1; then
341 error "mknod finished incorrectly"
344 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
345 wait $cpid || return 2
346 stat $TDIR/$tfile || error "mknod failed"
350 #define OBD_FAIL_MDS_DQACQ_NET 0x187
351 do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
352 # test the intent create path
353 openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
356 if ! ps -p $cpid > /dev/null 2>&1; then
357 error "open finished incorrectly"
360 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
361 wait $cpid || return 4
362 stat $TDIR/$tfile || error "open failed"
364 run_test 8d "Verify redo creation on -EINPROGRESS"
367 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
368 { skip "Need MDS version at least 2.3.0"; return; }
369 sleep 1 # ensure we have a fresh statfs
370 #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
371 do_facet ost1 "lctl set_param fail_loc=0x231"
375 if ! ps -p $dfpid > /dev/null 2>&1; then
376 do_facet ost1 "lctl set_param fail_loc=0"
377 error "df shouldn't have completed!"
380 do_facet ost1 "lctl set_param fail_loc=0"
382 run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
385 check_and_cleanup_lustre