Whamcloud - gitweb
3f8cdb88c95c3bca00c695b7bd7c6b9090005c51
[fs/lustre-release.git] / lustre / tests / replay-single.sh
1 #!/bin/bash
2
3 set -e
4
5 LUSTRE=${LUSTRE:-$(dirname $0)/..}
6 . $LUSTRE/tests/test-framework.sh
7 init_test_env $@
8 init_logging
9
10 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
11 # bug number for skipped test: LU-13614
12 ALWAYS_EXCEPT+="               59"
13
14 if [ "$mds1_FSTYPE" = zfs ]; then
15         # bug number for skipped test: LU-11388
16         ALWAYS_EXCEPT+="               131b"
17 fi
18
19 if $SHARED_KEY; then
20         # bug number for skipped tests: LU-9795
21         ALWAYS_EXCEPT="$ALWAYS_EXCEPT   121"
22 fi
23 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
24
25 build_test_filter
26
27 CHECK_GRANT=${CHECK_GRANT:-"yes"}
28 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
29
30 require_dsh_mds || exit 0
31 check_and_setup_lustre
32
33 mkdir -p $DIR
34
35 assert_DIR
36 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
37
38 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
39 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
40     sync
41     do_facet $SINGLEMDS sync
42 fi
43
44 test_0a() {     # was test_0
45         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
46         replay_barrier $SINGLEMDS
47         fail $SINGLEMDS
48         rmdir $DIR/$tdir
49 }
50 run_test 0a "empty replay"
51
52 test_0b() {
53         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
54
55         # this test attempts to trigger a race in the precreation code,
56         # and must run before any other objects are created on the filesystem
57         fail ost1
58         createmany -o $DIR/$tfile 20 || error "createmany -o $DIR/$tfile failed"
59         unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
60 }
61 run_test 0b "ensure object created after recover exists. (3284)"
62
63 test_0c() {
64         replay_barrier $SINGLEMDS
65         mcreate $DIR/$tfile
66         umount $MOUNT
67         facet_failover $SINGLEMDS
68         zconf_mount $(hostname) $MOUNT || error "mount fails"
69         client_up || error "post-failover df failed"
70         # file shouldn't exist if replay-barrier works as expected
71         rm $DIR/$tfile && error "File exists and it shouldn't"
72         return 0
73 }
74 run_test 0c "check replay-barrier"
75
76 test_0d() {
77         replay_barrier $SINGLEMDS
78         umount $MOUNT
79         facet_failover $SINGLEMDS
80         zconf_mount $(hostname) $MOUNT || error "mount fails"
81         client_up || error "post-failover df failed"
82 }
83 run_test 0d "expired recovery with no clients"
84
85 test_1() {
86         replay_barrier $SINGLEMDS
87         mcreate $DIR/$tfile
88         fail $SINGLEMDS
89         $CHECKSTAT -t file $DIR/$tfile ||
90                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
91         rm $DIR/$tfile
92 }
93 run_test 1 "simple create"
94
95 test_2a() {
96         replay_barrier $SINGLEMDS
97         touch $DIR/$tfile
98         fail $SINGLEMDS
99         $CHECKSTAT -t file $DIR/$tfile ||
100                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
101         rm $DIR/$tfile
102 }
103 run_test 2a "touch"
104
105 test_2b() {
106         mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
107         replay_barrier $SINGLEMDS
108         touch $DIR/$tfile
109         fail $SINGLEMDS
110         $CHECKSTAT -t file $DIR/$tfile ||
111                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
112         rm $DIR/$tfile
113 }
114 run_test 2b "touch"
115
116 test_2c() {
117         replay_barrier $SINGLEMDS
118         $LFS setstripe -c $OSTCOUNT $DIR/$tfile
119         fail $SINGLEMDS
120         $CHECKSTAT -t file $DIR/$tfile ||
121                 error "$CHECKSTAT $DIR/$tfile check failed"
122 }
123 run_test 2c "setstripe replay"
124
125 test_2d() {
126         [[ "$mds1_FSTYPE" = zfs ]] &&
127                 [[ "$MDS1_VERSION" -lt $(version_code 2.12.51) ]] &&
128                 skip "requires LU-10143 fix on MDS"
129         replay_barrier $SINGLEMDS
130         $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
131         fail $SINGLEMDS
132         $CHECKSTAT -t dir $DIR/$tdir ||
133                 error "$CHECKSTAT $DIR/$tdir check failed"
134 }
135 run_test 2d "setdirstripe replay"
136
137 test_3a() {
138         local file=$DIR/$tfile
139         replay_barrier $SINGLEMDS
140         mcreate $file
141         openfile -f O_DIRECTORY $file
142         fail $SINGLEMDS
143         $CHECKSTAT -t file $file ||
144                 error "$CHECKSTAT $file attribute check failed"
145         rm $file
146 }
147 run_test 3a "replay failed open(O_DIRECTORY)"
148
149 test_3b() {
150         replay_barrier $SINGLEMDS
151         #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
152         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
153         touch $DIR/$tfile
154         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
155         fail $SINGLEMDS
156         $CHECKSTAT -t file $DIR/$tfile &&
157                 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
158         return 0
159 }
160 run_test 3b "replay failed open -ENOMEM"
161
162 test_3c() {
163         replay_barrier $SINGLEMDS
164         #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
165         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
166         touch $DIR/$tfile
167         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
168         fail $SINGLEMDS
169
170         $CHECKSTAT -t file $DIR/$tfile &&
171                 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
172         return 0
173 }
174 run_test 3c "replay failed open -ENOMEM"
175
176 test_4a() {     # was test_4
177         replay_barrier $SINGLEMDS
178         for i in $(seq 10); do
179                 echo "tag-$i" > $DIR/$tfile-$i
180         done
181         fail $SINGLEMDS
182         for i in $(seq 10); do
183                 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
184         done
185 }
186 run_test 4a "|x| 10 open(O_CREAT)s"
187
188 test_4b() {
189         for i in $(seq 10); do
190                 echo "tag-$i" > $DIR/$tfile-$i
191         done
192         replay_barrier $SINGLEMDS
193         rm -rf $DIR/$tfile-*
194         fail $SINGLEMDS
195         $CHECKSTAT -t file $DIR/$tfile-* &&
196                 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
197                 true
198 }
199 run_test 4b "|x| rm 10 files"
200
201 # The idea is to get past the first block of precreated files on both
202 # osts, and then replay.
203 test_5() {
204         replay_barrier $SINGLEMDS
205         for i in $(seq 220); do
206                 echo "tag-$i" > $DIR/$tfile-$i
207         done
208         fail $SINGLEMDS
209         for i in $(seq 220); do
210                 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
211         done
212         rm -rf $DIR/$tfile-*
213         sleep 3
214         # waiting for commitment of removal
215 }
216 run_test 5 "|x| 220 open(O_CREAT)"
217
218 test_6a() {     # was test_6
219         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
220         replay_barrier $SINGLEMDS
221         mcreate $DIR/$tdir/$tfile
222         fail $SINGLEMDS
223         $CHECKSTAT -t dir $DIR/$tdir ||
224                 error "$CHECKSTAT $DIR/$tdir attribute check failed"
225         $CHECKSTAT -t file $DIR/$tdir/$tfile ||
226                 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
227         sleep 2
228         # waiting for log process thread
229 }
230 run_test 6a "mkdir + contained create"
231
232 test_6b() {
233         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
234         replay_barrier $SINGLEMDS
235         rm -rf $DIR/$tdir
236         fail $SINGLEMDS
237         $CHECKSTAT -t dir $DIR/$tdir &&
238                 error "$CHECKSTAT $DIR/$tdir attribute check should fail" ||
239                 true
240 }
241 run_test 6b "|X| rmdir"
242
243 test_7() {
244         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
245         replay_barrier $SINGLEMDS
246         mcreate $DIR/$tdir/$tfile
247         fail $SINGLEMDS
248         $CHECKSTAT -t dir $DIR/$tdir ||
249                 error "$CHECKSTAT $DIR/$tdir attribute check failed"
250         $CHECKSTAT -t file $DIR/$tdir/$tfile ||
251                 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check failed"
252         rm -fr $DIR/$tdir
253 }
254 run_test 7 "mkdir |X| contained create"
255
256 test_8() {
257         replay_barrier $SINGLEMDS
258         multiop_bg_pause $DIR/$tfile mo_c ||
259                 error "multiop mknod $DIR/$tfile failed"
260         MULTIPID=$!
261         fail $SINGLEMDS
262         ls $DIR/$tfile
263         $CHECKSTAT -t file $DIR/$tfile ||
264                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
265         kill -USR1 $MULTIPID || error "multiop mknod $MULTIPID not running"
266         wait $MULTIPID || error "multiop mknod $MULTIPID failed"
267         rm $DIR/$tfile
268 }
269 run_test 8 "creat open |X| close"
270
271 test_9() {
272         replay_barrier $SINGLEMDS
273         mcreate $DIR/$tfile
274         local old_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
275         fail $SINGLEMDS
276         local new_inum=$(ls -i $DIR/$tfile | awk '{print $1}')
277
278         echo " old_inum == $old_inum, new_inum == $new_inum"
279         if [ $old_inum -eq $new_inum  ] ;
280         then
281                 echo "old_inum and new_inum match"
282         else
283                 echo " old_inum and new_inum do not match"
284                 error "old index($old_inum) does not match new index($new_inum)"
285         fi
286         rm $DIR/$tfile
287 }
288 run_test 9 "|X| create (same inum/gen)"
289
290 test_10() {
291         mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
292         replay_barrier $SINGLEMDS
293         mv $DIR/$tfile $DIR/$tfile-2
294         rm -f $DIR/$tfile
295         fail $SINGLEMDS
296         $CHECKSTAT $DIR/$tfile &&
297                 error "$CHECKSTAT $DIR/$tfile attribute check should fail"
298         $CHECKSTAT $DIR/$tfile-2 ||
299                 error "$CHECKSTAT $DIR/$tfile-2 attribute check failed"
300         rm $DIR/$tfile-2
301         return 0
302 }
303 run_test 10 "create |X| rename unlink"
304
305 test_11() {
306         mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
307         echo "old" > $DIR/$tfile
308         mv $DIR/$tfile $DIR/$tfile-2
309         replay_barrier $SINGLEMDS
310         echo "new" > $DIR/$tfile
311         grep new $DIR/$tfile
312         grep old $DIR/$tfile-2
313         fail $SINGLEMDS
314         grep new $DIR/$tfile || error "grep $DIR/$tfile failed"
315         grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
316 }
317 run_test 11 "create open write rename |X| create-old-name read"
318
319 test_12() {
320         mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
321         multiop_bg_pause $DIR/$tfile o_tSc ||
322                 error "multiop_bg_pause $DIR/$tfile failed"
323         pid=$!
324         rm -f $DIR/$tfile
325         replay_barrier $SINGLEMDS
326         kill -USR1 $pid || error "multiop $pid not running"
327         wait $pid || error "multiop $pid failed"
328
329         fail $SINGLEMDS
330         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
331         return 0
332 }
333 run_test 12 "open, unlink |X| close"
334
335 # 1777 - replay open after committed chmod that would make
336 #        a regular open a failure
337 test_13() {
338         mcreate $DIR/$tfile || error "mcreate $DIR/$tfile failed"
339         multiop_bg_pause $DIR/$tfile O_wc ||
340                 error "multiop_bg_pause $DIR/$tfile failed"
341         pid=$!
342         chmod 0 $DIR/$tfile
343         $CHECKSTAT -p 0 $DIR/$tfile ||
344                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
345         replay_barrier $SINGLEMDS
346         fail $SINGLEMDS
347         kill -USR1 $pid || error "multiop $pid not running"
348         wait $pid || error "multiop $pid failed"
349
350         $CHECKSTAT -s 1 -p 0 $DIR/$tfile ||
351                 error "second $CHECKSTAT $DIR/$tfile attribute check failed"
352         rm $DIR/$tfile || error "rm $DIR/$tfile failed"
353         return 0
354 }
355 run_test 13 "open chmod 0 |x| write close"
356
357 test_14() {
358         multiop_bg_pause $DIR/$tfile O_tSc ||
359                 error "multiop_bg_pause $DIR/$tfile failed"
360         pid=$!
361         rm -f $DIR/$tfile
362         replay_barrier $SINGLEMDS
363         kill -USR1 $pid || error "multiop $pid not running"
364         wait $pid || error "multiop $pid failed"
365
366         fail $SINGLEMDS
367         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
368         return 0
369 }
370 run_test 14 "open(O_CREAT), unlink |X| close"
371
372 test_15() {
373         multiop_bg_pause $DIR/$tfile O_tSc ||
374                 error "multiop_bg_pause $DIR/$tfile failed"
375         pid=$!
376         rm -f $DIR/$tfile
377         replay_barrier $SINGLEMDS
378         touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
379         kill -USR1 $pid || error "multiop $pid not running"
380         wait $pid || error "multiop $pid failed"
381
382         fail $SINGLEMDS
383         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
384         touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
385         return 0
386 }
387 run_test 15 "open(O_CREAT), unlink |X|  touch new, close"
388
389 test_16() {
390         replay_barrier $SINGLEMDS
391         mcreate $DIR/$tfile
392         munlink $DIR/$tfile
393         mcreate $DIR/$tfile-2
394         fail $SINGLEMDS
395         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
396         [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
397         munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
398 }
399 run_test 16 "|X| open(O_CREAT), unlink, touch new,  unlink new"
400
401 test_17() {
402         replay_barrier $SINGLEMDS
403         multiop_bg_pause $DIR/$tfile O_c ||
404                 error "multiop_bg_pause $DIR/$tfile failed"
405         pid=$!
406         fail $SINGLEMDS
407         kill -USR1 $pid || error "multiop $pid not running"
408         wait $pid || error "multiop $pid failed"
409         $CHECKSTAT -t file $DIR/$tfile ||
410                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
411         rm $DIR/$tfile
412 }
413 run_test 17 "|X| open(O_CREAT), |replay| close"
414
415 test_18() {
416         replay_barrier $SINGLEMDS
417         multiop_bg_pause $DIR/$tfile O_tSc ||
418                 error "multiop_bg_pause $DIR/$tfile failed"
419         pid=$!
420         rm -f $DIR/$tfile
421         touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
422         echo "pid: $pid will close"
423         kill -USR1 $pid || error "multiop $pid not running"
424         wait $pid || error "multiop $pid failed"
425
426         fail $SINGLEMDS
427         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
428         [ -e $DIR/$tfile-2 ] || error "file $DIR/$tfile-2 does not exist"
429         # this touch frequently fails
430         touch $DIR/$tfile-3 || error "touch $DIR/$tfile-3 failed"
431         munlink $DIR/$tfile-2 || error "munlink $DIR/$tfile-2 failed"
432         munlink $DIR/$tfile-3 || error "munlink $DIR/$tfile-3 failed"
433         return 0
434 }
435 run_test 18 "open(O_CREAT), unlink, touch new, close, touch, unlink"
436
437 # bug 1855 (a simpler form of test_11 above)
438 test_19() {
439         replay_barrier $SINGLEMDS
440         mcreate $DIR/$tfile
441         echo "old" > $DIR/$tfile
442         mv $DIR/$tfile $DIR/$tfile-2
443         grep old $DIR/$tfile-2
444         fail $SINGLEMDS
445         grep old $DIR/$tfile-2 || error "grep $DIR/$tfile-2 failed"
446 }
447 run_test 19 "mcreate, open, write, rename "
448
449 test_20a() {    # was test_20
450         replay_barrier $SINGLEMDS
451         multiop_bg_pause $DIR/$tfile O_tSc ||
452                 error "multiop_bg_pause $DIR/$tfile failed"
453         pid=$!
454         rm -f $DIR/$tfile
455
456         fail $SINGLEMDS
457         kill -USR1 $pid || error "multiop $pid not running"
458         wait $pid || error "multiop $pid failed"
459         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
460         return 0
461 }
462 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
463
464 test_20b() { # bug 10480
465         local wait_timeout=$((TIMEOUT * 4))
466         local extra=$(fs_log_size)
467         local n_attempts=1
468
469         sync_all_data
470         save_layout_restore_at_exit $MOUNT
471         $LFS setstripe -i 0 -c 1 $DIR
472
473         local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
474
475         dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
476         while [ ! -e $DIR/$tfile ] ; do
477                 sleep 0.01                      # give dd a chance to start
478         done
479
480         $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
481         # make it an orphan
482         rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
483         mds_evict_client
484         client_up || client_up || true          # reconnect
485
486         do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
487
488         fail $SINGLEMDS                         # start orphan recovery
489         wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
490         wait_delete_completed $wait_timeout || error "delete did not finish"
491         sync_all_data
492
493         while true; do
494                 local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
495                 log "before $beforeused, after $afterused"
496
497                 (( $beforeused + $extra >= $afterused )) && break
498                 n_attempts=$((n_attempts + 1))
499                 [ $n_attempts -gt 3 ] &&
500                         error "after $afterused > before $beforeused + $extra"
501
502                 wait_zfs_commit $SINGLEMDS 5
503                 sync_all_data
504         done
505 }
506
507 run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
508
509 test_20c() { # bug 10480
510         multiop_bg_pause $DIR/$tfile Ow_c ||
511                 error "multiop_bg_pause $DIR/$tfile failed"
512         pid=$!
513
514         ls -la $DIR/$tfile
515
516         mds_evict_client
517         client_up || client_up || true    # reconnect
518
519         kill -USR1 $pid || error "multiop $pid not running"
520         wait $pid || error "multiop $pid failed"
521         [ -s $DIR/$tfile ] || error "File was truncated"
522
523         return 0
524 }
525 run_test 20c "check that client eviction does not affect file content"
526
527 test_21() {
528         replay_barrier $SINGLEMDS
529         multiop_bg_pause $DIR/$tfile O_tSc ||
530                 error "multiop_bg_pause $DIR/$tfile failed"
531         pid=$!
532         rm -f $DIR/$tfile
533         touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
534
535         fail $SINGLEMDS
536         kill -USR1 $pid || error "multiop $pid not running"
537         wait $pid || error "multiop $pid failed"
538         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
539         touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
540         return 0
541 }
542 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
543
544 test_22() {
545         multiop_bg_pause $DIR/$tfile O_tSc ||
546                 error "multiop_bg_pause $DIR/$tfile failed"
547         pid=$!
548
549         replay_barrier $SINGLEMDS
550         rm -f $DIR/$tfile
551
552         fail $SINGLEMDS
553         kill -USR1 $pid || error "multiop $pid not running"
554         wait $pid || error "multiop $pid failed"
555         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
556         return 0
557 }
558 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
559
560 test_23() {
561         multiop_bg_pause $DIR/$tfile O_tSc ||
562                 error "multiop_bg_pause $DIR/$tfile failed"
563         pid=$!
564
565         replay_barrier $SINGLEMDS
566         rm -f $DIR/$tfile
567         touch $DIR/$tfile-1 || error "touch $DIR/$tfile-1 failed"
568
569         fail $SINGLEMDS
570         kill -USR1 $pid || error "multiop $pid not running"
571         wait $pid || error "multiop $pid failed"
572         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
573         touch $DIR/$tfile-2 || error "touch $DIR/$tfile-2 failed"
574         return 0
575 }
576 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
577
578 test_24() {
579         multiop_bg_pause $DIR/$tfile O_tSc ||
580                 error "multiop_bg_pause $DIR/$tfile failed"
581         pid=$!
582
583         replay_barrier $SINGLEMDS
584         fail $SINGLEMDS
585         rm -f $DIR/$tfile
586         kill -USR1 $pid || error "multiop $pid not running"
587         wait $pid || error "multiop $pid failed"
588         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
589         return 0
590 }
591 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
592
593 test_25() {
594         multiop_bg_pause $DIR/$tfile O_tSc ||
595                 error "multiop_bg_pause $DIR/$tfile failed"
596         pid=$!
597         rm -f $DIR/$tfile
598
599         replay_barrier $SINGLEMDS
600         fail $SINGLEMDS
601         kill -USR1 $pid || error "multiop $pid not running"
602         wait $pid || error "multiop $pid failed"
603         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
604         return 0
605 }
606 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
607
608 test_26() {
609         replay_barrier $SINGLEMDS
610         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
611                 error "multiop_bg_pause $DIR/$tfile-1 failed"
612         pid1=$!
613         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
614                 error "multiop_bg_pause $DIR/$tfile-2 failed"
615         pid2=$!
616         rm -f $DIR/$tfile-1
617         rm -f $DIR/$tfile-2
618         kill -USR1 $pid2 || error "second multiop $pid2 not running"
619         wait $pid2 || error "second multiop $pid2 failed"
620
621         fail $SINGLEMDS
622         kill -USR1 $pid1 || error "multiop $pid1 not running"
623         wait $pid1 || error "multiop $pid1 failed"
624         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
625         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
626         return 0
627 }
628 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
629
630 test_27() {
631         replay_barrier $SINGLEMDS
632         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
633                 error "multiop_bg_pause $DIR/$tfile-1 failed"
634         pid1=$!
635         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
636                 error "multiop_bg_pause $DIR/$tfile-2 failed"
637         pid2=$!
638         rm -f $DIR/$tfile-1
639         rm -f $DIR/$tfile-2
640
641         fail $SINGLEMDS
642         kill -USR1 $pid1 || error "multiop $pid1 not running"
643         wait $pid1 || error "multiop $pid1 failed"
644         kill -USR1 $pid2 || error "second multiop $pid2 not running"
645         wait $pid2 || error "second multiop $pid2 failed"
646         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
647         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
648         return 0
649 }
650 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
651
652 test_28() {
653         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
654                 error "multiop_bg_pause $DIR/$tfile-1 failed"
655         pid1=$!
656         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
657                 error "multiop_bg_pause $DIR/$tfile-2 failed"
658         pid2=$!
659         replay_barrier $SINGLEMDS
660         rm -f $DIR/$tfile-1
661         rm -f $DIR/$tfile-2
662         kill -USR1 $pid2 || error "second multiop $pid2 not running"
663         wait $pid2 || error "second multiop $pid2 failed"
664
665         fail $SINGLEMDS
666         kill -USR1 $pid1 || error "multiop $pid1 not running"
667         wait $pid1 || error "multiop $pid1 failed"
668         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
669         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
670         return 0
671 }
672 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
673
674 test_29() {
675         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
676                 error "multiop_bg_pause $DIR/$tfile-1 failed"
677         pid1=$!
678         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
679                 error "multiop_bg_pause $DIR/$tfile-2 failed"
680         pid2=$!
681         replay_barrier $SINGLEMDS
682         rm -f $DIR/$tfile-1
683         rm -f $DIR/$tfile-2
684
685         fail $SINGLEMDS
686         kill -USR1 $pid1 || error "multiop $pid1 not running"
687         wait $pid1 || error "multiop $pid1 failed"
688         kill -USR1 $pid2 || error "second multiop $pid2 not running"
689         wait $pid2 || error "second multiop $pid2 failed"
690         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
691         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
692         return 0
693 }
694 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
695
696 test_30() {
697         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
698                 error "multiop_bg_pause $DIR/$tfile-1 failed"
699         pid1=$!
700         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
701                 error "multiop_bg_pause $DIR/$tfile-2 failed"
702         pid2=$!
703         rm -f $DIR/$tfile-1
704         rm -f $DIR/$tfile-2
705
706         replay_barrier $SINGLEMDS
707         fail $SINGLEMDS
708         kill -USR1 $pid1 || error "multiop $pid1 not running"
709         wait $pid1 || error "multiop $pid1 failed"
710         kill -USR1 $pid2 || error "second multiop $pid2 not running"
711         wait $pid2 || error "second multiop $pid2 failed"
712         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
713         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
714         return 0
715 }
716 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
717
718 test_31() {
719         multiop_bg_pause $DIR/$tfile-1 O_tSc ||
720                 error "multiop_bg_pause $DIR/$tfile-1 failed"
721         pid1=$!
722         multiop_bg_pause $DIR/$tfile-2 O_tSc ||
723                 error "multiop_bg_pause $DIR/$tfile-2 failed"
724         pid2=$!
725         rm -f $DIR/$tfile-1
726
727         replay_barrier $SINGLEMDS
728         rm -f $DIR/$tfile-2
729         fail $SINGLEMDS
730         kill -USR1 $pid1 || error "multiop $pid1 not running"
731         wait $pid1 || error "multiop $pid1 failed"
732         kill -USR1 $pid2 || error "second multiop $pid2 not running"
733         wait $pid2 || error "second multiop $pid2 failed"
734         [ -e $DIR/$tfile-1 ] && error "file $DIR/$tfile-1 should not exist"
735         [ -e $DIR/$tfile-2 ] && error "file $DIR/$tfile-2 should not exist"
736         return 0
737 }
738 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
739
740 # tests for bug 2104; completion without crashing is success.  The close is
741 # stale, but we always return 0 for close, so the app never sees it.
742 test_32() {
743         multiop_bg_pause $DIR/$tfile O_c ||
744                 error "multiop_bg_pause $DIR/$tfile failed"
745         pid1=$!
746         multiop_bg_pause $DIR/$tfile O_c ||
747                 error "second multiop_bg_pause $DIR/$tfile failed"
748         pid2=$!
749         mds_evict_client
750         client_up || client_up || error "client_up failed"
751         kill -USR1 $pid1 || error "multiop $pid1 not running"
752         kill -USR1 $pid2 || error "second multiop $pid2 not running"
753         wait $pid1 || error "multiop $pid1 failed"
754         wait $pid2 || error "second multiop $pid2 failed"
755         return 0
756 }
757 run_test 32 "close() notices client eviction; close() after client eviction"
758
759 test_33a() {
760         createmany -o $DIR/$tfile-%d 10 ||
761                 error "createmany create $DIR/$tfile failed"
762         replay_barrier_nosync $SINGLEMDS
763         fail_abort $SINGLEMDS
764         # recreate shouldn't fail
765         createmany -o $DIR/$tfile--%d 10 ||
766                 error "createmany recreate $DIR/$tfile failed"
767         rm $DIR/$tfile-* -f
768         return 0
769 }
770 run_test 33a "fid seq shouldn't be reused after abort recovery"
771
772 test_33b() {
773         #define OBD_FAIL_SEQ_ALLOC                          0x1311
774         do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
775
776         createmany -o $DIR/$tfile-%d 10
777         replay_barrier_nosync $SINGLEMDS
778         fail_abort $SINGLEMDS
779         # recreate shouldn't fail
780         createmany -o $DIR/$tfile--%d 10 ||
781                 error "createmany recreate $DIR/$tfile failed"
782         rm $DIR/$tfile-* -f
783         return 0
784 }
785 run_test 33b "test fid seq allocation"
786
787 test_34() {
788         multiop_bg_pause $DIR/$tfile O_c ||
789                 error "multiop_bg_pause $DIR/$tfile failed"
790         pid=$!
791         rm -f $DIR/$tfile
792
793         replay_barrier $SINGLEMDS
794         fail_abort $SINGLEMDS
795         kill -USR1 $pid || error "multiop $pid not running"
796         wait $pid || error "multiop $pid failed"
797         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
798         sync
799         return 0
800 }
801 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
802
803 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
804 test_35() {
805         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
806
807         #define OBD_FAIL_MDS_REINT_NET_REP       0x119
808         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
809         rm -f $DIR/$tfile &
810         sleep 1
811         sync
812         sleep 1
813         # give a chance to remove from MDS
814         fail_abort $SINGLEMDS
815         $CHECKSTAT -t file $DIR/$tfile &&
816                 error "$CHECKSTAT $DIR/$tfile attribute check should fail" ||
817                 true
818 }
819 run_test 35 "test recovery from llog for unlink op"
820
821 # b=2432 resent cancel after replay uses wrong cookie,
822 # so don't resend cancels
823 test_36() {
824         replay_barrier $SINGLEMDS
825         touch $DIR/$tfile
826         checkstat $DIR/$tfile
827         facet_failover $SINGLEMDS
828         cancel_lru_locks mdc
829         if $LCTL dk | grep "stale lock .*cookie"; then
830                 error "cancel after replay failed"
831         fi
832 }
833 run_test 36 "don't resend cancel"
834
835 # b=2368
836 # directory orphans can't be unlinked from PENDING directory
837 test_37() {
838         rmdir $DIR/$tfile 2>/dev/null
839         multiop_bg_pause $DIR/$tfile dD_c ||
840                 error "multiop_bg_pause $DIR/$tfile failed"
841         pid=$!
842         rmdir $DIR/$tfile
843
844         replay_barrier $SINGLEMDS
845         # clear the dmesg buffer so we only see errors from this recovery
846         do_facet $SINGLEMDS dmesg -c >/dev/null
847         fail_abort $SINGLEMDS
848         kill -USR1 $pid || error "multiop $pid not running"
849         do_facet $SINGLEMDS dmesg | grep "error unlinking orphan" &&
850                 error "error unlinking files"
851         wait $pid || error "multiop $pid failed"
852         sync
853         return 0
854 }
855 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
856
857 test_38() {
858         createmany -o $DIR/$tfile-%d 800 ||
859                 error "createmany -o $DIR/$tfile failed"
860         unlinkmany $DIR/$tfile-%d 0 400 || error "unlinkmany $DIR/$tfile failed"
861         replay_barrier $SINGLEMDS
862         fail $SINGLEMDS
863         unlinkmany $DIR/$tfile-%d 400 400 ||
864                 error "unlinkmany $DIR/$tfile 400 failed"
865         sleep 2
866         $CHECKSTAT -t file $DIR/$tfile-* &&
867                 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
868                 true
869 }
870 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
871
872 test_39() { # bug 4176
873         createmany -o $DIR/$tfile-%d 800 ||
874                 error "createmany -o $DIR/$tfile failed"
875         replay_barrier $SINGLEMDS
876         unlinkmany $DIR/$tfile-%d 0 400
877         fail $SINGLEMDS
878         unlinkmany $DIR/$tfile-%d 400 400 ||
879                 error "unlinkmany $DIR/$tfile 400 failed"
880         sleep 2
881         $CHECKSTAT -t file $DIR/$tfile-* &&
882                 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
883                 true
884 }
885 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
886
887 count_ost_writes() {
888     lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
889 }
890
891 #b=2477,2532
892 test_40(){
893         # always need connection to MDS to verify layout during IO. LU-2628.
894         lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
895                 skip "layout_lock needs MDS connection for IO" && return 0
896
897         $LCTL mark multiop $MOUNT/$tfile OS_c
898         multiop $MOUNT/$tfile OS_c  &
899         PID=$!
900         writeme -s $MOUNT/${tfile}-2 &
901         WRITE_PID=$!
902         sleep 1
903         facet_failover $SINGLEMDS
904         #define OBD_FAIL_MDS_CONNECT_NET         0x117
905         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
906         kill -USR1 $PID
907         stat1=$(count_ost_writes)
908         sleep $TIMEOUT
909         stat2=$(count_ost_writes)
910         echo "$stat1, $stat2"
911         if [ $stat1 -lt $stat2 ]; then
912                 echo "writes continuing during recovery"
913                 RC=0
914         else
915                 echo "writes not continuing during recovery, bug 2477"
916                 RC=4
917         fi
918         echo "waiting for writeme $WRITE_PID"
919         kill $WRITE_PID
920         wait $WRITE_PID
921
922         echo "waiting for multiop $PID"
923         wait $PID || error "multiop $PID failed"
924         do_facet client munlink $MOUNT/$tfile  ||
925                 error "munlink $MOUNT/$tfile failed"
926         do_facet client munlink $MOUNT/${tfile}-2  ||
927                 error "munlink $MOUNT/$tfile-2 failed"
928         return $RC
929 }
930 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
931
932 #b=2814
933 # make sure that a read to one osc doesn't try to double-unlock its page just
934 # because another osc is invalid.  trigger_group_io used to mistakenly return
935 # an error if any oscs were invalid even after having successfully put rpcs
936 # on valid oscs.  This was fatal if the caller was ll_readpage who unlocked
937 # the page, guarnateeing that the unlock from the RPC completion would
938 # assert on trying to unlock the unlocked page.
939 test_41() {
940         [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
941
942         local f=$MOUNT/$tfile
943         # make sure the start of the file is ost1
944         $LFS setstripe -S $((128 * 1024)) -i 0 $f
945         do_facet client dd if=/dev/zero of=$f bs=4k count=1 ||
946                 error "dd on client failed"
947         cancel_lru_locks osc
948         # fail ost2 and read from ost1
949         local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
950         local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
951                 grep $mdtosc | awk '{print $1}')
952         [ -z "$osc2dev" ] && echo "OST: $ost2_svc" &&
953                 lctl get_param -n devices &&
954                 error "OST 2 $osc2dev does not exist"
955         do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate ||
956                 error "deactive device on $SINGLEMDS failed"
957         do_facet client dd if=$f of=/dev/null bs=4k count=1 ||
958                 error "second dd on client failed"
959         do_facet $SINGLEMDS $LCTL --device $osc2dev activate ||
960                 error "active device on $SINGLEMDS failed"
961         return 0
962 }
963 run_test 41 "read from a valid osc while other oscs are invalid"
964
965 # test MDS recovery after ost failure
966 test_42() {
967         blocks=$(df -P $MOUNT | tail -n 1 | awk '{ print $2 }')
968         createmany -o $DIR/$tfile-%d 800 ||
969                 error "createmany -o $DIR/$tfile failed"
970         replay_barrier ost1
971         unlinkmany $DIR/$tfile-%d 0 400
972         debugsave
973         lctl set_param debug=-1
974         facet_failover ost1
975
976         # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
977         #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
978         #[ $blocks_after -lt $blocks ] || return 1
979         echo "wait for MDS to timeout and recover"
980         sleep $((TIMEOUT * 2))
981         debugrestore
982         unlinkmany $DIR/$tfile-%d 400 400 ||
983                 error "unlinkmany $DIR/$tfile 400 failed"
984         $CHECKSTAT -t file $DIR/$tfile-* &&
985                 error "$CHECKSTAT $DIR/$tfile-* attribute check should fail" ||
986                 true
987 }
988 run_test 42 "recovery after ost failure"
989
990 # timeout in MDS/OST recovery RPC will LBUG MDS
991 test_43() { # bug 2530
992         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
993
994         replay_barrier $SINGLEMDS
995
996         # OBD_FAIL_OST_CREATE_NET 0x204
997         do_facet ost1 "lctl set_param fail_loc=0x80000204"
998         fail $SINGLEMDS
999         sleep 10
1000
1001         return 0
1002 }
1003 run_test 43 "mds osc import failure during recovery; don't LBUG"
1004
1005 test_44a() { # was test_44
1006         local at_max_saved=0
1007
1008         local mdcdev=$($LCTL dl |
1009                 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1010         [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc- not UP"
1011         [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1012                 { $LCTL dl; error "looking for mdcdev=$mdcdev"; }
1013
1014         # adaptive timeouts slow this way down
1015         if at_is_enabled; then
1016                 at_max_saved=$(at_max_get mds)
1017                 at_max_set 40 mds
1018         fi
1019
1020         for i in $(seq 1 10); do
1021                 echo "$i of 10 ($(date +%s))"
1022                 do_facet $SINGLEMDS \
1023                         "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1024                 #define OBD_FAIL_TGT_CONN_RACE     0x701
1025                 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
1026                 # lctl below may fail, it is valid case
1027                 $LCTL --device $mdcdev recover
1028                 $LFS df $MOUNT
1029         done
1030         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1031         [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
1032         return 0
1033 }
1034 run_test 44a "race in target handle connect"
1035
1036 test_44b() {
1037         local mdcdev=$($LCTL dl |
1038                 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
1039         [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1040         [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1041                 { echo mdcdev=$mdcdev; $LCTL dl;
1042                   error "more than one ${FSNAME}-MDT0000-mdc"; }
1043
1044         for i in $(seq 1 10); do
1045                 echo "$i of 10 ($(date +%s))"
1046                 do_facet $SINGLEMDS \
1047                         "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
1048                 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1049                 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
1050                 # lctl below may fail, it is valid case
1051                 $LCTL --device $mdcdev recover
1052                 df $MOUNT
1053         done
1054         return 0
1055 }
1056 run_test 44b "race in target handle connect"
1057
1058 test_44c() {
1059         replay_barrier $SINGLEMDS
1060         createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
1061         #define OBD_FAIL_TGT_RCVG_FLAG 0x712
1062         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
1063         fail_abort $SINGLEMDS
1064         unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
1065         fail $SINGLEMDS
1066         unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
1067         return 0
1068 }
1069 run_test 44c "race in target handle connect"
1070
1071 # Handle failed close
1072 test_45() {
1073         local mdcdev=$($LCTL get_param -n devices |
1074                 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
1075         [ "$mdcdev" ] || error "${FSNAME}-MDT0000-mdc not up"
1076         [ $(echo $mdcdev | wc -w) -eq 1 ] ||
1077                 { echo mdcdev=$mdcdev; $LCTL dl;
1078                   error "more than one ${FSNAME}-MDT0000-mdc"; }
1079
1080         $LCTL --device $mdcdev recover ||
1081                 error "$LCTL --device $mdcdev recover failed"
1082
1083         multiop_bg_pause $DIR/$tfile O_c ||
1084                 error "multiop_bg_pause $DIR/$tfile failed"
1085         pid=$!
1086
1087         # This will cause the CLOSE to fail before even
1088         # allocating a reply buffer
1089         $LCTL --device $mdcdev deactivate ||
1090                 error "$LCTL --device $mdcdev deactivate failed"
1091
1092         # try the close
1093         kill -USR1 $pid || error "multiop $pid not running"
1094         wait $pid || error "multiop $pid failed"
1095
1096         $LCTL --device $mdcdev activate ||
1097                 error "$LCTL --device $mdcdev activate failed"
1098         sleep 1
1099
1100         $CHECKSTAT -t file $DIR/$tfile ||
1101                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1102         return 0
1103 }
1104 run_test 45 "Handle failed close"
1105
1106 test_46() {
1107         drop_reply "touch $DIR/$tfile"
1108         fail $SINGLEMDS
1109         # ironically, the previous test, 45, will cause a real forced close,
1110         # so just look for one for this test
1111         local FID=$($LFS path2fid $tfile)
1112         $LCTL dk | grep -i "force closing file handle $FID" &&
1113                 error "found force closing in dmesg"
1114         return 0
1115 }
1116 run_test 46 "Don't leak file handle after open resend (3325)"
1117
1118 test_47() { # bug 2824
1119         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1120
1121         # create some files to make sure precreate has been done on all
1122         # OSTs. (just in case this test is run independently)
1123         createmany -o $DIR/$tfile 20  ||
1124                 error "createmany create $DIR/$tfile failed"
1125
1126         # OBD_FAIL_OST_CREATE_NET 0x204
1127         fail ost1
1128         do_facet ost1 "lctl set_param fail_loc=0x80000204"
1129         client_up || error "client_up failed"
1130
1131         # let the MDS discover the OST failure, attempt to recover, fail
1132         # and recover again.
1133         sleep $((3 * TIMEOUT))
1134
1135         # Without 2824, this createmany would hang
1136         createmany -o $DIR/$tfile 20 ||
1137                 error "createmany recraete $DIR/$tfile failed"
1138         unlinkmany $DIR/$tfile 20 || error "unlinkmany $DIR/$tfile failed"
1139
1140         return 0
1141 }
1142 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1143
1144 test_48() {
1145         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1146         [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
1147
1148         replay_barrier $SINGLEMDS
1149         createmany -o $DIR/$tfile 20  ||
1150                 error "createmany -o $DIR/$tfile failed"
1151         # OBD_FAIL_OST_EROFS 0x216
1152         facet_failover $SINGLEMDS
1153         do_facet ost1 "lctl set_param fail_loc=0x80000216"
1154         client_up || error "client_up failed"
1155
1156         # let the MDS discover the OST failure, attempt to recover, fail
1157         # and recover again.
1158         sleep $((3 * TIMEOUT))
1159
1160         createmany -o $DIR/$tfile 20 20 ||
1161                 error "createmany recraete $DIR/$tfile failed"
1162         unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
1163         return 0
1164 }
1165 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1166
1167 test_50() {
1168         local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1169         local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" |
1170                 grep $mdtosc | awk '{print $1}')
1171         [ "$oscdev" ] || error "could not find OSC device on MDS"
1172         do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1173                 error "OSC device $oscdev recovery failed"
1174         do_facet $SINGLEMDS $LCTL --device $oscdev recover ||
1175                 error "second OSC device $oscdev recovery failed"
1176         # give the mds_lov_sync threads a chance to run
1177         sleep 5
1178 }
1179 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1180
1181 # b3764 timed out lock replay
1182 test_52() {
1183         [ "$MDS1_VERSION" -lt $(version_code 2.6.90) ] &&
1184                 skip "MDS prior to 2.6.90 handle LDLM_REPLY_NET incorrectly"
1185
1186         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1187         cancel_lru_locks mdc
1188
1189         multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
1190         mpid=$!
1191
1192         #define OBD_FAIL_MDS_LDLM_REPLY_NET     0x157
1193         lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
1194         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
1195
1196         fail $SINGLEMDS || error "fail $SINGLEMDS failed"
1197         kill -USR1 $mpid
1198         wait $mpid || error "multiop_bg_pause pid failed"
1199
1200         do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1201         lctl set_param fail_loc=0x0
1202         lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
1203         rm -f $DIR/$tfile
1204 }
1205 run_test 52 "time out lock replay (3764)"
1206
1207 # bug 3462 - simultaneous MDC requests
1208 test_53a() {
1209         [[ $(lctl get_param mdc.*.import |
1210              grep "connect_flags:.*multi_mod_rpc") ]] ||
1211                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1212
1213         cancel_lru_locks mdc    # cleanup locks from former test cases
1214         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1215         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1216         multiop $DIR/${tdir}-1/f O_c &
1217         close_pid=$!
1218         # give multiop a change to open
1219         sleep 1
1220
1221         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1222         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1223         kill -USR1 $close_pid
1224         cancel_lru_locks mdc    # force the close
1225         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1226
1227         mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1228
1229         # close should still be here
1230         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1231
1232         replay_barrier_nodf $SINGLEMDS
1233         fail $SINGLEMDS
1234         wait $close_pid || error "close_pid $close_pid failed"
1235
1236         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1237                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1238         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1239                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1240         rm -rf $DIR/${tdir}-*
1241 }
1242 run_test 53a "|X| close request while two MDC requests in flight"
1243
1244 test_53b() {
1245         cancel_lru_locks mdc    # cleanup locks from former test cases
1246
1247         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1248         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1249         multiop_bg_pause $DIR/${tdir}-1/f O_c ||
1250                 error "multiop_bg_pause $DIR/${tdir}-1/f failed"
1251         close_pid=$!
1252
1253         #define OBD_FAIL_MDS_REINT_NET 0x107
1254         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1255         mcreate $DIR/${tdir}-2/f &
1256         open_pid=$!
1257         sleep 1
1258
1259         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1260         kill -USR1 $close_pid
1261         cancel_lru_locks mdc    # force the close
1262         wait $close_pid || error "close_pid $close_pid failed"
1263         # open should still be here
1264         [ -d /proc/$open_pid ] || error "open_pid doesn't exist"
1265
1266         replay_barrier_nodf $SINGLEMDS
1267         fail $SINGLEMDS
1268         wait $open_pid || error "open_pid failed"
1269
1270         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1271                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1272         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1273                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1274         rm -rf $DIR/${tdir}-*
1275 }
1276 run_test 53b "|X| open request while two MDC requests in flight"
1277
1278 test_53c() {
1279         cancel_lru_locks mdc    # cleanup locks from former test cases
1280
1281         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1282         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1283         multiop $DIR/${tdir}-1/f O_c &
1284         close_pid=$!
1285
1286         #define OBD_FAIL_MDS_REINT_NET 0x107
1287         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1288         mcreate $DIR/${tdir}-2/f &
1289         open_pid=$!
1290         sleep 1
1291
1292         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1293         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1294         kill -USR1 $close_pid
1295         cancel_lru_locks mdc    # force the close
1296
1297         #bz20647: make sure all pids exist before failover
1298         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1299         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1300         replay_barrier_nodf $SINGLEMDS
1301         fail_nodf $SINGLEMDS
1302         wait $open_pid || error "open_pid failed"
1303         sleep 2
1304         # close should be gone
1305         [ -d /proc/$close_pid ] && error "close_pid should not exist"
1306         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1307
1308         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1309                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1310         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1311                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1312         rm -rf $DIR/${tdir}-*
1313 }
1314 run_test 53c "|X| open request and close request while two MDC requests in flight"
1315
1316 test_53d() {
1317         [[ $(lctl get_param mdc.*.import |
1318              grep "connect_flags:.*multi_mod_rpc") ]] ||
1319                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
1320
1321         cancel_lru_locks mdc    # cleanup locks from former test cases
1322
1323         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1324         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1325         multiop $DIR/${tdir}-1/f O_c &
1326         close_pid=$!
1327         # give multiop a chance to open
1328         sleep 1
1329
1330         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1331         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1332         kill -USR1 $close_pid
1333         cancel_lru_locks mdc    # force the close
1334         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1335         mcreate $DIR/${tdir}-2/f || error "mcreate $DIR/${tdir}-2/f failed"
1336
1337         # close should still be here
1338         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1339         fail $SINGLEMDS
1340         wait $close_pid || error "close_pid failed"
1341
1342         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1343                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1344         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1345                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1346         rm -rf $DIR/${tdir}-*
1347 }
1348 run_test 53d "close reply while two MDC requests in flight"
1349
1350 test_53e() {
1351         cancel_lru_locks mdc    # cleanup locks from former test cases
1352
1353         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1354         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1355         multiop $DIR/${tdir}-1/f O_c &
1356         close_pid=$!
1357
1358         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1359         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1360         mcreate $DIR/${tdir}-2/f &
1361         open_pid=$!
1362         sleep 1
1363
1364         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1365         kill -USR1 $close_pid
1366         cancel_lru_locks mdc    # force the close
1367         wait $close_pid || error "close_pid failed"
1368         # open should still be here
1369         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1370
1371         replay_barrier_nodf $SINGLEMDS
1372         fail $SINGLEMDS
1373         wait $open_pid || error "open_pid failed"
1374
1375         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1376                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1377         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1378                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1379         rm -rf $DIR/${tdir}-*
1380 }
1381 run_test 53e "|X| open reply while two MDC requests in flight"
1382
1383 test_53f() {
1384         cancel_lru_locks mdc    # cleanup locks from former test cases
1385
1386         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1387         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1388         multiop $DIR/${tdir}-1/f O_c &
1389         close_pid=$!
1390
1391         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1392         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1393         mcreate $DIR/${tdir}-2/f &
1394         open_pid=$!
1395         sleep 1
1396
1397         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1398         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1399         kill -USR1 $close_pid
1400         cancel_lru_locks mdc    # force the close
1401
1402         #bz20647: make sure all pids are exists before failover
1403         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1404         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1405         replay_barrier_nodf $SINGLEMDS
1406         fail_nodf $SINGLEMDS
1407         wait $open_pid || error "open_pid failed"
1408         sleep 2
1409         # close should be gone
1410         [ -d /proc/$close_pid ] && error "close_pid should not exist"
1411         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1412
1413         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1414                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1415         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1416                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1417         rm -rf $DIR/${tdir}-*
1418 }
1419 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1420
1421 test_53g() {
1422         cancel_lru_locks mdc    # cleanup locks from former test cases
1423
1424         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1425         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1426         multiop $DIR/${tdir}-1/f O_c &
1427         close_pid=$!
1428
1429         #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1430         do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1431         mcreate $DIR/${tdir}-2/f &
1432         open_pid=$!
1433         sleep 1
1434
1435         #define OBD_FAIL_MDS_CLOSE_NET 0x115
1436         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1437         kill -USR1 $close_pid
1438         cancel_lru_locks mdc    # force the close
1439         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1440
1441         #bz20647: make sure all pids are exists before failover
1442         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1443         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1444         replay_barrier_nodf $SINGLEMDS
1445         fail_nodf $SINGLEMDS
1446         wait $open_pid || error "open_pid failed"
1447         sleep 2
1448         # close should be gone
1449         [ -d /proc/$close_pid ] && error "close_pid should not exist"
1450
1451         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1452                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1453         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1454                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1455         rm -rf $DIR/${tdir}-*
1456 }
1457 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1458
1459 test_53h() {
1460         cancel_lru_locks mdc    # cleanup locks from former test cases
1461
1462         mkdir $DIR/${tdir}-1 || error "mkdir $DIR/${tdir}-1 failed"
1463         mkdir $DIR/${tdir}-2 || error "mkdir $DIR/${tdir}-2 failed"
1464         multiop $DIR/${tdir}-1/f O_c &
1465         close_pid=$!
1466
1467         #define OBD_FAIL_MDS_REINT_NET 0x107
1468         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1469         mcreate $DIR/${tdir}-2/f &
1470         open_pid=$!
1471         sleep 1
1472
1473         #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1474         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1475         kill -USR1 $close_pid
1476         cancel_lru_locks mdc    # force the close
1477         sleep 1
1478
1479         #bz20647: make sure all pids are exists before failover
1480         [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1481         [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1482         replay_barrier_nodf $SINGLEMDS
1483         fail_nodf $SINGLEMDS
1484         wait $open_pid || error "open_pid failed"
1485         sleep 2
1486         # close should be gone
1487         [ -d /proc/$close_pid ] && error "close_pid should not exist"
1488         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1489
1490         $CHECKSTAT -t file $DIR/${tdir}-1/f ||
1491                 error "$CHECKSTAT $DIR/${tdir}-1/f attribute check failed"
1492         $CHECKSTAT -t file $DIR/${tdir}-2/f ||
1493                 error "$CHECKSTAT $DIR/${tdir}-2/f attribute check failed"
1494         rm -rf $DIR/${tdir}-*
1495 }
1496 run_test 53h "open request and close reply while two MDC requests in flight"
1497
1498 #b3761 ASSERTION(hash != 0) failed
1499 test_55() {
1500 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1501     do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1502     touch $DIR/$tfile &
1503     # give touch a chance to run
1504     sleep 5
1505     do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1506     rm $DIR/$tfile
1507     return 0
1508 }
1509 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1510
1511 #b3440 ASSERTION(rec->ur_fid2->id) failed
1512 test_56() {
1513     ln -s foo $DIR/$tfile
1514     replay_barrier $SINGLEMDS
1515     #drop_reply "cat $DIR/$tfile"
1516     fail $SINGLEMDS
1517     sleep 10
1518 }
1519 run_test 56 "don't replay a symlink open request (3440)"
1520
1521 #recovery one mds-ost setattr from llog
1522 test_57() {
1523         #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1524         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1525         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1526         replay_barrier $SINGLEMDS
1527         fail $SINGLEMDS
1528         wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
1529         wait_mds_ost_sync || error "wait_mds_ost_sync failed"
1530         $CHECKSTAT -t file $DIR/$tfile ||
1531                 error "$CHECKSTAT $DIR/$tfile attribute check failed"
1532         do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1533         rm $DIR/$tfile
1534 }
1535 run_test 57 "test recovery from llog for setattr op"
1536
1537 cleanup_58() {
1538         zconf_umount $(hostname) $MOUNT2
1539         trap - EXIT
1540 }
1541
1542 #recovery many mds-ost setattr from llog
1543 test_58a() {
1544         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1545         #define OBD_FAIL_MDS_OST_SETATTR       0x12c
1546         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1547         createmany -o $DIR/$tdir/$tfile-%d 2500
1548         replay_barrier $SINGLEMDS
1549         fail $SINGLEMDS
1550         sleep 2
1551         $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null ||
1552                 error "$CHECKSTAT $DIR/$tfile-* attribute check failed"
1553         do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1554         unlinkmany $DIR/$tdir/$tfile-%d 2500 ||
1555                 error "unlinkmany $DIR/$tfile failed"
1556         rmdir $DIR/$tdir
1557 }
1558 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1559
1560 test_58b() {
1561         local orig
1562         local new
1563
1564         trap cleanup_58 EXIT
1565
1566         large_xattr_enabled &&
1567                 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1568         # Original extended attribute can be long. Print a small version of
1569         # attribute if an error occurs
1570         local sm_msg=$(printf "%.9s" $orig)
1571
1572         mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1573         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1574         touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1575         replay_barrier $SINGLEMDS
1576         setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1577         fail $SINGLEMDS
1578         new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1579         [[ "$new" = "$orig" ]] ||
1580                 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1581         rm -f $DIR/$tdir/$tfile
1582         rmdir $DIR/$tdir
1583         cleanup_58
1584         wait_clients_import_state ${CLIENTS:-$HOSTNAME} "mgs" FULL
1585 }
1586 run_test 58b "test replay of setxattr op"
1587
1588 test_58c() { # bug 16570
1589         local orig
1590         local orig1
1591         local new
1592
1593         trap cleanup_58 EXIT
1594
1595         if large_xattr_enabled; then
1596                 local xattr_size=$(max_xattr_size)
1597                 orig="$(generate_string $((xattr_size / 2)))"
1598                 orig1="$(generate_string $xattr_size)"
1599         else
1600                 orig="bar"
1601                 orig1="bar1"
1602         fi
1603
1604         # PING_INTERVAL max(obd_timeout / 4, 1U)
1605         sleep $((TIMEOUT / 4))
1606
1607         # Original extended attribute can be long. Print a small version of
1608         # attribute if an error occurs
1609         local sm_msg=$(printf "%.9s" $orig)
1610         local sm_msg1=$(printf "%.9s" $orig1)
1611
1612         mount_client $MOUNT2 || error "mount_client on $MOUNT2 failed"
1613         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1614         touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
1615         drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1616                 error "drop_request for setfattr failed"
1617         new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1618         [[ "$new" = "$orig" ]] ||
1619                 error "xattr set ($sm_msg...) differs from xattr get ($new)"
1620         drop_reint_reply "setfattr -n trusted.foo1 \
1621                           -v $orig1 $DIR/$tdir/$tfile" ||
1622                 error "drop_reint_reply for setfattr failed"
1623         new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1624         [[ "$new" = "$orig1" ]] ||
1625                 error "second xattr set ($sm_msg1...) differs xattr get ($new)"
1626         rm -f $DIR/$tdir/$tfile
1627         rmdir $DIR/$tdir
1628         cleanup_58
1629 }
1630 run_test 58c "resend/reconstruct setxattr op"
1631
1632 # log_commit_thread vs filter_destroy race used to lead to import use after free
1633 # bug 11658
1634 test_59() {
1635         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1636
1637         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1638         createmany -o $DIR/$tdir/$tfile-%d 200 ||
1639                 error "createmany create files failed"
1640         sync
1641         unlinkmany $DIR/$tdir/$tfile-%d 200 ||
1642                 error "unlinkmany $DIR/$tdir/$tfile failed"
1643         #define OBD_FAIL_PTLRPC_DELAY_RECOV       0x507
1644         do_facet ost1 "lctl set_param fail_loc=0x507"
1645         fail ost1
1646         fail $SINGLEMDS
1647         do_facet ost1 "lctl set_param fail_loc=0x0"
1648         sleep 20
1649         rmdir $DIR/$tdir
1650 }
1651 run_test 59 "test log_commit_thread vs filter_destroy race"
1652
1653 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1654 # bug 12086: should no oops and No ctxt error for this test
1655 test_60() {
1656         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1657         createmany -o $DIR/$tdir/$tfile-%d 200 ||
1658                 error "createmany create files failed"
1659         replay_barrier $SINGLEMDS
1660         unlinkmany $DIR/$tdir/$tfile-%d 0 100
1661         fail $SINGLEMDS
1662         unlinkmany $DIR/$tdir/$tfile-%d 100 100
1663         local no_ctxt=$(dmesg | grep "No ctxt")
1664         [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1665 }
1666 run_test 60 "test llog post recovery init vs llog unlink"
1667
1668 #test race  llog recovery thread vs llog cleanup
1669 test_61a() {    # was test_61
1670         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1671
1672         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1673         createmany -o $DIR/$tdir/$tfile-%d 800 ||
1674                 error "createmany create files failed"
1675         replay_barrier ost1
1676         unlinkmany $DIR/$tdir/$tfile-%d 800
1677         #   OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1678         set_nodes_failloc "$(osts_nodes)" 0x80000221
1679         facet_failover ost1
1680         sleep 10
1681         fail ost1
1682         sleep 30
1683         set_nodes_failloc "$(osts_nodes)" 0x0
1684
1685         $CHECKSTAT -t file $DIR/$tdir/$tfile-* &&
1686                 error "$CHECKSTAT $DIR/$tdir/$tfile attribute check should fail"
1687         rmdir $DIR/$tdir
1688 }
1689 run_test 61a "test race llog recovery vs llog cleanup"
1690
1691 #test race  mds llog sync vs llog cleanup
1692 test_61b() {
1693         #   OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1694         do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1695         facet_failover $SINGLEMDS
1696         sleep 10
1697         fail $SINGLEMDS
1698         do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 ||
1699                 error "dd failed"
1700 }
1701 run_test 61b "test race mds llog sync vs llog cleanup"
1702
1703 #test race  cancel cookie cb vs llog cleanup
1704 test_61c() {
1705         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1706
1707         #   OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1708         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
1709         set_nodes_failloc "$(osts_nodes)" 0x80000222
1710         rm $DIR/$tfile
1711         sleep 10
1712         fail ost1
1713         set_nodes_failloc "$(osts_nodes)" 0x0
1714 }
1715 run_test 61c "test race mds llog sync vs llog cleanup"
1716
1717 test_61d() { # bug 16002 # bug 17466 # bug 22137
1718 #   OBD_FAIL_OBD_LLOG_SETUP        0x605
1719     stop mgs
1720     do_facet mgs "lctl set_param fail_loc=0x80000605"
1721     start mgs $(mgsdevname) $MGS_MOUNT_OPTS &&
1722         error "mgs start should have failed"
1723     do_facet mgs "lctl set_param fail_loc=0"
1724     start mgs $(mgsdevname) $MGS_MOUNT_OPTS || error "cannot restart mgs"
1725 }
1726 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1727
1728 test_62() { # Bug 15756 - don't mis-drop resent replay
1729         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
1730         replay_barrier $SINGLEMDS
1731         createmany -o $DIR/$tdir/$tfile- 25 ||
1732                 error "createmany create files failed"
1733         #define OBD_FAIL_TGT_REPLAY_DROP         0x707
1734         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1735         fail $SINGLEMDS
1736         do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1737         unlinkmany $DIR/$tdir/$tfile- 25 ||
1738                 error "unlinkmany $DIR/$tdir/$tfile failed"
1739         return 0
1740 }
1741 run_test 62 "don't mis-drop resent replay"
1742
1743 #Adaptive Timeouts (bug 3055)
1744 AT_MAX_SET=0
1745
1746 at_cleanup () {
1747     local var
1748     local facet
1749     local at_new
1750
1751     echo "Cleaning up AT ..."
1752     if [ -n "$ATOLDBASE" ]; then
1753         local at_history=$($LCTL get_param -n at_history)
1754         do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1755         do_facet ost1 "lctl set_param at_history=$at_history" || true
1756     fi
1757
1758         if [ $AT_MAX_SET -ne 0 ]; then
1759                 for facet in mds client ost; do
1760                         var=AT_MAX_SAVE_${facet}
1761                         echo restore AT on $facet to saved value ${!var}
1762                         at_max_set ${!var} $facet
1763                         at_new=$(at_max_get $facet)
1764                         echo Restored AT value on $facet $at_new
1765                         [ $at_new -eq ${!var} ] ||
1766                         error "AT value not restored SAVED ${!var} NEW $at_new"
1767                 done
1768         fi
1769 }
1770
1771 at_start()
1772 {
1773     local at_max_new=600
1774
1775     # Save at_max original values
1776     local facet
1777     if [ $AT_MAX_SET -eq 0 ]; then
1778         # Suppose that all osts have the same at_max
1779         for facet in mds client ost; do
1780             eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1781         done
1782     fi
1783     local at_max
1784     for facet in mds client ost; do
1785         at_max=$(at_max_get $facet)
1786         if [ $at_max -ne $at_max_new ]; then
1787             echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1788             at_max_set $at_max_new $facet
1789             AT_MAX_SET=1
1790         fi
1791     done
1792
1793     if [ -z "$ATOLDBASE" ]; then
1794         ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1795         # speed up the timebase so we can check decreasing AT
1796         do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1797         do_facet ost1 "lctl set_param at_history=8" || true
1798
1799         # sleep for a while to cool down, should be > 8s and also allow
1800         # at least one ping to be sent. simply use TIMEOUT to be safe.
1801         sleep $TIMEOUT
1802     fi
1803 }
1804
1805 test_65a() #bug 3055
1806 {
1807     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1808
1809     at_start || return 0
1810     $LCTL dk > /dev/null
1811     debugsave
1812     $LCTL set_param debug="other"
1813     # Slow down a request to the current service time, this is critical
1814     # because previous tests may have caused this value to increase.
1815     REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1816                awk '/portal 12/ {print $5}'`
1817     REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1818
1819     do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1820 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1821     do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1822     createmany -o $DIR/$tfile 10 > /dev/null
1823     unlinkmany $DIR/$tfile 10 > /dev/null
1824     # check for log message
1825     $LCTL dk | grep -i "Early reply #" || error "No early reply"
1826     debugrestore
1827     # client should show REQ_DELAY estimates
1828     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1829     sleep 9
1830     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1831 }
1832 run_test 65a "AT: verify early replies"
1833
1834 test_65b() #bug 3055
1835 {
1836         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1837
1838         at_start || return 0
1839         # turn on D_ADAPTTO
1840         debugsave
1841         $LCTL set_param debug="other trace"
1842         $LCTL dk > /dev/null
1843         # Slow down a request to the current service time, this is critical
1844         # because previous tests may have caused this value to increase.
1845         $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1846                 error "$LFS setstripe failed for $DIR/$tfile"
1847
1848         multiop $DIR/$tfile Ow1yc
1849         REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1850                    awk '/portal 6/ {print $5}'`
1851         REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1852
1853         do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1854         #define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
1855         do_facet ost1 $LCTL set_param fail_loc=0x224
1856
1857         rm -f $DIR/$tfile
1858         $LFS setstripe --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
1859                 error "$LFS setstripe failed"
1860         # force some real bulk transfer
1861         multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1862
1863         do_facet ost1 $LCTL set_param fail_loc=0
1864         # check for log message
1865         $LCTL dk | grep -i "Early reply #" || error "No early reply"
1866         debugrestore
1867         # client should show REQ_DELAY estimates
1868         lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1869 }
1870 run_test 65b "AT: verify early replies on packed reply / bulk"
1871
1872 test_66a() #bug 3055
1873 {
1874     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1875
1876     at_start || return 0
1877     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1878     # adjust 5s at a time so no early reply is sent (within deadline)
1879     do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1880 #define OBD_FAIL_PTLRPC_PAUSE_REQ        0x50a
1881     do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1882     createmany -o $DIR/$tfile 20 > /dev/null
1883     unlinkmany $DIR/$tfile 20 > /dev/null
1884     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1885     do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1886     do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1887     createmany -o $DIR/$tfile 20 > /dev/null
1888     unlinkmany $DIR/$tfile 20 > /dev/null
1889     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1890     do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1891     sleep 9
1892     createmany -o $DIR/$tfile 20 > /dev/null
1893     unlinkmany $DIR/$tfile 20 > /dev/null
1894     lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1895     CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1896     WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1897     echo "Current MDT timeout $CUR, worst $WORST"
1898     [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1899 }
1900 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1901
1902 test_66b() #bug 3055
1903 {
1904         remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1905
1906         at_start || return 0
1907         ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1908                 awk '/network/ {print $4}')
1909         $LCTL set_param fail_val=$(($ORIG + 5))
1910         #define OBD_FAIL_PTLRPC_PAUSE_REP      0x50c
1911         $LCTL set_param fail_loc=0x50c
1912         touch $DIR/$tfile > /dev/null 2>&1
1913         $LCTL set_param fail_loc=0
1914         CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1915                 awk '/network/ {print $4}')
1916         WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1917                 awk '/network/ {print $6}')
1918         echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1919         [ $WORST -gt $ORIG ] ||
1920                 error "Worst $WORST should be worse than orig $ORIG"
1921 }
1922 run_test 66b "AT: verify net latency adjusts"
1923
1924 test_67a() #bug 3055
1925 {
1926     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1927
1928     at_start || return 0
1929     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1930     # sleeping threads may drive values above this
1931     do_facet ost1 "$LCTL set_param fail_val=400"
1932 #define OBD_FAIL_PTLRPC_PAUSE_REQ    0x50a
1933     do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1934     createmany -o $DIR/$tfile 20 > /dev/null
1935     unlinkmany $DIR/$tfile 20 > /dev/null
1936     do_facet ost1 "$LCTL set_param fail_loc=0"
1937     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1938     ATTEMPTS=$(($CONN2 - $CONN1))
1939     echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1940         [ $ATTEMPTS -gt 0 ] &&
1941                 error_ignore bz13721 "AT should have prevented reconnect"
1942         return 0
1943 }
1944 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1945
1946 test_67b() #bug 3055
1947 {
1948     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1949
1950     at_start || return 0
1951     CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1952
1953         # exhaust precreations on ost1
1954         local OST=$(ostname_from_index 0)
1955         local mdtosc=$(get_mdtosc_proc_path mds $OST)
1956         local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1957                         osp.$mdtosc.prealloc_last_id)
1958         local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1959                         osp.$mdtosc.prealloc_next_id)
1960
1961         mkdir -p $DIR/$tdir/${OST} || error "mkdir $DIR/$tdir/${OST} failed"
1962         $LFS setstripe -i 0 -c 1 $DIR/$tdir/${OST} ||
1963                 error "$LFS setstripe failed"
1964         echo "Creating to objid $last_id on ost $OST..."
1965 #define OBD_FAIL_OST_PAUSE_CREATE        0x223
1966     do_facet ost1 "$LCTL set_param fail_val=20000"
1967     do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1968     createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1969
1970     client_reconnect
1971     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1972     log "phase 2"
1973     CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1974     ATTEMPTS=$(($CONN2 - $CONN1))
1975     echo "$ATTEMPTS osc reconnect attempts on instant slow"
1976     # do it again; should not timeout
1977     do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1978     cp /etc/profile $DIR/$tfile || error "cp failed"
1979     do_facet ost1 "$LCTL set_param fail_loc=0"
1980     client_reconnect
1981     do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1982     CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1983     ATTEMPTS=$(($CONN3 - $CONN2))
1984     echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1985     [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1986     return 0
1987 }
1988 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1989
1990 test_68 () #bug 13813
1991 {
1992     remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1993
1994     at_start || return 0
1995     local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1996     [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1997     local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1998     [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1999     local ENQ_MIN=$(cat $ldlm_enqueue_min)
2000     local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
2001         echo $TIMEOUT >> $ldlm_enqueue_min
2002         do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
2003
2004         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2005         $LFS setstripe --stripe-index=0 -c 1 $DIR/$tdir ||
2006                 error "$LFS setstripe failed for $DIR/$tdir"
2007         #define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
2008         $LCTL set_param fail_val=$(($TIMEOUT - 1))
2009         $LCTL set_param fail_loc=0x80000312
2010         cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
2011         $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
2012         $LCTL set_param fail_loc=0x80000312
2013         cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
2014         $LCTL set_param fail_loc=0
2015
2016         echo $ENQ_MIN >> $ldlm_enqueue_min
2017         do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
2018         rm -rf $DIR/$tdir
2019         return 0
2020 }
2021 run_test 68 "AT: verify slowing locks"
2022
2023 at_cleanup
2024 # end of AT tests includes above lines
2025
2026 # start multi-client tests
2027 test_70a () {
2028         [ -z "$CLIENTS" ] &&
2029                 { skip "Need two or more clients." && return; }
2030         [ $CLIENTCOUNT -lt 2 ] &&
2031                 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
2032
2033         echo "mount clients $CLIENTS ..."
2034         zconf_mount_clients $CLIENTS $MOUNT
2035
2036         local clients=${CLIENTS//,/ }
2037         echo "Write/read files on $DIR ; clients $CLIENTS ... "
2038         for CLIENT in $clients; do
2039                 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
2040                         of=$DIR/${tfile}_${CLIENT} 2>/dev/null ||
2041                                 error "dd failed on $CLIENT"
2042         done
2043
2044         local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
2045         for C in ${CLIENTS//,/ }; do
2046                 do_node $prev_client dd if=$DIR/${tfile}_${C} \
2047                         of=/dev/null 2>/dev/null ||
2048                         error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
2049                 prev_client=$C
2050         done
2051
2052         ls $DIR
2053 }
2054 run_test 70a "check multi client t-f"
2055
2056 check_for_process () {
2057         local clients=$1
2058         shift
2059         local prog=$@
2060
2061         killall_process $clients "$prog" -0
2062 }
2063
2064 test_70b () {
2065         local clients=${CLIENTS:-$HOSTNAME}
2066
2067         zconf_mount_clients $clients $MOUNT
2068
2069         local duration=300
2070         [ "$SLOW" = "no" ] && duration=120
2071         # set duration to 900 because it takes some time to boot node
2072         [ "$FAILURE_MODE" = HARD ] && duration=900
2073
2074         local elapsed
2075         local start_ts=$(date +%s)
2076         local cmd="rundbench 1 -t $duration"
2077         local pid=""
2078         if [ $MDSCOUNT -ge 2 ]; then
2079                 test_mkdir -p -c$MDSCOUNT $DIR/$tdir
2080                 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
2081         fi
2082         do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
2083                 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
2084                 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
2085                 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
2086         pid=$!
2087
2088         #LU-1897 wait for all dbench copies to start
2089         while ! check_for_process $clients dbench; do
2090                 elapsed=$(($(date +%s) - start_ts))
2091                 if [ $elapsed -gt $duration ]; then
2092                         killall_process $clients dbench
2093                         error "dbench failed to start on $clients!"
2094                 fi
2095                 sleep 1
2096         done
2097
2098         log "Started rundbench load pid=$pid ..."
2099
2100         elapsed=$(($(date +%s) - start_ts))
2101         local num_failovers=0
2102         local fail_index=1
2103         while [ $elapsed -lt $duration ]; do
2104                 if ! check_for_process $clients dbench; then
2105                         error_noexit "dbench stopped on some of $clients!"
2106                         killall_process $clients dbench
2107                         break
2108                 fi
2109                 sleep 1
2110                 replay_barrier mds$fail_index
2111                 sleep 1 # give clients a time to do operations
2112                 # Increment the number of failovers
2113                 num_failovers=$((num_failovers+1))
2114                 log "$TESTNAME fail mds$fail_index $num_failovers times"
2115                 fail mds$fail_index
2116                 elapsed=$(($(date +%s) - start_ts))
2117                 if [ $fail_index -ge $MDSCOUNT ]; then
2118                         fail_index=1
2119                 else
2120                         fail_index=$((fail_index+1))
2121                 fi
2122         done
2123
2124         wait $pid || error "rundbench load on $clients failed!"
2125 }
2126 run_test 70b "dbench ${MDSCOUNT}mdts recovery; $CLIENTCOUNT clients"
2127 # end multi-client tests
2128
2129 random_fail_mdt() {
2130         local max_index=$1
2131         local duration=$2
2132         local monitor_pid=$3
2133         local elapsed
2134         local start_ts=$(date +%s)
2135         local num_failovers=0
2136         local fail_index
2137
2138         elapsed=$(($(date +%s) - start_ts))
2139         while [ $elapsed -lt $duration ]; do
2140                 fail_index=$((RANDOM%max_index+1))
2141                 kill -0 $monitor_pid ||
2142                         error "$monitor_pid stopped"
2143                 sleep 120
2144                 replay_barrier mds$fail_index
2145                 sleep 10
2146                 # Increment the number of failovers
2147                 num_failovers=$((num_failovers+1))
2148                 log "$TESTNAME fail mds$fail_index $num_failovers times"
2149                 fail mds$fail_index
2150                 elapsed=$(($(date +%s) - start_ts))
2151         done
2152 }
2153
2154 cleanup_70c() {
2155         trap 0
2156         rm -f $DIR/replay-single.70c.lck
2157         rm -rf /$DIR/$tdir
2158 }
2159
2160 test_70c () {
2161         local clients=${CLIENTS:-$HOSTNAME}
2162         local rc=0
2163
2164         zconf_mount_clients $clients $MOUNT
2165
2166         local duration=300
2167         [ "$SLOW" = "no" ] && duration=180
2168         # set duration to 900 because it takes some time to boot node
2169         [ "$FAILURE_MODE" = HARD ] && duration=600
2170
2171         local elapsed
2172         local start_ts=$(date +%s)
2173
2174         trap cleanup_70c EXIT
2175         (
2176                 while [ ! -e $DIR/replay-single.70c.lck ]; do
2177                         test_mkdir -p -c$MDSCOUNT $DIR/$tdir || break
2178                         if [ $MDSCOUNT -ge 2 ]; then
2179                                 $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir ||
2180                                 error "set default dirstripe failed"
2181                         fi
2182                         cd $DIR/$tdir || break
2183                         tar cf - /etc | tar xf - || error "tar failed in loop"
2184                 done
2185         )&
2186         tar_70c_pid=$!
2187         echo "Started tar $tar_70c_pid"
2188
2189         random_fail_mdt $MDSCOUNT $duration $tar_70c_pid
2190         kill -0 $tar_70c_pid || error "tar $tar_70c_pid stopped"
2191
2192         touch $DIR/replay-single.70c.lck
2193         wait $tar_70c_pid || error "$?: tar failed"
2194
2195         cleanup_70c
2196         true
2197 }
2198 run_test 70c "tar ${MDSCOUNT}mdts recovery"
2199
2200 cleanup_70d() {
2201         trap 0
2202         kill -9 $mkdir_70d_pid
2203 }
2204
2205 test_70d () {
2206         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2207         local clients=${CLIENTS:-$HOSTNAME}
2208         local rc=0
2209
2210         zconf_mount_clients $clients $MOUNT
2211
2212         local duration=300
2213         [ "$SLOW" = "no" ] && duration=180
2214         # set duration to 900 because it takes some time to boot node
2215         [ "$FAILURE_MODE" = HARD ] && duration=900
2216
2217         mkdir -p $DIR/$tdir
2218
2219         local elapsed
2220         local start_ts=$(date +%s)
2221
2222         trap cleanup_70d EXIT
2223         (
2224                 while true; do
2225                         $LFS mkdir -i0 -c2 $DIR/$tdir/test || {
2226                                 echo "mkdir fails"
2227                                 break
2228                         }
2229                         $LFS mkdir -i1 -c2 $DIR/$tdir/test1 || {
2230                                 echo "mkdir fails"
2231                                 break
2232                         }
2233
2234                         touch $DIR/$tdir/test/a || {
2235                                 echo "touch fails"
2236                                 break;
2237                         }
2238                         mkdir $DIR/$tdir/test/b || {
2239                                 echo "mkdir fails"
2240                                 break;
2241                         }
2242                         rm -rf $DIR/$tdir/test || {
2243                                 echo "rmdir fails"
2244                                 ls -lR $DIR/$tdir
2245                                 break
2246                         }
2247
2248                         touch $DIR/$tdir/test1/a || {
2249                                 echo "touch fails"
2250                                 break;
2251                         }
2252                         mkdir $DIR/$tdir/test1/b || {
2253                                 echo "mkdir fails"
2254                                 break;
2255                         }
2256
2257                         rm -rf $DIR/$tdir/test1 || {
2258                                 echo "rmdir fails"
2259                                 ls -lR $DIR/$tdir/test1
2260                                 break
2261                         }
2262                 done
2263         )&
2264         mkdir_70d_pid=$!
2265         echo "Started  $mkdir_70d_pid"
2266
2267         random_fail_mdt $MDSCOUNT $duration $mkdir_70d_pid
2268         kill -0 $mkdir_70d_pid || error "mkdir/rmdir $mkdir_70d_pid stopped"
2269
2270         cleanup_70d
2271         true
2272 }
2273 run_test 70d "mkdir/rmdir striped dir ${MDSCOUNT}mdts recovery"
2274
2275 test_70e () {
2276         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2277         local clients=${CLIENTS:-$HOSTNAME}
2278         local rc=0
2279
2280         lctl set_param debug=+ha
2281         zconf_mount_clients $clients $MOUNT
2282
2283         local duration=300
2284         [ "$SLOW" = "no" ] && duration=180
2285         # set duration to 900 because it takes some time to boot node
2286         [ "$FAILURE_MODE" = HARD ] && duration=900
2287
2288         mkdir -p $DIR/$tdir
2289         $LFS mkdir -i0 $DIR/$tdir/test_0
2290         $LFS mkdir -i0 $DIR/$tdir/test_1
2291         touch $DIR/$tdir/test_0/a
2292         touch $DIR/$tdir/test_1/b
2293         (
2294         while true; do
2295                 mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > /dev/null || {
2296                         echo "a->b fails"
2297                         break;
2298                 }
2299
2300                 checkstat $DIR/$tdir/test_0/a && {
2301                         echo "a still exists"
2302                         break
2303                 }
2304
2305                 checkstat $DIR/$tdir/test_1/b || {
2306                         echo "b still  exists"
2307                         break
2308                 }
2309
2310                 touch $DIR/$tdir/test_0/a || {
2311                         echo "touch a fails"
2312                         break
2313                 }
2314
2315                 mrename $DIR/$tdir/test_1/b $DIR/$tdir/test_0/a > /dev/null || {
2316                         echo "a->a fails"
2317                         break;
2318                 }
2319         done
2320         )&
2321         rename_70e_pid=$!
2322         stack_trap "kill -9 $rename_70e_pid" EXIT
2323         echo "Started PID=$rename_70e_pid"
2324
2325         random_fail_mdt 2 $duration $rename_70e_pid
2326         kill -0 $rename_70e_pid || error "rename $rename_70e_pid stopped"
2327 }
2328 run_test 70e "rename cross-MDT with random fails"
2329
2330 test_70f_write_and_read(){
2331         local srcfile=$1
2332         local stopflag=$2
2333         local client
2334
2335         echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
2336         for client in ${CLIENTS//,/ }; do
2337                 [ -f $stopflag ] || return
2338
2339                 local tgtfile=$DIR/$tdir/$tfile.$client
2340                 do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
2341                         of=$tgtfile 2>/dev/null ||
2342                         error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
2343                               "of=$tgtfile failed on $client, rc=$?"
2344         done
2345
2346         local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
2347         local index=0
2348
2349         for client in ${CLIENTS//,/ }; do
2350                 [ -f $stopflag ] || return
2351
2352                 # flush client cache in case test is running on only one client
2353                 # do_node $client cancel_lru_locks osc
2354                 do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
2355
2356                 tgtfile=$DIR/$tdir/$tfile.$client
2357                 local md5=$(do_node $prev_client "md5sum $tgtfile")
2358                 [ ${checksum[$index]// */} = ${md5// */} ] ||
2359                         error "$tgtfile: checksum doesn't match on $prev_client"
2360                 index=$((index + 1))
2361                 prev_client=$client
2362         done
2363 }
2364
2365 test_70f_loop(){
2366         local srcfile=$1
2367         local stopflag=$2
2368         DD_OPTS=
2369
2370         mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
2371         $LFS setstripe -c -1 $DIR/$tdir ||
2372                 error "cannot $LFS setstripe $DIR/$tdir"
2373
2374         touch $stopflag
2375         while [ -f $stopflag ]; do
2376                 test_70f_write_and_read $srcfile $stopflag
2377                 # use direct IO and buffer cache in turns if loop
2378                 [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
2379         done
2380 }
2381
2382 test_70f_cleanup() {
2383         trap 0
2384         rm -f $TMP/$tfile.stop
2385         do_nodes $CLIENTS rm -f $TMP/$tfile
2386         rm -f $DIR/$tdir/$tfile.*
2387 }
2388
2389 test_70f() {
2390 #       [ x$ost1failover_HOST = x$ost_HOST ] &&
2391 #               { skip "Failover host not defined" && return; }
2392 #       [ -z "$CLIENTS" ] &&
2393 #               { skip "CLIENTS are not specified." && return; }
2394 #       [ $CLIENTCOUNT -lt 2 ] &&
2395 #               { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
2396
2397         [[ "$OST1_VERSION" -lt $(version_code 2.9.53) ]] &&
2398                 skip "Need server version at least 2.9.53"
2399
2400         echo "mount clients $CLIENTS ..."
2401         zconf_mount_clients $CLIENTS $MOUNT
2402
2403         local srcfile=$TMP/$tfile
2404         local client
2405         local index=0
2406
2407         trap test_70f_cleanup EXIT
2408         # create a different source file local to each client node so we can
2409         # detect if the file wasn't written out properly after failover
2410         do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
2411                 2>/dev/null || error "can't create $srcfile on $CLIENTS"
2412         for client in ${CLIENTS//,/ }; do
2413                 checksum[$index]=$(do_node $client "md5sum $srcfile")
2414                 index=$((index + 1))
2415         done
2416
2417         local duration=120
2418         [ "$SLOW" = "no" ] && duration=60
2419         # set duration to 900 because it takes some time to boot node
2420         [ "$FAILURE_MODE" = HARD ] && duration=900
2421
2422         local stopflag=$TMP/$tfile.stop
2423         test_70f_loop $srcfile $stopflag &
2424         local pid=$!
2425
2426         local elapsed=0
2427         local num_failovers=0
2428         local start_ts=$SECONDS
2429         while [ $elapsed -lt $duration ]; do
2430                 sleep 3
2431                 replay_barrier ost1
2432                 sleep 1
2433                 num_failovers=$((num_failovers + 1))
2434                 log "$TESTNAME failing OST $num_failovers times"
2435                 fail ost1
2436                 sleep 2
2437                 elapsed=$((SECONDS - start_ts))
2438         done
2439
2440         rm -f $stopflag
2441         wait $pid
2442         test_70f_cleanup
2443 }
2444 run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
2445
2446 cleanup_71a() {
2447         trap 0
2448         kill -9 $mkdir_71a_pid
2449 }
2450
2451 random_double_fail_mdt() {
2452         local max_index=$1
2453         local duration=$2
2454         local monitor_pid=$3
2455         local elapsed
2456         local start_ts=$(date +%s)
2457         local num_failovers=0
2458         local fail_index
2459         local second_index
2460
2461         elapsed=$(($(date +%s) - start_ts))
2462         while [ $elapsed -lt $duration ]; do
2463                 fail_index=$((RANDOM%max_index + 1))
2464                 if [ $fail_index -eq $max_index ]; then
2465                         second_index=1
2466                 else
2467                         second_index=$((fail_index + 1))
2468                 fi
2469                 kill -0 $monitor_pid ||
2470                         error "$monitor_pid stopped"
2471                 sleep 120
2472                 replay_barrier mds$fail_index
2473                 replay_barrier mds$second_index
2474                 sleep 10
2475                 # Increment the number of failovers
2476                 num_failovers=$((num_failovers+1))
2477                 log "fail mds$fail_index mds$second_index $num_failovers times"
2478                 fail mds${fail_index},mds${second_index}
2479                 elapsed=$(($(date +%s) - start_ts))
2480         done
2481 }
2482
2483 test_71a () {
2484         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2485         local clients=${CLIENTS:-$HOSTNAME}
2486         local rc=0
2487
2488         zconf_mount_clients $clients $MOUNT
2489
2490         local duration=300
2491         [ "$SLOW" = "no" ] && duration=180
2492         # set duration to 900 because it takes some time to boot node
2493         [ "$FAILURE_MODE" = HARD ] && duration=900
2494
2495         mkdir -p $DIR/$tdir
2496
2497         local elapsed
2498         local start_ts=$(date +%s)
2499
2500         trap cleanup_71a EXIT
2501         (
2502                 while true; do
2503                         $LFS mkdir -i0 -c2 $DIR/$tdir/test
2504                         rmdir $DIR/$tdir/test
2505                 done
2506         )&
2507         mkdir_71a_pid=$!
2508         echo "Started  $mkdir_71a_pid"
2509
2510         random_double_fail_mdt 2 $duration $mkdir_71a_pid
2511         kill -0 $mkdir_71a_pid || error "mkdir/rmdir $mkdir_71a_pid stopped"
2512
2513         cleanup_71a
2514         true
2515 }
2516 run_test 71a "mkdir/rmdir striped dir with 2 mdts recovery"
2517
2518 test_73a() {
2519         multiop_bg_pause $DIR/$tfile O_tSc ||
2520                 error "multiop_bg_pause $DIR/$tfile failed"
2521         pid=$!
2522         rm -f $DIR/$tfile
2523
2524         replay_barrier $SINGLEMDS
2525         #define OBD_FAIL_LDLM_ENQUEUE_NET                       0x302
2526         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
2527         fail $SINGLEMDS
2528         kill -USR1 $pid
2529         wait $pid || error "multiop pid failed"
2530         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2531         return 0
2532 }
2533 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay, close"
2534
2535 test_73b() {
2536         multiop_bg_pause $DIR/$tfile O_tSc ||
2537                 error "multiop_bg_pause $DIR/$tfile failed"
2538         pid=$!
2539         rm -f $DIR/$tfile
2540
2541         replay_barrier $SINGLEMDS
2542         #define OBD_FAIL_MDS_LDLM_REPLY_NET       0x157
2543         do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000157"
2544         fail $SINGLEMDS
2545         kill -USR1 $pid
2546         wait $pid || error "multiop pid failed"
2547         [ -e $DIR/$tfile ] && error "file $DIR/$tfile should not exist"
2548         return 0
2549 }
2550 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
2551
2552 # bug 18554
2553 test_74() {
2554         local clients=${CLIENTS:-$HOSTNAME}
2555
2556         zconf_umount_clients $clients $MOUNT
2557         stop ost1
2558         facet_failover $SINGLEMDS
2559         zconf_mount_clients $clients $MOUNT
2560         mount_facet ost1
2561         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
2562         rm $DIR/$tfile || error "rm $DIR/$tfile failed"
2563         clients_up || error "client evicted: $?"
2564         return 0
2565 }
2566 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2567
2568 remote_dir_check_80() {
2569         local mdtidx=1
2570         local diridx
2571         local fileidx
2572
2573         diridx=$($LFS getstripe -m $remote_dir) ||
2574                 error "$LFS getstripe -m $remote_dir failed"
2575         [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2576
2577         createmany -o $remote_dir/f-%d 20 || error "creation failed"
2578         fileidx=$($LFS getstripe -m $remote_dir/f-1) ||
2579                 error "$LFS getstripe -m $remote_dir/f-1 failed"
2580         [ $fileidx -eq $mdtidx ] || error "$fileidx != $mdtidx"
2581
2582         return 0
2583 }
2584
2585 test_80a() {
2586         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2587         ([ $FAILURE_MODE == "HARD" ] &&
2588                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2589                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2590                 return 0
2591
2592         local MDTIDX=1
2593         local remote_dir=$DIR/$tdir/remote_dir
2594
2595         mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2596         #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
2597         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2598         $LFS mkdir -i $MDTIDX $remote_dir &
2599         local CLIENT_PID=$!
2600
2601         replay_barrier mds1
2602         fail mds${MDTIDX}
2603
2604         wait $CLIENT_PID || error "remote creation failed"
2605
2606         remote_dir_check_80 || error "remote dir check failed"
2607         rm -rf $DIR/$tdir || error "rmdir failed"
2608
2609         return 0
2610 }
2611 run_test 80a "DNE: create remote dir, drop update rep from MDT0, fail MDT0"
2612
2613 test_80b() {
2614         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2615         ([ $FAILURE_MODE == "HARD" ] &&
2616                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2617                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2618                 return 0
2619
2620         local MDTIDX=1
2621         local remote_dir=$DIR/$tdir/remote_dir
2622
2623         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2624         #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
2625         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2626         $LFS mkdir -i $MDTIDX $remote_dir &
2627         local CLIENT_PID=$!
2628
2629         replay_barrier mds1
2630         replay_barrier mds2
2631         fail mds$((MDTIDX + 1))
2632
2633         wait $CLIENT_PID || error "remote creation failed"
2634
2635         remote_dir_check_80 || error "remote dir check failed"
2636         rm -rf $DIR/$tdir || error "rmdir failed"
2637
2638         return 0
2639 }
2640 run_test 80b "DNE: create remote dir, drop update rep from MDT0, fail MDT1"
2641
2642 test_80c() {
2643         [[ "$mds1_FSTYPE" = zfs ]] &&
2644                 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2645                 skip "requires LU-10143 fix on MDS"
2646         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2647         ([ $FAILURE_MODE == "HARD" ] &&
2648                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2649                 skip "MDTs needs to be on diff hosts for HARD fail mode"
2650
2651         local MDTIDX=1
2652         local remote_dir=$DIR/$tdir/remote_dir
2653
2654         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2655         #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
2656         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2657         $LFS mkdir -i $MDTIDX $remote_dir &
2658         local CLIENT_PID=$!
2659
2660         replay_barrier mds1
2661         replay_barrier mds2
2662         fail mds${MDTIDX}
2663         fail mds$((MDTIDX + 1))
2664
2665         wait $CLIENT_PID || error "remote creation failed"
2666
2667         remote_dir_check_80 || error "remote dir check failed"
2668         rm -rf $DIR/$tdir || error "rmdir failed"
2669
2670         return 0
2671 }
2672 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2673
2674 test_80d() {
2675         [[ "$mds1_FSTYPE" = zfs ]] &&
2676                 [[ $MDS1_VERSION -lt $(version_code 2.12.51) ]] &&
2677                 skip "requires LU-10143 fix on MDS"
2678         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2679         local MDTIDX=1
2680         local remote_dir=$DIR/$tdir/remote_dir
2681
2682         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2683         #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
2684         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2685         $LFS mkdir -i $MDTIDX $remote_dir &
2686         local CLIENT_PID=$!
2687
2688         # sleep 3 seconds to make sure MDTs are failed after
2689         # lfs mkdir -i has finished on all of MDTs.
2690         sleep 3
2691
2692         replay_barrier mds1
2693         replay_barrier mds2
2694         fail mds${MDTIDX},mds$((MDTIDX + 1))
2695
2696         wait $CLIENT_PID || error "remote creation failed"
2697
2698         remote_dir_check_80 || error "remote dir check failed"
2699         rm -rf $DIR/$tdir || error "rmdir failed"
2700
2701         return 0
2702 }
2703 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2704
2705 test_80e() {
2706         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2707         ([ $FAILURE_MODE == "HARD" ] &&
2708                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2709                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2710                 return 0
2711
2712         local MDTIDX=1
2713         local remote_dir=$DIR/$tdir/remote_dir
2714
2715         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2716         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2717         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2718         $LFS mkdir -i $MDTIDX $remote_dir &
2719         local CLIENT_PID=$!
2720
2721         # sleep 3 seconds to make sure MDTs are failed after
2722         # lfs mkdir -i has finished on all of MDTs.
2723         sleep 3
2724
2725         replay_barrier mds1
2726         fail mds${MDTIDX}
2727
2728         wait $CLIENT_PID || error "remote creation failed"
2729
2730         remote_dir_check_80 || error "remote dir check failed"
2731         rm -rf $DIR/$tdir || error "rmdir failed"
2732
2733         return 0
2734 }
2735 run_test 80e "DNE: create remote dir, drop MDT1 rep, fail MDT0"
2736
2737 test_80f() {
2738         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2739         ([ $FAILURE_MODE == "HARD" ] &&
2740                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2741                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2742                 return 0
2743         local MDTIDX=1
2744         local remote_dir=$DIR/$tdir/remote_dir
2745
2746         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2747         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2748         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2749         $LFS mkdir -i $MDTIDX $remote_dir &
2750         local CLIENT_PID=$!
2751
2752         replay_barrier mds2
2753         fail mds$((MDTIDX + 1))
2754
2755         wait $CLIENT_PID || error "remote creation failed"
2756
2757         remote_dir_check_80 || error "remote dir check failed"
2758         rm -rf $DIR/$tdir || error "rmdir failed"
2759
2760         return 0
2761 }
2762 run_test 80f "DNE: create remote dir, drop MDT1 rep, fail MDT1"
2763
2764 test_80g() {
2765         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2766         ([ $FAILURE_MODE == "HARD" ] &&
2767                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2768                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2769                 return 0
2770
2771         local MDTIDX=1
2772         local remote_dir=$DIR/$tdir/remote_dir
2773
2774         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2775         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2776         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2777         $LFS mkdir -i $MDTIDX $remote_dir &
2778         local CLIENT_PID=$!
2779
2780         # sleep 3 seconds to make sure MDTs are failed after
2781         # lfs mkdir -i has finished on all of MDTs.
2782         sleep 3
2783
2784         replay_barrier mds1
2785         replay_barrier mds2
2786         fail mds${MDTIDX}
2787         fail mds$((MDTIDX + 1))
2788
2789         wait $CLIENT_PID || error "remote creation failed"
2790
2791         remote_dir_check_80 || error "remote dir check failed"
2792         rm -rf $DIR/$tdir || error "rmdir failed"
2793
2794         return 0
2795 }
2796 run_test 80g "DNE: create remote dir, drop MDT1 rep, fail MDT0, then MDT1"
2797
2798 test_80h() {
2799         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2800         local MDTIDX=1
2801         local remote_dir=$DIR/$tdir/remote_dir
2802
2803         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2804         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2805         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2806         $LFS mkdir -i $MDTIDX $remote_dir &
2807         local CLIENT_PID=$!
2808
2809         # sleep 3 seconds to make sure MDTs are failed after
2810         # lfs mkdir -i has finished on all of MDTs.
2811         sleep 3
2812
2813         replay_barrier mds1
2814         replay_barrier mds2
2815         fail mds${MDTIDX},mds$((MDTIDX + 1))
2816
2817         wait $CLIENT_PID || error "remote dir creation failed"
2818
2819         remote_dir_check_80 || error "remote dir check failed"
2820         rm -rf $DIR/$tdir || error "rmdir failed"
2821
2822         return 0
2823 }
2824 run_test 80h "DNE: create remote dir, drop MDT1 rep, fail 2 MDTs"
2825
2826 test_81a() {
2827         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2828         ([ $FAILURE_MODE == "HARD" ] &&
2829                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2830                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2831                 return 0
2832
2833         local MDTIDX=1
2834         local remote_dir=$DIR/$tdir/remote_dir
2835
2836         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2837         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2838
2839         touch $remote_dir || error "touch $remote_dir failed"
2840         # OBD_FAIL_OUT_UPDATE_NET_REP       0x1701
2841         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2842         rmdir $remote_dir &
2843         local CLIENT_PID=$!
2844
2845         replay_barrier mds2
2846         fail mds$((MDTIDX + 1))
2847
2848         wait $CLIENT_PID || error "rm remote dir failed"
2849
2850         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2851
2852         rm -rf $DIR/$tdir || error "rmdir failed"
2853
2854         return 0
2855 }
2856 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep,  fail MDT1"
2857
2858 test_81b() {
2859         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2860         ([ $FAILURE_MODE == "HARD" ] &&
2861                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2862                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2863                 return 0
2864         local MDTIDX=1
2865         local remote_dir=$DIR/$tdir/remote_dir
2866
2867         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2868         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2869
2870         # OBD_FAIL_OUT_UPDATE_NET_REP       0x1701
2871         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2872         rmdir $remote_dir &
2873         local CLIENT_PID=$!
2874
2875         replay_barrier mds1
2876         fail mds${MDTIDX}
2877
2878         wait $CLIENT_PID || error "rm remote dir failed"
2879
2880         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2881
2882         rm -rf $DIR/$tdir || error "rmdir failed"
2883
2884         return 0
2885 }
2886 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply,  fail MDT0"
2887
2888 test_81c() {
2889         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2890         ([ $FAILURE_MODE == "HARD" ] &&
2891                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2892                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2893                 return 0
2894
2895         local MDTIDX=1
2896         local remote_dir=$DIR/$tdir/remote_dir
2897
2898         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2899         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2900
2901         # OBD_FAIL_OUT_UPDATE_NET_REP       0x1701
2902         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2903         rmdir $remote_dir &
2904         local CLIENT_PID=$!
2905
2906         replay_barrier mds1
2907         replay_barrier mds2
2908         fail mds${MDTIDX}
2909         fail mds$((MDTIDX + 1))
2910
2911         wait $CLIENT_PID || error "rm remote dir failed"
2912
2913         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2914
2915         rm -rf $DIR/$tdir || error "rmdir failed"
2916
2917         return 0
2918 }
2919 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2920
2921 test_81d() {
2922         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2923         local MDTIDX=1
2924         local remote_dir=$DIR/$tdir/remote_dir
2925
2926         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2927         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2928
2929         # OBD_FAIL_OUT_UPDATE_NET_REP       0x1701
2930         do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2931         rmdir $remote_dir &
2932         local CLIENT_PID=$!
2933
2934         replay_barrier mds1
2935         replay_barrier mds2
2936         fail mds${MDTIDX},mds$((MDTIDX + 1))
2937
2938         wait $CLIENT_PID || error "rm remote dir failed"
2939
2940         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2941
2942         rm -rf $DIR/$tdir || error "rmdir failed"
2943
2944         return 0
2945 }
2946 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply,  fail 2 MDTs"
2947
2948 test_81e() {
2949         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2950         ([ $FAILURE_MODE == "HARD" ] &&
2951                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2952                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2953                 return 0
2954
2955         local MDTIDX=1
2956         local remote_dir=$DIR/$tdir/remote_dir
2957
2958         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2959         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2960
2961         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2962         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2963         rmdir $remote_dir &
2964         local CLIENT_PID=$!
2965         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2966
2967         replay_barrier mds1
2968         fail mds${MDTIDX}
2969
2970         wait $CLIENT_PID || error "rm remote dir failed"
2971
2972         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
2973
2974         rm -rf $DIR/$tdir || error "rmdir failed"
2975
2976         return 0
2977 }
2978 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2979
2980 test_81f() {
2981         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2982         ([ $FAILURE_MODE == "HARD" ] &&
2983                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2984                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2985                 return 0
2986
2987         local MDTIDX=1
2988         local remote_dir=$DIR/$tdir/remote_dir
2989
2990         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
2991         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2992
2993         # OBD_FAIL_MDS_REINT_NET_REP       0x119
2994         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2995         rmdir $remote_dir &
2996         local CLIENT_PID=$!
2997
2998         replay_barrier mds2
2999         fail mds$((MDTIDX + 1))
3000
3001         wait $CLIENT_PID || error "rm remote dir failed"
3002
3003         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3004
3005         rm -rf $DIR/$tdir || error "rmdir failed"
3006
3007         return 0
3008 }
3009 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
3010
3011 test_81g() {
3012         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3013         ([ $FAILURE_MODE == "HARD" ] &&
3014                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3015                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3016                 return 0
3017
3018         local MDTIDX=1
3019         local remote_dir=$DIR/$tdir/remote_dir
3020
3021         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3022         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3023
3024         # OBD_FAIL_MDS_REINT_NET_REP       0x119
3025         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3026         rmdir $remote_dir &
3027         local CLIENT_PID=$!
3028
3029         replay_barrier mds1
3030         replay_barrier mds2
3031         fail mds${MDTIDX}
3032         fail mds$((MDTIDX + 1))
3033
3034         wait $CLIENT_PID || error "rm remote dir failed"
3035
3036         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3037
3038         rm -rf $DIR/$tdir || error "rmdir failed"
3039
3040         return 0
3041 }
3042 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
3043
3044 test_81h() {
3045         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3046         local MDTIDX=1
3047         local remote_dir=$DIR/$tdir/remote_dir
3048
3049         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3050         $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
3051
3052         # OBD_FAIL_MDS_REINT_NET_REP       0x119
3053         do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
3054         rmdir $remote_dir &
3055         local CLIENT_PID=$!
3056
3057         replay_barrier mds1
3058         replay_barrier mds2
3059         fail mds${MDTIDX},mds$((MDTIDX + 1))
3060
3061         wait $CLIENT_PID || error "rm remote dir failed"
3062
3063         stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
3064
3065         rm -rf $DIR/$tdir || error "rmdir failed"
3066
3067         return 0
3068 }
3069 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
3070
3071 test_84a() {
3072 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE  0x144
3073     do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
3074     createmany -o $DIR/$tfile- 1 &
3075     PID=$!
3076     mds_evict_client
3077     wait $PID
3078     client_up || client_up || true    # reconnect
3079 }
3080 run_test 84a "stale open during export disconnect"
3081
3082 test_85a() { #bug 16774
3083         lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3084
3085         for i in $(seq 100); do
3086                 echo "tag-$i" > $DIR/$tfile-$i
3087                 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
3088         done
3089
3090         lov_id=$(lctl dl | grep "clilov")
3091         addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3092         count=$(lctl get_param -n \
3093                 ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3094         echo "before recovery: unused locks count = $count"
3095
3096         fail $SINGLEMDS
3097
3098         count2=$(lctl get_param -n \
3099                  ldlm.namespaces.*MDT0000*$addr.lock_unused_count)
3100         echo "after recovery: unused locks count = $count2"
3101
3102         if [ $count2 -ge $count ]; then
3103                 error "unused locks are not canceled"
3104         fi
3105 }
3106 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
3107
3108 test_85b() { #bug 16774
3109         rm -rf $DIR/$tdir
3110         mkdir $DIR/$tdir
3111
3112         lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
3113
3114         $LFS setstripe -c 1 -i 0 $DIR/$tdir
3115
3116         for i in $(seq 100); do
3117                 dd if=/dev/urandom of=$DIR/$tdir/$tfile-$i bs=4096 \
3118                         count=32 >/dev/null 2>&1
3119         done
3120
3121         cancel_lru_locks osc
3122
3123         for i in $(seq 100); do
3124                 dd if=$DIR/$tdir/$tfile-$i of=/dev/null bs=4096 \
3125                         count=32 >/dev/null 2>&1
3126         done
3127
3128         lov_id=$(lctl dl | grep "clilov")
3129         addr=$(echo $lov_id | awk '{print $4}' | awk -F '-' '{print $NF}')
3130         count=$(lctl get_param -n \
3131                           ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3132         echo "before recovery: unused locks count = $count"
3133         [ $count -ne 0 ] || error "unused locks ($count) should be zero"
3134
3135         fail ost1
3136
3137         count2=$(lctl get_param \
3138                  -n ldlm.namespaces.*OST0000*$addr.lock_unused_count)
3139         echo "after recovery: unused locks count = $count2"
3140
3141         if [ $count2 -ge $count ]; then
3142                 error "unused locks are not canceled"
3143         fi
3144
3145         rm -rf $DIR/$tdir
3146 }
3147 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
3148
3149 test_86() {
3150         local clients=${CLIENTS:-$HOSTNAME}
3151
3152         zconf_umount_clients $clients $MOUNT
3153         do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
3154         remount_facet $SINGLEMDS
3155         zconf_mount_clients $clients $MOUNT
3156 }
3157 run_test 86 "umount server after clear nid_stats should not hit LBUG"
3158
3159 test_87a() {
3160         do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3161
3162         replay_barrier ost1
3163         $LFS setstripe -i 0 -c 1 $DIR/$tfile
3164         dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3165                 error "dd to $DIR/$tfile failed"
3166         cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3167         cancel_lru_locks osc
3168         fail ost1
3169         dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3170         cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3171         if [ $cksum != $cksum2 ] ; then
3172                 error "New checksum $cksum2 does not match original $cksum"
3173         fi
3174 }
3175 run_test 87a "write replay"
3176
3177 test_87b() {
3178         do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
3179
3180         replay_barrier ost1
3181         $LFS setstripe -i 0 -c 1 $DIR/$tfile
3182         dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 ||
3183                 error "dd to $DIR/$tfile failed"
3184         sleep 1 # Give it a chance to flush dirty data
3185         echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
3186         cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
3187         cancel_lru_locks osc
3188         fail ost1
3189         dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
3190         cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
3191         if [ $cksum != $cksum2 ] ; then
3192                 error "New checksum $cksum2 does not match original $cksum"
3193         fi
3194 }
3195 run_test 87b "write replay with changed data (checksum resend)"
3196
3197 test_88() { #bug 17485
3198         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3199         mkdir -p $TMP/$tdir || error "mkdir $TMP/$tdir failed"
3200
3201         $LFS setstripe -i 0 -c 1 $DIR/$tdir || error "$LFS setstripe failed"
3202
3203         replay_barrier ost1
3204         replay_barrier $SINGLEMDS
3205
3206         # exhaust precreations on ost1
3207         local OST=$(ostname_from_index 0)
3208         local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
3209         local last_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3210         local next_id=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3211         echo "before test: last_id = $last_id, next_id = $next_id"
3212
3213         echo "Creating to objid $last_id on ost $OST..."
3214         createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2)) ||
3215                 error "createmany create files to last_id failed"
3216
3217         #create some files to use some uncommitted objids
3218         last_id=$(($last_id + 1))
3219         createmany -o $DIR/$tdir/f-%d $last_id 8 ||
3220                 error "createmany create files with uncommitted objids failed"
3221
3222     last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3223     next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3224     echo "before recovery: last_id = $last_id2, next_id = $next_id2" 
3225
3226     # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
3227     # it has to take care about the affected facets, bug20407
3228     local affected_mds1=$(affected_facets mds1)
3229     local affected_ost1=$(affected_facets ost1)
3230
3231     shutdown_facet $SINGLEMDS
3232     shutdown_facet ost1
3233
3234     reboot_facet $SINGLEMDS
3235     change_active $affected_mds1
3236     wait_for_facet $affected_mds1
3237     mount_facets $affected_mds1 || error "Restart of mds failed"
3238
3239     reboot_facet ost1
3240     change_active $affected_ost1
3241     wait_for_facet $affected_ost1
3242     mount_facets $affected_ost1 || error "Restart of ost1 failed"
3243
3244     clients_up
3245
3246     last_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_last_id)
3247     next_id2=$(do_facet $SINGLEMDS lctl get_param -n osp.$mdtosc.prealloc_next_id)
3248         echo "after recovery: last_id = $last_id2, next_id = $next_id2"
3249
3250         # create new files, which should use new objids, and ensure the orphan
3251         # cleanup phase for ost1 is completed at the same time
3252         for i in $(seq 8); do
3253                 file_id=$(($last_id + 10 + $i))
3254                 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3255         done
3256
3257         # if the objids were not recreated, then "ls" will fail with -ENOENT
3258         ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
3259
3260         local file_id
3261         # write into previously created files
3262         for i in $(seq 8); do
3263                 file_id=$(($last_id + $i))
3264                 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
3265                 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
3266         done
3267
3268         # compare the content
3269         for i in $(seq 8); do
3270                 file_id=$(($last_id + $i))
3271                 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id ||
3272                         error "the content of file is modified!"
3273         done
3274
3275         rm -fr $TMP/$tdir
3276 }
3277 run_test 88 "MDS should not assign same objid to different files "
3278
3279 function calc_osc_kbytes_used() {
3280         local kbtotal=$(calc_osc_kbytes kbytestotal)
3281         local kbfree=$(calc_osc_kbytes kbytesfree)
3282         echo $((kbtotal-kbfree))
3283 }
3284
3285 test_89() {
3286         cancel_lru_locks osc
3287         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3288         rm -f $DIR/$tdir/$tfile
3289         wait_mds_ost_sync || error "initial MDS-OST sync timed out"
3290         wait_delete_completed || error "initial wait delete timed out"
3291         local blocks1=$(calc_osc_kbytes_used)
3292         local write_size=$(fs_log_size)
3293
3294         $LFS setstripe -i 0 -c 1 $DIR/$tdir/$tfile
3295         [ $write_size -lt 1024 ] && write_size=1024
3296         dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
3297         sync
3298         stop ost1
3299         facet_failover $SINGLEMDS
3300         rm $DIR/$tdir/$tfile
3301         umount $MOUNT
3302         mount_facet ost1
3303         zconf_mount $(hostname) $MOUNT || error "mount fails"
3304         client_up || error "client_up failed"
3305
3306         # wait for the remounted client to connect to ost1
3307         local target=$(get_osc_import_name client ost1)
3308         wait_import_state "FULL" "osc.${target}.ost_server_uuid" \
3309                 $(max_recovery_time)
3310
3311         wait_mds_ost_sync || error "MDS-OST sync timed out"
3312         wait_delete_completed || error "wait delete timed out"
3313         local blocks2=$(calc_osc_kbytes_used)
3314
3315         [ $((blocks2 - blocks1)) -le $(fs_log_size)  ] ||
3316                 error $((blocks2 - blocks1)) blocks leaked
3317 }
3318 run_test 89 "no disk space leak on late ost connection"
3319
3320 cleanup_90 () {
3321         local facet=$1
3322
3323         trap 0
3324         reboot_facet $facet
3325         change_active $facet
3326         wait_for_facet $facet
3327         mount_facet $facet || error "Restart of $facet failed"
3328         clients_up
3329 }
3330
3331 test_90() { # bug 19494
3332         local dir=$DIR/$tdir
3333         local ostfail=$(get_random_entry $(get_facets OST))
3334
3335         if [[ $FAILURE_MODE = HARD ]]; then
3336                 local affected=$(affected_facets $ostfail);
3337
3338                 [[ "$affected" == $ostfail ]] ||
3339                         skip "cannot use FAILURE_MODE=$FAILURE_MODE, affected: $affected"
3340         fi
3341         # ensure all OSTs are active to allow allocations
3342         wait_osts_up
3343
3344         mkdir $dir || error "mkdir $dir failed"
3345
3346         echo "Create the files"
3347
3348         # file "f${index}" striped over 1 OST
3349         # file "all" striped over all OSTs
3350
3351         $LFS setstripe -c $OSTCOUNT $dir/all ||
3352                 error "setstripe failed to create $dir/all"
3353
3354         for ((i = 0; i < $OSTCOUNT; i++)); do
3355                 local f=$dir/f$i
3356
3357                 $LFS setstripe -i $i -c 1 $f ||
3358                         error "$LFS setstripe failed to create $f"
3359
3360                 # confirm setstripe actually created stripe on requested OST
3361                 local uuid=$(ostuuid_from_index $i)
3362
3363                 for file in f$i all; do
3364                         local found=$($LFS find --obd $uuid --name $file $dir)
3365
3366                         if [[ $dir/$file != $found ]]; then
3367                                 $LFS getstripe $dir/$file
3368                                 error "wrong stripe: $file, uuid: $uuid"
3369                         fi
3370                 done
3371         done
3372
3373         # Before failing an OST, get its obd name and index
3374         local varsvc=${ostfail}_svc
3375         local obd=$(do_facet $ostfail lctl get_param \
3376                     -n obdfilter.${!varsvc}.uuid)
3377         local index=$(($(facet_number $ostfail) - 1))
3378
3379         echo "Fail $ostfail $obd, display the list of affected files"
3380         shutdown_facet $ostfail || error "shutdown_facet $ostfail failed"
3381
3382         trap "cleanup_90 $ostfail" EXIT INT
3383         echo "General Query: lfs find $dir"
3384         local list=$($LFS find $dir)
3385         echo "$list"
3386         for (( i=0; i<$OSTCOUNT; i++ )); do
3387                 list_member "$list" $dir/f$i ||
3388                         error_noexit "lfs find $dir: no file f$i"
3389         done
3390         list_member "$list" $dir/all ||
3391                 error_noexit "lfs find $dir: no file all"
3392
3393         # focus on the missing OST,
3394         # we expect to see only two files affected: "f$(index)" and "all"
3395
3396         echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
3397     list=$($LFS find --obd $obd $dir)
3398     echo "$list"
3399     for file in all f$index; do
3400         list_member "$list" $dir/$file ||
3401             error_noexit "lfs find does not report the affected $obd for $file"
3402     done
3403
3404     [[ $(echo $list | wc -w) -eq 2 ]] ||
3405         error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
3406
3407         echo "Check getstripe: $LFS getstripe -r --obd $obd"
3408         list=$($LFS getstripe -r --obd $obd $dir)
3409         echo "$list"
3410     for file in all f$index; do
3411         echo "$list" | grep $dir/$file ||
3412             error_noexit "lfs getsripe does not report the affected $obd for $file"
3413     done
3414
3415     cleanup_90 $ostfail
3416 }
3417 run_test 90 "lfs find identifies the missing striped file segments"
3418
3419 test_93a() {
3420         [[ "$MDS1_VERSION" -ge $(version_code 2.6.90) ]] ||
3421                 [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
3422                    "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
3423                 skip "Need MDS version 2.5.4+ or 2.6.90+"
3424
3425         cancel_lru_locks osc
3426
3427         $LFS setstripe -i 0 -c 1 $DIR/$tfile ||
3428                 error "$LFS setstripe  $DIR/$tfile failed"
3429         dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 ||
3430                 error "dd to $DIR/$tfile failed"
3431         #define OBD_FAIL_TGT_REPLAY_RECONNECT     0x715
3432         # We need to emulate a state that OST is waiting for other clients
3433         # not completing the recovery. Final ping is queued, but reply will be
3434         # sent on the recovery completion. It is done by sleep before
3435         # processing final pings
3436         do_facet ost1 "$LCTL set_param fail_val=40"
3437         do_facet ost1 "$LCTL set_param fail_loc=0x715"
3438         fail ost1
3439 }
3440 run_test 93a "replay + reconnect"
3441
3442 test_93b() {
3443         [[ "$MDS1_VERSION" -ge $(version_code 2.7.90) ]] ||
3444                 skip "Need MDS version 2.7.90+"
3445
3446         cancel_lru_locks mdc
3447
3448         createmany -o $DIR/$tfile 20 ||
3449                         error "createmany -o $DIR/$tfile failed"
3450
3451         #define OBD_FAIL_TGT_REPLAY_RECONNECT     0x715
3452         # We need to emulate a state that MDT is waiting for other clients
3453         # not completing the recovery. Final ping is queued, but reply will be
3454         # sent on the recovery completion. It is done by sleep before
3455         # processing final pings
3456         do_facet mds1 "$LCTL set_param fail_val=80"
3457         do_facet mds1 "$LCTL set_param fail_loc=0x715"
3458         fail mds1
3459 }
3460 run_test 93b "replay + reconnect on mds"
3461
3462 striped_dir_check_100() {
3463         local striped_dir=$DIR/$tdir/striped_dir
3464         local stripe_count=$($LFS getdirstripe -c $striped_dir)
3465
3466         $LFS getdirstripe $striped_dir
3467         [ $stripe_count -eq 2 ] || error "$stripe_count != 2"
3468
3469         createmany -o $striped_dir/f-%d 20 ||
3470                 error "creation failed under striped dir"
3471 }
3472
3473 test_100a() {
3474         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3475         ([ $FAILURE_MODE == "HARD" ] &&
3476                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3477                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3478                 return 0
3479
3480         local striped_dir=$DIR/$tdir/striped_dir
3481         local MDTIDX=1
3482
3483         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3484
3485         #To make sure MDT1 and MDT0 are connected
3486         #otherwise it may create single stripe dir here
3487         $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3488
3489         #define OBD_FAIL_OUT_UPDATE_NET_REP     0x1701
3490         do_facet mds$((MDTIDX+1)) lctl set_param fail_loc=0x1701
3491         $LFS setdirstripe -i0 -c2 $striped_dir &
3492         local CLIENT_PID=$!
3493
3494         fail mds$((MDTIDX + 1))
3495
3496         wait $CLIENT_PID || error "striped dir creation failed"
3497
3498         striped_dir_check_100 || error "striped dir check failed"
3499         rm -rf $DIR/$tdir || error "rmdir failed"
3500 }
3501 run_test 100a "DNE: create striped dir, drop update rep from MDT1, fail MDT1"
3502
3503 test_100b() {
3504         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3505         ([ $FAILURE_MODE == "HARD" ] &&
3506                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3507                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3508                 return 0
3509
3510         local striped_dir=$DIR/$tdir/striped_dir
3511         local MDTIDX=1
3512
3513         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3514
3515         #To make sure MDT1 and MDT0 are connected
3516         #otherwise it may create single stripe dir here
3517         $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3518
3519         # OBD_FAIL_MDS_REINT_NET_REP       0x119
3520         do_facet mds$MDTIDX lctl set_param fail_loc=0x119
3521         $LFS mkdir -i0 -c2 $striped_dir &
3522
3523         local CLIENT_PID=$!
3524         fail mds$MDTIDX
3525
3526         wait $CLIENT_PID || error "striped dir creation failed"
3527
3528         striped_dir_check_100 || error "striped dir check failed"
3529         rm -rf $DIR/$tdir || error "rmdir failed"
3530 }
3531 run_test 100b "DNE: create striped dir, fail MDT0"
3532
3533 test_100c() {
3534         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3535         ([ $FAILURE_MODE == "HARD" ] &&
3536                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3537                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3538                 return 0
3539
3540         local striped_dir=$DIR/$tdir/striped_dir
3541
3542         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3543
3544         #To make sure MDT1 and MDT0 are connected
3545         #otherwise it may create single stripe dir here
3546         $LFS setdirstripe -i1 $DIR/$tdir/remote_dir
3547
3548         replay_barrier mds2
3549         $LFS mkdir -i1 -c2 $striped_dir
3550
3551         fail_abort mds2 abort_recov_mdt
3552
3553         createmany -o $striped_dir/f-%d 20 &&
3554                         error "createmany -o $DIR/$tfile should fail"
3555
3556         fail mds2
3557         striped_dir_check_100 || error "striped dir check failed"
3558         rm -rf $DIR/$tdir || error "rmdir failed"
3559 }
3560 run_test 100c "DNE: create striped dir, fail MDT0"
3561
3562 test_101() { #LU-5648
3563         mkdir -p $DIR/$tdir/d1
3564         mkdir -p $DIR/$tdir/d2
3565         touch $DIR/$tdir/file0
3566         num=1000
3567
3568         replay_barrier $SINGLEMDS
3569         for i in $(seq $num) ; do
3570                 echo test$i > $DIR/$tdir/d1/file$i
3571         done
3572
3573         fail_abort $SINGLEMDS
3574         for i in $(seq $num) ; do
3575                 touch $DIR/$tdir/d2/file$i
3576                 test -s $DIR/$tdir/d2/file$i &&
3577                         ls -al $DIR/$tdir/d2/file$i && error "file$i's size > 0"
3578         done
3579
3580         rm -rf $DIR/$tdir
3581 }
3582 run_test 101 "Shouldn't reassign precreated objs to other files after recovery"
3583
3584 test_102a() {
3585         local idx
3586         local facet
3587         local num
3588         local i
3589         local pids pid
3590
3591         [[ $(lctl get_param mdc.*.import |
3592              grep "connect_flags:.*multi_mod_rpc") ]] ||
3593                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3594
3595         $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3596         idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3597         facet="mds$((0x$idx + 1))"
3598
3599         # get current value of max_mod_rcps_in_flight
3600         num=$($LCTL get_param -n \
3601                 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3602         # set default value if client does not support multi mod RPCs
3603         [ -z "$num" ] && num=1
3604
3605         echo "creating $num files ..."
3606         umask 0022
3607         for i in $(seq $num); do
3608                 touch $DIR/$tdir/file-$i
3609         done
3610
3611         # drop request on MDT to force resend
3612         #define OBD_FAIL_MDS_REINT_MULTI_NET 0x159
3613         do_facet $facet "$LCTL set_param fail_loc=0x159"
3614         echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3615         for i in $(seq $num); do
3616                 chmod 0600 $DIR/$tdir/file-$i &
3617                 pids="$pids $!"
3618         done
3619         sleep 1
3620         do_facet $facet "$LCTL set_param fail_loc=0"
3621         for pid in $pids; do
3622                 wait $pid || error "chmod failed"
3623         done
3624         echo "done ($(date +%H:%M:%S))"
3625
3626         # check chmod succeed
3627         for i in $(seq $num); do
3628                 checkstat -vp 0600 $DIR/$tdir/file-$i
3629         done
3630
3631         rm -rf $DIR/$tdir
3632 }
3633 run_test 102a "check resend (request lost) with multiple modify RPCs in flight"
3634
3635 test_102b() {
3636         local idx
3637         local facet
3638         local num
3639         local i
3640         local pids pid
3641
3642         [[ $(lctl get_param mdc.*.import |
3643              grep "connect_flags:.*multi_mod_rpc") ]] ||
3644                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3645
3646         $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3647         idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3648         facet="mds$((0x$idx + 1))"
3649
3650         # get current value of max_mod_rcps_in_flight
3651         num=$($LCTL get_param -n \
3652                 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3653         # set default value if client does not support multi mod RPCs
3654         [ -z "$num" ] && num=1
3655
3656         echo "creating $num files ..."
3657         umask 0022
3658         for i in $(seq $num); do
3659                 touch $DIR/$tdir/file-$i
3660         done
3661
3662         # drop reply on MDT to force reconstruction
3663         #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3664         do_facet $facet "$LCTL set_param fail_loc=0x15a"
3665         echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3666         for i in $(seq $num); do
3667                 chmod 0600 $DIR/$tdir/file-$i &
3668                 pids="$pids $!"
3669         done
3670         sleep 1
3671         do_facet $facet "$LCTL set_param fail_loc=0"
3672         for pid in $pids; do
3673                 wait $pid || error "chmod failed"
3674         done
3675         echo "done ($(date +%H:%M:%S))"
3676
3677         # check chmod succeed
3678         for i in $(seq $num); do
3679                 checkstat -vp 0600 $DIR/$tdir/file-$i
3680         done
3681
3682         rm -rf $DIR/$tdir
3683 }
3684 run_test 102b "check resend (reply lost) with multiple modify RPCs in flight"
3685
3686 test_102c() {
3687         local idx
3688         local facet
3689         local num
3690         local i
3691         local pids pid
3692
3693         [[ $(lctl get_param mdc.*.import |
3694              grep "connect_flags:.*multi_mod_rpc") ]] ||
3695                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3696
3697         $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3698         idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3699         facet="mds$((0x$idx + 1))"
3700
3701         # get current value of max_mod_rcps_in_flight
3702         num=$($LCTL get_param -n \
3703                 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3704         # set default value if client does not support multi mod RPCs
3705         [ -z "$num" ] && num=1
3706
3707         echo "creating $num files ..."
3708         umask 0022
3709         for i in $(seq $num); do
3710                 touch $DIR/$tdir/file-$i
3711         done
3712
3713         replay_barrier $facet
3714
3715         # drop reply on MDT
3716         #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3717         do_facet $facet "$LCTL set_param fail_loc=0x15a"
3718         echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3719         for i in $(seq $num); do
3720                 chmod 0600 $DIR/$tdir/file-$i &
3721                 pids="$pids $!"
3722         done
3723         sleep 1
3724         do_facet $facet "$LCTL set_param fail_loc=0"
3725
3726         # fail MDT
3727         fail $facet
3728
3729         for pid in $pids; do
3730                 wait $pid || error "chmod failed"
3731         done
3732         echo "done ($(date +%H:%M:%S))"
3733
3734         # check chmod succeed
3735         for i in $(seq $num); do
3736                 checkstat -vp 0600 $DIR/$tdir/file-$i
3737         done
3738
3739         rm -rf $DIR/$tdir
3740 }
3741 run_test 102c "check replay w/o reconstruction with multiple mod RPCs in flight"
3742
3743 test_102d() {
3744         local idx
3745         local facet
3746         local num
3747         local i
3748         local pids pid
3749
3750         [[ $(lctl get_param mdc.*.import |
3751              grep "connect_flags:.*multi_mod_rpc") ]] ||
3752                 { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
3753
3754         $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
3755         idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
3756         facet="mds$((0x$idx + 1))"
3757
3758         # get current value of max_mod_rcps_in_flight
3759         num=$($LCTL get_param -n \
3760                 mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
3761         # set default value if client does not support multi mod RPCs
3762         [ -z "$num" ] && num=1
3763
3764         echo "creating $num files ..."
3765         umask 0022
3766         for i in $(seq $num); do
3767                 touch $DIR/$tdir/file-$i
3768         done
3769
3770         # drop reply on MDT
3771         #define OBD_FAIL_MDS_REINT_MULTI_NET_REP 0x15a
3772         do_facet $facet "$LCTL set_param fail_loc=0x15a"
3773         echo "launch $num chmod in parallel ($(date +%H:%M:%S)) ..."
3774         for i in $(seq $num); do
3775                 chmod 0600 $DIR/$tdir/file-$i &
3776                 pids="$pids $!"
3777         done
3778         sleep 1
3779
3780         # write MDT transactions to disk
3781         do_facet $facet "sync; sync; sync"
3782
3783         do_facet $facet "$LCTL set_param fail_loc=0"
3784
3785         # fail MDT
3786         fail $facet
3787
3788         for pid in $pids; do
3789                 wait $pid || error "chmod failed"
3790         done
3791         echo "done ($(date +%H:%M:%S))"
3792
3793         # check chmod succeed
3794         for i in $(seq $num); do
3795                 checkstat -vp 0600 $DIR/$tdir/file-$i
3796         done
3797
3798         rm -rf $DIR/$tdir
3799 }
3800 run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
3801
3802 test_103() {
3803         remote_mds_nodsh && skip "remote MDS with nodsh"
3804         [[ "$MDS1_VERSION" -gt $(version_code 2.8.54) ]] ||
3805                 skip "Need MDS version 2.8.54+"
3806
3807 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
3808         do_facet mds1 $LCTL set_param fail_loc=0x80000162
3809
3810         mkdir -p $DIR/$tdir
3811         createmany -o $DIR/$tdir/t- 30 ||
3812                 error "create files on remote directory failed"
3813         sync
3814         rm -rf $DIR/$tdir/t-*
3815         sync
3816 #MDS should crash with tr->otr_next_id overflow
3817         fail mds1
3818 }
3819 run_test 103 "Check otr_next_id overflow"
3820
3821
3822 check_striped_dir_110()
3823 {
3824         $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
3825                         error "create striped dir failed"
3826         local stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
3827         [ $stripe_count -eq $MDSCOUNT ] ||
3828                 error "$stripe_count != 2 after recovery"
3829 }
3830
3831 test_110a() {
3832         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3833         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3834                 skip "Need MDS version at least 2.7.56"
3835
3836         ([ $FAILURE_MODE == "HARD" ] &&
3837                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3838                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3839                 return 0
3840
3841         mkdir -p $DIR/$tdir
3842         replay_barrier mds1
3843         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3844         fail mds1
3845
3846         check_striped_dir_110 || error "check striped_dir failed"
3847         rm -rf $DIR/$tdir || error "rmdir failed"
3848
3849         return 0
3850 }
3851 run_test 110a "DNE: create striped dir, fail MDT1"
3852
3853 test_110b() {
3854         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3855         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3856                 skip "Need MDS version at least 2.7.56"
3857
3858         ([ $FAILURE_MODE == "HARD" ] &&
3859                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3860                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3861                 return 0
3862
3863         mkdir -p $DIR/$tdir
3864         replay_barrier mds1
3865         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3866         umount $MOUNT
3867         fail mds1
3868         zconf_mount $(hostname) $MOUNT
3869         client_up || return 1
3870
3871         check_striped_dir_110 || error "check striped_dir failed"
3872
3873         rm -rf $DIR/$tdir || error "rmdir failed"
3874
3875         return 0
3876 }
3877 run_test 110b "DNE: create striped dir, fail MDT1 and client"
3878
3879 test_110c() {
3880         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3881         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3882                 skip "Need MDS version at least 2.7.56"
3883
3884         ([ $FAILURE_MODE == "HARD" ] &&
3885                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3886                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3887                 return 0
3888
3889         mkdir -p $DIR/$tdir
3890         replay_barrier mds2
3891         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3892         fail mds2
3893
3894         check_striped_dir_110 || error "check striped_dir failed"
3895
3896         rm -rf $DIR/$tdir || error "rmdir failed"
3897
3898         return 0
3899 }
3900 run_test 110c "DNE: create striped dir, fail MDT2"
3901
3902 test_110d() {
3903         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3904         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3905                 skip "Need MDS version at least 2.7.56"
3906
3907         ([ $FAILURE_MODE == "HARD" ] &&
3908                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3909                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3910                 return 0
3911
3912         mkdir -p $DIR/$tdir
3913         replay_barrier mds2
3914         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3915         umount $MOUNT
3916         fail mds2
3917         zconf_mount $(hostname) $MOUNT
3918         client_up || return 1
3919
3920         check_striped_dir_110 || error "check striped_dir failed"
3921
3922         rm -rf $DIR/$tdir || error "rmdir failed"
3923
3924         return 0
3925 }
3926 run_test 110d "DNE: create striped dir, fail MDT2 and client"
3927
3928 test_110e() {
3929         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3930         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3931                 skip "Need MDS version at least 2.7.56"
3932
3933         ([ $FAILURE_MODE == "HARD" ] &&
3934                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3935                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3936                 return 0
3937
3938         mkdir -p $DIR/$tdir
3939         replay_barrier mds2
3940         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3941         umount $MOUNT
3942         replay_barrier mds1
3943         fail mds1,mds2
3944         zconf_mount $(hostname) $MOUNT
3945         client_up || return 1
3946
3947         check_striped_dir_110 || error "check striped_dir failed"
3948
3949         rm -rf $DIR/$tdir || error "rmdir failed"
3950
3951         return 0
3952 }
3953 run_test 110e "DNE: create striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
3954
3955 test_110f() {
3956         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3957         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3958                 skip "Need MDS version at least 2.7.56"
3959
3960         ([ $FAILURE_MODE == "HARD" ] &&
3961                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3962                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3963                 return 0
3964
3965         mkdir -p $DIR/$tdir
3966         replay_barrier mds1
3967         replay_barrier mds2
3968         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3969         fail mds2,mds1
3970
3971         check_striped_dir_110 || error "check striped_dir failed"
3972
3973         rm -rf $DIR/$tdir || error "rmdir failed"
3974
3975         return 0
3976 }
3977 run_test 110f "DNE: create striped dir, fail MDT1/MDT2"
3978
3979 test_110g() {
3980         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
3981         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
3982                 skip "Need MDS version at least 2.7.56"
3983
3984         ([ $FAILURE_MODE == "HARD" ] &&
3985                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
3986                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
3987                 return 0
3988
3989         mkdir -p $DIR/$tdir
3990         replay_barrier mds1
3991         $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
3992         umount $MOUNT
3993         replay_barrier mds2
3994         fail mds1,mds2
3995         zconf_mount $(hostname) $MOUNT
3996         client_up || return 1
3997
3998         check_striped_dir_110 || error "check striped_dir failed"
3999
4000         rm -rf $DIR/$tdir || error "rmdir failed"
4001
4002         return 0
4003 }
4004 run_test 110g "DNE: create striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4005
4006 test_111a() {
4007         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4008         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4009                 skip "Need MDS version at least 2.7.56"
4010
4011         ([ $FAILURE_MODE == "HARD" ] &&
4012                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4013                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4014                 return 0
4015
4016         mkdir -p $DIR/$tdir
4017         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4018         replay_barrier mds1
4019         rm -rf $DIR/$tdir/striped_dir
4020         fail mds1
4021
4022         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4023                         error "striped dir still exists"
4024         return 0
4025 }
4026 run_test 111a "DNE: unlink striped dir, fail MDT1"
4027
4028 test_111b() {
4029         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4030         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4031                 skip "Need MDS version at least 2.7.56"
4032
4033         ([ $FAILURE_MODE == "HARD" ] &&
4034                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4035                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4036                 return 0
4037
4038         mkdir -p $DIR/$tdir
4039         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4040         replay_barrier mds2
4041         rm -rf $DIR/$tdir/striped_dir
4042         umount $MOUNT
4043         fail mds2
4044         zconf_mount $(hostname) $MOUNT
4045         client_up || return 1
4046
4047         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4048                         error "striped dir still exists"
4049         return 0
4050 }
4051 run_test 111b "DNE: unlink striped dir, fail MDT2"
4052
4053 test_111c() {
4054         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4055         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4056                 skip "Need MDS version at least 2.7.56"
4057
4058         ([ $FAILURE_MODE == "HARD" ] &&
4059                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4060                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4061                 return 0
4062
4063         mkdir -p $DIR/$tdir
4064         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4065         replay_barrier mds1
4066         rm -rf $DIR/$tdir/striped_dir
4067         umount $MOUNT
4068         replay_barrier mds2
4069         fail mds1,mds2
4070         zconf_mount $(hostname) $MOUNT
4071         client_up || return 1
4072         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4073                         error "striped dir still exists"
4074         return 0
4075 }
4076 run_test 111c "DNE: unlink striped dir, uncommit on MDT1, fail client/MDT1/MDT2"
4077
4078 test_111d() {
4079         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4080         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4081                 skip "Need MDS version at least 2.7.56"
4082
4083         ([ $FAILURE_MODE == "HARD" ] &&
4084                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4085                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4086                 return 0
4087
4088         mkdir -p $DIR/$tdir
4089         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4090         replay_barrier mds2
4091         rm -rf $DIR/$tdir/striped_dir
4092         umount $MOUNT
4093         replay_barrier mds1
4094         fail mds1,mds2
4095         zconf_mount $(hostname) $MOUNT
4096         client_up || return 1
4097         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4098                         error "striped dir still exists"
4099
4100         return 0
4101 }
4102 run_test 111d "DNE: unlink striped dir, uncommit on MDT2, fail client/MDT1/MDT2"
4103
4104 test_111e() {
4105         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4106         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4107                 skip "Need MDS version at least 2.7.56"
4108
4109         ([ $FAILURE_MODE == "HARD" ] &&
4110                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4111                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4112                 return 0
4113
4114         mkdir -p $DIR/$tdir
4115         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4116         replay_barrier mds2
4117         rm -rf $DIR/$tdir/striped_dir
4118         replay_barrier mds1
4119         fail mds1,mds2
4120         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4121                         error "striped dir still exists"
4122         return 0
4123 }
4124 run_test 111e "DNE: unlink striped dir, uncommit on MDT2, fail MDT1/MDT2"
4125
4126 test_111f() {
4127         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4128         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4129                 skip "Need MDS version at least 2.7.56"
4130
4131         ([ $FAILURE_MODE == "HARD" ] &&
4132                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4133                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4134                 return 0
4135
4136         mkdir -p $DIR/$tdir
4137         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4138         replay_barrier mds1
4139         rm -rf $DIR/$tdir/striped_dir
4140         replay_barrier mds2
4141         fail mds1,mds2
4142         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4143                         error "striped dir still exists"
4144         return 0
4145 }
4146 run_test 111f "DNE: unlink striped dir, uncommit on MDT1, fail MDT1/MDT2"
4147
4148 test_111g() {
4149         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4150         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4151                 skip "Need MDS version at least 2.7.56"
4152
4153         ([ $FAILURE_MODE == "HARD" ] &&
4154                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4155                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4156                 return 0
4157
4158         mkdir -p $DIR/$tdir
4159         $LFS mkdir -i1 -c2 $DIR/$tdir/striped_dir
4160         replay_barrier mds1
4161         replay_barrier mds2
4162         rm -rf $DIR/$tdir/striped_dir
4163         fail mds1,mds2
4164         $CHECKSTAT -t dir $DIR/$tdir/striped_dir &&
4165                         error "striped dir still exists"
4166         return 0
4167 }
4168 run_test 111g "DNE: unlink striped dir, fail MDT1/MDT2"
4169
4170 test_112_rename_prepare() {
4171         mkdir -p $DIR/$tdir/src_dir
4172         $LFS mkdir -i 1 $DIR/$tdir/src_dir/src_child ||
4173                 error "create remote source failed"
4174
4175         touch $DIR/$tdir/src_dir/src_child/a
4176
4177         $LFS mkdir -i 2 $DIR/$tdir/tgt_dir ||
4178                 error "create remote target dir failed"
4179
4180         $LFS mkdir -i 3 $DIR/$tdir/tgt_dir/tgt_child ||
4181                 error "create remote target child failed"
4182 }
4183
4184 test_112_check() {
4185         find $DIR/$tdir/
4186         $CHECKSTAT -t dir $DIR/$tdir/src_dir/src_child &&
4187                 error "src_child still exists after rename"
4188
4189         $CHECKSTAT -t file $DIR/$tdir/tgt_dir/tgt_child/a ||
4190                 error "missing file(a) after rename"
4191 }
4192
4193 test_112a() {
4194         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4195         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4196                 skip "Need MDS version at least 2.7.56"
4197
4198         ([ $FAILURE_MODE == "HARD" ] &&
4199                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4200                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4201                 return 0
4202
4203         test_112_rename_prepare
4204         replay_barrier mds1
4205
4206         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4207                 error "rename dir cross MDT failed!"
4208         fail mds1
4209
4210         test_112_check
4211         rm -rf $DIR/$tdir || error "rmdir failed"
4212 }
4213 run_test 112a "DNE: cross MDT rename, fail MDT1"
4214
4215 test_112b() {
4216         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4217         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4218                 skip "Need MDS version at least 2.7.56"
4219
4220         ([ $FAILURE_MODE == "HARD" ] &&
4221                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4222                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4223                 return 0
4224
4225         test_112_rename_prepare
4226         replay_barrier mds2
4227
4228         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4229                 error "rename dir cross MDT failed!"
4230
4231         fail mds2
4232
4233         test_112_check
4234         rm -rf $DIR/$tdir || error "rmdir failed"
4235 }
4236 run_test 112b "DNE: cross MDT rename, fail MDT2"
4237
4238 test_112c() {
4239         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4240         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4241                 skip "Need MDS version at least 2.7.56"
4242
4243         ([ $FAILURE_MODE == "HARD" ] &&
4244                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4245                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4246                 return 0
4247
4248         test_112_rename_prepare
4249         replay_barrier mds3
4250
4251         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4252                 error "rename dir cross MDT failed!"
4253
4254         fail mds3
4255
4256         test_112_check
4257         rm -rf $DIR/$tdir || error "rmdir failed"
4258 }
4259 run_test 112c "DNE: cross MDT rename, fail MDT3"
4260
4261 test_112d() {
4262         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4263         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4264                 skip "Need MDS version at least 2.7.56"
4265
4266         ([ $FAILURE_MODE == "HARD" ] &&
4267                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4268                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4269                 return 0
4270
4271         test_112_rename_prepare
4272         replay_barrier mds4
4273
4274         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4275                 error "rename dir cross MDT failed!"
4276
4277         fail mds4
4278
4279         test_112_check
4280         rm -rf $DIR/$tdir || error "rmdir failed"
4281 }
4282 run_test 112d "DNE: cross MDT rename, fail MDT4"
4283
4284 test_112e() {
4285         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4286         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4287                 skip "Need MDS version at least 2.7.56"
4288
4289         ([ $FAILURE_MODE == "HARD" ] &&
4290                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4291                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4292                 return 0
4293
4294         test_112_rename_prepare
4295         replay_barrier mds1
4296         replay_barrier mds2
4297
4298         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4299                 error "rename dir cross MDT failed!"
4300
4301         fail mds1,mds2
4302
4303         test_112_check
4304         rm -rf $DIR/$tdir || error "rmdir failed"
4305 }
4306 run_test 112e "DNE: cross MDT rename, fail MDT1 and MDT2"
4307
4308 test_112f() {
4309         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4310         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4311                 skip "Need MDS version at least 2.7.56"
4312
4313         ([ $FAILURE_MODE == "HARD" ] &&
4314                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4315                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4316                 return 0
4317
4318         test_112_rename_prepare
4319         replay_barrier mds1
4320         replay_barrier mds3
4321
4322         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4323                 error "rename dir cross MDT failed!"
4324
4325         fail mds1,mds3
4326
4327         test_112_check
4328         rm -rf $DIR/$tdir || error "rmdir failed"
4329 }
4330 run_test 112f "DNE: cross MDT rename, fail MDT1 and MDT3"
4331
4332 test_112g() {
4333         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4334         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4335                 skip "Need MDS version at least 2.7.56"
4336
4337         ([ $FAILURE_MODE == "HARD" ] &&
4338                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4339                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4340                 return 0
4341
4342         test_112_rename_prepare
4343         replay_barrier mds1
4344         replay_barrier mds4
4345
4346         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4347                 error "rename dir cross MDT failed!"
4348
4349         fail mds1,mds4
4350
4351         test_112_check
4352         rm -rf $DIR/$tdir || error "rmdir failed"
4353 }
4354 run_test 112g "DNE: cross MDT rename, fail MDT1 and MDT4"
4355
4356 test_112h() {
4357         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4358         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4359                 skip "Need MDS version at least 2.7.56"
4360
4361         ([ $FAILURE_MODE == "HARD" ] &&
4362                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4363                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4364                 return 0
4365
4366         test_112_rename_prepare
4367         replay_barrier mds2
4368         replay_barrier mds3
4369
4370         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4371                 error "rename dir cross MDT failed!"
4372
4373         fail mds2,mds3
4374
4375         test_112_check
4376         rm -rf $DIR/$tdir || error "rmdir failed"
4377 }
4378 run_test 112h "DNE: cross MDT rename, fail MDT2 and MDT3"
4379
4380 test_112i() {
4381         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4382         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4383                 skip "Need MDS version at least 2.7.56"
4384
4385         ([ $FAILURE_MODE == "HARD" ] &&
4386                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4387                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4388                 return 0
4389
4390         test_112_rename_prepare
4391         replay_barrier mds2
4392         replay_barrier mds4
4393
4394         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4395                 error "rename dir cross MDT failed!"
4396
4397         fail mds2,mds4
4398
4399         test_112_check
4400         rm -rf $DIR/$tdir || error "rmdir failed"
4401 }
4402 run_test 112i "DNE: cross MDT rename, fail MDT2 and MDT4"
4403
4404 test_112j() {
4405         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4406         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4407                 skip "Need MDS version at least 2.7.56"
4408
4409         ([ $FAILURE_MODE == "HARD" ] &&
4410                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4411                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4412                 return 0
4413
4414         test_112_rename_prepare
4415         replay_barrier mds3
4416         replay_barrier mds4
4417
4418         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4419                 error "rename dir cross MDT failed!"
4420
4421         fail mds3,mds4
4422
4423         test_112_check
4424         rm -rf $DIR/$tdir || error "rmdir failed"
4425 }
4426 run_test 112j "DNE: cross MDT rename, fail MDT3 and MDT4"
4427
4428 test_112k() {
4429         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4430         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4431                 skip "Need MDS version at least 2.7.56"
4432
4433         ([ $FAILURE_MODE == "HARD" ] &&
4434                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4435                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4436                 return 0
4437
4438         test_112_rename_prepare
4439         replay_barrier mds1
4440         replay_barrier mds2
4441         replay_barrier mds3
4442
4443         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4444                 error "rename dir cross MDT failed!"
4445
4446         fail mds1,mds2,mds3
4447
4448         test_112_check
4449         rm -rf $DIR/$tdir || error "rmdir failed"
4450 }
4451 run_test 112k "DNE: cross MDT rename, fail MDT1,MDT2,MDT3"
4452
4453 test_112l() {
4454         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4455         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4456                 skip "Need MDS version at least 2.7.56"
4457
4458         ([ $FAILURE_MODE == "HARD" ] &&
4459                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4460                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4461                 return 0
4462
4463         test_112_rename_prepare
4464         replay_barrier mds1
4465         replay_barrier mds2
4466         replay_barrier mds4
4467
4468         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4469                 error "rename dir cross MDT failed!"
4470
4471         fail mds1,mds2,mds4
4472
4473         test_112_check
4474         rm -rf $DIR/$tdir || error "rmdir failed"
4475 }
4476 run_test 112l "DNE: cross MDT rename, fail MDT1,MDT2,MDT4"
4477
4478 test_112m() {
4479         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4480         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4481                 skip "Need MDS version at least 2.7.56"
4482
4483         ([ $FAILURE_MODE == "HARD" ] &&
4484                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4485                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4486                 return 0
4487
4488         test_112_rename_prepare
4489         replay_barrier mds1
4490         replay_barrier mds3
4491         replay_barrier mds4
4492
4493         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4494                 error "rename dir cross MDT failed!"
4495
4496         fail mds1,mds3,mds4
4497
4498         test_112_check
4499         rm -rf $DIR/$tdir || error "rmdir failed"
4500 }
4501 run_test 112m "DNE: cross MDT rename, fail MDT1,MDT3,MDT4"
4502
4503 test_112n() {
4504         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4505         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4506                 skip "Need MDS version at least 2.7.56"
4507
4508         ([ $FAILURE_MODE == "HARD" ] &&
4509                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4510                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4511                 return 0
4512
4513         test_112_rename_prepare
4514         replay_barrier mds2
4515         replay_barrier mds3
4516         replay_barrier mds4
4517
4518         mrename $DIR/$tdir/src_dir/src_child $DIR/$tdir/tgt_dir/tgt_child ||
4519                 error "rename dir cross MDT failed!"
4520
4521         fail mds2,mds3,mds4
4522
4523         test_112_check
4524         rm -rf $DIR/$tdir || error "rmdir failed"
4525 }
4526 run_test 112n "DNE: cross MDT rename, fail MDT2,MDT3,MDT4"
4527
4528 test_115() {
4529         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4530         [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
4531                 skip "Need MDS version at least 2.7.56"
4532
4533         ([ $FAILURE_MODE == "HARD" ] &&
4534                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4535                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4536                 return 0
4537         local fail_index=0
4538         local index
4539         local i
4540         local j
4541
4542         mkdir -p $DIR/$tdir
4543         for ((j=0;j<$((MDSCOUNT));j++)); do
4544                 fail_index=$((fail_index+1))
4545                 index=$((fail_index % MDSCOUNT))
4546                 replay_barrier mds$((index + 1))
4547                 for ((i=0;i<5;i++)); do
4548                         test_mkdir -i$index -c$MDSCOUNT $DIR/$tdir/test_$i ||
4549                                 error "create striped dir $DIR/$tdir/test_$i"
4550                 done
4551
4552                 fail mds$((index + 1))
4553                 for ((i=0;i<5;i++)); do
4554                         checkstat -t dir $DIR/$tdir/test_$i ||
4555                                 error "$DIR/$tdir/test_$i does not exist!"
4556                 done
4557                 rm -rf $DIR/$tdir/test_* ||
4558                                 error "rmdir fails"
4559         done
4560 }
4561 run_test 115 "failover for create/unlink striped directory"
4562
4563 test_116a() {
4564         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4565         [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4566                 skip "Do not support large update log before 2.7.55" &&
4567                 return 0
4568         ([ $FAILURE_MODE == "HARD" ] &&
4569                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4570                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4571                 return 0
4572         local fail_index=0
4573
4574         mkdir -p $DIR/$tdir
4575         replay_barrier mds1
4576
4577         # OBD_FAIL_SPLIT_UPDATE_REC       0x1702
4578         do_facet mds1 "lctl set_param fail_loc=0x80001702"
4579         $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4580
4581         fail mds1
4582         $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4583                 error "stried_dir does not exists"
4584 }
4585 run_test 116a "large update log master MDT recovery"
4586
4587 test_116b() {
4588         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4589         [ "$MDS1_VERSION" -lt $(version_code 2.7.55) ] &&
4590                 skip "Do not support large update log before 2.7.55" &&
4591                 return 0
4592
4593         ([ $FAILURE_MODE == "HARD" ] &&
4594                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4595                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4596                 return 0
4597         local fail_index=0
4598
4599         mkdir -p $DIR/$tdir
4600         replay_barrier mds2
4601
4602         # OBD_FAIL_SPLIT_UPDATE_REC       0x1702
4603         do_facet mds2 "lctl set_param fail_loc=0x80001702"
4604         $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
4605
4606         fail mds2
4607         $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
4608                 error "stried_dir does not exists"
4609 }
4610 run_test 116b "large update log slave MDT recovery"
4611
4612 test_117() {
4613         [ $MDSCOUNT -lt 4 ] && skip "needs >= 4 MDTs" && return 0
4614         ([ $FAILURE_MODE == "HARD" ] &&
4615                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4616                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4617                 return 0
4618         local index
4619         local mds_indexs
4620
4621         mkdir -p $DIR/$tdir
4622         $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/remote_dir
4623         $LFS setdirstripe -i1 -c$MDSCOUNT $DIR/$tdir/remote_dir_1
4624         sleep 2
4625
4626         # Let's set rdonly on all MDTs, so client will send
4627         # replay requests on all MDTs and replay these requests
4628         # at the same time. This test will verify the recovery
4629         # will not be deadlock in this case, LU-7531.
4630         for ((index = 0; index < $((MDSCOUNT)); index++)); do
4631                 replay_barrier mds$((index + 1))
4632                 if [ -z $mds_indexs ]; then
4633                         mds_indexs="${mds_indexs}mds$((index+1))"
4634                 else
4635                         mds_indexs="${mds_indexs},mds$((index+1))"
4636                 fi
4637         done
4638
4639         rm -rf $DIR/$tdir/remote_dir
4640         rm -rf $DIR/$tdir/remote_dir_1
4641
4642         fail $mds_indexs
4643
4644         rm -rf $DIR/$tdir || error "rmdir failed"
4645 }
4646 run_test 117 "DNE: cross MDT unlink, fail MDT1 and MDT2"
4647
4648 test_118() {
4649         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4650         [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4651                 skip "Do not support large update log before 2.7.64" &&
4652                 return 0
4653
4654         mkdir -p $DIR/$tdir
4655
4656         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
4657                 error "setdirstripe fails"
4658         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1 ||
4659                 error "setdirstripe fails 1"
4660         rm -rf $DIR/$tdir/striped_dir* || error "rmdir fails"
4661
4662         # OBD_FAIL_INVALIDATE_UPDATE       0x1705
4663         do_facet mds1 "lctl set_param fail_loc=0x1705"
4664         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4665         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4666         do_facet mds1 "lctl set_param fail_loc=0x0"
4667
4668         replay_barrier mds1
4669         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir
4670         $LFS setdirstripe -c2 $DIR/$tdir/striped_dir1
4671         fail mds1
4672
4673         true
4674 }
4675 run_test 118 "invalidate osp update will not cause update log corruption"
4676
4677 test_119() {
4678         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4679         [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4680                 skip "Do not support large update log before 2.7.64" &&
4681                 return 0
4682         local stripe_count
4683         local hard_timeout=$(do_facet mds1 \
4684                 "lctl get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard")
4685
4686         local clients=${CLIENTS:-$HOSTNAME}
4687         local time_min=$(recovery_time_min)
4688
4689         mkdir -p $DIR/$tdir
4690         mkdir $DIR/$tdir/tmp
4691         rmdir $DIR/$tdir/tmp
4692
4693         replay_barrier mds1
4694         mkdir $DIR/$tdir/dir_1
4695         for ((i = 0; i < 20; i++)); do
4696                 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
4697         done
4698
4699         stop mds1
4700         change_active mds1
4701         wait_for_facet mds1
4702
4703         #define OBD_FAIL_TGT_REPLAY_DELAY  0x714
4704         do_facet mds1 $LCTL set_param fail_loc=0x80000714
4705         #sleep (timeout + 5), so mds will evict the client exports,
4706         #but DNE update recovery will keep going.
4707         do_facet mds1 $LCTL set_param fail_val=$((time_min + 5))
4708
4709         mount_facet mds1 "-o recovery_time_hard=$time_min"
4710
4711         wait_clients_import_state "$clients" mds1 FULL
4712
4713         clients_up || clients_up || error "failover df: $?"
4714
4715         #revert back the hard timeout
4716         do_facet mds1 $LCTL set_param \
4717                 mdt.$FSNAME-MDT0000.recovery_time_hard=$hard_timeout
4718
4719         for ((i = 0; i < 20; i++)); do
4720                 stripe_count=$($LFS getdirstripe -c $DIR/$tdir/stripe_dir-$i)
4721                 [ $stripe_count == 2 ] || {
4722                         error "stripe_dir-$i creation replay fails"
4723                         break
4724                 }
4725         done
4726 }
4727 run_test 119 "timeout of normal replay does not cause DNE replay fails  "
4728
4729 test_120() {
4730         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4731         [ "$MDS1_VERSION" -lt $(version_code 2.7.64) ] &&
4732                 skip "Do not support large update log before 2.7.64" &&
4733                 return 0
4734
4735         mkdir $DIR/$tdir
4736         replay_barrier_nosync mds1
4737         for ((i = 0; i < 20; i++)); do
4738                 mkdir $DIR/$tdir/dir-$i || {
4739                         error "create dir-$i fails"
4740                         break
4741                 }
4742                 $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
4743                         error "create stripe_dir-$i fails"
4744                         break
4745                 }
4746         done
4747
4748         fail_abort mds1
4749
4750         for ((i = 0; i < 20; i++)); do
4751                 [ ! -e "$DIR/$tdir/dir-$i" ] || {
4752                         error "dir-$i still exists"
4753                         break
4754                 }
4755                 [ ! -e "$DIR/$tdir/stripe_dir-$i" ] || {
4756                         error "stripe_dir-$i still exists"
4757                         break
4758                 }
4759         done
4760 }
4761 run_test 120 "DNE fail abort should stop both normal and DNE replay"
4762
4763 test_121() {
4764         [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4765                 skip "Don't support it before 2.11" &&
4766                 return 0
4767
4768         local at_max_saved=$(at_max_get mds)
4769
4770         touch $DIR/$tfile || error "touch $DIR/$tfile failed"
4771         cancel_lru_locks mdc
4772
4773         multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
4774         mpid=$!
4775
4776         lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
4777
4778         stop mds1
4779         change_active mds1
4780         wait_for_facet mds1
4781
4782         #define OBD_FAIL_TGT_RECOVERY_REQ_RACE  0x721
4783         do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
4784         at_max_set 0 mds
4785
4786         mount_facet mds1
4787         wait_clients_import_state "$clients" mds1 FULL
4788         clients_up || clients_up || error "failover df: $?"
4789
4790         kill -USR1 $mpid
4791         wait $mpid || error "multiop_bg_pause pid failed"
4792
4793         do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
4794         lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
4795         at_max_set $at_max_saved mds
4796         rm -f $DIR/$tfile
4797 }
4798 run_test 121 "lock replay timed out and race"
4799
4800 test_130a() {
4801         [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4802                 skip "Do not support Data-on-MDT before 2.11"
4803
4804         replay_barrier $SINGLEMDS
4805         $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4806         fail $SINGLEMDS
4807
4808         [ $($LFS getstripe -L $DIR/$tfile) == "mdt" ] ||
4809                 error "Fail to replay DoM file creation"
4810 }
4811 run_test 130a "DoM file create (setstripe) replay"
4812
4813 test_130b() {
4814         [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4815                 skip "Do not support Data-on-MDT before 2.11"
4816
4817         mkdir $DIR/$tdir
4818         $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tdir
4819         replay_barrier $SINGLEMDS
4820         touch $DIR/$tdir/$tfile
4821         fail $SINGLEMDS
4822
4823         [ $($LFS getstripe -L $DIR/$tdir/$tfile) == "mdt" ] ||
4824                 error "Fail to replay DoM file creation"
4825 }
4826 run_test 130b "DoM file create (inherited) replay"
4827
4828 test_131a() {
4829         [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4830                 skip "Do not support Data-on-MDT before 2.11"
4831
4832         $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4833         replay_barrier $SINGLEMDS
4834         echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4835         # lock is not canceled and will be replayed
4836         fail $SINGLEMDS
4837
4838         [ $(cat $DIR/$tfile) == "dom_data" ] ||
4839                 error "Wrong file content after failover"
4840 }
4841 run_test 131a "DoM file write lock replay"
4842
4843 test_131b() {
4844         [ "$MDS1_VERSION" -lt $(version_code 2.10.90) ] &&
4845                 skip "Do not support Data-on-MDT before 2.11"
4846
4847         $LFS setstripe -E 1M -L mdt -E EOF -c 2 $DIR/$tfile
4848         replay_barrier $SINGLEMDS
4849         echo "dom_data" | dd of=$DIR/$tfile bs=8 count=1
4850         cancel_lru_locks mdc
4851
4852         fail $SINGLEMDS
4853
4854         [ $(cat $DIR/$tfile) == "dom_data" ] ||
4855                 error "Wrong file content after failover"
4856 }
4857 run_test 131b "DoM file write replay"
4858
4859 test_132a() {
4860         [ "$MDS1_VERSION" -lt $(version_code 2.12.0) ] &&
4861                 skip "Need MDS version 2.12.0 or later"
4862
4863         $LFS setstripe -E 1M -c 1 -E EOF -c 2 $DIR/$tfile
4864         replay_barrier $SINGLEMDS
4865         # write over the first component size cause next component instantiation
4866         dd if=/dev/urandom of=$DIR/$tfile bs=1M count=1 seek=1 ||
4867                 error "dd to $DIR/$tfile failed"
4868         lfs getstripe $DIR/$tfile
4869
4870         cksum=$(md5sum $DIR/$tfile | awk '{print $1}')
4871         $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4872                 error "Component #1 was not instantiated"
4873
4874         fail $SINGLEMDS
4875
4876         lfs getstripe $DIR/$tfile
4877         $LFS getstripe -I2 $DIR/$tfile | grep -q lmm_objects ||
4878                 error "Component #1 instantiation was not replayed"
4879         cksum2=$(md5sum $DIR/$tfile | awk '{print $1}')
4880         if [ $cksum != $cksum2 ] ; then
4881                 error_noexit "New cksum $cksum2 does not match original $cksum"
4882         fi
4883 }
4884 run_test 132a "PFL new component instantiate replay"
4885
4886 test_133() {
4887         [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
4888         ([ $FAILURE_MODE == "HARD" ] &&
4889                 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
4890                 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
4891                 return 0
4892
4893         local remote_dir=$DIR/$tdir/remote_dir
4894
4895         mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4896         $LFS mkdir -i 1 $remote_dir
4897
4898         umount $MOUNT
4899         do_facet mds2 $LCTL set_param seq.srv*MDT0001.space=clear
4900
4901         zconf_mount $(hostname) $MOUNT
4902         client_up || return 1
4903
4904         #define OBD_FAIL_MDS_ALL_REQUEST_NET     0x123
4905         # SEQ_QUERY                       = 700
4906         do_facet mds1 $LCTL set_param fail_val=700 fail_loc=0x80000123
4907         cp /etc/hosts $remote_dir/file &
4908         local pid=$!
4909         sleep 1
4910
4911         fail_nodf mds1
4912
4913         wait $pid || error "cp failed"
4914         rm -rf $DIR/$tdir || error "rmdir failed"
4915
4916         return 0
4917 }
4918 run_test 133 "check resend of ongoing requests for lwp during failover"
4919
4920 test_134() {
4921         [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
4922
4923         pool_add pool_134
4924         pool_add_targets pool_134 1 1
4925
4926         mkdir -p $DIR/$tdir/{A,B}
4927         $LFS setstripe -p pool_134 $DIR/$tdir/A
4928         $LFS setstripe -E EOF -p pool_134 $DIR/$tdir/B
4929
4930         replay_barrier mds1
4931
4932         touch $DIR/$tdir/A/$tfile || error "touch non-pfl file failed"
4933         touch $DIR/$tdir/B/$tfile || error "touch pfl failed"
4934
4935         fail mds1
4936
4937         [ -f $DIR/$tdir/A/$tfile ] || error "non-pfl file does not exist"
4938         [ -f $DIR/$tdir/B/$tfile ] || error "pfl file does not exist"
4939 }
4940 run_test 134 "replay creation of a file created in a pool"
4941
4942 # LU-14027
4943 test_135() {
4944         mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
4945
4946         # All files to ost1
4947         $LFS setstripe -S $((128 * 1024)) -i 0 $DIR/$tdir
4948
4949         replay_barrier ost1
4950
4951         # Create 20 files so we have 20 ost locks
4952         for i in $(seq 20) ; do
4953                 echo blah > $DIR/$tdir/file.${i}
4954         done
4955
4956         shutdown_facet ost1
4957         reboot_facet ost1
4958         change_active ost1
4959         wait_for_facet ost1
4960
4961         #define OBD_FAIL_TGT_REPLAY_RECONNECT     0x32d
4962         # Make sure lock replay server side never completes and errors out.
4963         do_facet ost1 "$LCTL set_param fail_val=20"
4964         do_facet ost1 "$LCTL set_param fail_loc=0x32d"
4965
4966         mount_facet ost1
4967
4968         # Now make sure we notice
4969         (sync;sync;sync) &
4970         local PID=$?
4971         sleep 20 # should we do something proactive to make reconnects go?
4972         kill -0 $PID || error "Unexpected sync success"
4973
4974         shutdown_facet ost1
4975         reboot_facet ost1
4976         change_active ost1
4977         wait_for_facet ost1
4978
4979         do_facet ost1 "$LCTL set_param fail_loc=0"
4980         mount_facet ost1
4981         echo blah > $DIR/$tdir/file.test2
4982
4983         rm -rf $DIR/$tdir
4984 }
4985 run_test 135 "Server failure in lock replay phase"
4986
4987 complete $SECONDS
4988 check_and_cleanup_lustre
4989 exit_status