Whamcloud - gitweb
0bf952603e730f03946e19222ec48a40167664ac
[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 $(client_var_name $client)_multiop_pid=$multiop_pid
65     eval export $(client_var_name $client)_do_node_pid=$pid
66     local var=$(client_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=$(client_var_name $client)_multiop_pid
74     local do_node_pid=$(client_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 $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 chown :$RUNAS_ID $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 chown :$RUNAS_ID $MOUNT2/$tfile
299     do_node $CLIENT1 chown $RUNAS_ID $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 $MOUNT2/$tfile
322     do_node $CLIENT1 chown :$RUNAS_ID $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 chown :$RUNAS_ID $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 test_7_cycle() {
656     local first=$1
657     local lost=$2
658     local last=$3
659     local rc=0
660     local var=${SINGLEMDS}_svc
661     zconf_mount $CLIENT2 $MOUNT2
662
663     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
664     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
665
666     do_node $CLIENT1 mkdir -p $DIR/$tdir
667     replay_barrier $SINGLEMDS
668     # first operation
669     do_node $CLIENT1 $first || error "Cannot do first operation"
670     # client2 operations that will be lost
671     do_node $CLIENT2 $lost || error "Cannot do 'lost' operations"
672     # second operation
673     do_node $CLIENT1 $last || error "Cannot do last operation"
674     zconf_umount $CLIENT2 $MOUNT2
675     facet_failover $SINGLEMDS
676     # should fail as conflict expected
677     client_evicted $CLIENT1 || rc=1
678
679     wait_recovery_complete $SINGLEMDS
680     wait_mds_ost_sync $SINGLEMDS
681
682     rm -rf $DIR/$tdir
683     return $rc
684 }
685
686 test_7a() {
687     first="createmany -o $DIR/$tdir/$tfile- 1"
688     lost="rm $MOUNT2/$tdir/$tfile-0"
689     last="createmany -o $DIR/$tdir/$tfile- 1"
690     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.1 failed"
691
692     first="createmany -o $DIR/$tdir/$tfile- 1"
693     lost="rm $MOUNT2/$tdir/$tfile-0"
694     last="mkdir $DIR/$tdir/$tfile-0"
695     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.2 failed"
696
697     first="mkdir $DIR/$tdir/$tfile-0"
698     lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
699     last="createmany -o $DIR/$tdir/$tfile- 1"
700     test_7_cycle "$first" "$lost" "$last" || error "Test 7a.3 failed"
701     return 0
702 }
703 run_test 7a "create, {lost}, create"
704
705 test_7b() {
706     first="createmany -o $DIR/$tdir/$tfile- 1"
707     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
708     last="rm $DIR/$tdir/$tfile-0"
709     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.1 failed"
710
711     first="createmany -o $DIR/$tdir/$tfile- 1"
712     lost="touch $MOUNT2/$tdir/$tfile; mv $MOUNT2/$tdir/$tfile $MOUNT2/$tdir/$tfile-0"
713     last="rm $DIR/$tdir/$tfile-0"
714     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.2 failed"
715
716     first="createmany -o $DIR/$tdir/$tfile- 1"
717     lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
718     last="rmdir $DIR/$tdir/$tfile-0"
719     test_7_cycle "$first" "$lost" "$last" || error "Test 7b.3 failed"
720     return 0
721 }
722 run_test 7b "create, {lost}, unlink"
723
724 test_7c() {
725     first="createmany -o $DIR/$tdir/$tfile- 1"
726     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
727     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
728     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.1 failed"
729
730     first="createmany -o $DIR/$tdir/$tfile- 2"
731     lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
732     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
733     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.2 failed"
734
735     first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile-1-0"
736     lost="rmdir $MOUNT2/$tdir/$tfile-1-0; createmany -o $MOUNT2/$tdir/$tfile-1- 1"
737     last="mv $DIR/$tdir/$tfile-1-0 $DIR/$tdir/$tfile-0"
738     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.3 failed"
739
740     first="createmany -o $DIR/$tdir/$tfile- 1"
741     lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile"
742     last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-0"
743     test_7_cycle "$first" "$lost" "$last" || error "Test 7c.4 failed"
744     return 0
745 }
746 run_test 7c "create, {lost}, rename"
747
748 test_7d() {
749     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
750     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
751     last="createmany -o $DIR/$tdir/$tfile- 1"
752     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.1 failed"
753
754     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
755     lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0"
756     last="mkdir $DIR/$tdir/$tfile-0"
757     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.2 failed"
758
759     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
760     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
761     last="createmany -o $DIR/$tdir/$tfile- 1"
762     test_7_cycle "$first" "$lost" "$last" && error "Test 7d.3 failed"
763     return 0
764 }
765 run_test 7d "unlink, {lost}, create"
766
767 test_7e() {
768     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
769     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0;createmany -o $MOUNT2/$tdir/$tfile- 1"
770     last="rm $DIR/$tdir/$tfile-0"
771     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.1 failed"
772
773     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
774     lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
775     last="rmdir $DIR/$tdir/$tfile-0"
776     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.2 failed"
777
778     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
779     lost="mkdir $MOUNT2/$tdir/$tfile-0"
780     last="rmdir $DIR/$tdir/$tfile-0"
781     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.3 failed"
782
783     first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
784     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
785     last="rm $DIR/$tdir/$tfile-0"
786     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.4 failed"
787
788     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
789     lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
790     last="rm $DIR/$tdir/$tfile-0"
791     test_7_cycle "$first" "$lost" "$last" || error "Test 7e.5 failed"
792     return 0
793 }
794 run_test 7e "unlink, {lost}, unlink"
795
796 test_7f() {
797     first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
798     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
799     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
800     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.1 failed"
801
802     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
803     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
804     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
805     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.2 failed"
806
807     first="mkdir $DIR/$tdir/$tfile; createmany -o $DIR/$tdir/$tfile- 1; rmdir $DIR/$tdir/$tfile"
808     lost="mkdir $MOUNT2/$tdir/$tfile"
809     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
810     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.3 failed"
811
812     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
813     lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
814     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
815     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.4 failed"
816
817     first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
818     lost="mkdir $MOUNT2/$tdir/$tfile-0"
819     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
820     test_7_cycle "$first" "$lost" "$last" || error "Test 7f.5 failed"
821     return 0
822 }
823 run_test 7f "unlink, {lost}, rename"
824
825 test_7g() {
826     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
827     lost="mkdir $MOUNT2/$tdir/$tfile-0;rmdir $MOUNT2/$tdir/$tfile-0"
828     last="createmany -o $DIR/$tdir/$tfile- 1"
829     test_7_cycle "$first" "$lost" "$last" && error "Test 7g.1 failed"
830
831     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
832     lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
833     last="mkdir $DIR/$tdir/$tfile-0"
834     test_7_cycle "$first" "$lost" "$last" && error "Test 7g.2 failed"
835
836     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
837     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
838     last="link $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
839     test_7_cycle "$first" "$lost" "$last" || error "Test 7g.3 failed"
840     return 0
841 }
842 run_test 7g "rename, {lost}, create"
843
844 test_7h() {
845     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
846     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
847     last="rm $DIR/$tdir/$tfile-0"
848     test_7_cycle "$first" "$lost" "$last" || error "Test 7h.1 failed"
849
850     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
851     lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
852     last="rm $DIR/$tdir/$tfile-0"
853     test_7_cycle "$first" "$lost" "$last" || error "Test 7h.2 failed"
854
855     first="createmany -o $DIR/$tdir/$tfile- 1; mkdir  $DIR/$tdir/$tfile; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
856     lost="rm $MOUNT2/$tdir/$tfile/$tfile-0"
857     last="rmdir $DIR/$tdir/$tfile"
858     #test_7_cycle "$first" "$lost" "$last" || error "Test 7h.3 failed"
859     return 0
860 }
861 run_test 7h "rename, {lost}, unlink"
862
863 test_7i() {
864     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
865     lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
866     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
867     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
868
869     first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
870     lost="mkdir $MOUNT2/$tdir/$tfile-0"
871     last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
872     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
873
874     first="createmany -o $DIR/$tdir/$tfile- 3; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
875     lost="mv $MOUNT2/$tdir/$tfile-2 $MOUNT2/$tdir/$tfile-0"
876     last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-2"
877     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.3 failed"
878
879     first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
880     lost="rm $MOUNT2/$tdir/$tfile-1"
881     last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-1"
882     test_7_cycle "$first" "$lost" "$last" || error "Test 7i.4 failed"
883     return 0
884 }
885 run_test 7i "rename, {lost}, rename"
886
887 # test set #8: orphan handling bug 15392.
888 # Unlink during recovery creates orphan always just in case some late open may
889 # arrive. These orphans will be removed after recovery anyway.
890 # Tests check that valid create,unlink,create sequence will work in this case
891 # too but not fail on second create due to orphan found.
892
893 test_8a() {
894     local var=${SINGLEMDS}_svc
895     zconf_mount $CLIENT2 $MOUNT2
896
897     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
898
899     do_node $CLIENT1 mcreate $DIR/$tfile
900     do_node $CLIENT1 mkdir $DIR/$tfile-2
901     replay_barrier $SINGLEMDS
902     # missed replay from client2 will lead to recovery by versions
903     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
904     do_node $CLIENT1 rm $DIR/$tfile || return 1
905     do_node $CLIENT1 touch $DIR/$tfile || return 2
906
907     zconf_umount $CLIENT2 $MOUNT2
908     facet_failover $SINGLEMDS
909     client_up $CLIENT1 || return 6
910
911     do_node $CLIENT1 rm $DIR/$tfile || error "$tfile doesn't exists"
912     return 0
913 }
914 run_test 8a "create | unlink, create shouldn't fail"
915
916 test_8b() {
917     local var=${SINGLEMDS}_svc
918     zconf_mount $CLIENT2 $MOUNT2
919
920     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
921
922     do_node $CLIENT1 touch $DIR/$tfile
923     do_node $CLIENT1 mkdir $DIR/$tfile-2
924     replay_barrier $SINGLEMDS
925     # missed replay from client2 will lead to recovery by versions
926     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
927     do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
928     do_node $CLIENT1 mcreate $MOUNT1/$tfile || return 2
929
930     zconf_umount $CLIENT2 $MOUNT2
931     facet_failover $SINGLEMDS
932     client_up $CLIENT1 || return 6
933
934     do_node $CLIENT1 rm $MOUNT1/$tfile || error "$tfile doesn't exists"
935     return 0
936 }
937 run_test 8b "create | unlink, create shouldn't fail"
938
939 test_8c() {
940     local var=${SINGLEMDS}_svc
941     zconf_mount $CLIENT2 $MOUNT2
942
943     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
944
945     do_node $CLIENT1 touch $DIR/$tfile
946     do_node $CLIENT1 mkdir $DIR/$tfile-2
947     replay_barrier $SINGLEMDS
948     # missed replay from client2 will lead to recovery by versions
949     do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
950     do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
951     do_node $CLIENT1 mkdir $MOUNT1/$tfile || return 2
952
953     zconf_umount $CLIENT2 $MOUNT2
954     facet_failover $SINGLEMDS
955     client_up $CLIENT1 || return 6
956
957     do_node $CLIENT1 rmdir $MOUNT1/$tfile || error "$tfile doesn't exists"
958     return 0
959 }
960 run_test 8c "create | unlink, create shouldn't fail"
961
962 #
963 # This test uses three Lustre clients on two hosts.
964 #
965 #   Lustre Client 1:    $CLIENT1:$MOUNT     ($DIR)
966 #   Lustre Client 2:    $CLIENT2:$MOUNT2    ($DIR2)
967 #   Lustre Client 3:    $CLIENT2:$MOUNT1    ($DIR1)
968 #
969 test_10b() { # former test_2b
970     local pre
971     local post
972     local var=${SINGLEMDS}_svc
973
974     [ -n "$CLIENTS" ] || { skip "Need two or more clients" && exit 0; }
975     [ $CLIENTCOUNT -ge 2 ] || \
976         { skip "Need two or more clients, have $CLIENTCOUNT" && exit 0; }
977
978     do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
979     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
980
981     zconf_mount $CLIENT1 $MOUNT
982     zconf_mount $CLIENT2 $MOUNT1
983     zconf_mount $CLIENT2 $MOUNT2
984     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-a
985     do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-b
986
987     #
988     # Save an MDT transaction number before recovery.
989     #
990     do_node $CLIENT1 touch $DIR1/$tfile
991     pre=$(get_version $CLIENT1 $DIR/$tfile)
992
993     #
994     # Comments on the replay sequence state the expected result
995     # of each request.
996     #
997     #   "R"     Replayed.
998     #   "U"     Unable to replay.
999     #   "J"     Rejected.
1000     #
1001     replay_barrier $SINGLEMDS
1002     do_node $CLIENT1 chmod 666 $DIR/$tfile-a            # R
1003     do_node $CLIENT2 chmod 666 $DIR1/$tfile-b           # R
1004     do_node $CLIENT2 chown :$RUNAS_ID $DIR2/$tfile-a    # U
1005     do_node $CLIENT1 chown $RUNAS_ID $DIR/$tfile-a      # J
1006     do_node $CLIENT2 truncate $DIR2/$tfile-b 1          # U
1007     do_node $CLIENT2 chown :$RUNAS_ID $DIR1/$tfile-b    # R
1008     do_node $CLIENT1 chown $RUNAS_ID $DIR/$tfile-b      # R
1009     zconf_umount $CLIENT2 $MOUNT2
1010     facet_failover $SINGLEMDS
1011
1012     client_evicted $CLIENT1 || error "$CLIENT1:$MOUNT not evicted"
1013     client_up $CLIENT2 || error "$CLIENT2:$MOUNT1 evicted"
1014
1015     #
1016     # Check the MDT epoch.  $post must be the first transaction
1017     # number assigned after recovery.
1018     #
1019     do_node $CLIENT2 chmod 666 $DIR1/$tfile
1020     post=$(get_version $CLIENT2 $DIR1/$tfile)
1021     if (($(($pre >> 32)) == $((post >> 32)))); then
1022         error "epoch not changed: pre $pre, post $post"
1023     fi
1024
1025     if (($(($post & 0x00000000ffffffff)) != 1)); then
1026         error "transno should restart from one: got $post"
1027     fi
1028
1029     do_node $CLIENT2 stat $DIR1/$tfile-a
1030     do_node $CLIENT2 stat $DIR1/$tfile-b
1031
1032     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
1033             $DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
1034     do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_ID \
1035             $DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
1036
1037     zconf_umount $CLIENT2 $MOUNT1
1038 }
1039 run_test 10b "3 clients: some, none, and all reqs replayed"
1040
1041 # test set #11: operations in single directory
1042 test_11a() {
1043     local var=${SINGLEMDS}_svc
1044     zconf_mount $CLIENT2 $MOUNT2
1045
1046     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1047
1048     replay_barrier $SINGLEMDS
1049
1050     do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1051     PID=$!
1052     do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1053     zconf_umount $CLIENT2 $MOUNT2
1054     wait $PID
1055
1056     facet_failover $SINGLEMDS
1057     # recovery shouldn't fail due to missing client 2
1058     client_up $CLIENT1 || return 1
1059     # All files from client1 should have been replayed
1060     do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1061
1062     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1063     return 0
1064 }
1065 run_test 11a "concurrent creates don't affect each other"
1066
1067 test_11b() {
1068     local var=${SINGLEMDS}_svc
1069     zconf_mount $CLIENT2 $MOUNT2
1070
1071     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1072
1073     do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1074
1075     replay_barrier $SINGLEMDS
1076     do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1077     PID=$!
1078     do_node $CLIENT2 unlinkmany -o $MOUNT2/$tfile-2- 100
1079     zconf_umount $CLIENT2 $MOUNT2
1080     wait $PID
1081
1082     facet_failover $SINGLEMDS
1083     # recovery shouldn't fail due to missing client 2
1084     client_up $CLIENT1 || return 1
1085     # All files from client1 should have been replayed
1086     do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1087
1088     [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1089     return 0
1090 }
1091 run_test 11b "concurrent creates and unlinks don't affect each other"
1092
1093 # test set #12: lock replay with VBR, bug 16356
1094 test_12a() { # former test_2a
1095     local var=${SINGLEMDS}_svc
1096     zconf_mount $CLIENT2 $MOUNT2
1097
1098     do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1099
1100     do_node $CLIENT2 mkdir -p $MOUNT2/$tdir
1101     replay_barrier $SINGLEMDS
1102     do_node $CLIENT2 mcreate $MOUNT2/$tdir/$tfile
1103     do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1104     #client1 read data from client2 which will be lost
1105     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
1106     do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1107     zconf_umount $CLIENT2 $MOUNT2
1108
1109     facet_failover $SINGLEMDS
1110     # recovery shouldn't fail due to missing client 2
1111     client_up $CLIENT1 || return 1
1112
1113     # All 50 files should have been replayed
1114     do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1115     do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1116     do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
1117
1118     return 0
1119 }
1120 run_test 12a "lost data due to missed REMOTE client during replay"
1121
1122 #restore COS setting
1123 restore_lustre_params < $cos_param_file
1124 rm -f $cos_param_file
1125
1126 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
1127
1128 equals_msg `basename $0`: test complete, cleaning up
1129 check_and_cleanup_lustre
1130 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true