2 # -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
3 # vim:shiftwidth=4:softtabstop=4:tabstop=4:
8 ALWAYS_EXCEPT=" $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"
49 local WAIT_MAX=${4:-60}
52 # We need to run do_node in bg, because pdsh does not exit
53 # if child process of run script exists.
54 # I.e. pdsh does not exit when runmultiop_bg_pause exited,
55 # because of multiop_bg_pause -> $MULTIOP_PROG &
56 # By the same reason we need sleep a bit after do_nodes starts
57 # to let runmultiop_bg_pause start muliop and
58 # update /tmp/multiop_bg.pid ;
59 # The rm /tmp/multiop_bg.pid guarantees here that
60 # we have the updated by runmultiop_bg_pause
61 # /tmp/multiop_bg.pid file
63 local pid_file=$TMP/multiop_bg.pid.$$
64 do_node $client "MULTIOP_PID_FILE=$pid_file LUSTRE= \
65 runmultiop_bg_pause $file $cmds" &
69 while [[ $wait_time -lt $WAIT_MAX ]]; do
71 wait_time=$((wait_time + 3))
72 multiop_pid=$(do_node $client cat $pid_file)
73 if [ -n "$multiop_pid" ]; then
78 [ -n "$multiop_pid" ] ||
79 error "$client : Can not get multiop_pid from $pid_file "
81 eval export $(node_var_name $client)_multiop_pid=$multiop_pid
82 eval export $(node_var_name $client)_do_node_pid=$pid
83 local var=$(node_var_name $client)_multiop_pid
84 echo client $client multiop_bg started multiop_pid=${!var}
90 local multiop_pid=$(node_var_name $client)_multiop_pid
91 local do_node_pid=$(node_var_name $client)_do_node_pid
93 echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
94 do_node $client kill -USR1 ${!multiop_pid}
100 # get_version(): Gets the version of an object on servers
101 # Parameter1: Client/Machine Name
102 # Parameter2: File Path
103 # Returns: Objectversion Or -1 if getobjversion fails.
106 local var=${SINGLEMDS}_svc
109 local fid=$(do_node $client $LFS path2fid $file)
110 local objver=$(do_facet $SINGLEMDS $LCTL --device ${!var} \
111 getobjversion \\\"$fid\\\")
113 [[ -z $objver ]] && objver=-1
118 # chk_get_version(): Wrapper to get_version().
119 # Parameter1: Client/Machine Name
120 # Parameter2: File Path
121 # Returns: Objectversion Or Exit with error in case objver is -1.
124 local objver=$(get_version $1 $2)
126 [[ "$objver" == "-1" ]] && error "object version is empty."
132 cos_param_file=$TMP/rvbr-cos-params
133 save_lustre_params $(get_facets MDS) "mdt.*.commit_on_sharing" > $cos_param_file
136 local ver=$(get_version $CLIENT1 $DIR/$tdir/1a)
138 [[ "$ver" == "-1" ]] && return 0
141 run_test 0a "getversion for non existent file shouldn't cause kernel panic"
144 local var=${SINGLEMDS}_svc
146 local file=$DIR/$tdir/f
148 do_node $CLIENT1 mkdir -p $DIR/$tdir/
149 do_node $CLIENT1 touch $file
150 fid=$(do_node $CLIENT1 $LFS path2fid $file)
151 do_node $CLIENT1 rm -rf $file
152 do_facet $SINGLEMDS $LCTL --device ${!var} getobjversion \\\"$fid\\\" || true
154 run_test 0b "getversion for non existent fid shouldn't cause kernel panic"
157 test_1a() { # former test_0a
158 local file=$DIR/$tfile
162 do_node $CLIENT1 mcreate $file
163 pre=$(chk_get_version $CLIENT1 $file)
164 do_node $CLIENT1 openfile -f O_RDWR $file
165 post=$(chk_get_version $CLIENT1 $file)
166 if (($pre != $post)); then
167 error "version changed unexpectedly: pre $pre, post $post"
170 run_test 1a "open and close do not change versions"
172 test_1b() { # former test_0b
173 local var=${SINGLEMDS}_svc
174 zconf_mount $CLIENT2 $MOUNT2
176 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
177 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
178 do_node $CLIENT1 mkdir -p -m 755 $MOUNT/$tdir
180 replay_barrier $SINGLEMDS
181 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
182 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT $MOUNT/$tdir/$tfile
183 zconf_umount $CLIENT2 $MOUNT2
184 facet_failover $SINGLEMDS
186 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
187 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
188 error_and_remount "open succeeded unexpectedly"
191 run_test 1b "open (O_CREAT) checks version of parent"
193 test_1c() { # former test_0c
194 local var=${SINGLEMDS}_svc
195 zconf_mount $CLIENT2 $MOUNT2
197 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
198 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
200 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
201 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tdir/$tfile
203 replay_barrier $SINGLEMDS
204 do_node $CLIENT2 chmod 0777 $MOUNT2/$tdir
205 do_node $CLIENT2 chmod 0666 $MOUNT2/$tdir/$tfile
206 rmultiop_start $CLIENT1 $DIR/$tdir/$tfile o_c
207 zconf_umount $CLIENT2 $MOUNT2
208 facet_failover $SINGLEMDS
210 client_up $CLIENT1 || error "$CLIENT1 evicted"
211 rmultiop_stop $CLIENT1 || error "close failed"
213 run_test 1c "open (non O_CREAT) does not checks versions"
215 # test set #2: CREAT (not open)
216 # - version of parent is not changed but checked
217 # - pre-version should be -1
218 # - post-version should be valid
219 test_2a() { # extended former test_0d
224 pre=$(chk_get_version $CLIENT1 $DIR)
225 do_node $CLIENT1 mkfifo $DIR/$tfile-fifo
226 post=$(chk_get_version $CLIENT1 $DIR)
227 if (($pre != $post)); then
228 error "version was changed: pre $pre, post $post"
231 pre=$(chk_get_version $CLIENT1 $DIR)
232 do_node $CLIENT1 mkdir $DIR/$tfile-dir
233 post=$(chk_get_version $CLIENT1 $DIR)
234 if (($pre != $post)); then
235 error "version was changed: pre $pre, post $post"
237 do_node $CLIENT1 rmdir $DIR/$tfile-dir
240 pre=$(chk_get_version $CLIENT1 $DIR)
241 do_node $CLIENT1 mkfifo $DIR/$tfile-nod
242 post=$(chk_get_version $CLIENT1 $DIR)
243 if (($pre != $post)); then
244 error "version was changed: pre $pre, post $post"
247 pre=$(chk_get_version $CLIENT1 $DIR)
248 do_node $CLIENT1 mkfifo $DIR/$tfile-symlink
249 post=$(chk_get_version $CLIENT1 $DIR)
250 if (($pre != $post)); then
251 error "version was changed: pre $pre, post $post"
254 if [ $MDSCOUNT -ge 2 ]; then
257 pre=$(chk_get_version $CLIENT1 $DIR)
258 do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
259 post=$(chk_get_version $CLIENT1 $DIR)
260 if (($pre != $post)); then
261 error "version was changed: pre $pre, post $post"
264 do_node $CLIENT1 rm -rf $DIR/$tfile-*
267 run_test 2a "create operations doesn't change version of parent"
269 test_2b() { # former test_0e
270 local var=${SINGLEMDS}_svc
271 zconf_mount $CLIENT2 $MOUNT2
273 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
274 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
276 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
278 replay_barrier $SINGLEMDS
279 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
280 do_node $CLIENT1 mkfifo $DIR/$tdir/$tfile
281 zconf_umount $CLIENT2 $MOUNT2
282 facet_failover $SINGLEMDS
284 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
285 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
286 error_and_remount "create succeeded unexpectedly"
289 run_test 2b "create checks version of parent"
291 test_3a() { # former test_0f
295 do_node $CLIENT1 mcreate $DIR/$tfile
296 pre=$(chk_get_version $CLIENT1 $DIR)
297 do_node $CLIENT1 rm $DIR/$tfile
298 post=$(chk_get_version $CLIENT1 $DIR)
299 if (($pre != $post)); then
300 error "version was changed: pre $pre, post $post"
303 if [ $MDSCOUNT -ge 2 ]; then
306 do_node $CLIENT1 $LFS mkdir -i $MDT_IDX $DIR/$tfile-remote_dir
307 pre=$(chk_get_version $CLIENT1 $DIR)
308 do_node $CLIENT1 rmdir $DIR/$tfile-remote_dir
309 post=$(chk_get_version $CLIENT1 $DIR)
310 if (($pre != $post)); then
311 error "version was changed: pre $pre, post $post"
315 run_test 3a "unlink doesn't change version of parent"
317 test_3b() { # former test_0g
318 local var=${SINGLEMDS}_svc
319 zconf_mount $CLIENT2 $MOUNT2
321 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
322 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
324 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
325 do_node $CLIENT1 mcreate $DIR/$tdir/$tfile
327 replay_barrier $SINGLEMDS
328 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
329 do_node $CLIENT1 rm $DIR/$tdir/$tfile
330 zconf_umount $CLIENT2 $MOUNT2
331 facet_failover $SINGLEMDS
333 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
334 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
335 error_and_remount "unlink succeeded unexpectedly"
338 run_test 3b "unlink checks version of parent"
340 test_4a() { # former test_0h
341 local file=$DIR/$tfile
345 do_node $CLIENT1 mcreate $file
346 pre=$(chk_get_version $CLIENT1 $file)
347 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
348 post=$(chk_get_version $CLIENT1 $file)
349 if (($pre == $post)); then
350 error "version not changed: pre $pre, post $post"
353 run_test 4a "setattr of UID changes versions"
355 test_4b() { # former test_0i
356 local file=$DIR/$tfile
360 do_node $CLIENT1 mcreate $file
361 pre=$(chk_get_version $CLIENT1 $file)
362 do_node $CLIENT1 chgrp $RUNAS_GID $file
363 post=$(chk_get_version $CLIENT1 $file)
364 if (($pre == $post)); then
365 error "version not changed: pre $pre, post $post"
368 run_test 4b "setattr of GID changes versions"
370 test_4c() { # former test_0j
371 local file=$DIR/$tfile
372 local var=${SINGLEMDS}_svc
373 zconf_mount $CLIENT2 $MOUNT2
375 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
376 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
378 do_node $CLIENT1 mcreate $file
380 replay_barrier $SINGLEMDS
381 do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
382 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $file
383 zconf_umount $CLIENT2 $MOUNT2
384 facet_failover $SINGLEMDS
386 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
387 if ! do_node $CLIENT1 $CHECKSTAT -u \\\#$UID $file; then
388 error_and_remount "setattr of UID succeeded unexpectedly"
391 run_test 4c "setattr of UID checks versions"
393 test_4d() { # former test_0k
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 mcreate $file
403 replay_barrier $SINGLEMDS
404 do_node $CLIENT2 chown $RUNAS_ID:$RUNAS_GID $MOUNT2/$tfile
405 do_node $CLIENT1 chgrp $RUNAS_GID $file
406 zconf_umount $CLIENT2 $MOUNT2
407 facet_failover $SINGLEMDS
409 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
410 if ! do_node $CLIENT1 $CHECKSTAT -g \\\#$UID $file; then
411 error_and_remount "setattr of GID succeeded unexpectedly"
414 run_test 4d "setattr of GID checks versions"
416 test_4e() { # former test_0l
417 local file=$DIR/$tfile
421 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
422 pre=$(chk_get_version $CLIENT1 $file)
423 do_node $CLIENT1 chmod 666 $file
424 post=$(chk_get_version $CLIENT1 $file)
425 if (($pre == $post)); then
426 error "version not changed: pre $pre, post $post"
429 run_test 4e "setattr of permission changes versions"
431 test_4f() { # former test_0m
432 local file=$DIR/$tfile
433 local var=${SINGLEMDS}_svc
434 zconf_mount $CLIENT2 $MOUNT2
436 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
437 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
439 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
441 replay_barrier $SINGLEMDS
442 do_node $CLIENT2 chgrp $RUNAS_GID $MOUNT2/$tfile
443 do_node $CLIENT1 chmod 666 $file
444 zconf_umount $CLIENT2 $MOUNT2
445 facet_failover $SINGLEMDS
447 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
448 if ! do_node $CLIENT1 $CHECKSTAT -p 0644 $file; then
449 error_and_remount "setattr of permission succeeded unexpectedly"
452 run_test 4f "setattr of permission checks versions"
454 test_4g() { # former test_0n
455 local file=$DIR/$tfile
459 do_node $CLIENT1 mcreate $file
460 pre=$(chk_get_version $CLIENT1 $file)
461 do_node $CLIENT1 chattr +i $file
462 post=$(chk_get_version $CLIENT1 $file)
463 do_node $CLIENT1 chattr -i $file
464 if (($pre == $post)); then
465 error "version not changed: pre $pre, post $post"
468 run_test 4g "setattr of flags changes versions"
476 if ((${#attr} != 1)); then
477 error "checking multiple attributes not implemented yet"
479 do_node $client lsattr $file | cut -d ' ' -f 1 | grep -q $attr
482 test_4h() { # former test_0o
483 local file=$DIR/$tfile
485 local var=${SINGLEMDS}_svc
486 zconf_mount $CLIENT2 $MOUNT2
488 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
489 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
491 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
493 replay_barrier $SINGLEMDS
494 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
495 do_node $CLIENT1 chattr +i $file
496 zconf_umount $CLIENT2 $MOUNT2
497 facet_failover $SINGLEMDS
499 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
500 checkattr $CLIENT1 i $file
502 do_node $CLIENT1 chattr -i $file
503 if [ $rc -eq 0 ]; then
504 error "setattr of flags succeeded unexpectedly"
507 run_test 4h "setattr of flags checks versions"
509 test_4i() { # former test_0p
510 local file=$DIR/$tfile
514 local var=${SINGLEMDS}_svc
516 ad_orig=$(do_facet $SINGLEMDS "$LCTL get_param mdd.${!var}.atime_diff")
517 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
518 do_node $CLIENT1 mcreate $file
519 pre=$(chk_get_version $CLIENT1 $file)
520 do_node $CLIENT1 touch $file
521 post=$(chk_get_version $CLIENT1 $file)
523 # We don't fail MDS in this test. atime_diff shall be
524 # restored to its original value.
526 do_facet $SINGLEMDS "$LCTL set_param $ad_orig"
527 if (($pre != $post)); then
528 error "version changed unexpectedly: pre $pre, post $post"
531 run_test 4i "setattr of times does not change versions"
533 test_4j() { # former test_0q
534 local file=$DIR/$tfile
538 do_node $CLIENT1 mcreate $file
539 pre=$(chk_get_version $CLIENT1 $file)
540 do_node $CLIENT1 $TRUNCATE $file 1
541 post=$(chk_get_version $CLIENT1 $file)
542 if (($pre != $post)); then
543 error "version changed unexpectedly: pre $pre, post $post"
546 run_test 4j "setattr of size does not change versions"
548 test_4k() { # former test_0r
549 local file=$DIR/$tfile
553 local var=${SINGLEMDS}_svc
554 zconf_mount $CLIENT2 $MOUNT2
556 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
557 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.atime_diff=0"
558 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
560 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $file
562 replay_barrier $SINGLEMDS
563 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
564 do_node $CLIENT1 $TRUNCATE $file 1
566 mtime_pre=$(do_node $CLIENT1 stat --format=%Y $file)
567 do_node $CLIENT1 touch $file
568 sleep 1 # avoid stat caching
569 mtime_post=$(do_node $CLIENT1 stat --format=%Y $file)
570 zconf_umount $CLIENT2 $MOUNT2
571 facet_failover $SINGLEMDS
573 client_up $CLIENT1 || error "$CLIENT1 evicted"
574 if (($mtime_pre >= $mtime_post)); then
575 error "time not changed: pre $mtime_pre, post $mtime_post"
577 if ! do_node $CLIENT1 $CHECKSTAT -s 1 $file; then
578 error_and_remount "setattr of size failed"
580 mtime=$(do_node $CLIENT1 stat --format=%Y $file)
581 if (($mtime != $mtime_post)); then
582 error "setattr of times failed: expected $mtime_post, got $mtime"
585 run_test 4k "setattr of times and size does not check versions"
587 test_5a() { # former test_0s
593 do_node $CLIENT1 mcreate $DIR/$tfile
594 do_node $CLIENT1 mkdir -p $DIR/$tdir
595 pre=$(chk_get_version $CLIENT1 $DIR/$tfile)
596 tp_pre=$(chk_get_version $CLIENT1 $DIR/$tdir)
597 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
598 post=$(chk_get_version $CLIENT1 $DIR/$tfile)
599 tp_post=$(chk_get_version $CLIENT1 $DIR/$tdir)
600 if (($pre == $post)); then
601 error "version of source not changed: pre $pre, post $post"
603 if (($tp_pre != $tp_post)); then
604 error "version of target parent was changed:"\
605 "pre $tp_pre, post $tp_post"
608 run_test 5a "link changes versions of source but not target parent"
610 test_5b() { # former test_0t
611 local var=${SINGLEMDS}_svc
612 zconf_mount $CLIENT2 $MOUNT2
614 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
615 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
617 do_node $CLIENT1 mcreate $DIR/$tfile
618 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
620 replay_barrier $SINGLEMDS
621 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
622 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
623 zconf_umount $CLIENT2 $MOUNT2
624 facet_failover $SINGLEMDS
626 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
627 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
628 error_and_remount "link should fail"
631 run_test 5b "link checks version of target parent"
633 test_5c() { # former test_0u
634 local var=${SINGLEMDS}_svc
635 zconf_mount $CLIENT2 $MOUNT2
637 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
638 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
640 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
641 do_node $CLIENT1 mkdir -p $DIR/$tdir
643 replay_barrier $SINGLEMDS
644 do_node $CLIENT2 chmod 666 $MOUNT2/$tfile
645 do_node $CLIENT1 link $DIR/$tfile $DIR/$tdir/$tfile
646 zconf_umount $CLIENT2 $MOUNT2
647 facet_failover $SINGLEMDS
649 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
650 if ! do_node $CLIENT1 $CHECKSTAT -a $DIR/$tdir/$tfile; then
651 error_and_remount "link should fail"
654 run_test 5c "link checks version of source"
656 test_6a() { # former test_0v
662 do_node $CLIENT1 mcreate $DIR/$tfile
663 do_node $CLIENT1 mkdir -p $DIR/$tdir
664 sp_pre=$(chk_get_version $CLIENT1 $DIR)
665 tp_pre=$(chk_get_version $CLIENT1 $DIR/$tdir)
666 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
667 sp_post=$(chk_get_version $CLIENT1 $DIR)
668 tp_post=$(chk_get_version $CLIENT1 $DIR/$tdir)
669 if (($sp_pre != $sp_post)); then
670 error "version of source parent was changed:" \
671 "pre $sp_pre, post $sp_post"
673 if (($tp_pre != $tp_post)); then
674 error "version of target parent was changed:" \
675 "pre $tp_pre, post $tp_post"
678 run_test 6a "rename doesn't change versions of source parent and target parent"
680 test_6b() { # former test_0w
684 do_node $CLIENT1 mcreate $DIR/$tfile
685 pre=$(chk_get_version $CLIENT1 $DIR)
686 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tfile-new
687 post=$(chk_get_version $CLIENT1 $DIR)
688 if (($pre != $post)); then
689 error "version of parent was changed: pre $pre, post $post"
692 run_test 6b "rename within same dir doesn't change version of parent"
694 test_6c() { # former test_0x
695 local var=${SINGLEMDS}_svc
696 zconf_mount $CLIENT2 $MOUNT2
698 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
699 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
701 do_node $CLIENT1 mcreate $DIR/$tfile
702 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
704 replay_barrier $SINGLEMDS
705 do_node $CLIENT2 chmod 777 $MOUNT2
706 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
707 zconf_umount $CLIENT2 $MOUNT2
708 facet_failover $SINGLEMDS
710 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
711 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
712 error_and_remount "rename should fail"
715 run_test 6c "rename checks version of source parent"
717 test_6d() { # former test_0y
718 local var=${SINGLEMDS}_svc
719 zconf_mount $CLIENT2 $MOUNT2
721 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
722 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
724 do_node $CLIENT1 mcreate $DIR/$tfile
725 do_node $CLIENT1 mkdir -p -m 755 $DIR/$tdir
727 replay_barrier $SINGLEMDS
728 do_node $CLIENT2 chmod 777 $MOUNT2/$tdir
729 do_node $CLIENT1 mv $DIR/$tfile $DIR/$tdir/$tfile
730 zconf_umount $CLIENT2 $MOUNT2
731 facet_failover $SINGLEMDS
733 client_evicted $CLIENT1 || error "$CLIENT1 not evicted"
734 if do_node $CLIENT1 $CHECKSTAT -a $DIR/$tfile; then
735 error_and_remount "rename should fail"
738 run_test 6d "rename checks version of target parent"
740 # pdirops tests, bug 18143
747 local var=${SINGLEMDS}_svc
748 zconf_mount $CLIENT2 $MOUNT2
750 local cname=$TESTNAME.$cycle
752 echo "start cycle: $cname"
753 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
754 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
756 do_node $CLIENT1 mkdir -p $DIR/$tdir
757 replay_barrier $SINGLEMDS
759 echo "$cname first: $first"
760 do_node $CLIENT1 $first || error "$cname: Cannot do first operation"
761 # client2 operations that will be lost
762 echo "$cname lost: $lost"
763 do_node $CLIENT2 $lost || error "$cname: Cannot do 'lost' operations"
765 echo "$cname last: $last"
766 do_node $CLIENT1 $last || error "$cname: Cannot do last operation"
767 zconf_umount $CLIENT2 $MOUNT2
768 facet_failover $SINGLEMDS
769 # should fail as conflict expected
770 client_evicted $CLIENT1 || rc=1
772 wait_recovery_complete $SINGLEMDS
773 wait_mds_ost_sync || error "wait_mds_ost_sync failed"
780 first="createmany -o $DIR/$tdir/$tfile- 1"
781 lost="rm $MOUNT2/$tdir/$tfile-0"
782 last="createmany -o $DIR/$tdir/$tfile- 1"
783 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.1 failed"
785 first="createmany -o $DIR/$tdir/$tfile- 1"
786 lost="rm $MOUNT2/$tdir/$tfile-0"
787 last="mkdir $DIR/$tdir/$tfile-0"
788 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.2 failed"
790 first="mkdir $DIR/$tdir/$tfile-0"
791 lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
792 last="createmany -o $DIR/$tdir/$tfile- 1"
793 test_7_cycle "$first" "$lost" "$last" || error "Test 7a.3 failed"
796 run_test 7a "create, {lost}, create"
799 first="createmany -o $DIR/$tdir/$tfile- 1"
800 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
801 last="rm $DIR/$tdir/$tfile-0"
802 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.1 failed"
804 first="createmany -o $DIR/$tdir/$tfile- 1"
805 lost="touch $MOUNT2/$tdir/$tfile; mv $MOUNT2/$tdir/$tfile $MOUNT2/$tdir/$tfile-0"
806 last="rm $DIR/$tdir/$tfile-0"
807 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.2 failed"
809 first="createmany -o $DIR/$tdir/$tfile- 1"
810 lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
811 last="rmdir $DIR/$tdir/$tfile-0"
812 test_7_cycle "$first" "$lost" "$last" || error "Test 7b.3 failed"
815 run_test 7b "create, {lost}, unlink"
818 first="createmany -o $DIR/$tdir/$tfile- 1"
819 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
820 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
821 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.1 failed"
823 first="createmany -o $DIR/$tdir/$tfile- 2"
824 lost="rm $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
825 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
826 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.2 failed"
828 first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile-1-0"
829 lost="rmdir $MOUNT2/$tdir/$tfile-1-0; createmany -o $MOUNT2/$tdir/$tfile-1- 1"
830 last="mv $DIR/$tdir/$tfile-1-0 $DIR/$tdir/$tfile-0"
831 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.3 failed"
833 first="createmany -o $DIR/$tdir/$tfile- 1"
834 lost="mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile"
835 last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-0"
836 test_7_cycle "$first" "$lost" "$last" || error "Test 7c.4 failed"
839 run_test 7c "create, {lost}, rename"
842 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
843 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
844 last="createmany -o $DIR/$tdir/$tfile- 1"
845 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.1 failed"
847 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
848 lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0"
849 last="mkdir $DIR/$tdir/$tfile-0"
850 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.2 failed"
852 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
853 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; mv $MOUNT2/$tdir/$tfile-0 $MOUNT2/$tdir/$tfile-1"
854 last="createmany -o $DIR/$tdir/$tfile- 1"
855 test_7_cycle "$first" "$lost" "$last" && error "Test 7d.3 failed"
858 run_test 7d "unlink, {lost}, create"
861 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
862 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0;createmany -o $MOUNT2/$tdir/$tfile- 1"
863 last="rm $DIR/$tdir/$tfile-0"
864 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.1 failed"
866 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
867 lost="mkdir $MOUNT2/$tdir/$tfile-0; rmdir $MOUNT2/$tdir/$tfile-0; mkdir $MOUNT2/$tdir/$tfile-0"
868 last="rmdir $DIR/$tdir/$tfile-0"
869 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.2 failed"
871 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
872 lost="mkdir $MOUNT2/$tdir/$tfile-0"
873 last="rmdir $DIR/$tdir/$tfile-0"
874 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.3 failed"
876 first="mkdir $DIR/$tdir/$tfile-0; rmdir $DIR/$tdir/$tfile-0"
877 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
878 last="rm $DIR/$tdir/$tfile-0"
879 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.4 failed"
881 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
882 lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
883 last="rm $DIR/$tdir/$tfile-0"
884 test_7_cycle "$first" "$lost" "$last" || error "Test 7e.5 failed"
887 run_test 7e "unlink, {lost}, unlink"
890 first="createmany -o $DIR/$tdir/$tfile- 1; rm $DIR/$tdir/$tfile-0"
891 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
892 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
893 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.1 failed"
895 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
896 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
897 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
898 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.2 failed"
900 first="mkdir $DIR/$tdir/$tfile; createmany -o $DIR/$tdir/$tfile- 1; rmdir $DIR/$tdir/$tfile"
901 lost="mkdir $MOUNT2/$tdir/$tfile"
902 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
903 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.3 failed"
905 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
906 lost="mv $MOUNT2/$tdir/$tfile-1 $MOUNT2/$tdir/$tfile-0"
907 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
908 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.4 failed"
910 first="createmany -o $DIR/$tdir/$tfile- 2; rm $DIR/$tdir/$tfile-0"
911 lost="mkdir $MOUNT2/$tdir/$tfile-0"
912 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
913 test_7_cycle "$first" "$lost" "$last" || error "Test 7f.5 failed"
916 run_test 7f "unlink, {lost}, rename"
919 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
920 lost="mkdir $MOUNT2/$tdir/$tfile-0;rmdir $MOUNT2/$tdir/$tfile-0"
921 last="createmany -o $DIR/$tdir/$tfile- 1"
922 test_7_cycle "$first" "$lost" "$last" && error "Test 7g.1 failed"
924 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
925 lost="createmany -o $MOUNT2/$tdir/$tfile- 1; rm $MOUNT2/$tdir/$tfile-0"
926 last="mkdir $DIR/$tdir/$tfile-0"
927 test_7_cycle "$first" "$lost" "$last" && error "Test 7g.2 failed"
929 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
930 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
931 last="link $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
932 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.1) ]
934 test_7_cycle "$first" "$lost" "$last" ||
935 error "Test 7g.3 failed"
936 else #LU-4442 LU-3528
937 test_7_cycle "$first" "$lost" "$last" &&
938 error "Test 7g.3 failed"
942 run_test 7g "rename, {lost}, create"
945 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
946 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
947 last="rm $DIR/$tdir/$tfile-0"
948 test_7_cycle "$first" "$lost" "$last" || error "Test 7h.1 failed"
950 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
951 lost="rm $MOUNT2/$tdir/$tfile-0; createmany -o $MOUNT2/$tdir/$tfile- 1"
952 last="rm $DIR/$tdir/$tfile-0"
953 test_7_cycle "$first" "$lost" "$last" || error "Test 7h.2 failed"
955 first="createmany -o $DIR/$tdir/$tfile- 1; mkdir $DIR/$tdir/$tfile; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
956 lost="rm $MOUNT2/$tdir/$tfile/$tfile-0"
957 last="rmdir $DIR/$tdir/$tfile"
958 #test_7_cycle "$first" "$lost" "$last" || error "Test 7h.3 failed"
961 run_test 7h "rename, {lost}, unlink"
964 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
965 lost="createmany -o $MOUNT2/$tdir/$tfile- 1"
966 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
967 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
969 first="createmany -o $DIR/$tdir/$tfile- 1; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-1"
970 lost="mkdir $MOUNT2/$tdir/$tfile-0"
971 last="mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
972 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.1 failed"
974 first="createmany -o $DIR/$tdir/$tfile- 3; mv $DIR/$tdir/$tfile-1 $DIR/$tdir/$tfile-0"
975 lost="mv $MOUNT2/$tdir/$tfile-2 $MOUNT2/$tdir/$tfile-0"
976 last="mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile-2"
977 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.3 failed"
979 first="createmany -o $DIR/$tdir/$tfile- 2; mv $DIR/$tdir/$tfile-0 $DIR/$tdir/$tfile"
980 lost="rm $MOUNT2/$tdir/$tfile-1"
981 last="mv $DIR/$tdir/$tfile $DIR/$tdir/$tfile-1"
982 test_7_cycle "$first" "$lost" "$last" || error "Test 7i.4 failed"
985 run_test 7i "rename, {lost}, rename"
987 # test set #8: orphan handling bug 15392.
988 # Unlink during recovery creates orphan always just in case some late open may
989 # arrive. These orphans will be removed after recovery anyway.
990 # Tests check that valid create,unlink,create sequence will work in this case
991 # too but not fail on second create due to orphan found.
994 local var=${SINGLEMDS}_svc
995 zconf_mount $CLIENT2 $MOUNT2
997 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
999 do_node $CLIENT1 mcreate $DIR/$tfile
1000 do_node $CLIENT1 mkdir $DIR/$tfile-2
1001 replay_barrier $SINGLEMDS
1002 # missed replay from client2 will lead to recovery by versions
1003 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
1004 do_node $CLIENT1 rm $DIR/$tfile || return 1
1005 do_node $CLIENT1 touch $DIR/$tfile || return 2
1007 zconf_umount $CLIENT2 $MOUNT2
1008 facet_failover $SINGLEMDS
1009 client_up $CLIENT1 || return 6
1011 do_node $CLIENT1 rm $DIR/$tfile || error "$tfile doesn't exists"
1014 run_test 8a "create | unlink, create shouldn't fail"
1017 local var=${SINGLEMDS}_svc
1018 zconf_mount $CLIENT2 $MOUNT2
1020 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1022 do_node $CLIENT1 touch $DIR/$tfile
1023 do_node $CLIENT1 mkdir $DIR/$tfile-2
1024 replay_barrier $SINGLEMDS
1025 # missed replay from client2 will lead to recovery by versions
1026 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
1027 do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
1028 do_node $CLIENT1 mcreate $MOUNT1/$tfile || return 2
1030 zconf_umount $CLIENT2 $MOUNT2
1031 facet_failover $SINGLEMDS
1032 client_up $CLIENT1 || return 6
1034 do_node $CLIENT1 rm $MOUNT1/$tfile || error "$tfile doesn't exists"
1037 run_test 8b "create | unlink, create shouldn't fail"
1040 local var=${SINGLEMDS}_svc
1041 zconf_mount $CLIENT2 $MOUNT2
1043 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1045 do_node $CLIENT1 touch $DIR/$tfile
1046 do_node $CLIENT1 mkdir $DIR/$tfile-2
1047 replay_barrier $SINGLEMDS
1048 # missed replay from client2 will lead to recovery by versions
1049 do_node $CLIENT2 touch $MOUNT2/$tfile-2/$tfile
1050 do_node $CLIENT1 rm -f $MOUNT1/$tfile || return 1
1051 do_node $CLIENT1 mkdir $MOUNT1/$tfile || return 2
1053 zconf_umount $CLIENT2 $MOUNT2
1054 facet_failover $SINGLEMDS
1055 client_up $CLIENT1 || return 6
1057 do_node $CLIENT1 rmdir $MOUNT1/$tfile || error "$tfile doesn't exists"
1060 run_test 8c "create | unlink, create shouldn't fail"
1063 # This test uses three Lustre clients on two hosts.
1065 # Lustre Client 1: $CLIENT1:$MOUNT ($DIR)
1066 # Lustre Client 2: $CLIENT2:$MOUNT2 ($DIR2)
1067 # Lustre Client 3: $CLIENT2:$MOUNT1 ($DIR1)
1069 test_10b() { # former test_2b
1072 local var=${SINGLEMDS}_svc
1074 [ -n "$CLIENTS" ] || { skip "Need two or more clients" && exit 0; }
1075 [ $CLIENTCOUNT -ge 2 ] || \
1076 { skip "Need two or more clients, have $CLIENTCOUNT" && \
1079 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
1080 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1082 zconf_mount $CLIENT1 $MOUNT
1083 zconf_mount $CLIENT2 $MOUNT1
1084 zconf_mount $CLIENT2 $MOUNT2
1085 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-a
1086 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile-b
1089 # Save an MDT transaction number before recovery.
1091 do_node $CLIENT1 touch $DIR1/$tfile
1092 pre=$(chk_get_version $CLIENT1 $DIR/$tfile)
1095 # Comments on the replay sequence state the expected result
1099 # "U" Unable to replay.
1102 replay_barrier $SINGLEMDS
1103 do_node $CLIENT1 chmod 666 $DIR/$tfile-a # R
1104 do_node $CLIENT2 chmod 666 $DIR1/$tfile-b # R
1105 do_node $CLIENT2 chgrp $RUNAS_GID $DIR2/$tfile-a # U
1106 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-a # J
1107 do_node $CLIENT2 $TRUNCATE $DIR2/$tfile-b 1 # U
1108 do_node $CLIENT2 chgrp $RUNAS_GID $DIR1/$tfile-b # R
1109 do_node $CLIENT1 chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile-b # R
1110 zconf_umount $CLIENT2 $MOUNT2
1111 facet_failover $SINGLEMDS
1113 client_evicted $CLIENT1 || error "$CLIENT1:$MOUNT not evicted"
1114 client_up $CLIENT2 || error "$CLIENT2:$MOUNT1 evicted"
1117 # Check the MDT epoch. $post must be the first transaction
1118 # number assigned after recovery.
1120 do_node $CLIENT2 chmod 666 $DIR1/$tfile
1121 post=$(chk_get_version $CLIENT2 $DIR1/$tfile)
1122 if (($(($pre >> 32)) == $((post >> 32)))); then
1123 error "epoch not changed: pre $pre, post $post"
1126 if (($(($post & 0x00000000ffffffff)) != 1)); then
1127 error "transno should restart from one: got $post"
1130 do_node $CLIENT2 stat $DIR1/$tfile-a
1131 do_node $CLIENT2 stat $DIR1/$tfile-b
1133 do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$UID -g \\\#$UID \
1134 $DIR1/$tfile-a || error "$DIR/$tfile-a: unexpected state"
1135 do_node $CLIENT2 $CHECKSTAT -p 0666 -u \\\#$RUNAS_ID -g \\\#$RUNAS_GID \
1136 $DIR1/$tfile-b || error "$DIR/$tfile-b: unexpected state"
1138 zconf_umount $CLIENT2 $MOUNT1
1140 run_test 10b "3 clients: some, none, and all reqs replayed"
1142 # test set #11: operations in single directory
1144 local var=${SINGLEMDS}_svc
1145 zconf_mount $CLIENT2 $MOUNT2
1147 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1149 replay_barrier $SINGLEMDS
1151 do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1153 do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1154 zconf_umount $CLIENT2 $MOUNT2
1157 facet_failover $SINGLEMDS
1158 # recovery shouldn't fail due to missing client 2
1159 client_up $CLIENT1 || return 1
1160 # All files from client1 should have been replayed
1161 do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1163 [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1166 run_test 11a "concurrent creates don't affect each other"
1169 local var=${SINGLEMDS}_svc
1170 zconf_mount $CLIENT2 $MOUNT2
1172 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1174 do_node $CLIENT2 createmany -o $MOUNT2/$tfile-2- 100
1176 replay_barrier $SINGLEMDS
1177 do_node $CLIENT1 createmany -o $DIR/$tfile-1- 100 &
1179 do_node $CLIENT2 unlinkmany -o $MOUNT2/$tfile-2- 100
1180 zconf_umount $CLIENT2 $MOUNT2
1183 facet_failover $SINGLEMDS
1184 # recovery shouldn't fail due to missing client 2
1185 client_up $CLIENT1 || return 1
1186 # All files from client1 should have been replayed
1187 do_node $CLIENT1 unlinkmany $DIR/$tfile-1- 100 || return 2
1189 [ -e $DIR/$tdir/$tfile-2-0 ] && error "$tfile-2-0 exists"
1192 run_test 11b "concurrent creates and unlinks don't affect each other"
1194 # test set #12: lock replay with VBR, bug 16356
1195 test_12a() { # former test_2a
1196 local var=${SINGLEMDS}_svc
1197 zconf_mount $CLIENT2 $MOUNT2
1199 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1201 do_node $CLIENT2 mkdir -p $MOUNT2/$tdir
1202 replay_barrier $SINGLEMDS
1203 do_node $CLIENT2 mcreate $MOUNT2/$tdir/$tfile
1204 do_node $CLIENT1 createmany -o $DIR/$tfile- 25
1205 #client1 read data from client2 which will be lost
1206 do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile
1207 do_node $CLIENT1 createmany -o $DIR/$tfile-3- 25
1208 zconf_umount $CLIENT2 $MOUNT2
1210 facet_failover $SINGLEMDS
1211 # recovery shouldn't fail due to missing client 2
1212 client_up $CLIENT1 || return 1
1214 # All 50 files should have been replayed
1215 do_node $CLIENT1 unlinkmany $DIR/$tfile- 25 || return 2
1216 do_node $CLIENT1 unlinkmany $DIR/$tfile-3- 25 || return 3
1217 do_node $CLIENT1 $CHECKSTAT $DIR/$tdir/$tfile && return 4
1221 run_test 12a "lost data due to missed REMOTE client during replay"
1223 test_13() { # LU-8826
1224 local var=${SINGLEMDS}_svc
1226 if combined_mgs_mds ; then
1227 skip "Needs separate MGS to enable IR"
1231 do_facet $SINGLEMDS "$LCTL set_param mdd.${!var}.sync_permission=0"
1232 do_facet $SINGLEMDS "$LCTL set_param mdt.${!var}.commit_on_sharing=0"
1234 zconf_mount $CLIENT2 $MOUNT2
1235 do_node $CLIENT1 openfile -f O_RDWR:O_CREAT -m 0644 $DIR/$tfile
1237 # set ir_timeout to a reasonable small value
1238 local ir_timeout=$(do_facet mgs $LCTL get_param -n mgs.*.ir_timeout)
1239 do_facet mgs $LCTL set_param mgs.*.ir_timeout=5
1240 # make sure IR functional
1243 replay_barrier $SINGLEMDS
1244 do_node $CLIENT1 chmod 666 $DIR/$tfile
1245 do_node $CLIENT2 chmod 777 $DIR2/$tfile
1247 # make sure client data of $CLIENT2:$MOUNT2 is remained
1248 # define OBD_FAIL_TGT_CLIENT_DEL 0x718
1249 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x718
1250 zconf_umount $CLIENT2 $MOUNT2
1251 # define OBD_FAIL_TGT_SLUGGISH_NET 0x719
1252 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x719
1253 facet_failover $SINGLEMDS
1255 client_up $CLIENT1 || error "$CLIENT1 evicted"
1257 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
1258 do_facet mgs $LCTL set_param mgs.*.ir_timeout=$ir_timeout
1260 do_node $CLIENT1 $CHECKSTAT -p 0666 $DIR/$tfile ||
1261 error "$DIR/$tfile-a: unexpected state"
1263 run_test 13 "Shouldn't give up VBR easily on sluggish network"
1265 #restore COS setting
1266 restore_lustre_params < $cos_param_file
1267 rm -f $cos_param_file
1269 [ "$CLIENTS" ] && zconf_mount_clients $CLIENTS $DIR
1272 check_and_cleanup_lustre