6 # This test needs to be run on the client
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 . $LUSTRE/tests/test-framework.sh
14 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
22 add_mds mds --dev $MDSDEV --size $MDSSIZE
23 if [ ! -z "$mdsfailover_HOST" ]; then
24 add_mdsfailover mds --dev $MDSDEV --size $MDSSIZE
27 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
28 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
29 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
30 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
31 add_client client mds --lov lov1 --path $MOUNT
37 # make sure we are using the primary MDS, so the config log will
38 # be able to clean up properly.
39 activemds=`facet_active mds`
40 if [ $activemds != "mds" ]; then
44 stop mds ${FORCE} $MDSLCONFARGS
45 stop ost2 ${FORCE} --dump cleanup.log
46 stop ost ${FORCE} --dump cleanup.log
49 if [ "$ONLY" == "cleanup" ]; then
50 sysctl -w portals.debug=0 || true
57 start ost --reformat $OSTLCONFARGS
58 start ost2 --reformat $OSTLCONFARGS
59 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
60 start mds $MDSLCONFARGS --reformat
63 if [ "$ONLY" == "setup" ]; then
73 run_test 0 "empty replay"
79 $CHECKSTAT -t file $DIR/$tfile || return 1
82 run_test 1 "simple create"
88 $CHECKSTAT -t file $DIR/$tfile || return 1
98 $CHECKSTAT -t file $DIR/$tfile || return 1
106 o_directory $DIR/$tfile
108 $CHECKSTAT -t file $DIR/$tfile || return 2
111 run_test 3 "replay failed open"
115 for i in `seq 10`; do
116 echo "tag-$i" > $DIR/$tfile-$i
119 for i in `seq 10`; do
120 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
123 run_test 4 "|x| 10 open(O_CREAT)s"
129 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
131 run_test 4b "|x| rm 10 files"
133 # The idea is to get past the first block of precreated files on both
134 # osts, and then replay.
137 for i in `seq 220`; do
138 echo "tag-$i" > $DIR/$tfile-$i
141 for i in `seq 220`; do
142 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
146 # waiting for commitment of removal
148 run_test 5 "|x| 220 open(O_CREAT)"
154 mcreate $DIR/$tdir/$tfile
156 $CHECKSTAT -t dir $DIR/$tdir || return 1
157 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
159 # waiting for log process thread
161 run_test 6 "mkdir + contained create"
167 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
169 run_test 6b "|X| rmdir"
174 mcreate $DIR/$tdir/$tfile
176 $CHECKSTAT -t dir $DIR/$tdir || return 1
177 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
180 run_test 7 "mkdir |X| contained create"
184 multiop $DIR/$tfile mo_c &
189 $CHECKSTAT -t file $DIR/$tfile || return 1
190 kill -USR1 $MULTIPID || return 2
191 wait $MULTIPID || return 3
194 run_test 8 "creat open |X| close"
199 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
201 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
203 echo " old_inum == $old_inum, new_inum == $new_inum"
204 if [ $old_inum -eq $new_inum ] ;
206 echo " old_inum and new_inum match"
208 echo "!!!! old_inum and new_inum NOT match"
213 run_test 9 "|X| create (same inum/gen)"
218 mv $DIR/$tfile $DIR/$tfile-2
221 $CHECKSTAT $DIR/$tfile && return 1
222 $CHECKSTAT $DIR/$tfile-2 ||return 2
226 run_test 10 "create |X| rename unlink"
230 echo "old" > $DIR/$tfile
231 mv $DIR/$tfile $DIR/$tfile-2
233 echo "new" > $DIR/$tfile
235 grep old $DIR/$tfile-2
237 grep new $DIR/$tfile || return 1
238 grep old $DIR/$tfile-2 || return 2
240 run_test 11 "create open write rename |X| create-old-name read"
244 multiop $DIR/$tfile o_tSc &
246 # give multiop a chance to open
251 wait $pid || return 1
254 [ -e $DIR/$tfile ] && return 2
257 run_test 12 "open, unlink |X| close"
260 # 1777 - replay open after committed chmod that would make
261 # a regular open a failure
264 multiop $DIR/$tfile O_wc &
266 # give multiop a chance to open
269 $CHECKSTAT -p 0 $DIR/$tfile
273 wait $pid || return 1
275 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
278 run_test 13 "open chmod 0 |x| write close"
281 multiop $DIR/$tfile O_tSc &
283 # give multiop a chance to open
287 kill -USR1 $pid || return 1
288 wait $pid || return 2
291 [ -e $DIR/$tfile ] && return 3
294 run_test 14 "open(O_CREAT), unlink |X| close"
297 multiop $DIR/$tfile O_tSc &
299 # give multiop a chance to open
303 touch $DIR/g11 || return 1
305 wait $pid || return 2
308 [ -e $DIR/$tfile ] && return 3
309 touch $DIR/h11 || return 4
312 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
319 mcreate $DIR/$tfile-2
321 [ -e $DIR/$tfile ] && return 1
322 [ -e $DIR/$tfile-2 ] || return 2
323 munlink $DIR/$tfile-2 || return 3
325 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
329 multiop $DIR/$tfile O_c &
331 # give multiop a chance to open
334 kill -USR1 $pid || return 1
335 wait $pid || return 2
336 $CHECKSTAT -t file $DIR/$tfile || return 3
339 run_test 17 "|X| open(O_CREAT), |replay| close"
343 multiop $DIR/$tfile O_tSc &
345 # give multiop a chance to open
348 touch $DIR/$tfile-2 || return 1
350 wait $pid || return 2
353 [ -e $DIR/$tfile ] && return 3
354 [ -e $DIR/$tfile-2 ] || return 4
355 # this touch frequently fails
356 touch $DIR/$tfile-3 || return 5
357 munlink $DIR/$tfile-2 || return 6
358 munlink $DIR/$tfile-3 || return 7
361 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
363 # bug 1855 (a simpler form of test_11 above)
367 echo "old" > $DIR/$tfile
368 mv $DIR/$tfile $DIR/$tfile-2
369 grep old $DIR/$tfile-2
371 grep old $DIR/$tfile-2 || return 2
373 run_test 19 "|X| mcreate, open, write, rename "
377 multiop $DIR/$tfile O_tSc &
379 # give multiop a chance to open
385 wait $pid || return 1
386 [ -e $DIR/$tfile ] && return 2
389 run_test 20 "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
393 multiop $DIR/$tfile O_tSc &
395 # give multiop a chance to open
398 touch $DIR/g11 || return 1
402 wait $pid || return 2
403 [ -e $DIR/$tfile ] && return 3
404 touch $DIR/h11 || return 4
407 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
410 multiop $DIR/$tfile O_tSc &
412 # give multiop a chance to open
420 wait $pid || return 1
421 [ -e $DIR/$tfile ] && return 2
424 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
427 multiop $DIR/$tfile O_tSc &
429 # give multiop a chance to open
434 touch $DIR/g11 || return 1
438 wait $pid || return 2
439 [ -e $DIR/$tfile ] && return 3
440 touch $DIR/h11 || return 4
443 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
446 multiop $DIR/$tfile O_tSc &
448 # give multiop a chance to open
455 wait $pid || return 1
456 [ -e $DIR/$tfile ] && return 2
459 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
462 multiop $DIR/$tfile O_tSc &
464 # give multiop a chance to open
471 wait $pid || return 1
472 [ -e $DIR/$tfile ] && return 2
475 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
479 multiop $DIR/$tfile-1 O_tSc &
481 multiop $DIR/$tfile-2 O_tSc &
483 # give multiop a chance to open
488 wait $pid2 || return 1
492 wait $pid1 || return 2
493 [ -e $DIR/$tfile-1 ] && return 3
494 [ -e $DIR/$tfile-2 ] && return 4
497 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
501 multiop $DIR/$tfile-1 O_tSc &
503 multiop $DIR/$tfile-2 O_tSc &
505 # give multiop a chance to open
512 wait $pid1 || return 1
514 wait $pid2 || return 2
515 [ -e $DIR/$tfile-1 ] && return 3
516 [ -e $DIR/$tfile-2 ] && return 4
519 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
522 multiop $DIR/$tfile-1 O_tSc &
524 multiop $DIR/$tfile-2 O_tSc &
526 # give multiop a chance to open
532 wait $pid2 || return 1
536 wait $pid1 || return 2
537 [ -e $DIR/$tfile-1 ] && return 3
538 [ -e $DIR/$tfile-2 ] && return 4
541 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
544 multiop $DIR/$tfile-1 O_tSc &
546 multiop $DIR/$tfile-2 O_tSc &
548 # give multiop a chance to open
556 wait $pid1 || return 1
558 wait $pid2 || return 2
559 [ -e $DIR/$tfile-1 ] && return 3
560 [ -e $DIR/$tfile-2 ] && return 4
563 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
566 multiop $DIR/$tfile-1 O_tSc &
568 multiop $DIR/$tfile-2 O_tSc &
570 # give multiop a chance to open
578 wait $pid1 || return 1
580 wait $pid2 || return 2
581 [ -e $DIR/$tfile-1 ] && return 3
582 [ -e $DIR/$tfile-2 ] && return 4
585 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
588 multiop $DIR/$tfile-1 O_tSc &
590 multiop $DIR/$tfile-2 O_tSc &
592 # give multiop a chance to open
600 wait $pid1 || return 1
602 wait $pid2 || return 2
603 [ -e $DIR/$tfile-1 ] && return 3
604 [ -e $DIR/$tfile-2 ] && return 4
607 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
609 # tests for bug 2104; completion without crashing is success. The close is
610 # stale, but we always return 0 for close, so the app never sees it.
612 multiop $DIR/$tfile O_c &
614 multiop $DIR/$tfile O_c &
616 # give multiop a chance to open
619 df $MOUNT || df $MOUNT || return 1
625 run_test 32 "close() notices client eviction; close() after client eviction"
627 # Abort recovery before client complete
632 # this file should be gone, because the replay was aborted
633 $CHECKSTAT -t file $DIR/$tfile && return 1
636 run_test 33 "abort recovery before client does replay"
639 multiop $DIR/$tfile O_c &
641 # give multiop a chance to open
648 [ -e $DIR/$tfile ] && return 1
650 # wait for commitment of removal
653 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
655 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
659 echo 0x80000119 > /proc/sys/lustre/fail_loc
662 # give a chance to remove from MDS
664 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
666 run_test 35 "test recovery from llog for unlink op"
668 equals_msg test complete, cleaning up