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