Whamcloud - gitweb
b=24226 typo fix for sanity test 72
[fs/lustre-release.git] / lustre / tests / replay-vbr.sh
1 #!/bin/bash
2
3 set -e
4
5 # bug number: 16356
6 ALWAYS_EXCEPT="2 3c 4b 4c 10 $REPLAY_VBR_EXCEPT"
7
8 SAVE_PWD=$PWD
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 SETUP=${SETUP:-""}
12 CLEANUP=${CLEANUP:-""}
13 . $LUSTRE/tests/test-framework.sh
14
15 init_test_env $@
16
17 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18
19 [ -n "$CLIENTS" ] || { skip_env "Need two or more clients" && exit 0; }
20 [ $CLIENTCOUNT -ge 2 ] || \
21     { skip_env "Need two or more remote clients, have $CLIENTCOUNT" && exit 0; }
22 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
23
24 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
25
26
27 [ ! "$NAME" = "ncli" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
28 [ "$NAME" = "ncli" ] && MOUNT_2=""
29 MOUNT_2=""
30 build_test_filter
31
32 check_and_setup_lustre
33 rm -rf $DIR/[df][0-9]*
34
35 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
36
37 rmultiop_start() {
38     local client=$1
39     local file=$2
40     local cmds=$3
41
42     # We need to run do_node in bg, because pdsh does not exit
43     # if child process of run script exists.
44     # I.e. pdsh does not exit when runmultiop_bg_pause exited,
45     # because of multiop_bg_pause -> $MULTIOP_PROG &
46     # By the same reason we need sleep a bit after do_nodes starts
47     # to let runmultiop_bg_pause start muliop and
48     # update /tmp/multiop_bg.pid ;
49     # The rm /tmp/multiop_bg.pid guarantees here that
50     # we have the updated by runmultiop_bg_pause
51     # /tmp/multiop_bg.pid file
52
53     local pid_file=$TMP/multiop_bg.pid.$$
54     do_node $client "rm -f $pid_file && MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file $cmds" &
55     local pid=$!
56     sleep 3
57     local multiop_pid
58     multiop_pid=$(do_node $client cat $pid_file)
59     [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
60     eval export $(client_var_name $client)_multiop_pid=$multiop_pid
61     eval export $(client_var_name $client)_do_node_pid=$pid
62     local var=$(client_var_name $client)_multiop_pid
63     echo client $client multiop_bg started multiop_pid=${!var}
64     return $?
65 }
66
67 rmultiop_stop() {
68     local client=$1
69     local multiop_pid=$(client_var_name $client)_multiop_pid
70     local do_node_pid=$(client_var_name $client)_do_node_pid
71
72     echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
73     do_node $client kill -USR1 ${!multiop_pid}
74
75     wait ${!do_node_pid}
76 }
77
78 get_version() {
79     local client=$1
80     local file=$2
81     local fid
82
83     fid=$(do_node $client $LFS path2fid $file)
84     do_facet mds $LCTL --device $mds_svc getobjversion $fid
85 }
86
87 # interop 18 <-> 20
88 lustre_version=$(get_lustre_version mds)
89 if [[ $lustre_version != 1.8* ]]; then
90     mds20="yes"
91 fi
92
93 test_0a() {
94     local file=$DIR/$tfile
95     local pre
96     local post
97
98     do_node $CLIENT1 mcreate $file
99     pre=$(get_version $CLIENT1 $file)
100     do_node $CLIENT1 openfile -f O_RDWR $file
101     post=$(get_version $CLIENT1 $file)
102     if (($pre != $post)); then
103         error "version changed unexpectedly: pre $pre, post $post"
104     fi
105 }
106 run_test 0a "VBR: open and close do not change versions"
107
108 test_0b() {
109     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
110     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
111
112     replay_barrier mds
113     do_node $CLIENT2 chmod 777 $DIR/$tdir
114     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT $DIR/$tdir/$tfile
115     zconf_umount $CLIENT2 $MOUNT
116     facet_failover mds
117
118     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
119     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
120         error "open succeeded unexpectedly"
121     fi
122     zconf_mount $CLIENT2 $MOUNT
123 }
124 run_test 0b "VBR: open (O_CREAT) checks version of parent"
125
126 test_0c() {
127     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
128     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
129     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tdir/$tfile
130
131     replay_barrier mds
132     do_node $CLIENT2 chmod 777 $DIR/$tdir
133     do_node $CLIENT2 chmod 666 $DIR/$tdir/$tfile
134     rmultiop_start $CLIENT1 $DIR/$tdir/$tfile o_c
135     zconf_umount $CLIENT2 $MOUNT
136     facet_failover mds
137     client_up $CLIENT1 || error "$CLIENT1 evicted"
138
139     rmultiop_stop $CLIENT1 || error "close failed"
140     zconf_mount $CLIENT2 $MOUNT
141 }
142 run_test 0c "VBR: open (non O_CREAT) does not checks versions"
143
144 test_0d() {
145     local pre
146     local post
147
148     pre=$(get_version $CLIENT1 $DIR)
149     do_node $CLIENT1 mkfifo $DIR/$tfile
150     post=$(get_version $CLIENT1 $DIR)
151     if (($pre == $post)); then
152         [ -n "$mds20" ] || error "version not changed: pre $pre, post $post"
153     fi
154 }
155 run_test 0d "VBR: create changes version of parent"
156
157 test_0e() {
158     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
159     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
160
161     replay_barrier mds
162     do_node $CLIENT2 chmod 777 $DIR/$tdir
163     do_node $CLIENT1 mkfifo $DIR/$tdir/$tfile
164     zconf_umount $CLIENT2 $MOUNT
165     facet_failover mds
166
167     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
168     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
169         error "create succeeded unexpectedly"
170     fi
171     zconf_mount $CLIENT2 $MOUNT
172 }
173 run_test 0e "VBR: create checks version of parent"
174
175 test_0f() {
176     local pre
177     local post
178
179     do_node $CLIENT1 mcreate $DIR/$tfile
180     pre=$(get_version $CLIENT1 $DIR)
181     do_node $CLIENT1 rm $DIR/$tfile
182     post=$(get_version $CLIENT1 $DIR)
183     if (($pre == $post)); then
184         [ -n "$mds20" ] || error "version not changed: pre $pre, post $post"
185     fi
186 }
187 run_test 0f "VBR: unlink changes version of parent"
188
189 test_0g() {
190     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
191     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
192     do_node $CLIENT1 mcreate $DIR/$tdir/$tfile
193
194     replay_barrier mds
195     do_node $CLIENT2 chmod 777 $DIR/$tdir
196     do_node $CLIENT1 rm $DIR/$tdir/$tfile
197     zconf_umount $CLIENT2 $MOUNT
198     facet_failover mds
199
200     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
201     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
202         error "unlink succeeded unexpectedly"
203     fi
204     zconf_mount $CLIENT2 $MOUNT
205 }
206 run_test 0g "VBR: unlink checks version of parent"
207
208 test_0h() {
209     local file=$DIR/$tfile
210     local pre
211     local post
212
213     do_node $CLIENT1 mcreate $file
214     pre=$(get_version $CLIENT1 $file)
215     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
216     post=$(get_version $CLIENT1 $file)
217     if (($pre == $post)); then
218         error "version not changed: pre $pre, post $post"
219     fi
220 }
221 run_test 0h "VBR: setattr of UID changes versions"
222
223 test_0i() {
224     local file=$DIR/$tfile
225     local pre
226     local post
227
228     do_node $CLIENT1 mcreate $file
229     pre=$(get_version $CLIENT1 $file)
230     do_node $CLIENT1 chgrp $RUNAS_GID $file
231     post=$(get_version $CLIENT1 $file)
232     if (($pre == $post)); then
233         error "version not changed: pre $pre, post $post"
234     fi
235 }
236 run_test 0i "VBR: setattr of GID changes versions"
237
238 test_0j() {
239     local file=$DIR/$tfile
240
241     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
242     do_node $CLIENT1 mcreate $file
243
244     replay_barrier mds
245     do_node $CLIENT2 chgrp $RUNAS_GID $file
246     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
247     zconf_umount $CLIENT2 $MOUNT
248     facet_failover mds
249
250     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
251     if ! do_node $CLIENT1 $CHECKSTAT -u \\\#$UID $file; then
252         error "setattr of UID succeeded unexpectedly"
253     fi
254     zconf_mount $CLIENT2 $MOUNT
255 }
256 run_test 0j "VBR: setattr of UID checks versions"
257
258 test_0k() {
259     local file=$DIR/$tfile
260
261     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
262     do_node $CLIENT1 mcreate $file
263
264     replay_barrier mds
265     do_node $CLIENT2 chown $RUNAS_ID:$RUNAS_GID $file
266     do_node $CLIENT1 chgrp $RUNAS_GID $file
267     zconf_umount $CLIENT2 $MOUNT
268     facet_failover mds
269
270     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
271     if ! do_node $CLIENT1 $CHECKSTAT -g \\\#$UID $file; then
272         error "setattr of GID succeeded unexpectedly"
273     fi
274     zconf_mount $CLIENT2 $MOUNT
275 }
276 run_test 0k "VBR: setattr of GID checks versions"
277
278 test_0l() {
279     local file=$DIR/$tfile
280     local pre
281     local post
282
283     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
284     pre=$(get_version $CLIENT1 $file)
285     do_node $CLIENT1 chmod 666 $file
286     post=$(get_version $CLIENT1 $file)
287     if (($pre == $post)); then
288         error "version not changed: pre $pre, post $post"
289     fi
290 }
291 run_test 0l "VBR: setattr of permission changes versions"
292
293 test_0m() {
294     local file=$DIR/$tfile
295
296     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
297     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
298
299     replay_barrier mds
300     do_node $CLIENT2 chgrp $RUNAS_GID $file
301     do_node $CLIENT1 chmod 666 $file
302     zconf_umount $CLIENT2 $MOUNT
303     facet_failover mds
304
305     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
306     if ! do_node $CLIENT1 $CHECKSTAT -p 0644 $file; then
307         error "setattr of permission succeeded unexpectedly"
308     fi
309     zconf_mount $CLIENT2 $MOUNT
310 }
311 run_test 0m "VBR: setattr of permission checks versions"
312
313 test_0n() {
314     local file=$DIR/$tfile
315     local pre
316     local post
317
318     do_node $CLIENT1 mcreate $file
319     pre=$(get_version $CLIENT1 $file)
320     do_node $CLIENT1 chattr +i $file
321     post=$(get_version $CLIENT1 $file)
322     do_node $CLIENT1 chattr -i $file
323     if (($pre == $post)); then
324         error "version not changed: pre $pre, post $post"
325     fi
326 }
327 run_test 0n "VBR: setattr of flags changes versions"
328
329 checkattr() {
330     local client=$1
331     local attr=$2
332     local file=$3
333     local rc
334
335     if ((${#attr} != 1)); then
336         error "checking multiple attributes not implemented yet"
337     fi
338     do_node $client lsattr $file | cut -d ' ' -f 1 | grep -q $attr
339 }
340
341 test_0o() {
342     local file=$DIR/$tfile
343     local rc
344
345     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
346     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
347
348     replay_barrier mds
349     do_node $CLIENT2 chmod 666 $file
350     do_node $CLIENT1 chattr +i $file
351     zconf_umount $CLIENT2 $MOUNT
352     facet_failover mds
353
354     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
355     checkattr $CLIENT1 i $file
356     rc=$?
357     do_node $CLIENT1 chattr -i $file
358     if [ $rc -eq 0 ]; then
359         error "setattr of flags succeeded unexpectedly"
360     fi
361     zconf_mount $CLIENT2 $MOUNT
362 }
363 run_test 0o "VBR: setattr of flags checks versions"
364
365 test_0p() {
366     local file=$DIR/$tfile
367     local pre
368     local post
369     local ad_orig
370
371     ad_orig=$(do_facet mds "$LCTL get_param *.${mds_svc}.atime_diff")
372     do_facet mds "$LCTL set_param *.${mds_svc}.atime_diff=0"
373     do_node $CLIENT1 mcreate $file
374     pre=$(get_version $CLIENT1 $file)
375     do_node $CLIENT1 touch $file
376     post=$(get_version $CLIENT1 $file)
377     #
378     # We don't fail MDS in this test.  atime_diff shall be
379     # restored to its original value.
380     #
381     do_facet mds "$LCTL set_param $ad_orig"
382     if (($pre != $post)); then
383         error "version changed unexpectedly: pre $pre, post $post"
384     fi
385 }
386 run_test 0p "VBR: setattr of times does not change versions"
387
388 test_0q() {
389     local file=$DIR/$tfile
390     local pre
391     local post
392
393     do_node $CLIENT1 mcreate $file
394     pre=$(get_version $CLIENT1 $file)
395     do_node $CLIENT1 $TRUNCATE $file 1
396     post=$(get_version $CLIENT1 $file)
397     if (($pre != $post)); then
398         error "version changed unexpectedly: pre $pre, post $post"
399     fi
400 }
401 run_test 0q "VBR: setattr of size does not change versions"
402
403 test_0r() {
404     local file=$DIR/$tfile
405     local mtime_pre
406     local mtime_post
407     local mtime
408
409     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
410     do_facet mds "$LCTL set_param *.${mds_svc}.atime_diff=0"
411     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
412
413     replay_barrier mds
414     do_node $CLIENT2 chmod 666 $file
415     do_node $CLIENT1 $TRUNCATE $file 1
416     sleep 1
417     mtime_pre=$(do_node $CLIENT1 stat --format=%Y $file)
418     do_node $CLIENT1 touch $file
419     mtime_post=$(do_node $CLIENT1 stat --format=%Y $file)
420     zconf_umount $CLIENT2 $MOUNT
421     facet_failover mds
422
423     client_up $CLIENT1 || error "$CLIENT1 evicted"
424     if (($mtime_pre >= $mtime_post)); then
425         error "time not changed: pre $mtime_pre, post $mtime_post"
426     fi
427     if ! do_node $CLIENT1 $CHECKSTAT -s 1 $file; then
428         error "setattr of size failed"
429     fi
430     mtime=$(do_node $CLIENT1 stat --format=%Y $file)
431     if (($mtime != $mtime_post)); then
432         error "setattr of times failed: expected $mtime_post, got $mtime"
433     fi
434     zconf_mount $CLIENT2 $MOUNT
435 }
436 run_test 0r "VBR: setattr of times and size does not check versions"
437
438 test_0s() {
439     local pre
440     local post
441     local tp_pre
442     local tp_post
443
444     do_node $CLIENT1 mcreate $DIR/$tfile
445     do_node $CLIENT1 mkdir -p $DIR/$tdir
446     pre=$(get_version $CLIENT1 $DIR/$tfile)
447     tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
448     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
449     post=$(get_version $CLIENT1 $DIR/$tfile)
450     tp_post=$(get_version $CLIENT1 $DIR/$tdir)
451     if (($pre == $post)); then
452         error "version of source not changed: pre $pre, post $post"
453     fi
454     if (($tp_pre == $tp_post)); then
455         [ -n "$mds20" ] || \
456             error "version of target parent not changed: pre $tp_pre, post $tp_post"
457     fi
458 }
459 run_test 0s "VBR: link changes versions of source and target parent"
460
461 test_0t() {
462     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
463     do_node $CLIENT1 mcreate $DIR/$tfile
464     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
465
466     replay_barrier mds
467     do_node $CLIENT2 chmod 777 $DIR/$tdir
468     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
469     zconf_umount $CLIENT2 $MOUNT
470     facet_failover mds
471
472     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
473     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
474         error "link should fail"
475     fi
476     zconf_mount $CLIENT2 $MOUNT
477 }
478 run_test 0t "VBR: link checks version of target parent"
479
480 test_0u() {
481     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
482     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
483     do_node $CLIENT1 mkdir -p $DIR/$tdir
484
485     replay_barrier mds
486     do_node $CLIENT2 chmod 666 $DIR/$tfile
487     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
488     zconf_umount $CLIENT2 $MOUNT
489     facet_failover mds
490
491     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
492     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
493         error "link should fail"
494     fi
495     zconf_mount $CLIENT2 $MOUNT
496 }
497 run_test 0u "VBR: link checks version of source"
498
499 test_0v() {
500     local sp_pre
501     local tp_pre
502     local sp_post
503     local tp_post
504
505     do_node $CLIENT1 mcreate $DIR/$tfile
506     do_node $CLIENT1 mkdir -p $DIR/$tdir
507     sp_pre=$(get_version $CLIENT1 $DIR)
508     tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
509     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
510     sp_post=$(get_version $CLIENT1 $DIR)
511     tp_post=$(get_version $CLIENT1 $DIR/$tdir)
512     if (($sp_pre == $sp_post)); then
513         [ -n "$mds20" ] || \
514             error "version of source parent not changed: pre $sp_pre, post $sp_post"
515     fi
516     if (($tp_pre == $tp_post)); then
517         [ -n "$mds20" ] || \
518             error "version of target parent not changed: pre $tp_pre, post $tp_post"
519     fi
520 }
521 run_test 0v "VBR: rename changes versions of source parent and target parent"
522
523 test_0w() {
524     local pre
525     local post
526
527     do_node $CLIENT1 mcreate $DIR/$tfile
528     pre=$(get_version $CLIENT1 $DIR)
529     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tfile-new
530     post=$(get_version $CLIENT1 $DIR)
531     if (($pre == $post)); then
532         [ -n "$mds20" ] || \
533             error "version of parent not changed: pre $pre, post $post"
534     fi
535 }
536 run_test 0w "VBR: rename within same dir changes version of parent"
537
538 test_0x() {
539     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
540     do_node $CLIENT1 mcreate $DIR/$tfile
541     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
542
543     replay_barrier mds
544     do_node $CLIENT2 chmod 777 $DIR
545     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
546     zconf_umount $CLIENT2 $MOUNT
547     facet_failover mds
548
549     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
550     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
551         error "rename should fail"
552     fi
553     zconf_mount $CLIENT2 $MOUNT
554 }
555 run_test 0x "VBR: rename checks version of source parent"
556
557 test_0y() {
558     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
559     do_node $CLIENT1 mcreate $DIR/$tfile
560     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
561
562     replay_barrier mds
563     do_node $CLIENT2 chmod 777 $DIR/$tdir
564     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
565     zconf_umount $CLIENT2 $MOUNT
566     facet_failover mds
567
568     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
569     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
570         error "rename should fail"
571     fi
572     zconf_mount $CLIENT2 $MOUNT
573 }
574 run_test 0y "VBR: rename checks version of target parent"
575
576 [ "$CLIENTS" ] && zconf_umount_clients $CLIENTS $DIR
577
578 test_1() {
579     echo "mount client $CLIENT1,$CLIENT2..."
580     zconf_mount_clients $CLIENT1 $DIR
581     zconf_mount_clients $CLIENT2 $DIR
582
583     do_node $CLIENT2 mkdir -p $DIR/$tdir
584     replay_barrier mds
585     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
586     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 1
587     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
588     zconf_umount $CLIENT2 $DIR
589
590     facet_failover mds
591     # recovery shouldn't fail due to missing client 2
592     client_up $CLIENT1 || return 1
593
594     # All 50 files should have been replayed
595     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
596     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
597
598     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
599     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
600
601     zconf_umount_clients $CLIENTS $DIR
602     return 0
603 }
604 run_test 1 "VBR: client during replay doesn't affect another one"
605
606 test_2a() { # was test_2
607     #ls -al $DIR/$tdir/$tfile
608
609     zconf_mount_clients $CLIENT1 $DIR
610     zconf_mount_clients $CLIENT2 $DIR
611
612     do_node $CLIENT2 mkdir -p $DIR/$tdir
613     replay_barrier mds
614     do_node $CLIENT2 mcreate $DIR/$tdir/$tfile
615     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
616     #do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 1
617     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
618     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
619     zconf_umount $CLIENT2 $DIR
620
621     facet_failover mds
622     # recovery shouldn't fail due to missing client 2
623     client_up $CLIENT1 || return 1
624
625     # All 50 files should have been replayed
626     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
627     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
628
629     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
630
631     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
632
633     zconf_umount_clients $CLIENTS $DIR
634     return 0
635 }
636 run_test 2a "VBR: lost data due to missed REMOTE client during replay"
637
638 #
639 # This test uses three Lustre clients on two hosts.
640 #
641 #   Lustre Client 1:    $CLIENT1:$MOUNT     ($DIR)
642 #   Lustre Client 2:    $CLIENT2:$MOUNT2    ($DIR2)
643 #   Lustre Client 3:    $CLIENT2:$MOUNT1    ($DIR1)
644 #
645 test_2b() {
646     local pre
647     local post
648
649     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0"
650     zconf_mount $CLIENT1 $MOUNT
651     zconf_mount $CLIENT2 $MOUNT2
652     zconf_mount $CLIENT2 $MOUNT1
653     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-a
654     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-b
655
656     #
657     # Save an MDT transaction number before recovery.
658     #
659     pre=$(get_version $CLIENT1 $DIR/$tfile-a)
660
661     #
662     # Comments on the replay sequence state the expected result
663     # of each request.
664     #
665     #   "R"     Replayed.
666     #   "U"     Unable to replay.
667     #   "J"     Rejected.
668     #
669     replay_barrier mds
670     do_node $CLIENT1 chmod 666 $DIR/$tfile-a            # R
671     do_node $CLIENT2 chmod 666 $DIR1/$tfile-b           # R
672     do_node $CLIENT2 chgrp $RUNAS_GID $DIR2/$tfile-a    # U
673     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-a      # J
674     do_node $CLIENT2 $TRUNCATE $DIR2/$tfile-b 1          # U
675     do_node $CLIENT2 chgrp $RUNAS_GID $DIR1/$tfile-b    # R
676     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-b      # R
677     zconf_umount $CLIENT2 $MOUNT2
678     facet_failover mds
679
680     client_evicted $CLIENT1 || error "$CLIENT1:$MOUNT not evicted"
681     client_up $CLIENT2 || error "$CLIENT2:$MOUNT1 evicted"
682
683     #
684     # Check the MDT epoch.  $post must be the first transaction
685     # number assigned after recovery.
686     #
687     do_node $CLIENT2 touch $DIR1/$tfile
688     post=$(get_version $CLIENT2 $DIR1/$tfile)
689     if (($(($pre >> 32)) == $((post >> 32)))); then
690         error "epoch not changed: pre $pre, post $post"
691     fi
692     if (($(($post & 0x00000000ffffffff)) != 1)); then
693         error "transno should restart from one: got $post"
694     fi
695
696     do_node $CLIENT2 stat $DIR1/$tfile-a
697     do_node $CLIENT2 stat $DIR1/$tfile-b
698
699     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
700             $DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
701     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_GID \
702             $DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
703
704     zconf_umount $CLIENT2 $MOUNT1
705     zconf_umount $CLIENT1 $MOUNT
706 }
707 run_test 2b "VBR: 3 clients: some, none, and all reqs replayed"
708
709 test_3a() {
710     zconf_mount_clients $CLIENT1 $DIR
711     zconf_mount_clients $CLIENT2 $DIR
712
713     #make sure the time will change
714     do_facet mds "$LCTL set_param *.${mds_svc}.atime_diff=0" || return
715     do_node $CLIENT1 touch $DIR/$tfile
716     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
717     sleep 1
718     replay_barrier mds
719     #change time
720     do_node $CLIENT2 touch $DIR/$tfile
721     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
722     #another change
723     do_node $CLIENT1 touch $DIR/$tfile
724     #remove file
725     do_node $CLIENT2 rm $DIR/$tfile
726     zconf_umount $CLIENT2 $DIR
727
728     facet_failover mds
729     # recovery shouldn't fail due to missing client 2
730     client_up $CLIENT1 || return 1
731     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile && return 2
732
733     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
734
735     zconf_umount_clients $CLIENTS $DIR
736
737     return 0
738 }
739 run_test 3a "VBR: setattr of time/size doesn't change version"
740
741 test_3b() {
742     zconf_mount_clients $CLIENT1 $DIR
743     zconf_mount_clients $CLIENT2 $DIR
744
745     #make sure the time will change
746     do_facet mds "$LCTL set_param *.${mds_svc}.atime_diff=0" || return
747     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=0" || return
748     do_node $CLIENT1 touch $DIR/$tfile
749     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
750     sleep 1
751     replay_barrier mds
752     #change mode
753     do_node $CLIENT2 chmod +x $DIR/$tfile
754     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
755     #abother chmod
756     do_node $CLIENT1 chmod -x $DIR/$tfile
757     zconf_umount $CLIENT2 $DIR
758
759     facet_failover mds
760     # recovery should fail due to missing client 2
761     client_evicted $CLIENT1 || return 1
762
763     do_node $CLIENT1 $CHECKSTAT -p 0755 $DIR/$tfile && return 2
764     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
765
766     zconf_umount_clients $CLIENTS $DIR
767
768     return 0
769 }
770 run_test 3b "VBR: setattr of permissions changes version"
771
772 test_3c() {
773     [ "$FAILURE_MODE" = HARD ] || \
774         { skip "The HARD failure is needed" && return 0; }
775
776     [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
777
778     zconf_mount_clients $CLIENT1 $DIR
779     zconf_mount_clients $CLIENT2 $DIR
780
781     # check that permission changes are synced
782     do_facet mds "$LCTL set_param *.${mds_svc}.sync_permission=1"
783
784     do_node $CLIENT1 mkdir -p $DIR/d3c/sub || error
785     #chown -R $RUNAS_ID $MOUNT1/d3
786     do_node $CLIENT1 ls -la $DIR/d3c
787
788     # only HARD failure will work as we use sync operation
789     replay_barrier mds
790     do_node $CLIENT2 mcreate $DIR/d3c/$tfile-2
791     #set permissions
792     do_node $CLIENT1 chmod 0700 $UID $DIR/d3c
793     #secret file
794     do_node $CLIENT1 mcreate $DIR/d3c/sub/$tfile
795     do_node $CLIENT1 echo "Top Secret" > $DIR/d3c/sub/$tfile
796     #check user can't access new file
797     do_node $CLIENT2 $RUNAS ls $DIR/d3c && return 3
798     do_node $CLIENT1 $RUNAS ls $DIR/d3c && return 4
799     do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 5
800
801     zconf_umount $CLIENT2 $DIR
802
803     facet_failover mds
804     # recovery shouldn't fail due to missing client 2
805     client_up $CLIENT1 || return 1
806
807     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
808     do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 6
809     do_node $CLIENT2 $RUNAS cat $DIR/d3c/sub/$tfile && return 7
810     do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=0"
811
812     return 0
813 }
814 run_test 3c "VBR: permission dependency failure"
815
816 vbr_deactivate_client() {
817     local client=$1
818     echo "Deactivating client $client";
819     do_node $client "sysctl -w lustre.fail_loc=0x50d"
820 }
821
822 vbr_activate_client() {
823     local client=$1
824     echo "Activating client $client";
825     do_node $client "sysctl -w lustre.fail_loc=0x0"
826 }
827
828 remote_server ()
829 {
830     local client=$1
831     [ -z "$(do_node $client lctl dl | grep mdt)" ] && \
832     [ -z "$(do_node $client lctl dl | grep ost)" ]
833 }
834
835 test_4a() {
836     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
837
838     remote_server $CLIENT2 || \
839         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
840
841     zconf_mount_clients $CLIENT1 $DIR
842     zconf_mount_clients $CLIENT2 $DIR
843
844     do_node $CLIENT2 mkdir -p $DIR/$tdir
845     replay_barrier mds
846     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
847     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
848     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
849     vbr_deactivate_client $CLIENT2
850
851     facet_failover mds
852     client_up $CLIENT1 || return 1
853
854     # All 50 files should have been replayed
855     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
856     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
857
858     vbr_activate_client $CLIENT2
859     client_up $CLIENT2 || return 4
860     # All 25 files from client2 should have been replayed
861     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
862
863     zconf_umount_clients $CLIENTS $DIR
864     return 0
865 }
866 run_test 4a "fail MDS, delayed recovery"
867
868 test_4b() {
869     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
870
871     remote_server $CLIENT2 || \
872         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
873
874     zconf_mount_clients $CLIENT1 $DIR
875     zconf_mount_clients $CLIENT2 $DIR
876
877     replay_barrier mds
878     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
879     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
880     vbr_deactivate_client $CLIENT2
881
882     facet_failover mds
883     client_up $CLIENT1 || return 1
884
885     # create another set of files
886     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
887
888     vbr_activate_client $CLIENT2
889     client_up $CLIENT2 || return 2
890
891     # All files from should have been replayed
892     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
893     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
894     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
895
896     zconf_umount_clients $CLIENTS $DIR
897 }
898 run_test 4b "fail MDS, normal operation, delayed open recovery"
899
900 test_4c() {
901     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
902
903     remote_server $CLIENT2 || \
904         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
905
906     zconf_mount_clients $CLIENT1 $DIR
907     zconf_mount_clients $CLIENT2 $DIR
908
909     replay_barrier mds
910     do_node $CLIENT1 createmany -m $DIR/$tfile- 25
911     do_node $CLIENT2 createmany -m $DIR/$tdir/$tfile-2- 25
912     vbr_deactivate_client $CLIENT2
913
914     facet_failover mds
915     client_up $CLIENT1 || return 1
916
917     # create another set of files
918     do_node $CLIENT1 createmany -m $DIR/$tfile-3- 25
919
920     vbr_activate_client $CLIENT2
921     client_up $CLIENT2 || return 2
922
923     # All files from should have been replayed
924     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
925     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
926     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
927
928     zconf_umount_clients $CLIENTS $DIR
929 }
930 run_test 4c "fail MDS, normal operation, delayed recovery"
931
932 test_5a() {
933     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
934
935     remote_server $CLIENT2 || \
936         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
937
938     zconf_mount_clients $CLIENT1 $DIR
939     zconf_mount_clients $CLIENT2 $DIR
940
941     replay_barrier mds
942     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
943     do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
944     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 1
945     vbr_deactivate_client $CLIENT2
946
947     facet_failover mds
948     client_evicted $CLIENT1 || return 1
949
950     vbr_activate_client $CLIENT2
951     client_up $CLIENT2 || return 2
952
953     # First 25 files should have been replayed
954     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
955     # Third file is failed due to missed client2
956     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-3-0 && error "$tfile-3-0 exists"
957     # file from client2 should exists
958     do_node $CLIENT2 unlinkmany $DIR/$tfile-2- 1 || return 4
959
960     zconf_umount_clients $CLIENTS $DIR
961 }
962 run_test 5a "fail MDS, delayed recovery should fail"
963
964 test_5b() {
965     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
966
967     remote_server $CLIENT2 || \
968         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
969
970     zconf_mount_clients $CLIENT1 $DIR
971     zconf_mount_clients $CLIENT2 $DIR
972
973     replay_barrier mds
974     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
975     do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
976     vbr_deactivate_client $CLIENT2
977
978     facet_failover mds
979     client_up $CLIENT1 || return 1
980     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
981
982     # create another set of files
983     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
984
985     vbr_activate_client $CLIENT2
986     client_evicted $CLIENT2 || return 4
987     # file from client2 should fail
988     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
989
990     # All 50 files from client 1 should have been replayed
991     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
992     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
993
994     zconf_umount_clients $CLIENTS $DIR
995 }
996 run_test 5b "fail MDS, normal operation, delayed recovery should fail"
997
998 test_6a() {
999     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1000
1001     remote_server $CLIENT2 || \
1002         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1003
1004     zconf_mount_clients $CLIENT1 $DIR
1005     zconf_mount_clients $CLIENT2 $DIR
1006
1007     do_node $CLIENT2 mkdir -p $DIR/$tdir
1008     replay_barrier mds
1009     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1010     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
1011     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1012     vbr_deactivate_client $CLIENT2
1013
1014     facet_failover mds
1015     # replay only 5 requests
1016     do_node $CLIENT2 "sysctl -w lustre.fail_val=5"
1017 #define OBD_FAIL_PTLRPC_REPLAY        0x50e
1018     do_node $CLIENT2 "sysctl -w lustre.fail_loc=0x2000050e"
1019     client_up $CLIENT2
1020     # vbr_activate_client $CLIENT2
1021     # need way to know that client stops replays
1022     sleep 5
1023
1024     facet_failover mds
1025     client_up $CLIENT1 || return 1
1026
1027     # All files should have been replayed
1028     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1029     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1030     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
1031
1032     zconf_umount_clients $CLIENTS $DIR
1033     return 0
1034 }
1035 run_test 6a "fail MDS, delayed recovery, fail MDS"
1036
1037 test_7a() {
1038     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1039
1040     remote_server $CLIENT2 || \
1041         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1042
1043     zconf_mount_clients $CLIENT1 $DIR
1044     zconf_mount_clients $CLIENT2 $DIR
1045
1046     do_node $CLIENT2 mkdir -p $DIR/$tdir
1047     replay_barrier mds
1048     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1049     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
1050     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1051     vbr_deactivate_client $CLIENT2
1052
1053     facet_failover mds
1054     vbr_activate_client $CLIENT2
1055     client_up $CLIENT2 || return 4
1056
1057     facet_failover mds
1058     client_up $CLIENT1 || return 1
1059
1060     # All files should have been replayed
1061     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1062     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1063     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
1064
1065     zconf_umount_clients $CLIENTS $DIR
1066     return 0
1067 }
1068 run_test 7a "fail MDS, delayed recovery, fail MDS"
1069
1070 test_8a() {
1071     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1072
1073     remote_server $CLIENT2 || \
1074         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1075
1076     zconf_mount_clients $CLIENT1 $DIR
1077     zconf_mount_clients $CLIENT2 $DIR
1078
1079     rmultiop_start $CLIENT2 $DIR/$tfile O_tSc || return 1
1080     do_node $CLIENT2 rm -f $DIR/$tfile
1081     replay_barrier mds
1082     rmultiop_stop $CLIENT2 || return 2
1083
1084     vbr_deactivate_client $CLIENT2
1085     facet_failover mds
1086     client_up $CLIENT1 || return 3
1087     #client1 is back and will try to open orphan
1088     vbr_activate_client $CLIENT2
1089     client_up $CLIENT2 || return 4
1090
1091     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
1092     zconf_umount_clients $CLIENTS $DIR
1093     return 0
1094 }
1095 run_test 8a "orphans are kept until delayed recovery"
1096
1097 test_8b() {
1098     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1099
1100     remote_server $CLIENT2 || \
1101         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1102
1103     zconf_mount_clients $CLIENT1 $DIR
1104     zconf_mount_clients $CLIENT2 $DIR
1105
1106     rmultiop_start $CLIENT2 $DIR/$tfile O_tSc || return 1
1107     replay_barrier mds
1108     do_node $CLIENT1 rm -f $DIR/$tfile
1109
1110     vbr_deactivate_client $CLIENT2
1111     facet_failover mds
1112     client_up $CLIENT1 || return 2
1113     #client1 is back and will try to open orphan
1114     vbr_activate_client $CLIENT2
1115     client_up $CLIENT2 || return 3
1116
1117     rmultiop_stop $CLIENT2 || return 1
1118     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
1119     zconf_umount_clients $CLIENTS $DIR
1120     return 0
1121 }
1122 run_test 8b "open1 | unlink2 X delayed_replay1, close1"
1123
1124 test_8c() {
1125     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1126
1127     remote_server $CLIENT2 || \
1128         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1129
1130     zconf_mount_clients $CLIENT1 $DIR
1131     zconf_mount_clients $CLIENT2 $DIR
1132
1133     rmultiop_start $CLIENT2 $DIR/$tfile O_tSc || return 1
1134     replay_barrier mds
1135     do_node $CLIENT1 rm -f $DIR/$tfile
1136     rmultiop_stop $CLIENT2 || return 2
1137
1138     vbr_deactivate_client $CLIENT2
1139     facet_failover mds
1140     client_up $CLIENT1 || return 3
1141     #client1 is back and will try to open orphan
1142     vbr_activate_client $CLIENT2
1143     client_up $CLIENT2 || return 4
1144
1145     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
1146     zconf_umount_clients $CLIENTS $DIR
1147     return 0
1148 }
1149 run_test 8c "open1 | unlink2, close1 X delayed_replay1"
1150
1151 test_8d() {
1152     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1153
1154     remote_server $CLIENT2 || \
1155         { skip_env "Client $CLIENT2 is on the server node" && return 0; }
1156
1157     zconf_mount_clients $CLIENT1 $DIR
1158     zconf_mount_clients $CLIENT2 $DIR
1159
1160     rmultiop_start $CLIENT1 $DIR/$tfile O_tSc || return 1
1161     rmultiop_start $CLIENT2 $DIR/$tfile O_tSc || return 2
1162     replay_barrier mds
1163     do_node $CLIENT1 rm -f $DIR/$tfile
1164     rmultiop_stop $CLIENT2 || return 3
1165     rmultiop_stop $CLIENT1 || return 4
1166
1167     vbr_deactivate_client $CLIENT2
1168     facet_failover mds
1169     client_up $CLIENT1 || return 6
1170
1171     #client1 is back and will try to open orphan
1172     vbr_activate_client $CLIENT2
1173     client_up $CLIENT2 || return 8
1174
1175     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
1176     zconf_umount_clients $CLIENTS $DIR
1177     return 0
1178 }
1179 run_test 8d "open1, open2 | unlink2, close1, close2 X delayed_replay1"
1180
1181 test_8e() {
1182     zconf_mount $CLIENT1 $DIR
1183     zconf_mount $CLIENT2 $DIR
1184
1185     do_node $CLIENT1 mcreate $DIR/$tfile
1186     do_node $CLIENT1 mkdir $DIR/$tfile-2
1187     replay_barrier mds
1188     # missed replay from client1 will lead to recovery by versions
1189     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
1190     do_node $CLIENT2 rm $DIR/$tfile || return 1
1191     do_node $CLIENT2 touch $DIR/$tfile || return 2
1192
1193     zconf_umount $CLIENT1 $DIR
1194     facet_failover mds
1195     client_up $CLIENT2 || return 6
1196
1197     do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
1198     zconf_umount_clients $CLIENTS $DIR
1199     return 0
1200 }
1201 run_test 8e "create | unlink, create shouldn't fail"
1202
1203 test_8f() {
1204     zconf_mount_clients $CLIENT1 $DIR
1205     zconf_mount_clients $CLIENT2 $DIR
1206
1207     do_node $CLIENT1 touch $DIR/$tfile
1208     do_node $CLIENT1 mkdir $DIR/$tfile-2
1209     replay_barrier mds
1210     # missed replay from client1 will lead to recovery by versions
1211     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
1212     do_node $CLIENT2 rm -f $DIR/$tfile || return 1
1213     do_node $CLIENT2 mcreate $DIR/$tfile || return 2
1214
1215     zconf_umount $CLIENT1 $DIR
1216     facet_failover mds
1217     client_up $CLIENT2 || return 6
1218
1219     do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
1220     zconf_umount $CLIENT2 $DIR
1221     return 0
1222 }
1223 run_test 8f "create | unlink, create shouldn't fail"
1224
1225 test_8g() {
1226     zconf_mount_clients $CLIENT1 $DIR
1227     zconf_mount_clients $CLIENT2 $DIR
1228
1229     do_node $CLIENT1 touch $DIR/$tfile
1230     do_node $CLIENT1 mkdir $DIR/$tfile-2
1231     replay_barrier mds
1232     # missed replay from client1 will lead to recovery by versions
1233     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
1234     do_node $CLIENT2 rm -f $DIR/$tfile || return 1
1235     do_node $CLIENT2 mkdir $DIR/$tfile || return 2
1236
1237     zconf_umount $CLIENT1 $DIR
1238     facet_failover mds
1239     do_node $CLIENT2 df $DIR || return 6
1240
1241     do_node $CLIENT2 rmdir $DIR/$tfile || error "$tfile doesn't exists"
1242     zconf_umount $CLIENT2 $DIR
1243     return 0
1244 }
1245 run_test 8g "create | unlink, create shouldn't fail"
1246
1247 test_10 () {
1248     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1249
1250     [ -z "$DBENCH_LIB" ] && skip_env "DBENCH_LIB is not set" && return 0
1251
1252     zconf_mount_clients $CLIENTS $DIR
1253
1254     local duration="-t 60"
1255     local cmd="rundbench 1 $duration "
1256     local PID=""
1257     for CLIENT in ${CLIENTS//,/ }; do
1258         $PDSH $CLIENT "set -x; PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:${DBENCH_LIB} DBENCH_LIB=${DBENCH_LIB} $cmd" &
1259         PID=$!
1260         echo $PID >pid.$CLIENT
1261         echo "Started load PID=`cat pid.$CLIENT`"
1262     done
1263
1264     replay_barrier mds
1265     sleep 3 # give clients a time to do operations
1266
1267     vbr_deactivate_client $CLIENT2
1268
1269     log "$TESTNAME fail mds 1"
1270     fail mds
1271
1272 # wait for client to reconnect to MDS
1273     sleep $TIMEOUT
1274
1275     vbr_activate_client $CLIENT2
1276     client_up $CLIENT2 || return 4
1277
1278     for CLIENT in ${CLIENTS//,/ }; do
1279         PID=`cat pid.$CLIENT`
1280         wait $PID
1281         rc=$?
1282         echo "load on ${CLIENT} returned $rc"
1283     done
1284
1285     zconf_umount_clients $CLIENTS $DIR
1286 }
1287 run_test 10 "mds version recovery; $CLIENTCOUNT clients"
1288
1289 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
1290
1291 equals_msg `basename $0`: test complete, cleaning up
1292 #SLEEP=$((`date +%s` - $NOW))
1293 #[ $SLEEP -lt $TIMEOUT ] && sleep $SLEEP
1294 check_and_cleanup_lustre
1295 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true