Whamcloud - gitweb
f4ffeb35297c03dbc318a1ffe9def917044f800a
[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 [ "$CLIENTS" ] && zconf_umount_clients $CLIENTS $DIR
38
39 test_1() {
40     echo "mount client $CLIENT1,$CLIENT2..."
41     zconf_mount_clients $CLIENT1 $DIR
42     zconf_mount_clients $CLIENT2 $DIR
43
44     do_node $CLIENT2 mkdir -p $DIR/$tdir
45     replay_barrier mds
46     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
47     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 1
48     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
49     zconf_umount $CLIENT2 $DIR
50
51     facet_failover mds
52     # recovery shouldn't fail due to missing client 2
53     do_node $CLIENT1 df $DIR || return 1
54
55     # All 50 files should have been replayed
56     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
57     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
58
59     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
60     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
61
62     zconf_umount_clients $CLIENTS $DIR
63     return 0
64 }
65 run_test 1 "VBR: client during replay doesn't affect another one"
66
67 test_2() {
68     #ls -al $DIR/$tdir/$tfile
69
70     zconf_mount_clients $CLIENT1 $DIR
71     zconf_mount_clients $CLIENT2 $DIR
72
73     do_node $CLIENT2 mkdir -p $DIR/$tdir
74     replay_barrier mds
75     do_node $CLIENT2 mcreate $DIR/$tdir/$tfile
76     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
77     #do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 1
78     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
79     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
80     zconf_umount $CLIENT2 $DIR
81
82     facet_failover mds
83     # recovery shouldn't fail due to missing client 2
84     do_node $CLIENT1 df $DIR || return 1
85
86     # All 50 files should have been replayed
87     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
88     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
89
90     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
91
92     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
93
94     zconf_umount_clients $CLIENTS $DIR
95     return 0
96 }
97 run_test 2 "VBR: lost data due to missed REMOTE client during replay"
98
99 test_3a() {
100     zconf_mount_clients $CLIENT1 $DIR
101     zconf_mount_clients $CLIENT2 $DIR
102
103     #make sure the time will change
104     do_facet mds "$LCTL set_param mds.${mds_svc}.atime_diff=0" || return
105     do_node $CLIENT1 touch $DIR/$tfile
106     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
107     sleep 1
108     replay_barrier mds
109     #change time
110     do_node $CLIENT2 touch $DIR/$tfile
111     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
112     #another change
113     do_node $CLIENT1 touch $DIR/$tfile
114     #remove file
115     do_node $CLIENT2 rm $DIR/$tfile
116     zconf_umount $CLIENT2 $DIR
117
118     facet_failover mds
119     # recovery shouldn't fail due to missing client 2
120     do_node $CLIENT1 df $DIR || return 1
121     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile && return 2
122
123     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
124
125     zconf_umount_clients $CLIENTS $DIR
126
127     return 0
128 }
129 run_test 3a "VBR: setattr of time/size doesn't change version"
130
131 test_3b() {
132     zconf_mount_clients $CLIENT1 $DIR
133     zconf_mount_clients $CLIENT2 $DIR
134
135     #make sure the time will change
136     do_facet mds "$LCTL set_param mds.${mds_svc}.atime_diff=0" || return
137     do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=0" || return
138     do_node $CLIENT1 touch $DIR/$tfile
139     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
140     sleep 1
141     replay_barrier mds
142     #change mode
143     do_node $CLIENT2 chmod +x $DIR/$tfile
144     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile
145     #abother chmod
146     do_node $CLIENT1 chmod -x $DIR/$tfile
147     zconf_umount $CLIENT2 $DIR
148
149     facet_failover mds
150     # recovery should fail due to missing client 2
151     do_node $CLIENT1 df $DIR && return 1
152
153     do_node $CLIENT1 $CHECKSTAT -p 755 $DIR/$tfile && return 2
154     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
155
156     zconf_umount_clients $CLIENTS $DIR
157
158     return 0
159 }
160 run_test 3b "VBR: setattr of permissions changes version"
161
162 test_3c() {
163     [ "$FAILURE_MODE" = HARD ] || \
164         { skip "The HARD failure is needed" && return 0; }
165
166     [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
167
168     zconf_mount_clients $CLIENT1 $DIR
169     zconf_mount_clients $CLIENT2 $DIR
170
171     # check that permission changes are synced
172     do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=1"
173
174     do_node $CLIENT1 mkdir -p $DIR/d3c/sub || error
175     #chown -R $RUNAS_ID $MOUNT1/d3
176     do_node $CLIENT1 ls -la $DIR/d3c
177
178     # only HARD failure will work as we use sync operation
179     replay_barrier mds
180     do_node $CLIENT2 mcreate $DIR/d3c/$tfile-2
181     #set permissions
182     do_node $CLIENT1 chmod 0700 $UID $DIR/d3c
183     #secret file
184     do_node $CLIENT1 mcreate $DIR/d3c/sub/$tfile
185     do_node $CLIENT1 echo "Top Secret" > $DIR/d3c/sub/$tfile
186     #check user can't access new file
187     do_node $CLIENT2 $RUNAS ls $DIR/d3c && return 3
188     do_node $CLIENT1 $RUNAS ls $DIR/d3c && return 4
189     do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 5
190
191     zconf_umount $CLIENT2 $DIR
192
193     facet_failover mds
194     # recovery shouldn't fail due to missing client 2
195     do_node $CLIENT1 df $DIR || return 1
196     sleep 1
197
198     zconf_mount $CLIENT2 $DIR || error "mount $CLIENT2 $DIR fail"
199     do_node $CLIENT1 $RUNAS cat $DIR/d3c/sub/$tfile && return 6
200     do_node $CLIENT2 $RUNAS cat $DIR/d3c/sub/$tfile && return 7
201     do_facet mds "$LCTL set_param mds.${mds_svc}.sync_permission=0"
202
203     return 0
204 }
205 run_test 3c "VBR: permission dependency failure"
206
207 vbr_deactivate_client() {
208     local client=$1
209     echo "Deactivating client $client";
210     do_node $client "sysctl -w lustre.fail_loc=0x50d"
211 }
212
213 vbr_activate_client() {
214     local client=$1
215     echo "Activating client $client";
216     do_node $client "sysctl -w lustre.fail_loc=0x0"
217 }
218
219 remote_server ()
220 {
221     local client=$1
222     [ -z "$(do_node $client lctl dl | grep mdt)" ] && \
223     [ -z "$(do_node $client lctl dl | grep ost)" ]
224 }
225
226 test_4a() {
227     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
228
229     remote_server $CLIENT2 || \
230         { skip "Client $CLIENT2 is on the server node" && return 0; }
231
232     zconf_mount_clients $CLIENT1 $DIR
233     zconf_mount_clients $CLIENT2 $DIR
234
235     do_node $CLIENT2 mkdir -p $DIR/$tdir
236     replay_barrier mds
237     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
238     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
239     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
240     vbr_deactivate_client $CLIENT2
241
242     facet_failover mds
243     do_node $CLIENT1 df $DIR || return 1
244
245     # All 50 files should have been replayed
246     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
247     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
248
249     vbr_activate_client $CLIENT2
250     do_node $CLIENT2 df $DIR || return 4
251     # All 25 files from client2 should have been replayed
252     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
253
254     zconf_umount_clients $CLIENTS $DIR
255     return 0
256 }
257 run_test 4a "fail MDS, delayed recovery"
258
259 test_4b() {
260     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
261
262     remote_server $CLIENT2 || \
263         { skip "Client $CLIENT2 is on the server node" && return 0; }
264
265     zconf_mount_clients $CLIENT1 $DIR
266     zconf_mount_clients $CLIENT2 $DIR
267
268     replay_barrier mds
269     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
270     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
271     vbr_deactivate_client $CLIENT2
272
273     facet_failover mds
274     do_node $CLIENT1 df $DIR || return 1
275
276     # create another set of files
277     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
278
279     vbr_activate_client $CLIENT2
280     do_node $CLIENT2 df $DIR || return 2
281
282     # All files from should have been replayed
283     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
284     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
285     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
286
287     zconf_umount_clients $CLIENTS $DIR
288 }
289 run_test 4b "fail MDS, normal operation, delayed open recovery"
290
291 test_4c() {
292     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
293
294     remote_server $CLIENT2 || \
295         { skip "Client $CLIENT2 is on the server node" && return 0; }
296
297     zconf_mount_clients $CLIENT1 $DIR
298     zconf_mount_clients $CLIENT2 $DIR
299
300     replay_barrier mds
301     do_node $CLIENT1 createmany -m $DIR/$tfile- 25
302     do_node $CLIENT2 createmany -m $DIR/$tdir/$tfile-2- 25
303     vbr_deactivate_client $CLIENT2
304
305     facet_failover mds
306     do_node $CLIENT1 df $DIR || return 1
307
308     # create another set of files
309     do_node $CLIENT1 createmany -m $DIR/$tfile-3- 25
310
311     vbr_activate_client $CLIENT2
312     do_node $CLIENT2 df $DIR || return 2
313
314     # All files from should have been replayed
315     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
316     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 4
317     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
318
319     zconf_umount_clients $CLIENTS $DIR
320 }
321 run_test 4c "fail MDS, normal operation, delayed recovery"
322
323 test_5a() {
324     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
325
326     remote_server $CLIENT2 || \
327         { skip "Client $CLIENT2 is on the server node" && return 0; }
328
329     zconf_mount_clients $CLIENT1 $DIR
330     zconf_mount_clients $CLIENT2 $DIR
331
332     replay_barrier mds
333     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
334     do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
335     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 1
336     vbr_deactivate_client $CLIENT2
337
338     facet_failover mds
339     do_node $CLIENT1 df $DIR && return 1
340
341     vbr_activate_client $CLIENT2
342     do_node $CLIENT2 df $DIR || return 2
343
344     # First 25 files should have been replayed
345     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 3
346     # Third file is failed due to missed client2
347     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-3-0 && error "$tfile-3-0 exists"
348     # file from client2 should exists
349     do_node $CLIENT2 unlinkmany $DIR/$tfile-2- 1 || return 4
350
351     zconf_umount_clients $CLIENTS $DIR
352 }
353 run_test 5a "fail MDS, delayed recovery should fail"
354
355 test_5b() {
356     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
357
358     remote_server $CLIENT2 || \
359         { skip "Client $CLIENT2 is on the server node" && return 0; }
360
361     zconf_mount_clients $CLIENT1 $DIR
362     zconf_mount_clients $CLIENT2 $DIR
363
364     replay_barrier mds
365     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
366     do_node $CLIENT2 createmany -o $DIR/$tfile-2- 1
367     vbr_deactivate_client $CLIENT2
368
369     facet_failover mds
370     do_node $CLIENT1 df $DIR || return 1
371     do_node $CLIENT1 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
372
373     # create another set of files
374     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
375
376     vbr_activate_client $CLIENT2
377     do_node $CLIENT2 df $DIR && return 4
378     # file from client2 should fail
379     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile-2-0 && error "$tfile-2-0 exists"
380
381     # All 50 files from client 1 should have been replayed
382     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
383     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
384
385     zconf_umount_clients $CLIENTS $DIR
386 }
387 run_test 5b "fail MDS, normal operation, delayed recovery should fail"
388
389 test_6a() {
390     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
391
392     remote_server $CLIENT2 || \
393         { skip "Client $CLIENT2 is on the server node" && return 0; }
394
395     zconf_mount_clients $CLIENT1 $DIR
396     zconf_mount_clients $CLIENT2 $DIR
397
398     do_node $CLIENT2 mkdir -p $DIR/$tdir
399     replay_barrier mds
400     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
401     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
402     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
403     vbr_deactivate_client $CLIENT2
404
405     facet_failover mds
406     # replay only 5 requests
407     do_node $CLIENT2 "sysctl -w lustre.fail_val=5"
408 #define OBD_FAIL_PTLRPC_REPLAY        0x50e
409     do_node $CLIENT2 "sysctl -w lustre.fail_loc=0x2000050e"
410     do_node $CLIENT2 df $DIR
411     # vbr_activate_client $CLIENT2
412     # need way to know that client stops replays
413     sleep 5
414
415     facet_failover mds
416     do_node $CLIENT1 df $DIR || return 1
417
418     # All files should have been replayed
419     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
420     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
421     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
422
423     zconf_umount_clients $CLIENTS $DIR
424     return 0
425 }
426 run_test 6a "fail MDS, delayed recovery, fail MDS"
427
428 test_7a() {
429     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
430
431     remote_server $CLIENT2 || \
432         { skip "Client $CLIENT2 is on the server node" && return 0; }
433
434     zconf_mount_clients $CLIENT1 $DIR
435     zconf_mount_clients $CLIENT2 $DIR
436
437     do_node $CLIENT2 mkdir -p $DIR/$tdir
438     replay_barrier mds
439     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
440     do_node $CLIENT2 createmany -o $DIR/$tdir/$tfile-2- 25
441     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
442     vbr_deactivate_client $CLIENT2
443
444     facet_failover mds
445     vbr_activate_client $CLIENT2
446     do_node $CLIENT2 df $DIR || return 4
447
448     facet_failover mds
449     do_node $CLIENT1 df $DIR || return 1
450
451     # All files should have been replayed
452     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
453     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
454     do_node $CLIENT2 unlinkmany $DIR/$tdir/$tfile-2- 25 || return 5
455
456     zconf_umount_clients $CLIENTS $DIR
457     return 0
458 }
459 run_test 7a "fail MDS, delayed recovery, fail MDS"
460
461 rmultiop_start() {
462     local client=$1
463     local file=$2
464
465     # We need to run do_node in bg, because pdsh does not exit
466     # if child process of run script exists.
467     # I.e. pdsh does not exit when runmultiop_bg_pause exited,
468     # because of multiop_bg_pause -> $MULTIOP_PROG &
469     # By the same reason we need sleep a bit after do_nodes starts 
470     # to let runmultiop_bg_pause start muliop and
471     # update /tmp/multiop_bg.pid ;
472     # The rm /tmp/multiop_bg.pid guarantees here that 
473     # we have the updated by runmultiop_bg_pause
474     # /tmp/multiop_bg.pid file
475
476     local pid_file=$TMP/multiop_bg.pid.$$
477     do_node $client "rm -f $pid_file && MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file O_tSc" & 
478     local pid=$!
479     sleep 3
480     local multiop_pid
481     multiop_pid=$(do_node $client cat $pid_file)
482     [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
483     eval export ${client}_multiop_pid=$multiop_pid
484     eval export ${client}_do_node_pid=$pid
485     local var=${client}_multiop_pid
486     echo client $client multiop_bg started multiop_pid=${!var}
487     return $?
488 }
489
490 rmultiop_stop() {
491     local client=$1
492     local multiop_pid=${client}_multiop_pid
493     local do_node_pid=${client}_do_node_pid
494
495     echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
496     do_node $client kill -USR1 ${!multiop_pid}
497
498     wait ${!do_node_pid} || true
499 }
500
501 test_8a() {
502     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
503
504     remote_server $CLIENT2 || \
505         { skip "Client $CLIENT2 is on the server node" && return 0; }
506
507     zconf_mount_clients $CLIENT1 $DIR
508     zconf_mount_clients $CLIENT2 $DIR
509
510     rmultiop_start $CLIENT2 $DIR/$tfile || return 1
511     do_node $CLIENT2 rm -f $DIR/$tfile
512     replay_barrier mds
513     rmultiop_stop $CLIENT2 || return 2
514
515     vbr_deactivate_client $CLIENT2
516     facet_failover mds
517     do_node $CLIENT1 df $DIR || return 3
518     #client1 is back and will try to open orphan
519     vbr_activate_client $CLIENT2
520     do_node $CLIENT2 df $DIR || return 4
521
522     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
523     zconf_umount_clients $CLIENTS $DIR
524     return 0
525 }
526 run_test 8a "orphans are kept until delayed recovery"
527
528 test_8b() {
529     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
530
531     remote_server $CLIENT2 || \
532         { skip "Client $CLIENT2 is on the server node" && return 0; }
533
534     zconf_mount_clients $CLIENT1 $DIR
535     zconf_mount_clients $CLIENT2 $DIR
536
537     rmultiop_start $CLIENT2 $DIR/$tfile || return 1
538     replay_barrier mds
539     do_node $CLIENT1 rm -f $DIR/$tfile
540
541     vbr_deactivate_client $CLIENT2
542     facet_failover mds
543     do_node $CLIENT1 df $DIR || return 2
544     #client1 is back and will try to open orphan
545     vbr_activate_client $CLIENT2
546     do_node $CLIENT2 df $DIR || return 3
547
548     rmultiop_stop $CLIENT2 || return 1
549     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
550     zconf_umount_clients $CLIENTS $DIR
551     return 0
552 }
553 run_test 8b "open1 | unlink2 X delayed_replay1, close1"
554
555 test_8c() {
556     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
557
558     remote_server $CLIENT2 || \
559         { skip "Client $CLIENT2 is on the server node" && return 0; }
560
561     zconf_mount_clients $CLIENT1 $DIR
562     zconf_mount_clients $CLIENT2 $DIR
563
564     rmultiop_start $CLIENT2 $DIR/$tfile || return 1
565     replay_barrier mds
566     do_node $CLIENT1 rm -f $DIR/$tfile
567     rmultiop_stop $CLIENT2 || return 2
568
569     vbr_deactivate_client $CLIENT2
570     facet_failover mds
571     do_node $CLIENT1 df $DIR || return 3
572     #client1 is back and will try to open orphan
573     vbr_activate_client $CLIENT2
574     do_node $CLIENT2 df $DIR || return 4
575
576     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
577     zconf_umount_clients $CLIENTS $DIR
578     return 0
579 }
580 run_test 8c "open1 | unlink2, close1 X delayed_replay1"
581
582 test_8d() {
583     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
584
585     remote_server $CLIENT2 || \
586         { skip "Client $CLIENT2 is on the server node" && return 0; }
587
588     zconf_mount_clients $CLIENT1 $DIR
589     zconf_mount_clients $CLIENT2 $DIR
590
591     rmultiop_start $CLIENT1 $DIR/$tfile || return 1
592     rmultiop_start $CLIENT2 $DIR/$tfile || return 2
593     replay_barrier mds
594     do_node $CLIENT1 rm -f $DIR/$tfile
595     rmultiop_stop $CLIENT2 || return 3
596     rmultiop_stop $CLIENT1 || return 4
597
598     vbr_deactivate_client $CLIENT2
599     facet_failover mds
600     do_node $CLIENT1 df $DIR || return 6
601
602     #client1 is back and will try to open orphan
603     vbr_activate_client $CLIENT2
604     do_node $CLIENT2 df $DIR || return 8
605
606     do_node $CLIENT2 $CHECKSTAT $DIR/$tfile && error "$tfile exists"
607     zconf_umount_clients $CLIENTS $DIR
608     return 0
609 }
610 run_test 8d "open1, open2 | unlink2, close1, close2 X delayed_replay1"
611
612 test_8e() {
613     zconf_mount $CLIENT1 $DIR
614     zconf_mount $CLIENT2 $DIR
615
616     do_node $CLIENT1 mcreate $DIR/$tfile
617     do_node $CLIENT1 mkdir $DIR/$tfile-2
618     replay_barrier mds
619     # missed replay from client1 will lead to recovery by versions
620     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
621     do_node $CLIENT2 rm $DIR/$tfile || return 1
622     do_node $CLIENT2 touch $DIR/$tfile || return 2
623
624     zconf_umount $CLIENT1 $DIR
625     facet_failover mds
626     do_node $CLIENT2 df $DIR || return 6
627
628     do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
629     zconf_umount_clients $CLIENTS $DIR
630     return 0
631 }
632 run_test 8e "create | unlink, create shouldn't fail"
633
634 test_8f() {
635     zconf_mount_clients $CLIENT1 $DIR
636     zconf_mount_clients $CLIENT2 $DIR
637
638     do_node $CLIENT1 touch $DIR/$tfile
639     do_node $CLIENT1 mkdir $DIR/$tfile-2
640     replay_barrier mds
641     # missed replay from client1 will lead to recovery by versions
642     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
643     do_node $CLIENT2 rm -f $DIR/$tfile || return 1
644     do_node $CLIENT2 mcreate $DIR/$tfile || return 2
645
646     zconf_umount $CLIENT1 $DIR
647     facet_failover mds
648     do_node $CLIENT2 df $DIR || return 6
649
650     do_node $CLIENT2 rm $DIR/$tfile || error "$tfile doesn't exists"
651     zconf_umount $CLIENT2 $DIR
652     return 0
653 }
654 run_test 8f "create | unlink, create shouldn't fail"
655
656 test_8g() {
657     zconf_mount_clients $CLIENT1 $DIR
658     zconf_mount_clients $CLIENT2 $DIR
659
660     do_node $CLIENT1 touch $DIR/$tfile
661     do_node $CLIENT1 mkdir $DIR/$tfile-2
662     replay_barrier mds
663     # missed replay from client1 will lead to recovery by versions
664     do_node $CLIENT1 touch $DIR/$tfile-2/$tfile
665     do_node $CLIENT2 rm -f $DIR/$tfile || return 1
666     do_node $CLIENT2 mkdir $DIR/$tfile || return 2
667
668     zconf_umount $CLIENT1 $DIR
669     facet_failover mds
670     do_node $CLIENT2 df $DIR || return 6
671
672     do_node $CLIENT2 rmdir $DIR/$tfile || error "$tfile doesn't exists"
673     zconf_umount $CLIENT2 $DIR
674     return 0
675 }
676 run_test 8g "create | unlink, create shouldn't fail"
677
678 test_10 () {
679     delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
680
681     [ -z "$DBENCH_LIB" ] && skip "DBENCH_LIB is not set" && return 0
682
683     zconf_mount_clients $CLIENTS $DIR
684
685     local duration="-t 60"
686     local cmd="rundbench 1 $duration "
687     local PID=""
688     for CLIENT in ${CLIENTS//,/ }; do
689         $PDSH $CLIENT "set -x; PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:${DBENCH_LIB} DBENCH_LIB=${DBENCH_LIB} $cmd" &
690         PID=$!
691         echo $PID >pid.$CLIENT
692         echo "Started load PID=`cat pid.$CLIENT`"
693     done
694
695     replay_barrier mds
696     sleep 3 # give clients a time to do operations
697
698     vbr_deactivate_client $CLIENT2
699
700     log "$TESTNAME fail mds 1"
701     fail mds
702
703 # wait for client to reconnect to MDS
704     sleep $TIMEOUT
705
706     vbr_activate_client $CLIENT2
707     do_node $CLIENT2 df $DIR || return 4
708
709     for CLIENT in ${CLIENTS//,/ }; do
710         PID=`cat pid.$CLIENT`
711         wait $PID
712         rc=$?
713         echo "load on ${CLIENT} returned $rc"
714     done
715
716     zconf_umount_clients $CLIENTS $DIR
717 }
718 run_test 10 "mds version recovery; $CLIENTCOUNT clients"
719
720 equals_msg `basename $0`: test complete, cleaning up
721 #SLEEP=$((`date +%s` - $NOW))
722 #[ $SLEEP -lt $TIMEOUT ] && sleep $SLEEP
723 check_and_cleanup_lustre
724 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true