Whamcloud - gitweb
LU-357 racer test cleanup
[fs/lustre-release.git] / lustre / tests / replay-vbr.sh
1 #!/bin/bash
2
3 set -e
4
5 # bug number:  16356
6 ALWAYS_EXCEPT="12a   $REPLAY_VBR_EXCEPT"
7
8 SAVE_PWD=$PWD
9 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
10 SETUP=${SETUP:-}
11 CLEANUP=${CLEANUP:-}
12 MOUNT_2=${MOUNT_2:-"yes"}
13 . $LUSTRE/tests/test-framework.sh
14 init_test_env $@
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 init_logging
17
18 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
19
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW="7"
21
22 build_test_filter
23
24 check_and_setup_lustre
25
26 assert_DIR
27 rm -rf $DIR/[df][0-9]*
28
29 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
30
31 # if there is no CLIENT1 defined, some tests can be ran on localhost
32 CLIENT1=${CLIENT1:-$HOSTNAME}
33 # if CLIENT2 doesn't exist then use CLIENT1 instead
34 # All tests should use CLIENT2 with MOUNT2 only therefore it will work if
35 # $CLIENT2 == CLIENT1
36 # Exception is the test which need two separate nodes
37 CLIENT2=${CLIENT2:-$CLIENT1}
38
39 is_mounted $MOUNT2 || error "MOUNT2 is not mounted"
40
41 rmultiop_start() {
42     local client=$1
43     local file=$2
44     local cmds=$3
45
46     # We need to run do_node in bg, because pdsh does not exit
47     # if child process of run script exists.
48     # I.e. pdsh does not exit when runmultiop_bg_pause exited,
49     # because of multiop_bg_pause -> $MULTIOP_PROG &
50     # By the same reason we need sleep a bit after do_nodes starts
51     # to let runmultiop_bg_pause start muliop and
52     # update /tmp/multiop_bg.pid ;
53     # The rm /tmp/multiop_bg.pid guarantees here that
54     # we have the updated by runmultiop_bg_pause
55     # /tmp/multiop_bg.pid file
56
57     local pid_file=$TMP/multiop_bg.pid.$$
58     do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= sh runmultiop_bg_pause $file $cmds" &
59     local pid=$!
60     sleep 3
61     local multiop_pid
62     multiop_pid=$(do_node $client cat $pid_file)
63     [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
64     eval export $(node_var_name $client)_multiop_pid=$multiop_pid
65     eval export $(node_var_name $client)_do_node_pid=$pid
66     local var=$(node_var_name $client)_multiop_pid
67     echo client $client multiop_bg started multiop_pid=${!var}
68     return $?
69 }
70
71 rmultiop_stop() {
72     local client=$1
73     local multiop_pid=$(node_var_name $client)_multiop_pid
74     local do_node_pid=$(node_var_name $client)_do_node_pid
75
76     echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
77     do_node $client kill -USR1 ${!multiop_pid}
78
79     wait ${!do_node_pid}
80 }
81
82 get_version() {
83     local var=${SINGLEMDS}_svc
84     local client=$1
85     local file=$2
86     local fid
87
88     fid=$(do_node $client $LFS path2fid $file)
89     do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion $fid
90 }
91
92 #save COS setting
93 cos_param_file=$TMP/rvbr-cos-params
94 save_lustre_params $(comma_list $(mdts_nodes)) "mdt.*.commit_on_sharing" > $cos_param_file
95
96 # test set #1: OPEN
97 test_1a() { # former test_0a
98     local file=$DIR/$tfile
99     local pre
100     local post
101
102     do_node $CLIENT1 mcreate $file
103     pre=$(get_version $CLIENT1 $file)
104     do_node $CLIENT1 openfile -f O_RDWR $file
105     post=$(get_version $CLIENT1 $file)
106     if (($pre != $post)); then
107         error "version changed unexpectedly: pre $pre, post $post"
108     fi
109 }
110 run_test 1a "open and close do not change versions"
111
112 test_1b() { # former test_0b
113     local var=${SINGLEMDS}_svc
114     zconf_mount $CLIENT2 $MOUNT2
115
116     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
117     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
118     do_node $CLIENT1 mkdir -p -m 755 $MOUNT/$tdir
119
120     replay_barrier $SINGLEMDS
121     do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
122     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT $MOUNT/$tdir/$tfile
123     zconf_umount $CLIENT2 $MOUNT2
124     facet_failover $SINGLEMDS
125
126     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
127     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
128         error "open succeeded unexpectedly"
129     fi
130 }
131 run_test 1b "open (O_CREAT) checks version of parent"
132
133 test_1c() { # former test_0c
134     local var=${SINGLEMDS}_svc
135     zconf_mount $CLIENT2 $MOUNT2
136
137     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
138     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
139
140     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
141     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tdir/$tfile
142
143     replay_barrier $SINGLEMDS
144     do_node $CLIENT2 chmod 0777 $MOUNT2/$tdir
145     do_node $CLIENT2 chmod 0666 $MOUNT2/$tdir/$tfile
146     rmultiop_start $CLIENT1 $DIR/$tdir/$tfile o_c
147     zconf_umount $CLIENT2 $MOUNT2
148     facet_failover $SINGLEMDS
149
150     client_up $CLIENT1 || error "$CLIENT1 evicted"
151     rmultiop_stop $CLIENT1 || error "close failed"
152 }
153 run_test 1c "open (non O_CREAT) does not checks versions"
154
155 # test set #2: CREAT (not open)
156 # - version of parent is not changed but checked
157 # - pre-version should be -1
158 # - post-version should be valid
159 test_2a() {  # extended former test_0d
160     local pre
161     local post
162
163     # fifo
164     pre=$(get_version $CLIENT1 $DIR)
165     do_node $CLIENT1 mkfifo $DIR/$tfile-fifo
166     post=$(get_version $CLIENT1 $DIR)
167     if (($pre != $post)); then
168         error "version was changed: pre $pre, post $post"
169     fi
170     # mkdir
171     pre=$(get_version $CLIENT1 $DIR)
172     do_node $CLIENT1 mkdir $DIR/$tfile-dir
173     post=$(get_version $CLIENT1 $DIR)
174     if (($pre != $post)); then
175         error "version was changed: pre $pre, post $post"
176     fi
177     do_node $CLIENT1 rmdir $DIR/$tfile-dir
178
179     # mknod
180     pre=$(get_version $CLIENT1 $DIR)
181     do_node $CLIENT1 mkfifo $DIR/$tfile-nod
182     post=$(get_version $CLIENT1 $DIR)
183     if (($pre != $post)); then
184         error "version was changed: pre $pre, post $post"
185     fi
186     # symlink
187     pre=$(get_version $CLIENT1 $DIR)
188     do_node $CLIENT1 mkfifo $DIR/$tfile-symlink
189     post=$(get_version $CLIENT1 $DIR)
190     if (($pre != $post)); then
191         error "version was changed: pre $pre, post $post"
192     fi
193     do_node $CLIENT1 rm $DIR/$tfile-*
194
195 }
196 run_test 2a "create operations doesn't change version of parent"
197
198 test_2b() { # former test_0e
199     local var=${SINGLEMDS}_svc
200     zconf_mount $CLIENT2 $MOUNT2
201
202     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
203     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
204
205     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
206
207     replay_barrier $SINGLEMDS
208     do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
209     do_node $CLIENT1 mkfifo $DIR/$tdir/$tfile
210     zconf_umount $CLIENT2 $MOUNT2
211     facet_failover $SINGLEMDS
212
213     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
214     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
215         error "create succeeded unexpectedly"
216     fi
217 }
218 run_test 2b "create checks version of parent"
219
220 test_3a() { # former test_0f
221     local pre
222     local post
223
224     do_node $CLIENT1 mcreate $DIR/$tfile
225     pre=$(get_version $CLIENT1 $DIR)
226     do_node $CLIENT1 rm $DIR/$tfile
227     post=$(get_version $CLIENT1 $DIR)
228     if (($pre != $post)); then
229         error "version was changed: pre $pre, post $post"
230     fi
231 }
232 run_test 3a "unlink doesn't change version of parent"
233
234 test_3b() { # former test_0g
235     local var=${SINGLEMDS}_svc
236     zconf_mount $CLIENT2 $MOUNT2
237
238     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
239     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
240
241     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
242     do_node $CLIENT1 mcreate $DIR/$tdir/$tfile
243
244     replay_barrier $SINGLEMDS
245     do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
246     do_node $CLIENT1 rm $DIR/$tdir/$tfile
247     zconf_umount $CLIENT2 $MOUNT2
248     facet_failover $SINGLEMDS
249
250     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
251     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
252         error "unlink succeeded unexpectedly"
253     fi
254 }
255 run_test 3b "unlink checks version of parent"
256
257 test_4a() { # former test_0h
258     local file=$DIR/$tfile
259     local pre
260     local post
261
262     do_node $CLIENT1 mcreate $file
263     pre=$(get_version $CLIENT1 $file)
264     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
265     post=$(get_version $CLIENT1 $file)
266     if (($pre == $post)); then
267         error "version not changed: pre $pre, post $post"
268     fi
269 }
270 run_test 4a "setattr of UID changes versions"
271
272 test_4b() { # former test_0i
273     local file=$DIR/$tfile
274     local pre
275     local post
276
277     do_node $CLIENT1 mcreate $file
278     pre=$(get_version $CLIENT1 $file)
279     do_node $CLIENT1 chgrp $RUNAS_GID $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 4b "setattr of GID changes versions"
286
287 test_4c() { # former test_0j
288     local file=$DIR/$tfile
289     local var=${SINGLEMDS}_svc
290     zconf_mount $CLIENT2 $MOUNT2
291
292     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
293     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
294
295     do_node $CLIENT1 mcreate $file
296
297     replay_barrier $SINGLEMDS
298     do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
299     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
300     zconf_umount $CLIENT2 $MOUNT2
301     facet_failover $SINGLEMDS
302
303     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
304     if ! do_node $CLIENT1 $CHECKSTAT -u \\\#$UID $file; then
305         error "setattr of UID succeeded unexpectedly"
306     fi
307 }
308 run_test 4c "setattr of UID checks versions"
309
310 test_4d() { # former test_0k
311     local file=$DIR/$tfile
312     local var=${SINGLEMDS}_svc
313     zconf_mount $CLIENT2 $MOUNT2
314
315     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
316     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
317
318     do_node $CLIENT1 mcreate $file
319
320     replay_barrier $SINGLEMDS
321     do_node $CLIENT2 chown $RUNAS_ID:$RUNAS_GID $MOUNT2/$tfile
322     do_node $CLIENT1 chgrp $RUNAS_GID $file
323     zconf_umount $CLIENT2 $MOUNT2
324     facet_failover $SINGLEMDS
325
326     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
327     if ! do_node $CLIENT1 $CHECKSTAT -g \\\#$UID $file; then
328         error "setattr of GID succeeded unexpectedly"
329     fi
330 }
331 run_test 4d "setattr of GID checks versions"
332
333 test_4e() { # former test_0l
334     local file=$DIR/$tfile
335     local pre
336     local post
337
338     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
339     pre=$(get_version $CLIENT1 $file)
340     do_node $CLIENT1 chmod 666 $file
341     post=$(get_version $CLIENT1 $file)
342     if (($pre == $post)); then
343         error "version not changed: pre $pre, post $post"
344     fi
345 }
346 run_test 4e "setattr of permission changes versions"
347
348 test_4f() { # former test_0m
349     local file=$DIR/$tfile
350     local var=${SINGLEMDS}_svc
351     zconf_mount $CLIENT2 $MOUNT2
352
353     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
354     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
355
356     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
357
358     replay_barrier $SINGLEMDS
359     do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
360     do_node $CLIENT1 chmod 666 $file
361     zconf_umount $CLIENT2 $MOUNT2
362     facet_failover $SINGLEMDS
363
364     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
365     if ! do_node $CLIENT1 $CHECKSTAT -p 0644 $file; then
366         error "setattr of permission succeeded unexpectedly"
367     fi
368 }
369 run_test 4f "setattr of permission checks versions"
370
371 test_4g() { # former test_0n
372     local file=$DIR/$tfile
373     local pre
374     local post
375
376     do_node $CLIENT1 mcreate $file
377     pre=$(get_version $CLIENT1 $file)
378     do_node $CLIENT1 chattr +i $file
379     post=$(get_version $CLIENT1 $file)
380     do_node $CLIENT1 chattr -i $file
381     if (($pre == $post)); then
382         error "version not changed: pre $pre, post $post"
383     fi
384 }
385 run_test 4g "setattr of flags changes versions"
386
387 checkattr() {
388     local client=$1
389     local attr=$2
390     local file=$3
391     local rc
392
393     if ((${#attr} != 1)); then
394         error "checking multiple attributes not implemented yet"
395     fi
396     do_node $client lsattr $file | cut -d ' ' -f 1 | grep -q $attr
397 }
398
399 test_4h() { # former test_0o
400     local file=$DIR/$tfile
401     local rc
402     local var=${SINGLEMDS}_svc
403     zconf_mount $CLIENT2 $MOUNT2
404
405     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
406     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
407
408     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
409
410     replay_barrier $SINGLEMDS
411     do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
412     do_node $CLIENT1 chattr +i $file
413     zconf_umount $CLIENT2 $MOUNT2
414     facet_failover $SINGLEMDS
415
416     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
417     checkattr $CLIENT1 i $file
418     rc=$?
419     do_node $CLIENT1 chattr -i $file
420     if [ $rc -eq 0 ]; then
421         error "setattr of flags succeeded unexpectedly"
422     fi
423 }
424 run_test 4h "setattr of flags checks versions"
425
426 test_4i() { # former test_0p
427     local file=$DIR/$tfile
428     local pre
429     local post
430     local ad_orig
431     local var=${SINGLEMDS}_svc
432
433     ad_orig=$(do_facet $SINGLEMDS "$LCTL get_param mdd.${!var}.atime_diff")
434     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
435     do_node $CLIENT1 mcreate $file
436     pre=$(get_version $CLIENT1 $file)
437     do_node $CLIENT1 touch $file
438     post=$(get_version $CLIENT1 $file)
439     #
440     # We don't fail MDS in this test.  atime_diff shall be
441     # restored to its original value.
442     #
443     do_facet $SINGLEMDS "$LCTL set_param $ad_orig"
444     if (($pre != $post)); then
445         error "version changed unexpectedly: pre $pre, post $post"
446     fi
447 }
448 run_test 4i "setattr of times does not change versions"
449
450 test_4j() { # former test_0q
451     local file=$DIR/$tfile
452     local pre
453     local post
454
455     do_node $CLIENT1 mcreate $file
456     pre=$(get_version $CLIENT1 $file)
457     do_node $CLIENT1 $TRUNCATE $file 1
458     post=$(get_version $CLIENT1 $file)
459     if (($pre != $post)); then
460         error "version changed unexpectedly: pre $pre, post $post"
461     fi
462 }
463 run_test 4j "setattr of size does not change versions"
464
465 test_4k() { # former test_0r
466     local file=$DIR/$tfile
467     local mtime_pre
468     local mtime_post
469     local mtime
470     local var=${SINGLEMDS}_svc
471     zconf_mount $CLIENT2 $MOUNT2
472
473     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
474     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
475     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
476
477     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
478
479     replay_barrier $SINGLEMDS
480     do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
481     do_node $CLIENT1 $TRUNCATE $file 1
482     sleep 1
483     mtime_pre=$(do_node $CLIENT1 stat --format=%Y $file)
484     do_node $CLIENT1 touch $file
485     sleep 1 # avoid stat caching
486     mtime_post=$(do_node $CLIENT1 stat --format=%Y $file)
487     zconf_umount $CLIENT2 $MOUNT2
488     facet_failover $SINGLEMDS
489
490     client_up $CLIENT1 || error "$CLIENT1 evicted"
491     if (($mtime_pre >= $mtime_post)); then
492         error "time not changed: pre $mtime_pre, post $mtime_post"
493     fi
494     if ! do_node $CLIENT1 $CHECKSTAT -s 1 $file; then
495         error "setattr of size failed"
496     fi
497     mtime=$(do_node $CLIENT1 stat --format=%Y $file)
498     if (($mtime != $mtime_post)); then
499         error "setattr of times failed: expected $mtime_post, got $mtime"
500     fi
501 }
502 run_test 4k "setattr of times and size does not check versions"
503
504 test_5a() { # former test_0s
505     local pre
506     local post
507     local tp_pre
508     local tp_post
509
510     do_node $CLIENT1 mcreate $DIR/$tfile
511     do_node $CLIENT1 mkdir -p $DIR/$tdir
512     pre=$(get_version $CLIENT1 $DIR/$tfile)
513     tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
514     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
515     post=$(get_version $CLIENT1 $DIR/$tfile)
516     tp_post=$(get_version $CLIENT1 $DIR/$tdir)
517     if (($pre == $post)); then
518         error "version of source not changed: pre $pre, post $post"
519     fi
520     if (($tp_pre != $tp_post)); then
521         error "version of target parent was changed: pre $tp_pre, post $tp_post"
522     fi
523 }
524 run_test 5a "link changes versions of source but not target parent"
525
526 test_5b() { # former test_0t
527     local var=${SINGLEMDS}_svc
528     zconf_mount $CLIENT2 $MOUNT2
529
530     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
531     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
532
533     do_node $CLIENT1 mcreate $DIR/$tfile
534     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
535
536     replay_barrier $SINGLEMDS
537     do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
538     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
539     zconf_umount $CLIENT2 $MOUNT2
540     facet_failover $SINGLEMDS
541
542     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
543     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
544         error "link should fail"
545     fi
546 }
547 run_test 5b "link checks version of target parent"
548
549 test_5c() { # former test_0u
550     local var=${SINGLEMDS}_svc
551     zconf_mount $CLIENT2 $MOUNT2
552
553     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
554     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
555
556     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
557     do_node $CLIENT1 mkdir -p $DIR/$tdir
558
559     replay_barrier $SINGLEMDS
560     do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
561     do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
562     zconf_umount $CLIENT2 $MOUNT2
563     facet_failover $SINGLEMDS
564
565     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
566     if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
567         error "link should fail"
568     fi
569 }
570 run_test 5c "link checks version of source"
571
572 test_6a() { # former test_0v
573     local sp_pre
574     local tp_pre
575     local sp_post
576     local tp_post
577
578     do_node $CLIENT1 mcreate $DIR/$tfile
579     do_node $CLIENT1 mkdir -p $DIR/$tdir
580     sp_pre=$(get_version $CLIENT1 $DIR)
581     tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
582     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
583     sp_post=$(get_version $CLIENT1 $DIR)
584     tp_post=$(get_version $CLIENT1 $DIR/$tdir)
585     if (($sp_pre != $sp_post)); then
586         error "version of source parent was changed: pre $sp_pre, post $sp_post"
587     fi
588     if (($tp_pre != $tp_post)); then
589         error "version of target parent was changed: pre $tp_pre, post $tp_post"
590     fi
591 }
592 run_test 6a "rename doesn't change versions of source parent and target parent"
593
594 test_6b() { # former test_0w
595     local pre
596     local post
597
598     do_node $CLIENT1 mcreate $DIR/$tfile
599     pre=$(get_version $CLIENT1 $DIR)
600     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tfile-new
601     post=$(get_version $CLIENT1 $DIR)
602     if (($pre != $post)); then
603         error "version of parent was changed: pre $pre, post $post"
604     fi
605 }
606 run_test 6b "rename within same dir doesn't change version of parent"
607
608 test_6c() { # former test_0x
609     local var=${SINGLEMDS}_svc
610     zconf_mount $CLIENT2 $MOUNT2
611
612     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
613     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
614
615     do_node $CLIENT1 mcreate $DIR/$tfile
616     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
617
618     replay_barrier $SINGLEMDS
619     do_node $CLIENT2 chmod 777 $MOUNT2
620     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
621     zconf_umount $CLIENT2 $MOUNT2
622     facet_failover $SINGLEMDS
623
624     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
625     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
626         error "rename should fail"
627     fi
628 }
629 run_test 6c "rename checks version of source parent"
630
631 test_6d() { # former test_0y
632     local var=${SINGLEMDS}_svc
633     zconf_mount $CLIENT2 $MOUNT2
634
635     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
636     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
637
638     do_node $CLIENT1 mcreate $DIR/$tfile
639     do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
640
641     replay_barrier $SINGLEMDS
642     do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
643     do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
644     zconf_umount $CLIENT2 $MOUNT2
645     facet_failover $SINGLEMDS
646
647     client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
648     if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
649         error "rename should fail"
650     fi
651 }
652 run_test 6d "rename checks version of target parent"
653
654 # pdirops tests, bug 18143
655 cycle=0
656 test_7_cycle() {
657     local first=$1
658     local lost=$2
659     local last=$3
660     local rc=0
661     local var=${SINGLEMDS}_svc
662     zconf_mount $CLIENT2 $MOUNT2
663     cycle=$((cycle + 1))
664     local cname=$TESTNAME.$cycle
665
666     echo "start cycle: $cname"
667     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
668     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
669
670     do_node $CLIENT1 mkdir -p $DIR/$tdir
671     replay_barrier $SINGLEMDS
672     # first operation
673     echo "$cname first: $first"
674     do_node $CLIENT1 $first || error "$cname: Cannot do first operation"
675     # client2 operations that will be lost
676     echo "$cname lost: $lost"
677     do_node $CLIENT2 $lost || error "$cname: Cannot do 'lost' operations"
678     # second operation
679     echo "$cname last: $last"
680     do_node $CLIENT1 $last || error "$cname: Cannot do last operation"
681     zconf_umount $CLIENT2 $MOUNT2
682     facet_failover $SINGLEMDS
683     # should fail as conflict expected
684     client_evicted $CLIENT1 || rc=1
685
686     wait_recovery_complete $SINGLEMDS
687     wait_mds_ost_sync $SINGLEMDS
688
689     rm -rf $DIR/$tdir
690     return $rc
691 }
692
693 test_7a() {
694     first="createmany -o $DIR/$tdir/$tfile- 1"
695     lost="rm $MOUNT2/$tdir/$tfile-0"
696     last="createmany -o $DIR/$tdir/$tfile- 1"
697     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.1 failed"
698
699     first="createmany -o $DIR/$tdir/$tfile- 1"
700     lost="rm $MOUNT2/$tdir/$tfile-0"
701     last="mkdir $DIR/$tdir/$tfile-0"
702     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.2 failed"
703
704     first="mkdir $DIR/$tdir/$tfile-0"
705     lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
706     last="createmany -o $DIR/$tdir/$tfile- 1"
707     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.3 failed"
708     return 0
709 }
710 run_test 7a "create, {lost}, create"
711
712 test_7b() {
713     first="createmany -o $DIR/$tdir/$tfile- 1"
714     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
715     last="rm $DIR/$tdir/$tfile-0"
716     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.1 failed"
717
718     first="createmany -o $DIR/$tdir/$tfile- 1"
719     lost="touch $MOUNT2/$tdir/$tfile; mv $MOUNT2/$tdir/$tfile $MOUNT2/$tdir/$tfile-0"
720     last="rm $DIR/$tdir/$tfile-0"
721     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.2 failed"
722
723     first="createmany -o $DIR/$tdir/$tfile- 1"
724     lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
725     last="rmdir $DIR/$tdir/$tfile-0"
726     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.3 failed"
727     return 0
728 }
729 run_test 7b "create, {lost}, unlink"
730
731 test_7c() {
732     first="createmany -o $DIR/$tdir/$tfile- 1"
733     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
734     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
735     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.1 failed"
736
737     first="createmany -o $DIR/$tdir/$tfile- 2"
738     lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
739     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
740     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.2 failed"
741
742     first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile-1-0"
743     lost="rmdir $MOUNT2/$tdir/$tfile-1-0; createmany -o $MOUNT2/$tdir/$tfile-1- 1"
744     last="mv $DIR/$tdir/$tfile-1-0 $DIR/$tdir/$tfile-0"
745     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.3 failed"
746
747     first="createmany -o $DIR/$tdir/$tfile- 1"
748     lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile"
749     last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-0"
750     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.4 failed"
751     return 0
752 }
753 run_test 7c "create, {lost}, rename"
754
755 test_7d() {
756     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
757     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
758     last="createmany -o $DIR/$tdir/$tfile- 1"
759     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.1 failed"
760
761     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
762     lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0"
763     last="mkdir $DIR/$tdir/$tfile-0"
764     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.2 failed"
765
766     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
767     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
768     last="createmany -o $DIR/$tdir/$tfile- 1"
769     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.3 failed"
770     return 0
771 }
772 run_test 7d "unlink, {lost}, create"
773
774 test_7e() {
775     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
776     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0;createmany -o $MOUNT2/$tdir/$tfile- 1"
777     last="rm $DIR/$tdir/$tfile-0"
778     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.1 failed"
779
780     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
781     lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
782     last="rmdir $DIR/$tdir/$tfile-0"
783     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.2 failed"
784
785     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
786     lost="mkdir $MOUNT2/$tdir/$tfile-0"
787     last="rmdir $DIR/$tdir/$tfile-0"
788     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.3 failed"
789
790     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
791     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
792     last="rm $DIR/$tdir/$tfile-0"
793     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.4 failed"
794
795     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
796     lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
797     last="rm $DIR/$tdir/$tfile-0"
798     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.5 failed"
799     return 0
800 }
801 run_test 7e "unlink, {lost}, unlink"
802
803 test_7f() {
804     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
805     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
806     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
807     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.1 failed"
808
809     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
810     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
811     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
812     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.2 failed"
813
814     first="mkdir $DIR/$tdir/$tfile; createmany -o $DIR/$tdir/$tfile- 1; rmdir $DIR/$tdir/$tfile"
815     lost="mkdir $MOUNT2/$tdir/$tfile"
816     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
817     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.3 failed"
818
819     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
820     lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
821     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
822     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.4 failed"
823
824     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
825     lost="mkdir $MOUNT2/$tdir/$tfile-0"
826     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
827     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.5 failed"
828     return 0
829 }
830 run_test 7f "unlink, {lost}, rename"
831
832 test_7g() {
833     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
834     lost="mkdir $MOUNT2/$tdir/$tfile-0;rmdir $MOUNT2/$tdir/$tfile-0"
835     last="createmany -o $DIR/$tdir/$tfile- 1"
836     test_7_cycle "$first" "$lost" "$last" && error "Test 7g.1 failed"
837
838     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
839     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
840     last="mkdir $DIR/$tdir/$tfile-0"
841     test_7_cycle "$first" "$lost" "$last" && error "Test 7g.2 failed"
842
843     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
844     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
845     last="link $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
846     test_7_cycle "$first" "$lost" "$last" || error "Test 7g.3 failed"
847     return 0
848 }
849 run_test 7g "rename, {lost}, create"
850
851 test_7h() {
852     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
853     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
854     last="rm $DIR/$tdir/$tfile-0"
855     test_7_cycle "$first" "$lost" "$last" || error "Test 7h.1 failed"
856
857     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
858     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
859     last="rm $DIR/$tdir/$tfile-0"
860     test_7_cycle "$first" "$lost" "$last" || error "Test 7h.2 failed"
861
862     first="createmany -o $DIR/$tdir/$tfile- 1; mkdir  $DIR/$tdir/$tfile; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
863     lost="rm $MOUNT2/$tdir/$tfile/$tfile-0"
864     last="rmdir $DIR/$tdir/$tfile"
865     #test_7_cycle "$first" "$lost" "$last" || error "Test 7h.3 failed"
866     return 0
867 }
868 run_test 7h "rename, {lost}, unlink"
869
870 test_7i() {
871     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
872     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
873     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
874     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
875
876     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
877     lost="mkdir $MOUNT2/$tdir/$tfile-0"
878     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
879     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
880
881     first="createmany -o $DIR/$tdir/$tfile- 3; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
882     lost="mv $MOUNT2/$tdir/$tfile-2 $MOUNT2/$tdir/$tfile-0"
883     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-2"
884     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.3 failed"
885
886     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
887     lost="rm $MOUNT2/$tdir/$tfile-1"
888     last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-1"
889     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.4 failed"
890     return 0
891 }
892 run_test 7i "rename, {lost}, rename"
893
894 # test set #8: orphan handling bug 15392.
895 # Unlink during recovery creates orphan always just in case some late open may
896 # arrive. These orphans will be removed after recovery anyway.
897 # Tests check that valid create,unlink,create sequence will work in this case
898 # too but not fail on second create due to orphan found.
899
900 test_8a() {
901     local var=${SINGLEMDS}_svc
902     zconf_mount $CLIENT2 $MOUNT2
903
904     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
905
906     do_node $CLIENT1 mcreate $DIR/$tfile
907     do_node $CLIENT1 mkdir $DIR/$tfile-2
908     replay_barrier $SINGLEMDS
909     # missed replay from client2 will lead to recovery by versions
910     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
911     do_node $CLIENT1 rm $DIR/$tfile || return 1
912     do_node $CLIENT1 touch $DIR/$tfile || return 2
913
914     zconf_umount $CLIENT2 $MOUNT2
915     facet_failover $SINGLEMDS
916     client_up $CLIENT1 || return 6
917
918     do_node $CLIENT1 rm $DIR/$tfile || error "$tfile doesn't exists"
919     return 0
920 }
921 run_test 8a "create | unlink, create shouldn't fail"
922
923 test_8b() {
924     local var=${SINGLEMDS}_svc
925     zconf_mount $CLIENT2 $MOUNT2
926
927     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
928
929     do_node $CLIENT1 touch $DIR/$tfile
930     do_node $CLIENT1 mkdir $DIR/$tfile-2
931     replay_barrier $SINGLEMDS
932     # missed replay from client2 will lead to recovery by versions
933     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
934     do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
935     do_node $CLIENT1 mcreate $MOUNT1/$tfile || return 2
936
937     zconf_umount $CLIENT2 $MOUNT2
938     facet_failover $SINGLEMDS
939     client_up $CLIENT1 || return 6
940
941     do_node $CLIENT1 rm $MOUNT1/$tfile || error "$tfile doesn't exists"
942     return 0
943 }
944 run_test 8b "create | unlink, create shouldn't fail"
945
946 test_8c() {
947     local var=${SINGLEMDS}_svc
948     zconf_mount $CLIENT2 $MOUNT2
949
950     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
951
952     do_node $CLIENT1 touch $DIR/$tfile
953     do_node $CLIENT1 mkdir $DIR/$tfile-2
954     replay_barrier $SINGLEMDS
955     # missed replay from client2 will lead to recovery by versions
956     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
957     do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
958     do_node $CLIENT1 mkdir $MOUNT1/$tfile || return 2
959
960     zconf_umount $CLIENT2 $MOUNT2
961     facet_failover $SINGLEMDS
962     client_up $CLIENT1 || return 6
963
964     do_node $CLIENT1 rmdir $MOUNT1/$tfile || error "$tfile doesn't exists"
965     return 0
966 }
967 run_test 8c "create | unlink, create shouldn't fail"
968
969 #
970 # This test uses three Lustre clients on two hosts.
971 #
972 #   Lustre Client 1:    $CLIENT1:$MOUNT     ($DIR)
973 #   Lustre Client 2:    $CLIENT2:$MOUNT2    ($DIR2)
974 #   Lustre Client 3:    $CLIENT2:$MOUNT1    ($DIR1)
975 #
976 test_10b() { # former test_2b
977     local pre
978     local post
979     local var=${SINGLEMDS}_svc
980
981     [ -n "$CLIENTS" ] || { skip "Need two or more clients" && exit 0; }
982     [ $CLIENTCOUNT -ge 2 ] || \
983         { skip "Need two or more clients, have $CLIENTCOUNT" && exit 0; }
984
985     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
986     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
987
988     zconf_mount $CLIENT1 $MOUNT
989     zconf_mount $CLIENT2 $MOUNT1
990     zconf_mount $CLIENT2 $MOUNT2
991     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-a
992     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-b
993
994     #
995     # Save an MDT transaction number before recovery.
996     #
997     do_node $CLIENT1 touch $DIR1/$tfile
998     pre=$(get_version $CLIENT1 $DIR/$tfile)
999
1000     #
1001     # Comments on the replay sequence state the expected result
1002     # of each request.
1003     #
1004     #   "R"     Replayed.
1005     #   "U"     Unable to replay.
1006     #   "J"     Rejected.
1007     #
1008     replay_barrier $SINGLEMDS
1009     do_node $CLIENT1 chmod 666 $DIR/$tfile-a            # R
1010     do_node $CLIENT2 chmod 666 $DIR1/$tfile-b           # R
1011     do_node $CLIENT2 chgrp $RUNAS_GID $DIR2/$tfile-a    # U
1012     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-a      # J
1013     do_node $CLIENT2 $TRUNCATE $DIR2/$tfile-b 1          # U
1014     do_node $CLIENT2 chgrp $RUNAS_GID $DIR1/$tfile-b    # R
1015     do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-b      # R
1016     zconf_umount $CLIENT2 $MOUNT2
1017     facet_failover $SINGLEMDS
1018
1019     client_evicted $CLIENT1 || error "$CLIENT1:$MOUNT not evicted"
1020     client_up $CLIENT2 || error "$CLIENT2:$MOUNT1 evicted"
1021
1022     #
1023     # Check the MDT epoch.  $post must be the first transaction
1024     # number assigned after recovery.
1025     #
1026     do_node $CLIENT2 chmod 666 $DIR1/$tfile
1027     post=$(get_version $CLIENT2 $DIR1/$tfile)
1028     if (($(($pre >> 32)) == $((post >> 32)))); then
1029         error "epoch not changed: pre $pre, post $post"
1030     fi
1031
1032     if (($(($post & 0x00000000ffffffff)) != 1)); then
1033         error "transno should restart from one: got $post"
1034     fi
1035
1036     do_node $CLIENT2 stat $DIR1/$tfile-a
1037     do_node $CLIENT2 stat $DIR1/$tfile-b
1038
1039     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
1040             $DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
1041     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_GID \
1042             $DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
1043
1044     zconf_umount $CLIENT2 $MOUNT1
1045 }
1046 run_test 10b "3 clients: some, none, and all reqs replayed"
1047
1048 # test set #11: operations in single directory
1049 test_11a() {
1050     local var=${SINGLEMDS}_svc
1051     zconf_mount $CLIENT2 $MOUNT2
1052
1053     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1054
1055     replay_barrier $SINGLEMDS
1056
1057     do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1058     PID=$!
1059     do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1060     zconf_umount $CLIENT2 $MOUNT2
1061     wait $PID
1062
1063     facet_failover $SINGLEMDS
1064     # recovery shouldn't fail due to missing client 2
1065     client_up $CLIENT1 || return 1
1066     # All files from client1 should have been replayed
1067     do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1068
1069     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1070     return 0
1071 }
1072 run_test 11a "concurrent creates don't affect each other"
1073
1074 test_11b() {
1075     local var=${SINGLEMDS}_svc
1076     zconf_mount $CLIENT2 $MOUNT2
1077
1078     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1079
1080     do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1081
1082     replay_barrier $SINGLEMDS
1083     do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1084     PID=$!
1085     do_node $CLIENT2 unlinkmany -o $MOUNT2/$tfile-2- 100
1086     zconf_umount $CLIENT2 $MOUNT2
1087     wait $PID
1088
1089     facet_failover $SINGLEMDS
1090     # recovery shouldn't fail due to missing client 2
1091     client_up $CLIENT1 || return 1
1092     # All files from client1 should have been replayed
1093     do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1094
1095     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1096     return 0
1097 }
1098 run_test 11b "concurrent creates and unlinks don't affect each other"
1099
1100 # test set #12: lock replay with VBR, bug 16356
1101 test_12a() { # former test_2a
1102     local var=${SINGLEMDS}_svc
1103     zconf_mount $CLIENT2 $MOUNT2
1104
1105     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1106
1107     do_node $CLIENT2 mkdir -p $MOUNT2/$tdir
1108     replay_barrier $SINGLEMDS
1109     do_node $CLIENT2 mcreate $MOUNT2/$tdir/$tfile
1110     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1111     #client1 read data from client2 which will be lost
1112     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
1113     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1114     zconf_umount $CLIENT2 $MOUNT2
1115
1116     facet_failover $SINGLEMDS
1117     # recovery shouldn't fail due to missing client 2
1118     client_up $CLIENT1 || return 1
1119
1120     # All 50 files should have been replayed
1121     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1122     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1123     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
1124
1125     return 0
1126 }
1127 run_test 12a "lost data due to missed REMOTE client during replay"
1128
1129 #restore COS setting
1130 restore_lustre_params < $cos_param_file
1131 rm -f $cos_param_file
1132
1133 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
1134
1135 complete $(basename $0) $SECONDS
1136 check_and_cleanup_lustre
1137 exit_status