2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:shiftwidth=4:softtabstop=4:tabstop=4:
8 ALWAYS_EXCEPT="12a $REPLAY_VBR_EXCEPT"
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 MOUNT_2=${MOUNT_2:-"yes"}
15 export MULTIOP=${MULTIOP:-multiop}
16 . $LUSTRE/tests/test-framework.sh
18 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
21 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
24 [ "$SLOW" = "no" ] && EXCEPT_SLOW="7"
28 check_and_setup_lustre
31 rm -rf $DIR/[df][0-9]*
33 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
35 # if there is no CLIENT1 defined, some tests can be ran on localhost
36 CLIENT1=${CLIENT1:-$HOSTNAME}
37 # if CLIENT2 doesn't exist then use CLIENT1 instead
38 # All tests should use CLIENT2 with MOUNT2 only therefore it will work if
40 # Exception is the test which need two separate nodes
41 CLIENT2=${CLIENT2:-$CLIENT1}
43 is_mounted $MOUNT2 || error "MOUNT2 is not mounted"
50 # We need to run do_node in bg, because pdsh does not exit
51 # if child process of run script exists.
52 # I.e. pdsh does not exit when runmultiop_bg_pause exited,
53 # because of multiop_bg_pause -> $MULTIOP_PROG &
54 # By the same reason we need sleep a bit after do_nodes starts
55 # to let runmultiop_bg_pause start muliop and
56 # update /tmp/multiop_bg.pid ;
57 # The rm /tmp/multiop_bg.pid guarantees here that
58 # we have the updated by runmultiop_bg_pause
59 # /tmp/multiop_bg.pid file
61 local pid_file=$TMP/multiop_bg.pid.$$
62 do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file $cmds" &
66 multiop_pid=$(do_node $client cat $pid_file)
67 [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
68 eval export $(node_var_name $client)_multiop_pid=$multiop_pid
69 eval export $(node_var_name $client)_do_node_pid=$pid
70 local var=$(node_var_name $client)_multiop_pid
71 echo client $client multiop_bg started multiop_pid=${!var}
77 local multiop_pid=$(node_var_name $client)_multiop_pid
78 local do_node_pid=$(node_var_name $client)_do_node_pid
80 echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
81 do_node $client kill -USR1 ${!multiop_pid}
87 local var=${SINGLEMDS}_svc
92 fid=$(do_node $client $LFS path2fid $file)
93 do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\"
97 cos_param_file=$TMP/rvbr-cos-params
98 save_lustre_params $(get_facets MDS) "mdt.*.commit_on_sharing" > $cos_param_file
101 get_version $CLIENT1 $DIR/$tdir/1a || true
103 run_test 0a "getversion for non existent file shouldn't cause kernel panic"
106 local var=${SINGLEMDS}_svc
108 local file=$DIR/$tdir/f
110 do_node $CLIENT1 mkdir -p $DIR/$tdir/
111 do_node $CLIENT1 touch $file
112 fid=$(do_node $CLIENT1 $LFS path2fid $file)
113 do_node $CLIENT1 rm -rf $file
114 do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\" || true
116 run_test 0b "getversion for non existent fid shouldn't cause kernel panic"
119 test_1a() { # former test_0a
120 local file=$DIR/$tfile
124 do_node $CLIENT1 mcreate $file
125 pre=$(get_version $CLIENT1 $file)
126 do_node $CLIENT1 openfile -f O_RDWR $file
127 post=$(get_version $CLIENT1 $file)
128 if (($pre != $post)); then
129 error "version changed unexpectedly: pre $pre, post $post"
132 run_test 1a "open and close do not change versions"
134 test_1b() { # former test_0b
135 local var=${SINGLEMDS}_svc
136 zconf_mount $CLIENT2 $MOUNT2
138 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
139 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
140 do_node $CLIENT1 mkdir -p -m 755 $MOUNT/$tdir
142 replay_barrier $SINGLEMDS
143 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
144 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT $MOUNT/$tdir/$tfile
145 zconf_umount $CLIENT2 $MOUNT2
146 facet_failover $SINGLEMDS
148 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
149 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
150 error_and_remount "open succeeded unexpectedly"
153 run_test 1b "open (O_CREAT) checks version of parent"
155 test_1c() { # former test_0c
156 local var=${SINGLEMDS}_svc
157 zconf_mount $CLIENT2 $MOUNT2
159 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
160 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
162 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
163 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tdir/$tfile
165 replay_barrier $SINGLEMDS
166 do_node $CLIENT2 chmod 0777 $MOUNT2/$tdir
167 do_node $CLIENT2 chmod 0666 $MOUNT2/$tdir/$tfile
168 rmultiop_start $CLIENT1 $DIR/$tdir/$tfile o_c
169 zconf_umount $CLIENT2 $MOUNT2
170 facet_failover $SINGLEMDS
172 client_up $CLIENT1 || error "$CLIENT1 evicted"
173 rmultiop_stop $CLIENT1 || error "close failed"
175 run_test 1c "open (non O_CREAT) does not checks versions"
177 # test set #2: CREAT (not open)
178 # - version of parent is not changed but checked
179 # - pre-version should be -1
180 # - post-version should be valid
181 test_2a() { # extended former test_0d
186 pre=$(get_version $CLIENT1 $DIR)
187 do_node $CLIENT1 mkfifo $DIR/$tfile-fifo
188 post=$(get_version $CLIENT1 $DIR)
189 if (($pre != $post)); then
190 error "version was changed: pre $pre, post $post"
193 pre=$(get_version $CLIENT1 $DIR)
194 do_node $CLIENT1 mkdir $DIR/$tfile-dir
195 post=$(get_version $CLIENT1 $DIR)
196 if (($pre != $post)); then
197 error "version was changed: pre $pre, post $post"
199 do_node $CLIENT1 rmdir $DIR/$tfile-dir
202 pre=$(get_version $CLIENT1 $DIR)
203 do_node $CLIENT1 mkfifo $DIR/$tfile-nod
204 post=$(get_version $CLIENT1 $DIR)
205 if (($pre != $post)); then
206 error "version was changed: pre $pre, post $post"
209 pre=$(get_version $CLIENT1 $DIR)
210 do_node $CLIENT1 mkfifo $DIR/$tfile-symlink
211 post=$(get_version $CLIENT1 $DIR)
212 if (($pre != $post)); then
213 error "version was changed: pre $pre, post $post"
216 if [ $MDSCOUNT -ge 2 ]; then
219 pre=$(get_version $CLIENT1 $DIR)
220 do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
221 post=$(get_version $CLIENT1 $DIR)
222 if (($pre != $post)); then
223 error "version was changed: pre $pre, post $post"
226 do_node $CLIENT1 rm -rf $DIR/$tfile-*
229 run_test 2a "create operations doesn't change version of parent"
231 test_2b() { # former test_0e
232 local var=${SINGLEMDS}_svc
233 zconf_mount $CLIENT2 $MOUNT2
235 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
236 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
238 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
240 replay_barrier $SINGLEMDS
241 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
242 do_node $CLIENT1 mkfifo $DIR/$tdir/$tfile
243 zconf_umount $CLIENT2 $MOUNT2
244 facet_failover $SINGLEMDS
246 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
247 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
248 error_and_remount "create succeeded unexpectedly"
251 run_test 2b "create checks version of parent"
253 test_3a() { # former test_0f
257 do_node $CLIENT1 mcreate $DIR/$tfile
258 pre=$(get_version $CLIENT1 $DIR)
259 do_node $CLIENT1 rm $DIR/$tfile
260 post=$(get_version $CLIENT1 $DIR)
261 if (($pre != $post)); then
262 error "version was changed: pre $pre, post $post"
265 if [ $MDSCOUNT -ge 2 ]; then
268 do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
269 pre=$(get_version $CLIENT1 $DIR)
270 do_node $CLIENT1 rmdir $DIR/$tfile-remote_dir
271 post=$(get_version $CLIENT1 $DIR)
272 if (($pre != $post)); then
273 error "version was changed: pre $pre, post $post"
277 run_test 3a "unlink doesn't change version of parent"
279 test_3b() { # former test_0g
280 local var=${SINGLEMDS}_svc
281 zconf_mount $CLIENT2 $MOUNT2
283 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
284 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
286 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
287 do_node $CLIENT1 mcreate $DIR/$tdir/$tfile
289 replay_barrier $SINGLEMDS
290 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
291 do_node $CLIENT1 rm $DIR/$tdir/$tfile
292 zconf_umount $CLIENT2 $MOUNT2
293 facet_failover $SINGLEMDS
295 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
296 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
297 error_and_remount "unlink succeeded unexpectedly"
300 run_test 3b "unlink checks version of parent"
302 test_4a() { # former test_0h
303 local file=$DIR/$tfile
307 do_node $CLIENT1 mcreate $file
308 pre=$(get_version $CLIENT1 $file)
309 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
310 post=$(get_version $CLIENT1 $file)
311 if (($pre == $post)); then
312 error "version not changed: pre $pre, post $post"
315 run_test 4a "setattr of UID changes versions"
317 test_4b() { # former test_0i
318 local file=$DIR/$tfile
322 do_node $CLIENT1 mcreate $file
323 pre=$(get_version $CLIENT1 $file)
324 do_node $CLIENT1 chgrp $RUNAS_GID $file
325 post=$(get_version $CLIENT1 $file)
326 if (($pre == $post)); then
327 error "version not changed: pre $pre, post $post"
330 run_test 4b "setattr of GID changes versions"
332 test_4c() { # former test_0j
333 local file=$DIR/$tfile
334 local var=${SINGLEMDS}_svc
335 zconf_mount $CLIENT2 $MOUNT2
337 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
338 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
340 do_node $CLIENT1 mcreate $file
342 replay_barrier $SINGLEMDS
343 do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
344 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
345 zconf_umount $CLIENT2 $MOUNT2
346 facet_failover $SINGLEMDS
348 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
349 if ! do_node $CLIENT1 $CHECKSTAT -u \\\#$UID $file; then
350 error_and_remount "setattr of UID succeeded unexpectedly"
353 run_test 4c "setattr of UID checks versions"
355 test_4d() { # former test_0k
356 local file=$DIR/$tfile
357 local var=${SINGLEMDS}_svc
358 zconf_mount $CLIENT2 $MOUNT2
360 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
361 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
363 do_node $CLIENT1 mcreate $file
365 replay_barrier $SINGLEMDS
366 do_node $CLIENT2 chown $RUNAS_ID:$RUNAS_GID $MOUNT2/$tfile
367 do_node $CLIENT1 chgrp $RUNAS_GID $file
368 zconf_umount $CLIENT2 $MOUNT2
369 facet_failover $SINGLEMDS
371 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
372 if ! do_node $CLIENT1 $CHECKSTAT -g \\\#$UID $file; then
373 error_and_remount "setattr of GID succeeded unexpectedly"
376 run_test 4d "setattr of GID checks versions"
378 test_4e() { # former test_0l
379 local file=$DIR/$tfile
383 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
384 pre=$(get_version $CLIENT1 $file)
385 do_node $CLIENT1 chmod 666 $file
386 post=$(get_version $CLIENT1 $file)
387 if (($pre == $post)); then
388 error "version not changed: pre $pre, post $post"
391 run_test 4e "setattr of permission changes versions"
393 test_4f() { # former test_0m
394 local file=$DIR/$tfile
395 local var=${SINGLEMDS}_svc
396 zconf_mount $CLIENT2 $MOUNT2
398 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
399 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
401 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
403 replay_barrier $SINGLEMDS
404 do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
405 do_node $CLIENT1 chmod 666 $file
406 zconf_umount $CLIENT2 $MOUNT2
407 facet_failover $SINGLEMDS
409 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
410 if ! do_node $CLIENT1 $CHECKSTAT -p 0644 $file; then
411 error_and_remount "setattr of permission succeeded unexpectedly"
414 run_test 4f "setattr of permission checks versions"
416 test_4g() { # former test_0n
417 local file=$DIR/$tfile
421 do_node $CLIENT1 mcreate $file
422 pre=$(get_version $CLIENT1 $file)
423 do_node $CLIENT1 chattr +i $file
424 post=$(get_version $CLIENT1 $file)
425 do_node $CLIENT1 chattr -i $file
426 if (($pre == $post)); then
427 error "version not changed: pre $pre, post $post"
430 run_test 4g "setattr of flags changes versions"
438 if ((${#attr} != 1)); then
439 error "checking multiple attributes not implemented yet"
441 do_node $client lsattr $file | cut -d ' ' -f 1 | grep -q $attr
444 test_4h() { # former test_0o
445 local file=$DIR/$tfile
447 local var=${SINGLEMDS}_svc
448 zconf_mount $CLIENT2 $MOUNT2
450 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
451 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
453 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
455 replay_barrier $SINGLEMDS
456 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
457 do_node $CLIENT1 chattr +i $file
458 zconf_umount $CLIENT2 $MOUNT2
459 facet_failover $SINGLEMDS
461 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
462 checkattr $CLIENT1 i $file
464 do_node $CLIENT1 chattr -i $file
465 if [ $rc -eq 0 ]; then
466 error "setattr of flags succeeded unexpectedly"
469 run_test 4h "setattr of flags checks versions"
471 test_4i() { # former test_0p
472 local file=$DIR/$tfile
476 local var=${SINGLEMDS}_svc
478 ad_orig=$(do_facet $SINGLEMDS "$LCTL get_param mdd.${!var}.atime_diff")
479 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
480 do_node $CLIENT1 mcreate $file
481 pre=$(get_version $CLIENT1 $file)
482 do_node $CLIENT1 touch $file
483 post=$(get_version $CLIENT1 $file)
485 # We don't fail MDS in this test. atime_diff shall be
486 # restored to its original value.
488 do_facet $SINGLEMDS "$LCTL set_param $ad_orig"
489 if (($pre != $post)); then
490 error "version changed unexpectedly: pre $pre, post $post"
493 run_test 4i "setattr of times does not change versions"
495 test_4j() { # former test_0q
496 local file=$DIR/$tfile
500 do_node $CLIENT1 mcreate $file
501 pre=$(get_version $CLIENT1 $file)
502 do_node $CLIENT1 $TRUNCATE $file 1
503 post=$(get_version $CLIENT1 $file)
504 if (($pre != $post)); then
505 error "version changed unexpectedly: pre $pre, post $post"
508 run_test 4j "setattr of size does not change versions"
510 test_4k() { # former test_0r
511 local file=$DIR/$tfile
515 local var=${SINGLEMDS}_svc
516 zconf_mount $CLIENT2 $MOUNT2
518 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
519 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
520 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
522 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
524 replay_barrier $SINGLEMDS
525 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
526 do_node $CLIENT1 $TRUNCATE $file 1
528 mtime_pre=$(do_node $CLIENT1 stat --format=%Y $file)
529 do_node $CLIENT1 touch $file
530 sleep 1 # avoid stat caching
531 mtime_post=$(do_node $CLIENT1 stat --format=%Y $file)
532 zconf_umount $CLIENT2 $MOUNT2
533 facet_failover $SINGLEMDS
535 client_up $CLIENT1 || error "$CLIENT1 evicted"
536 if (($mtime_pre >= $mtime_post)); then
537 error "time not changed: pre $mtime_pre, post $mtime_post"
539 if ! do_node $CLIENT1 $CHECKSTAT -s 1 $file; then
540 error_and_remount "setattr of size failed"
542 mtime=$(do_node $CLIENT1 stat --format=%Y $file)
543 if (($mtime != $mtime_post)); then
544 error "setattr of times failed: expected $mtime_post, got $mtime"
547 run_test 4k "setattr of times and size does not check versions"
549 test_5a() { # former test_0s
555 do_node $CLIENT1 mcreate $DIR/$tfile
556 do_node $CLIENT1 mkdir -p $DIR/$tdir
557 pre=$(get_version $CLIENT1 $DIR/$tfile)
558 tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
559 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
560 post=$(get_version $CLIENT1 $DIR/$tfile)
561 tp_post=$(get_version $CLIENT1 $DIR/$tdir)
562 if (($pre == $post)); then
563 error "version of source not changed: pre $pre, post $post"
565 if (($tp_pre != $tp_post)); then
566 error "version of target parent was changed: pre $tp_pre, post $tp_post"
569 run_test 5a "link changes versions of source but not target parent"
571 test_5b() { # former test_0t
572 local var=${SINGLEMDS}_svc
573 zconf_mount $CLIENT2 $MOUNT2
575 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
576 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
578 do_node $CLIENT1 mcreate $DIR/$tfile
579 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
581 replay_barrier $SINGLEMDS
582 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
583 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
584 zconf_umount $CLIENT2 $MOUNT2
585 facet_failover $SINGLEMDS
587 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
588 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
589 error_and_remount "link should fail"
592 run_test 5b "link checks version of target parent"
594 test_5c() { # former test_0u
595 local var=${SINGLEMDS}_svc
596 zconf_mount $CLIENT2 $MOUNT2
598 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
599 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
601 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
602 do_node $CLIENT1 mkdir -p $DIR/$tdir
604 replay_barrier $SINGLEMDS
605 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
606 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
607 zconf_umount $CLIENT2 $MOUNT2
608 facet_failover $SINGLEMDS
610 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
611 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
612 error_and_remount "link should fail"
615 run_test 5c "link checks version of source"
617 test_6a() { # former test_0v
623 do_node $CLIENT1 mcreate $DIR/$tfile
624 do_node $CLIENT1 mkdir -p $DIR/$tdir
625 sp_pre=$(get_version $CLIENT1 $DIR)
626 tp_pre=$(get_version $CLIENT1 $DIR/$tdir)
627 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
628 sp_post=$(get_version $CLIENT1 $DIR)
629 tp_post=$(get_version $CLIENT1 $DIR/$tdir)
630 if (($sp_pre != $sp_post)); then
631 error "version of source parent was changed: pre $sp_pre, post $sp_post"
633 if (($tp_pre != $tp_post)); then
634 error "version of target parent was changed: pre $tp_pre, post $tp_post"
637 run_test 6a "rename doesn't change versions of source parent and target parent"
639 test_6b() { # former test_0w
643 do_node $CLIENT1 mcreate $DIR/$tfile
644 pre=$(get_version $CLIENT1 $DIR)
645 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tfile-new
646 post=$(get_version $CLIENT1 $DIR)
647 if (($pre != $post)); then
648 error "version of parent was changed: pre $pre, post $post"
651 run_test 6b "rename within same dir doesn't change version of parent"
653 test_6c() { # former test_0x
654 local var=${SINGLEMDS}_svc
655 zconf_mount $CLIENT2 $MOUNT2
657 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
658 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
660 do_node $CLIENT1 mcreate $DIR/$tfile
661 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
663 replay_barrier $SINGLEMDS
664 do_node $CLIENT2 chmod 777 $MOUNT2
665 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
666 zconf_umount $CLIENT2 $MOUNT2
667 facet_failover $SINGLEMDS
669 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
670 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
671 error_and_remount "rename should fail"
674 run_test 6c "rename checks version of source parent"
676 test_6d() { # former test_0y
677 local var=${SINGLEMDS}_svc
678 zconf_mount $CLIENT2 $MOUNT2
680 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
681 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
683 do_node $CLIENT1 mcreate $DIR/$tfile
684 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
686 replay_barrier $SINGLEMDS
687 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
688 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
689 zconf_umount $CLIENT2 $MOUNT2
690 facet_failover $SINGLEMDS
692 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
693 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
694 error_and_remount "rename should fail"
697 run_test 6d "rename checks version of target parent"
699 # pdirops tests, bug 18143
706 local var=${SINGLEMDS}_svc
707 zconf_mount $CLIENT2 $MOUNT2
709 local cname=$TESTNAME.$cycle
711 echo "start cycle: $cname"
712 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
713 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
715 do_node $CLIENT1 mkdir -p $DIR/$tdir
716 replay_barrier $SINGLEMDS
718 echo "$cname first: $first"
719 do_node $CLIENT1 $first || error "$cname: Cannot do first operation"
720 # client2 operations that will be lost
721 echo "$cname lost: $lost"
722 do_node $CLIENT2 $lost || error "$cname: Cannot do 'lost' operations"
724 echo "$cname last: $last"
725 do_node $CLIENT1 $last || error "$cname: Cannot do last operation"
726 zconf_umount $CLIENT2 $MOUNT2
727 facet_failover $SINGLEMDS
728 # should fail as conflict expected
729 client_evicted $CLIENT1 || rc=1
731 wait_recovery_complete $SINGLEMDS
732 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
739 first="createmany -o $DIR/$tdir/$tfile- 1"
740 lost="rm $MOUNT2/$tdir/$tfile-0"
741 last="createmany -o $DIR/$tdir/$tfile- 1"
742 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.1 failed"
744 first="createmany -o $DIR/$tdir/$tfile- 1"
745 lost="rm $MOUNT2/$tdir/$tfile-0"
746 last="mkdir $DIR/$tdir/$tfile-0"
747 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.2 failed"
749 first="mkdir $DIR/$tdir/$tfile-0"
750 lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
751 last="createmany -o $DIR/$tdir/$tfile- 1"
752 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.3 failed"
755 run_test 7a "create, {lost}, create"
758 first="createmany -o $DIR/$tdir/$tfile- 1"
759 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
760 last="rm $DIR/$tdir/$tfile-0"
761 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.1 failed"
763 first="createmany -o $DIR/$tdir/$tfile- 1"
764 lost="touch $MOUNT2/$tdir/$tfile; mv $MOUNT2/$tdir/$tfile $MOUNT2/$tdir/$tfile-0"
765 last="rm $DIR/$tdir/$tfile-0"
766 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.2 failed"
768 first="createmany -o $DIR/$tdir/$tfile- 1"
769 lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
770 last="rmdir $DIR/$tdir/$tfile-0"
771 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.3 failed"
774 run_test 7b "create, {lost}, unlink"
777 first="createmany -o $DIR/$tdir/$tfile- 1"
778 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
779 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
780 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.1 failed"
782 first="createmany -o $DIR/$tdir/$tfile- 2"
783 lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
784 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
785 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.2 failed"
787 first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile-1-0"
788 lost="rmdir $MOUNT2/$tdir/$tfile-1-0; createmany -o $MOUNT2/$tdir/$tfile-1- 1"
789 last="mv $DIR/$tdir/$tfile-1-0 $DIR/$tdir/$tfile-0"
790 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.3 failed"
792 first="createmany -o $DIR/$tdir/$tfile- 1"
793 lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile"
794 last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-0"
795 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.4 failed"
798 run_test 7c "create, {lost}, rename"
801 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
802 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
803 last="createmany -o $DIR/$tdir/$tfile- 1"
804 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.1 failed"
806 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
807 lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0"
808 last="mkdir $DIR/$tdir/$tfile-0"
809 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.2 failed"
811 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
812 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
813 last="createmany -o $DIR/$tdir/$tfile- 1"
814 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.3 failed"
817 run_test 7d "unlink, {lost}, create"
820 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
821 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0;createmany -o $MOUNT2/$tdir/$tfile- 1"
822 last="rm $DIR/$tdir/$tfile-0"
823 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.1 failed"
825 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
826 lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
827 last="rmdir $DIR/$tdir/$tfile-0"
828 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.2 failed"
830 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
831 lost="mkdir $MOUNT2/$tdir/$tfile-0"
832 last="rmdir $DIR/$tdir/$tfile-0"
833 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.3 failed"
835 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
836 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
837 last="rm $DIR/$tdir/$tfile-0"
838 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.4 failed"
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="rm $DIR/$tdir/$tfile-0"
843 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.5 failed"
846 run_test 7e "unlink, {lost}, unlink"
849 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
850 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
851 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
852 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.1 failed"
854 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
855 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
856 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
857 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.2 failed"
859 first="mkdir $DIR/$tdir/$tfile; createmany -o $DIR/$tdir/$tfile- 1; rmdir $DIR/$tdir/$tfile"
860 lost="mkdir $MOUNT2/$tdir/$tfile"
861 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
862 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.3 failed"
864 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
865 lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
866 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
867 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.4 failed"
869 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
870 lost="mkdir $MOUNT2/$tdir/$tfile-0"
871 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
872 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.5 failed"
875 run_test 7f "unlink, {lost}, rename"
878 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
879 lost="mkdir $MOUNT2/$tdir/$tfile-0;rmdir $MOUNT2/$tdir/$tfile-0"
880 last="createmany -o $DIR/$tdir/$tfile- 1"
881 test_7_cycle "$first" "$lost" "$last" && error "Test 7g.1 failed"
883 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
884 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
885 last="mkdir $DIR/$tdir/$tfile-0"
886 test_7_cycle "$first" "$lost" "$last" && error "Test 7g.2 failed"
888 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
889 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
890 last="link $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
891 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.1) ]
893 test_7_cycle "$first" "$lost" "$last" ||
894 error "Test 7g.3 failed"
895 else #LU-4442 LU-3528
896 test_7_cycle "$first" "$lost" "$last" &&
897 error "Test 7g.3 failed"
901 run_test 7g "rename, {lost}, create"
904 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
905 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
906 last="rm $DIR/$tdir/$tfile-0"
907 test_7_cycle "$first" "$lost" "$last" || error "Test 7h.1 failed"
909 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
910 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
911 last="rm $DIR/$tdir/$tfile-0"
912 test_7_cycle "$first" "$lost" "$last" || error "Test 7h.2 failed"
914 first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
915 lost="rm $MOUNT2/$tdir/$tfile/$tfile-0"
916 last="rmdir $DIR/$tdir/$tfile"
917 #test_7_cycle "$first" "$lost" "$last" || error "Test 7h.3 failed"
920 run_test 7h "rename, {lost}, unlink"
923 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
924 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
925 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
926 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
928 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
929 lost="mkdir $MOUNT2/$tdir/$tfile-0"
930 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
931 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
933 first="createmany -o $DIR/$tdir/$tfile- 3; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
934 lost="mv $MOUNT2/$tdir/$tfile-2 $MOUNT2/$tdir/$tfile-0"
935 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-2"
936 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.3 failed"
938 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
939 lost="rm $MOUNT2/$tdir/$tfile-1"
940 last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-1"
941 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.4 failed"
944 run_test 7i "rename, {lost}, rename"
946 # test set #8: orphan handling bug 15392.
947 # Unlink during recovery creates orphan always just in case some late open may
948 # arrive. These orphans will be removed after recovery anyway.
949 # Tests check that valid create,unlink,create sequence will work in this case
950 # too but not fail on second create due to orphan found.
953 local var=${SINGLEMDS}_svc
954 zconf_mount $CLIENT2 $MOUNT2
956 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
958 do_node $CLIENT1 mcreate $DIR/$tfile
959 do_node $CLIENT1 mkdir $DIR/$tfile-2
960 replay_barrier $SINGLEMDS
961 # missed replay from client2 will lead to recovery by versions
962 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
963 do_node $CLIENT1 rm $DIR/$tfile || return 1
964 do_node $CLIENT1 touch $DIR/$tfile || return 2
966 zconf_umount $CLIENT2 $MOUNT2
967 facet_failover $SINGLEMDS
968 client_up $CLIENT1 || return 6
970 do_node $CLIENT1 rm $DIR/$tfile || error "$tfile doesn't exists"
973 run_test 8a "create | unlink, create shouldn't fail"
976 local var=${SINGLEMDS}_svc
977 zconf_mount $CLIENT2 $MOUNT2
979 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
981 do_node $CLIENT1 touch $DIR/$tfile
982 do_node $CLIENT1 mkdir $DIR/$tfile-2
983 replay_barrier $SINGLEMDS
984 # missed replay from client2 will lead to recovery by versions
985 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
986 do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
987 do_node $CLIENT1 mcreate $MOUNT1/$tfile || return 2
989 zconf_umount $CLIENT2 $MOUNT2
990 facet_failover $SINGLEMDS
991 client_up $CLIENT1 || return 6
993 do_node $CLIENT1 rm $MOUNT1/$tfile || error "$tfile doesn't exists"
996 run_test 8b "create | unlink, create shouldn't fail"
999 local var=${SINGLEMDS}_svc
1000 zconf_mount $CLIENT2 $MOUNT2
1002 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1004 do_node $CLIENT1 touch $DIR/$tfile
1005 do_node $CLIENT1 mkdir $DIR/$tfile-2
1006 replay_barrier $SINGLEMDS
1007 # missed replay from client2 will lead to recovery by versions
1008 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
1009 do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
1010 do_node $CLIENT1 mkdir $MOUNT1/$tfile || return 2
1012 zconf_umount $CLIENT2 $MOUNT2
1013 facet_failover $SINGLEMDS
1014 client_up $CLIENT1 || return 6
1016 do_node $CLIENT1 rmdir $MOUNT1/$tfile || error "$tfile doesn't exists"
1019 run_test 8c "create | unlink, create shouldn't fail"
1022 # This test uses three Lustre clients on two hosts.
1024 # Lustre Client 1: $CLIENT1:$MOUNT ($DIR)
1025 # Lustre Client 2: $CLIENT2:$MOUNT2 ($DIR2)
1026 # Lustre Client 3: $CLIENT2:$MOUNT1 ($DIR1)
1028 test_10b() { # former test_2b
1031 local var=${SINGLEMDS}_svc
1033 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && exit 0; }
1034 [ $CLIENTCOUNT -ge 2 ] || \
1035 { skip "Need two or more clients, have $CLIENTCOUNT" && exit 0; }
1037 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
1038 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1040 zconf_mount $CLIENT1 $MOUNT
1041 zconf_mount $CLIENT2 $MOUNT1
1042 zconf_mount $CLIENT2 $MOUNT2
1043 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-a
1044 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-b
1047 # Save an MDT transaction number before recovery.
1049 do_node $CLIENT1 touch $DIR1/$tfile
1050 pre=$(get_version $CLIENT1 $DIR/$tfile)
1053 # Comments on the replay sequence state the expected result
1057 # "U" Unable to replay.
1060 replay_barrier $SINGLEMDS
1061 do_node $CLIENT1 chmod 666 $DIR/$tfile-a # R
1062 do_node $CLIENT2 chmod 666 $DIR1/$tfile-b # R
1063 do_node $CLIENT2 chgrp $RUNAS_GID $DIR2/$tfile-a # U
1064 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-a # J
1065 do_node $CLIENT2 $TRUNCATE $DIR2/$tfile-b 1 # U
1066 do_node $CLIENT2 chgrp $RUNAS_GID $DIR1/$tfile-b # R
1067 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-b # R
1068 zconf_umount $CLIENT2 $MOUNT2
1069 facet_failover $SINGLEMDS
1071 client_evicted $CLIENT1 || error "$CLIENT1:$MOUNT not evicted"
1072 client_up $CLIENT2 || error "$CLIENT2:$MOUNT1 evicted"
1075 # Check the MDT epoch. $post must be the first transaction
1076 # number assigned after recovery.
1078 do_node $CLIENT2 chmod 666 $DIR1/$tfile
1079 post=$(get_version $CLIENT2 $DIR1/$tfile)
1080 if (($(($pre >> 32)) == $((post >> 32)))); then
1081 error "epoch not changed: pre $pre, post $post"
1084 if (($(($post & 0x00000000ffffffff)) != 1)); then
1085 error "transno should restart from one: got $post"
1088 do_node $CLIENT2 stat $DIR1/$tfile-a
1089 do_node $CLIENT2 stat $DIR1/$tfile-b
1091 do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
1092 $DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
1093 do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_GID \
1094 $DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
1096 zconf_umount $CLIENT2 $MOUNT1
1098 run_test 10b "3 clients: some, none, and all reqs replayed"
1100 # test set #11: operations in single directory
1102 local var=${SINGLEMDS}_svc
1103 zconf_mount $CLIENT2 $MOUNT2
1105 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1107 replay_barrier $SINGLEMDS
1109 do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1111 do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1112 zconf_umount $CLIENT2 $MOUNT2
1115 facet_failover $SINGLEMDS
1116 # recovery shouldn't fail due to missing client 2
1117 client_up $CLIENT1 || return 1
1118 # All files from client1 should have been replayed
1119 do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1121 [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1124 run_test 11a "concurrent creates don't affect each other"
1127 local var=${SINGLEMDS}_svc
1128 zconf_mount $CLIENT2 $MOUNT2
1130 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1132 do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1134 replay_barrier $SINGLEMDS
1135 do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1137 do_node $CLIENT2 unlinkmany -o $MOUNT2/$tfile-2- 100
1138 zconf_umount $CLIENT2 $MOUNT2
1141 facet_failover $SINGLEMDS
1142 # recovery shouldn't fail due to missing client 2
1143 client_up $CLIENT1 || return 1
1144 # All files from client1 should have been replayed
1145 do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1147 [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1150 run_test 11b "concurrent creates and unlinks don't affect each other"
1152 # test set #12: lock replay with VBR, bug 16356
1153 test_12a() { # former test_2a
1154 local var=${SINGLEMDS}_svc
1155 zconf_mount $CLIENT2 $MOUNT2
1157 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1159 do_node $CLIENT2 mkdir -p $MOUNT2/$tdir
1160 replay_barrier $SINGLEMDS
1161 do_node $CLIENT2 mcreate $MOUNT2/$tdir/$tfile
1162 do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1163 #client1 read data from client2 which will be lost
1164 do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
1165 do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1166 zconf_umount $CLIENT2 $MOUNT2
1168 facet_failover $SINGLEMDS
1169 # recovery shouldn't fail due to missing client 2
1170 client_up $CLIENT1 || return 1
1172 # All 50 files should have been replayed
1173 do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1174 do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1175 do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
1179 run_test 12a "lost data due to missed REMOTE client during replay"
1181 test_13() { # LU-8826
1182 local var=${SINGLEMDS}_svc
1184 if combined_mgs_mds ; then
1185 skip "Needs separate MGS to enable IR"
1189 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
1190 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1192 zconf_mount $CLIENT2 $MOUNT2
1193 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
1195 # set ir_timeout to a reasonable small value
1196 local ir_timeout=$(do_facet mgs $LCTL get_param -n mgs.*.ir_timeout)
1197 do_facet mgs $LCTL set_param mgs.*.ir_timeout=5
1198 # make sure IR functional
1201 replay_barrier $SINGLEMDS
1202 do_node $CLIENT1 chmod 666 $DIR/$tfile
1203 do_node $CLIENT2 chmod 777 $DIR2/$tfile
1205 # make sure client data of $CLIENT2:$MOUNT2 is remained
1206 # define OBD_FAIL_TGT_CLIENT_DEL 0x718
1207 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x718
1208 zconf_umount $CLIENT2 $MOUNT2
1209 # define OBD_FAIL_TGT_SLUGGISH_NET 0x719
1210 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x719
1211 facet_failover $SINGLEMDS
1213 client_up $CLIENT1 || error "$CLIENT1 evicted"
1215 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1216 do_facet mgs $LCTL set_param mgs.*.ir_timeout=$ir_timeout
1218 do_node $CLIENT1 $CHECKSTAT -p 0666 $DIR/$tfile ||
1219 error "$DIR/$tfile-a: unexpected state"
1221 run_test 13 "Shouldn't give up VBR easily on sluggish network"
1223 #restore COS setting
1224 restore_lustre_params < $cos_param_file
1225 rm -f $cos_param_file
1227 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
1230 check_and_cleanup_lustre