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