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