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