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