6 ALWAYS_EXCEPT="52 60 $RECOVERY_SMALL_EXCEPT"
8 export MULTIOP=${MULTIOP:-multiop}
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 require_dsh_mds || exit 0
18 # also long tests: 19, 21a, 21e, 21f, 23, 27
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
22 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
23 # bug number for skipped test: LU-2547
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 24a 24b"
28 # Allow us to override the setup if we already have a mounted system by
29 # setting SETUP=" " and CLEANUP=" "
31 CLEANUP=${CLEANUP:-""}
33 check_and_setup_lustre
36 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
39 local f1="$DIR/$tfile"
40 local f2="$DIR/$tfile.2"
42 drop_request "mcreate $f1" ||
43 error_noexit "create '$f1': drop req"
45 drop_reint_reply "mcreate $f2" ||
46 error_noexit "create '$f2': drop rep"
48 drop_request "tchmod 111 $f2" ||
49 error_noexit "chmod '$f2': drop req"
51 drop_reint_reply "tchmod 666 $f2" ||
52 error_noexit "chmod '$f2': drop rep"
54 drop_request "statone $f2" ||
55 error_noexit "stat '$f2': drop req"
57 drop_reply "statone $f2" ||
58 error_noexit "stat '$f2': drop rep"
60 run_test 1 "create, chmod, stat: drop req, drop rep"
64 do_facet_create_file client $t 10K ||
65 error_noexit "Create file $t"
67 drop_request "cat $t > /dev/null" ||
68 error_noexit "Open request for $t file"
70 drop_reply "cat $t > /dev/null" ||
71 error_noexit "Open replay for $t file"
73 run_test 4 "open: drop req, drop rep"
78 local RR="$T-renamed-again"
79 do_facet_create_file client $T 10K ||
80 error_noexit "Create file $T"
82 drop_request "mv $T $R" ||
83 error_noexit "Rename $T"
85 drop_reint_reply "mv $R $RR" ||
86 error_noexit "Failed rename replay on $R"
88 do_facet client "checkstat -v $RR" ||
89 error_noexit "checkstat error on $RR"
91 do_facet client "rm $RR" ||
92 error_noexit "Can't remove file $RR"
94 run_test 5 "rename: drop req, drop rep"
98 local LINK1=$DIR/$tfile.link1
99 local LINK2=$DIR/$tfile.link2
101 do_facet_create_file client $T 10K ||
102 error_noexit "Create file $T"
104 drop_request "mlink $T $LINK1" ||
105 error_noexit "mlink request for $T"
107 drop_reint_reply "mlink $T $LINK2" ||
108 error_noexit "mlink reply for $T"
110 drop_request "munlink $LINK1" ||
111 error_noexit "munlink request for $T"
113 drop_reint_reply "munlink $LINK2" ||
114 error_noexit "munlink reply for $T"
116 do_facet client "rm $T" ||
117 error_noexit "Can't remove file $T"
119 run_test 6 "link, unlink: drop req, drop rep"
123 drop_reint_reply "touch $DIR/$tfile" || return 1
125 run_test 8 "touch: drop rep (bug 1423)"
129 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
133 do_facet_random_file client $TMP/$tfile 1K ||
134 error_noexit "Create random file $TMP/$tfile"
135 # make this big, else test 9 doesn't wait for bulk -- bz 5595
136 do_facet_create_file client $TMP/$t1 4M ||
137 error_noexit "Create file $TMP/$t1"
138 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
139 error_noexit "Can't copy to $DIR/$t1 file"
140 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
141 error_noexit "Can't pause_bulk copy"
142 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
143 error_noexit "Can't copy file"
144 do_facet client "sync"
145 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
146 error_noexit "Can't remove files"
147 do_facet client "rm $TMP/$t1 $TMP/$tfile"
149 run_test 9 "pause bulk on OST (bug 1420)"
153 local before=$(date +%s)
156 do_facet client "stat $DIR > /dev/null" ||
157 error "failed to stat $DIR: $?"
158 drop_bl_callback "chmod 0777 $DIR" ||
159 error "failed to chmod $DIR: $?"
161 # let the client reconnect
163 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
164 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
165 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
166 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
167 error "no eviction: $evict before:$before")
169 do_facet client checkstat -v -p 0777 $DIR ||
170 error "client checkstat failed: $?"
172 run_test 10a "finish request on server after client eviction (bug 1521)"
175 local before=$(date +%s)
178 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
179 skip "Need MDS version at least 2.6.53" && return
180 do_facet client "stat $DIR > /dev/null" ||
181 error "failed to stat $DIR: $?"
182 drop_bl_callback_once "chmod 0777 $DIR" ||
183 error "failed to chmod $DIR: $?"
185 # let the client reconnect
187 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
188 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
190 [ -z "$evict" ] || [[ $evict -le $before ]] ||
191 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
192 error "eviction happened: $evict before:$before")
194 do_facet client checkstat -v -p 0777 $DIR ||
195 error "client checkstat failed: $?"
197 run_test 10b "re-send BL AST"
200 local before=$(date +%s)
209 workdir="${DIR}/${tdir}"
210 mkdir -p ${workdir} || error "can't create workdir $?"
211 stat ${workdir} > /dev/null ||
212 error "failed to stat ${workdir}: $?"
213 mdtidx=$($LFS getdirstripe -i ${workdir})
214 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
215 awk '{sub("_UUID", "", $2); print $2;}')
217 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
218 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
219 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
221 drop_bl_callback_once "chmod 0777 ${workdir}" &
226 # force client reconnect
227 $LCTL set_param "${mdcpath}"
229 # wait client reconnect
233 evict=$($LCTL get_param mdc.${mdccli}.state |
234 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
236 [[ $evict -le $before ]] ||
237 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
238 error "eviction happened: $EVICT before:$BEFORE" )
240 [ $rc -eq 0 ] || error "chmod must finished OK"
241 checkstat -v -p 0777 "${workdir}" ||
242 error "client checkstat failed: $?"
244 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
247 local before=$(date +%s)
250 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
251 skip "Need MDS version at least 2.6.90" && return
253 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
256 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
258 remount_client $MOUNT
262 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
263 echo -n hello | dd of=$DIR1/$tfile bs=5
265 stat $DIR2/$tfile >& /dev/null
266 $LCTL set_param fail_err=71
267 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
272 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
273 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
275 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
277 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
279 [[ $evict -gt $before ]] ||
280 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
281 error "no eviction: $evict before:$before")
283 $LCTL set_param fail_err=0
285 umount_client $MOUNT2
287 run_test 10d "test failed blocking ast"
290 # wake up a thread waiting for completion after eviction
292 do_facet client $MULTIOP $DIR/$tfile Ow ||
293 { error "multiop write failed: $?"; return 1; }
294 do_facet client $MULTIOP $DIR/$tfile or ||
295 { error "multiop read failed: $?"; return 2; }
299 do_facet client $MULTIOP $DIR/$tfile or ||
300 { error "multiop read failed: $?"; return 3; }
301 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
302 echo "evicted as expected"
304 do_facet client munlink $DIR/$tfile ||
305 { error "munlink failed: $?"; return 4; }
306 # allow recovery to complete
307 client_up || client_up || sleep $TIMEOUT
309 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
313 $LCTL mark $MULTIOP $DIR/$tfile OS_c
314 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
315 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
316 multiop_bg_pause $DIR/$tfile OS_c ||
317 { error "multiop failed: $?"; return 1; }
319 #define OBD_FAIL_MDS_CLOSE_NET 0x115
321 echo "waiting for multiop $PID"
322 wait $PID || { error "wait for multiop faile: $?"; return 2; }
323 do_facet client munlink $DIR/$tfile ||
324 { error "client munlink failed: $?"; return 3; }
325 # allow recovery to complete
326 client_up || client_up || sleep $TIMEOUT
328 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
330 # Bug 113, check that readdir lost recv timeout works.
332 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
333 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
334 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
335 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
336 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
337 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
338 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
340 run_test 13 "mdc_readpage restart test (bug 1138)"
342 # Bug 113, check that readdir lost send timeout works.
345 touch $DIR/$tdir/newentry
346 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
347 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
348 ls $DIR/$tdir || return 1
349 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
351 run_test 14 "mdc_readpage resend test (bug 1138)"
354 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
355 touch $DIR/$tfile && return 1
358 run_test 15 "failed open (-ENOMEM)"
360 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
362 lctl set_param -n llite.*.max_read_ahead_mb 0
366 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
370 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
372 do_facet_random_file client $TMP/$tfile 100K ||
373 { error_noexit "Create random file $TMP/$T" ; return 0; }
374 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
375 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
379 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
380 do_facet ost1 "lctl set_param fail_loc=0x80000504"
382 # OST bulk will time out here, client resends
383 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
384 do_facet ost1 lctl set_param fail_loc=0
385 # give recovery a chance to finish (shouldn't take long)
387 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
391 run_test 16 "timeout bulk put, don't evict client (2732)"
396 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
398 local SAMPLE_FILE=$TMP/$tfile
399 do_facet_random_file client $SAMPLE_FILE 20K ||
400 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
402 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
403 if at_is_enabled; then
404 at_max_saved=$(at_max_get ost1)
405 at_max_set $TIMEOUT ost1
408 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
409 # OST bulk will time out here, client retries
410 do_facet ost1 lctl set_param fail_loc=0x80000503
411 # need to ensure we send an RPC
412 do_facet client cp $SAMPLE_FILE $DIR/$tfile
415 # with AT, client will wait adaptive_max*factor+net_latency before
416 # expiring the req, hopefully timeout*2 is enough
417 sleep $(($TIMEOUT*2))
419 do_facet ost1 lctl set_param fail_loc=0
420 do_facet client "df $DIR"
421 # expect cmp to succeed, client resent bulk
422 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
423 do_facet client "rm $DIR/$tfile" || return 4
424 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
427 run_test 17 "timeout bulk get, don't evict client (2732)"
430 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
432 do_facet_create_file client $TMP/$tfile 20K ||
433 { error_noexit "Create file $TMP/$tfile" ; return 0; }
435 do_facet client mkdir -p $DIR/$tdir
439 pgcache_empty || return 1
442 $LFS setstripe -i 1 -c 1 $f
443 stripe_index=$($LFS getstripe -i $f)
444 if [ $stripe_index -ne 1 ]; then
446 error "$f: stripe_index $stripe_index != 1" && return
449 do_facet client cp $TMP/$tfile $f
451 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
452 $LCTL --device $osc2dev deactivate || return 3
453 # my understanding is that there should be nothing in the page
454 # cache after the client reconnects?
456 pgcache_empty || rc=2
457 $LCTL --device $osc2dev activate
461 run_test 18a "manual ost invalidate clears page cache immediately"
464 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
466 do_facet_create_file client $TMP/$tfile 20K ||
467 { error_noexit "Create file $TMP/$tfile" ; return 0; }
469 do_facet client mkdir -p $DIR/$tdir
473 pgcache_empty || return 1
475 $LFS setstripe -i 0 -c 1 $f
476 stripe_index=$($LFS getstripe -i $f)
477 if [ $stripe_index -ne 0 ]; then
479 error "$f: stripe_index $stripe_index != 0" && return
482 do_facet client cp $TMP/$tfile $f
485 # allow recovery to complete
486 sleep $((TIMEOUT + 2))
487 # my understanding is that there should be nothing in the page
488 # cache after the client reconnects?
490 pgcache_empty || rc=2
494 run_test 18b "eviction and reconnect clears page cache (2766)"
497 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
499 do_facet_create_file client $TMP/$tfile 20K ||
500 { error_noexit "Create file $TMP/$tfile" ; return 0; }
502 do_facet client mkdir -p $DIR/$tdir
506 pgcache_empty || return 1
508 $LFS setstripe -i 0 -c 1 $f
509 stripe_index=$($LFS getstripe -i $f)
510 if [ $stripe_index -ne 0 ]; then
512 error "$f: stripe_index $stripe_index != 0" && return
515 do_facet client cp $TMP/$tfile $f
519 # OBD_FAIL_OST_CONNECT_NET2
520 # lost reply to connect request
521 do_facet ost1 lctl set_param fail_loc=0x80000225
524 $LFS df $MOUNT > /dev/null 2>&1
526 # my understanding is that there should be nothing in the page
527 # cache after the client reconnects?
529 pgcache_empty || rc=2
533 run_test 18c "Dropped connect reply after eviction handing (14755)"
536 local BEFORE=`date +%s`
539 mount_client $DIR2 || error "failed to mount $DIR2"
541 # cancel cached locks from OST to avoid eviction from it
544 do_facet client "stat $DIR > /dev/null" ||
545 error "failed to stat $DIR: $?"
546 drop_ldlm_cancel "chmod 0777 $DIR2" ||
547 error "failed to chmod $DIR2"
551 # let the client reconnect
553 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
554 awk -F"[ [,]" '/EVICTED ]$/ \
555 { if (mx<$5) {mx=$5;} } END { print mx }')
557 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
558 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
559 error "no eviction: $EVICT before:$BEFORE")
561 run_test 19a "test expired_lock_main on mds (2867)"
564 local BEFORE=`date +%s`
567 mount_client $DIR2 || error "failed to mount $DIR2: $?"
569 # cancel cached locks from MDT to avoid eviction from it
572 do_facet client $MULTIOP $DIR/$tfile Ow ||
573 error "failed to run multiop: $?"
574 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
575 error "failed to ldlm_cancel: $?"
577 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
578 do_facet client munlink $DIR/$tfile ||
579 error "failed to unlink $DIR/$tfile: $?"
581 # let the client reconnect
583 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
584 awk -F"[ [,]" '/EVICTED ]$/ \
585 { if (mx < $5) {mx = $5;} } END { print mx }')
587 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
588 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
589 error "no eviction: $EVICT before:$BEFORE")
591 run_test 19b "test expired_lock_main on ost (2867)"
594 local BEFORE=`date +%s`
597 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
599 mkdir -p $DIR1/$tfile
602 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
603 do_facet mds $LCTL set_param fail_loc=0x80000516
605 touch $DIR2/$tfile/file1 &
607 # let touch to get blocked on the server
611 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
614 # let the client reconnect
616 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
617 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
619 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
621 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
623 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
624 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
627 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
628 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
631 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
632 do_facet ost1 lctl set_param fail_loc=0x80000308
633 kill -USR1 $MULTI_PID
636 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
638 run_test 20a "ldlm_handle_enqueue error (should return error)"
640 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
641 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
644 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
646 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
647 do_facet ost1 lctl set_param fail_loc=0x80000308
648 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
649 error "didn't fail open enqueue" || true
651 run_test 20b "ldlm_handle_enqueue error (should return error)"
654 mkdir -p $DIR/$tdir-1
655 mkdir -p $DIR/$tdir-2
656 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
659 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
660 $MULTIOP $DIR/$tdir-2/f Oc &
663 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
665 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
666 kill -USR1 $close_pid
668 wait $close_pid || return 1
669 wait $open_pid || return 2
670 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
672 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
673 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
677 run_test 21a "drop close request while close and open are both in flight"
680 mkdir -p $DIR/$tdir-1
681 mkdir -p $DIR/$tdir-2
682 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
685 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
686 mcreate $DIR/$tdir-2/f &
689 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
691 kill -USR1 $close_pid
693 wait $close_pid || return 1
694 wait $open_pid || return 3
696 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
697 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
700 run_test 21b "drop open request while close and open are both in flight"
703 mkdir -p $DIR/$tdir-1
704 mkdir -p $DIR/$tdir-2
705 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
708 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
709 mcreate $DIR/$tdir-2/f &
712 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
714 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
715 kill -USR1 $close_pid
717 wait $close_pid || return 1
718 wait $open_pid || return 2
720 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
722 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
723 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
726 run_test 21c "drop both request while close and open are both in flight"
729 mkdir -p $DIR/$tdir-1
730 mkdir -p $DIR/$tdir-2
731 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
734 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
735 $MULTIOP $DIR/$tdir-2/f Oc &
737 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
739 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
742 wait $pid || return 1
743 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
745 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
746 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
750 run_test 21d "drop close reply while close and open are both in flight"
753 mkdir -p $DIR/$tdir-1
754 mkdir -p $DIR/$tdir-2
755 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
758 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
759 touch $DIR/$tdir-2/f &
761 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
765 wait $pid || return 1
768 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
769 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
772 run_test 21e "drop open reply while close and open are both in flight"
775 mkdir -p $DIR/$tdir-1
776 mkdir -p $DIR/$tdir-2
777 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
781 touch $DIR/$tdir-2/f &
783 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
785 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
788 wait $pid || return 1
789 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
791 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
792 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
795 run_test 21f "drop both reply while close and open are both in flight"
798 mkdir -p $DIR/$tdir-1
799 mkdir -p $DIR/$tdir-2
800 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
803 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
804 touch $DIR/$tdir-2/f &
806 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
808 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
811 wait $pid || return 1
812 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
814 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
815 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
818 run_test 21g "drop open reply and close request while close and open are both in flight"
821 mkdir -p $DIR/$tdir-1
822 mkdir -p $DIR/$tdir-2
823 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
826 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
827 touch $DIR/$tdir-2/f &
830 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
832 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
835 wait $pid || return 1
836 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
838 wait $touch_pid || return 2
840 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
841 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
844 run_test 21h "drop open request and close reply while close and open are both in flight"
846 # bug 3462 - multiple MDC requests
851 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
856 $MULTIOP $f1 msu || return 1
859 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
861 wait $close_pid || return 2
862 rm -rf $f2 || return 4
864 run_test 22 "drop close request and do mknod"
867 multiop_bg_pause $DIR/$tfile O_c || return 1
869 # give a chance for open
873 drop_request "kill -USR1 $pid"
876 wait $pid || return 1
879 run_test 23 "client hang when close a file after mds crash"
881 test_24a() { # bug 11710 details correct fsync() behavior
882 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
885 $LFS setstripe -i 0 -c 1 $DIR/$tdir
887 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
890 kill -USR1 $MULTI_PID
893 lctl set_param fail_loc=0x0
896 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
898 run_test 24a "fsync error (should return error)"
900 wait_client_evicted () {
903 local varsvc=${facet}_svc
905 wait_update $(facet_active_host $facet) \
906 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
911 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
915 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
917 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
918 error "mulitop Ow8192_yc failed"
921 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
922 error "mulitop Ow8192_c failed"
927 kill -USR1 $MULTI_PID1
930 kill -USR1 $MULTI_PID2
933 lctl set_param fail_loc=0x0
935 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
936 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
939 dmesg | grep "dirty page discard:" ||
940 error "no discarded dirty page found!"
942 run_test 24b "test dirty page discard due to client eviction"
944 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
945 # this test can only run from a client on a separate node.
946 remote_ost || { skip "local OST" && return 0; }
947 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
948 remote_mds || { skip "local MDS" && return 0; }
950 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
951 skip "msg and ost1 are at the same node"
955 check_timeout || return 1
957 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
959 echo starting with $OST_NEXP OST exports
960 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
961 do_facet client lctl set_param fail_loc=0x505
962 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
963 # But if there's a race to start the evictor from various obds,
964 # the loser might have to wait for the next ping.
967 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
969 do_facet client lctl set_param fail_loc=0x0
970 [ $rc -eq 0 ] || error "client not evicted from OST"
972 run_test 26a "evict dead exports"
974 test_26b() { # bug 10140 - evict dead exports by pinger
975 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
977 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
978 skip "msg and ost1 are at the same node"
982 check_timeout || return 1
984 zconf_mount `hostname` $MOUNT2 ||
985 { error "Failed to mount $MOUNT2"; return 2; }
986 sleep 1 # wait connections being established
988 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
989 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
991 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
993 zconf_umount `hostname` $MOUNT2 -f
995 # PING_INTERVAL max(obd_timeout / 4, 1U)
996 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
998 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
999 # But if there's a race to start the evictor from various obds,
1000 # the loser might have to wait for the next ping.
1001 # = 9 * PING_INTERVAL + PING_INTERVAL
1002 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1003 # let's wait $((TIMEOUT * 3)) # bug 19887
1005 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1006 error "Client was not evicted by ost" rc=1
1007 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1008 error "Client was not evicted by mds"
1010 run_test 26b "evict dead exports"
1014 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1017 local save_FAILURE_MODE=$FAILURE_MODE
1019 facet_failover $SINGLEMDS
1020 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1021 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1022 # need to wait for reconnect
1023 echo waiting for fail_loc
1024 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1025 facet_failover $SINGLEMDS
1026 #no crashes allowed!
1027 kill -USR1 $CLIENT_PID
1030 FAILURE_MODE=$save_FAILURE_MODE
1032 run_test 27 "fail LOV while using OSC's"
1034 test_28() { # bug 6086 - error adding new clients
1035 do_facet client mcreate $DIR/$tfile || return 1
1036 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1037 echo "evicted as expected"
1038 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1039 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1040 # fail once (evicted), reconnect fail (fail_loc), ok
1041 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1043 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1045 run_test 28 "handle error adding new clients (bug 6086)"
1047 test_29a() { # bug 22273 - error adding new clients
1048 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1049 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1050 # fail abort so client will be new again
1051 fail_abort $SINGLEMDS
1052 client_up || error "reconnect failed"
1053 wait_osc_import_state $SINGLEMDS ost FULL
1056 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1058 test_29b() { # bug 22273 - error adding new clients
1059 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1060 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1061 # fail abort so client will be new again
1063 client_up || error "reconnect failed"
1066 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1070 # put a load of file creates/writes/deletes
1071 writemany -q $DIR/$tdir/$tfile 0 5 &
1073 echo writemany pid $CLIENT_PID
1077 # wait for client to reconnect to MDS
1082 # client process should see no problems even though MDS went down
1084 kill -USR1 $CLIENT_PID
1087 echo writemany returned $rc
1088 #these may fail because of eviction due to slow AST response.
1090 error_ignore bz13652 "writemany returned rc $rc" || true
1092 run_test 50 "failover MDS under load"
1095 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1096 do_facet ost1 lctl set_param fail_loc=0x00001310
1099 # put a load of file creates/writes/deletes
1100 writemany -q $DIR/$tdir/$tfile 0 5 &
1104 facet_failover $SINGLEMDS
1105 # failover at various points during recovery
1106 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1107 echo will failover at $SEQ
1110 #echo failover in $i sec
1111 log "test_$testnum: failover in $i sec"
1113 facet_failover $SINGLEMDS
1115 # client process should see no problems even though MDS went down
1116 # and recovery was interrupted
1118 kill -USR1 $CLIENT_PID
1121 echo writemany returned $rc
1123 error_ignore bz13652 "writemany returned rc $rc" || true
1125 run_test 51 "failover MDS during recovery"
1128 do_facet client "mkdir -p $DIR/$tdir"
1129 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1131 echo writemany pid $CLIENT_PID
1136 wait $CLIENT_PID || rc=$?
1137 # active client process should see an EIO for down OST
1138 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1139 # but timing or failover setup may allow success
1140 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1141 echo "writemany returned $rc"
1146 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1151 [ $rc -ne 0 ] && { return $rc; }
1152 # wait for client to reconnect to OST
1156 [ $rc -ne 0 ] && { return $rc; }
1163 run_test 52 "failover OST under load"
1165 # test of open reconstruct
1168 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1171 run_test 53 "touch: drop rep"
1174 zconf_mount `hostname` $MOUNT2
1176 touch $DIR2/$tfile.1
1178 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1181 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1182 [ x"$ERROR" == x ] || error "back in time occured"
1184 run_test 54 "back in time"
1186 # bug 11330 - liblustre application death during I/O locks up OST
1188 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1192 # Minimum pass speed is 2MBps
1194 # LU-2887/LU-3089 - set min pass speed to 500KBps
1195 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1197 # first dd should be finished quickly
1198 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1199 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1202 echo "step1: testing ......"
1203 while kill -0 $DDPID 2> /dev/null; do
1205 if [ $count -gt $ddtimeout ]; then
1206 error "dd should be finished!"
1210 echo "(dd_pid=$DDPID, time=$count)successful"
1212 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1213 #define OBD_FAIL_OST_DROP_REQ 0x21d
1214 do_facet ost1 lctl set_param fail_loc=0x0000021d
1215 # second dd will be never finished
1216 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1219 echo "step2: testing ......"
1220 while [ $count -le $ddtimeout ]; do
1221 if ! kill -0 $DDPID 2> /dev/null; then
1223 error "dd shouldn't be finished! (time=$count)"
1228 echo "(dd_pid=$DDPID, time=$count)successful"
1230 #Recover fail_loc and dd will finish soon
1231 do_facet ost1 lctl set_param fail_loc=0
1233 echo "step3: testing ......"
1234 while kill -0 $DDPID 2> /dev/null; do
1236 if [ $count -gt $((ddtimeout + 440)) ]; then
1237 error "dd should be finished!"
1241 echo "(dd_pid=$DDPID, time=$count)successful"
1245 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1247 test_56() { # b=11277
1248 #define OBD_FAIL_MDS_RESEND 0x136
1250 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1251 stat $DIR/$tfile || error "stat failed"
1252 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1255 run_test 56 "do not fail on getattr resend"
1258 # no oscs means no client or mdt
1259 while lctl get_param osc.*.* > /dev/null 2>&1; do
1260 : # loop until proc file is removed
1264 test_57() { # bug 10866
1268 #define OBD_FAIL_LPROC_REMOVE 0xB00
1269 lctl set_param fail_loc=0x80000B00
1270 zconf_umount `hostname` $DIR
1271 lctl set_param fail_loc=0x80000B00
1272 fail_abort $SINGLEMDS
1274 lctl set_param fail_loc=0
1276 do_facet client "df $DIR"
1278 run_test 57 "read procfs entries causes kernel crash"
1280 test_58() { # bug 11546
1281 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1284 lctl set_param fail_loc=0x80000801
1285 cp $DIR/$tfile /dev/null &
1288 lctl set_param fail_loc=0
1289 drop_bl_callback_once rm -f $DIR/$tfile
1291 # the first 'df' could tigger the eviction caused by
1292 # 'drop_bl_callback_once', and it's normal case.
1293 # but the next 'df' should return successfully.
1294 do_facet client "df $DIR" || do_facet client "df $DIR"
1296 run_test 58 "Eviction in the middle of open RPC reply processing"
1298 test_59() { # bug 10589
1299 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1300 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1301 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1302 lctl set_param fail_loc=0x311
1303 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1304 [ $? = 0 ] || error "dd write failed"
1305 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1306 lctl set_param fail_loc=0
1308 zconf_umount `hostname` $MOUNT2 -f
1309 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1310 [ $? = 0 ] || error "dd read failed"
1311 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1312 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1314 run_test 59 "Read cancel race on client eviction"
1317 # we assume that all md changes are in the MDT0 changelog
1318 if [ $MDSCOUNT -gt 1 ]; then
1319 error_ignore bz17935 $*
1326 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1327 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1332 # Register (and start) changelog
1333 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1334 echo "Registered as $MDT0 changelog user $USER"
1336 # Generate a large number of changelog entries
1337 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1341 # Unlink files in the background
1342 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1346 # Failover the MDS while unlinks are happening
1347 facet_failover $SINGLEMDS
1349 # Wait for unlinkmany to finish
1352 # Check if all the create/unlink events were recorded
1354 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1355 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1356 echo "$cl_count unlinks in $MDT0 changelog"
1358 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1359 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1360 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1361 if [ $USERS -eq 0 ]; then
1362 [ $cl_count -eq $NUM_FILES ] || \
1363 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1364 # Also make sure we can clear large changelogs
1365 cl_count=$($LFS changelog $FSNAME | wc -l)
1366 [ $cl_count -le 2 ] || \
1367 error "Changelog not empty: $cl_count entries"
1369 # If there are other users, there may be other unlinks in the log
1370 [ $cl_count -ge $NUM_FILES ] || \
1371 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1372 echo "$USERS other changelog users; can't verify clear"
1375 run_test 60 "Add Changelog entries during MDS failover"
1379 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1380 mdtosc=${mdtosc/-MDT*/-MDT\*}
1381 local cflags="osc.$mdtosc.connect_flags"
1382 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1383 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1385 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1386 # Set the default stripe of $DIR/$tdir to put the files to ost1
1387 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1389 replay_barrier $SINGLEMDS
1390 createmany -o $DIR/$tdir/$tfile-%d 10
1391 local oid=$(do_facet ost1 "lctl get_param -n \
1392 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1394 fail_abort $SINGLEMDS
1396 touch $DIR/$tdir/$tfile
1397 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1398 awk '$1 == 0 { print $2 }')
1399 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1404 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1406 # test_62 as seen it b2_1 please do not reuse test_62
1409 # zconf_umount `hostname` $DIR
1410 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1411 # lctl set_param fail_loc=0x516
1414 #run_test 62 "Verify connection flags race - bug LU-1716"
1418 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1419 { skip "Need MDS version at least 2.7.51"; return 0; }
1421 local list=$(comma_list $(osts_nodes))
1423 # modify dir so that next revalidate would not obtain UPDATE lock
1426 # drop 1 reply with UPDATE lock
1427 mcreate $DIR/$tfile || error "mcreate failed: $?"
1428 drop_ldlm_reply_once "stat $DIR/$tfile" &
1431 # make the re-sent lock to sleep
1432 #define OBD_FAIL_MDS_RESEND 0x136
1433 do_nodes $list $LCTL set_param fail_loc=0x80000136
1435 #initiate the re-connect & re-send
1436 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1437 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1438 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1441 #initiate the client eviction while enqueue re-send is in progress
1447 run_test 66 "lock enqueue re-send vs client eviction"
1452 #grant lock1, export2
1453 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1454 $MULTIOP $DIR2/$tfile Ow || return 2
1456 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1457 do_facet ost $LCTL set_param fail_loc=0x31e
1458 #get waiting lock2, export1
1459 $MULTIOP $DIR/$tfile Ow &
1461 # let enqueue to get asleep
1465 $MULTIOP $DIR2/$tfile Ow &
1473 do_facet ost $LCTL set_param fail_loc=0
1480 run_test 65 "lock enqueue for destroyed export"
1482 check_cli_ir_state()
1484 local NODE=${1:-$HOSTNAME}
1486 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1487 awk '/imperative_recovery:/ { print \\\$2}'")
1488 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1489 error "Error state $st, must be ENABLED or DISABLED"
1493 check_target_ir_state()
1496 local name=${target}_svc
1497 local recovery_proc=obdfilter.${!name}.recovery_status
1501 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1502 awk '/status:/{ print \\\$2}'")
1503 [ x$st = xRECOVERING ] || break
1505 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1506 awk '/IR:/{ print \\\$2}'")
1507 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1508 error "Error state $st, must be ENABLED or DISABLED"
1514 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1519 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1520 awk '/state:/{ print \\\$2 }'")
1524 nidtbl_version_mgs()
1526 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1527 awk '/nidtbl_version:/{ print \\\$2 }'")
1531 # nidtbl_version_client <mds1|client> [node]
1532 nidtbl_version_client()
1535 local node=${2:-$HOSTNAME}
1537 if [ X$cli = Xclient ]; then
1540 local obdtype=${cli/%[0-9]*/}
1541 [ $obdtype != mds ] && error "wrong parameters $cli"
1543 node=$(facet_active_host $cli)
1548 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1549 awk "/$cli/{print \$6}" |sort -u)
1551 # in case there are multiple mounts on the client node
1553 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1557 nidtbl_versions_match()
1559 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1562 target_instance_match()
1568 obdtype=${srv/%[0-9]*/}
1579 error "invalid target type" $srv
1584 local target=${srv}_svc
1585 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1586 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1587 awk '/instance/{ print $2 }' | head -n1)
1589 return $([ $si -eq $ci ])
1594 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1595 { skip "MGS without IR support"; return 0; }
1597 # MDT was just restarted in the previous test, make sure everything
1600 while [ $cnt -gt 0 ]; do
1601 nidtbl_versions_match && break
1607 set_ir_status disabled
1609 local prev_ver=$(nidtbl_version_client client)
1611 local saved_FAILURE_MODE=$FAILURE_MODE
1612 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1616 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1617 error "version must not change due to IR disabled"
1618 target_instance_match ost1 || error "instance mismatch"
1622 FAILURE_MODE=$saved_FAILURE_MODE
1624 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1628 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1629 { skip "MGS without IR support"; return 0; }
1633 local OST1_IMP=$(get_osc_import_name client ost1)
1635 # disable pinger recovery
1636 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1640 target_instance_match ost1 || error "instance mismatch"
1641 nidtbl_versions_match || error "version must match"
1643 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1645 run_test 101 "IR: Make sure IR works w/o normal recovery"
1649 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1650 { skip "MGS without IR support"; return 0; }
1652 local clients=${CLIENTS:-$HOSTNAME}
1659 # let's have a new nidtbl version
1662 # sleep for a while so that clients can see the failure of ost
1663 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1664 # int mgc_request.c:
1665 # define MGC_TIMEOUT_MIN_SECONDS 5
1666 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1667 local count=30 # 20 seconds at most
1668 while [ $count -gt 0 ]; do
1669 nidtbl_versions_match && break
1674 nidtbl_versions_match || error "nidtbl mismatch"
1677 old_version=$(nidtbl_version_client client)
1679 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1682 combined_mgs_mds && mgsdev=mds1
1683 remount_facet $mgsdev
1686 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1689 new_version=$(nidtbl_version_client client)
1690 [ $new_version -lt $old_version ] &&
1691 error "nidtbl version wrong after mgs restarts"
1694 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1698 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1699 { skip "MGS without IR support"; return 0; }
1701 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1703 # workaround solution to generate config log on the mds
1709 # We need this test because mds is like a client in IR context.
1710 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1711 error "MDS should start w/o mgs"
1713 # start mgs and remount mds w/ ir
1714 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1717 # remount client so that fsdb will be created on the MGS
1718 umount_client $MOUNT || error "umount failed"
1719 mount_client $MOUNT || error "mount failed"
1721 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1723 while [ $count -gt 0 ]; do
1724 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1729 # after a while, mds should be able to reconnect to mgs and fetch
1730 # up-to-date nidtbl version
1731 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1736 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1740 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1741 { skip "MGS without IR support"; return 0; }
1746 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1747 error "OST1 cannot start"
1750 local ir_state=$(check_target_ir_state ost1)
1751 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1752 error "ir status on ost1 should be DISABLED"
1754 run_test 104 "IR: ost can disable IR voluntarily"
1758 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1759 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1760 { skip "MGS without IR support"; return 0; }
1764 # get one of the clients from client list
1765 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1767 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1768 zconf_umount $rcli $MOUNT || error "umount failed"
1769 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1771 # make sure lustre mount at $rcli disabling IR
1772 local ir_state=$(check_cli_ir_state $rcli)
1773 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1774 error "IR state must be DISABLED at $rcli"
1776 # Since the client just mounted, its last_rcvd entry is not on disk.
1777 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1778 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1779 $SETSTRIPE -i 0 $DIR/$tfile
1780 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1782 # make sure MGS's state is Partial
1783 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1786 # make sure IR on ost1 is DISABLED
1787 local ir_state=$(check_target_ir_state ost1)
1788 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1789 error "IR status on ost1 should be DISABLED"
1791 # remount with the default MOUNT_OPTS
1792 zconf_umount $rcli $MOUNT || error "umount failed"
1793 zconf_mount $rcli $MOUNT || error "mount failed"
1795 # make sure MGS's state is full
1796 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1799 # make sure IR on ost1 is ENABLED
1800 local ir_state=$(check_target_ir_state ost1)
1801 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1802 error "IR status on ost1 should be ENABLED"
1806 run_test 105 "IR: NON IR clients support"
1814 test_106() { # LU-1789
1815 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1816 { skip "Need MDS version at least 2.3.50"; return 0; }
1818 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1819 $LCTL set_param fail_loc=0x805
1822 trap cleanup_106 EXIT
1824 # enable lightweight flag on mdc connection
1827 local MDS_NEXP=$(do_facet $SINGLEMDS \
1828 lctl get_param -n mdt.${mds1_svc}.num_exports |
1830 $LCTL set_param fail_loc=0
1832 touch $DIR2/$tfile || error "failed to create empty file"
1833 replay_barrier $SINGLEMDS
1835 $LCTL set_param debug=console
1837 facet_failover $SINGLEMDS
1839 # lightweight connection must be evicted
1840 touch -c $DIR2/$tfile || true
1841 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1842 evicted=`awk '/This client was evicted by .*MDT0000/ {
1844 }' $TMP/lustre-log-$TESTNAME.log`
1845 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1847 # and all operations performed by lightweight client should be
1848 # synchronous, so the file created before mds restart should be there
1849 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1854 run_test 106 "lightweight connection support"
1861 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1862 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1863 multiop $DIR/$tdir D_c &
1865 mkdir $DIR/$tdir/dir_106 &
1867 do_facet $SINGLEMDS lctl set_param fail_loc=0
1870 wait $CLIENT_PID || rc=$?
1871 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1873 kill -USR1 $close_pid
1874 wait $close_pid || return 2
1878 run_test 107 "drop reint reply, then restart MDT"
1882 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1884 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
1892 client_up || error "reconnect failed"
1893 rm -f $DIR/$tdir/$tfile
1895 run_test 108 "client eviction don't crash"
1898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1899 local remote_dir=$DIR/$tdir/remote_dir
1903 #prepare for 110 test, which need set striped dir on remote MDT.
1904 for num in $(seq $MDSCOUNT); do
1906 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1911 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1912 error "lfs mkdir failed"
1913 local diridx=$($GETSTRIPE -M $remote_dir)
1914 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1916 rm -rf $DIR/$tdir || error "rmdir failed"
1918 run_test 110a "create remote directory: drop client req"
1921 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1922 local remote_dir=$DIR/$tdir/remote_dir
1926 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1927 error "lfs mkdir failed"
1929 diridx=$($GETSTRIPE -M $remote_dir)
1930 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1932 rm -rf $DIR/$tdir || error "rmdir failed"
1934 run_test 110b "create remote directory: drop Master rep"
1937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1938 local remote_dir=$DIR/$tdir/remote_dir
1942 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1943 error "lfs mkdir failed"
1945 diridx=$($GETSTRIPE -M $remote_dir)
1946 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1948 rm -rf $DIR/$tdir || error "rmdir failed"
1950 run_test 110c "create remote directory: drop update rep on slave MDT"
1953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1954 local remote_dir=$DIR/$tdir/remote_dir
1958 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1960 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1962 rm -rf $DIR/$tdir || error "rmdir failed"
1966 run_test 110d "remove remote directory: drop client req"
1969 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1970 local remote_dir=$DIR/$tdir/remote_dir
1974 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1975 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1977 rm -rf $DIR/$tdir || error "rmdir failed"
1981 run_test 110e "remove remote directory: drop master rep"
1984 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1985 local remote_dir=$DIR/$tdir/remote_dir
1989 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1990 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1991 error "rm remote dir failed"
1993 rm -rf $DIR/$tdir || error "rmdir failed"
1995 run_test 110f "remove remote directory: drop slave rep"
1998 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1999 local remote_dir=$DIR/$tdir/remote_dir
2002 mkdir -p $remote_dir
2004 createmany -o $remote_dir/f 100
2006 #define OBD_FAIL_MIGRATE_NET_REP 0x1800
2007 do_facet mds$MDTIDX lctl set_param fail_loc=0x1800
2008 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
2009 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
2011 for file in $(find $remote_dir); do
2012 mdt_index=$($LFS getstripe -M $file)
2013 [ $mdt_index == $MDTIDX ] ||
2014 error "$file is not on MDT${MDTIDX}"
2017 rm -rf $DIR/$tdir || error "rmdir failed"
2019 run_test 110g "drop reply during migration"
2022 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2023 local src_dir=$DIR/$tdir/source_dir
2024 local tgt_dir=$DIR/$tdir/target_dir
2028 $LFS mkdir -i $MDTIDX $tgt_dir
2030 dd if=/etc/hosts of=$src_dir/src_file
2031 touch $tgt_dir/tgt_file
2032 drop_update_reply $MDTIDX \
2033 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2034 error "mrename failed"
2036 $CHECKSTAT -t file $src_dir/src_file &&
2037 error "src_file present after rename"
2039 diff /etc/hosts $tgt_dir/tgt_file ||
2040 error "file changed after rename"
2043 run_test 110h "drop update reply during cross-MDT file rename"
2046 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2047 local src_dir=$DIR/$tdir/source_dir
2048 local tgt_dir=$DIR/$tdir/target_dir
2052 $LFS mkdir -i $MDTIDX $tgt_dir
2054 mkdir $src_dir/src_dir
2055 touch $src_dir/src_dir/a
2056 mkdir $tgt_dir/tgt_dir
2057 drop_update_reply $MDTIDX \
2058 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2059 error "mrename failed"
2061 $CHECKSTAT -t dir $src_dir/src_dir &&
2062 error "src_dir present after rename"
2064 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2065 error "tgt_dir not present after rename"
2067 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2068 error "a not present after rename"
2070 run_test 110i "drop update reply during cross-MDT dir rename"
2073 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2074 local remote_dir=$DIR/$tdir/remote_dir
2075 local local_dir=$DIR/$tdir/local_dir
2079 mkdir $DIR/$tdir/local_dir
2080 $LFS mkdir -i $MDTIDX $remote_dir
2082 touch $local_dir/local_file
2083 drop_update_reply $MDTIDX \
2084 "ln $local_dir/local_file $remote_dir/remote_file" ||
2087 $CHECKSTAT -t file $remote_dir/remote_file ||
2088 error "remote not present after ln"
2090 run_test 110j "drop update reply during cross-MDT ln"
2092 # LU-2844 mdt prepare fail should not cause umount oops
2095 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2096 { skip "Need MDS version at least 2.3.62"; return 0; }
2098 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2099 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2100 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2101 stop $SINGLEMDS || error "stop MDS failed"
2102 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2103 do_facet $SINGLEMDS lctl set_param fail_loc=0
2104 start $SINGLEMDS $mdsdev || error "start MDS failed"
2106 run_test 111 "mdd setup fail should not cause umount oops"
2110 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2112 do_facet_random_file client $TMP/$tfile 100K ||
2113 error_noexit "Create random file $TMP/$tfile"
2115 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2116 error_noexit "Can't pause_bulk copy"
2119 # expect cmp to succeed, client resent bulk
2120 cmp $TMP/$tfile $DIR/$tfile ||
2121 error_noexit "Wrong data has been written"
2123 error_noexit "Can't remove file"
2126 run_test 112a "bulk resend while orignal request is in progress"
2133 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2134 cancel_lru_locks osc
2137 $LCTL set_param fail_loc=$fail1 fail_val=3
2138 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2142 set_nodes_failloc "$(osts_nodes)" $fail2
2144 wait $pid || error "dd failed"
2152 local fail_val2=${4:-0}
2158 $LCTL set_param fail_loc=$fail1 fail_val=4
2159 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2164 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2168 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2169 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2174 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2175 skip "need at least 2.8.50 on OST" && return 0
2177 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2178 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2179 test_115_read 0x8000051b 0x8000051a
2181 run_test 115a "read: late REQ MDunlink and no bulk"
2184 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2185 skip "need at least 2.8.50 on OST" && return 0
2187 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2188 #define OBD_FAIL_OST_ENOSPC 0x215
2190 # pass $OSTCOUNT for the fail_loc to be caught
2191 # appropriately by the IO thread
2192 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2194 run_test 115b "write: late REQ MDunlink and no bulk"
2197 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2198 skip "need at least 2.8.50 on OST" && return 0
2200 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2201 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2202 test_115_read 0x8000050f 0x8000051a
2204 run_test 115c "read: late Reply MDunlink and no bulk"
2207 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2208 skip "need at least 2.8.50 on OST" && return 0
2210 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2211 #define OBD_FAIL_OST_ENOSPC 0x215
2212 test_115_write 0x8000050f 0x80000215 0
2214 run_test 115d "write: late Reply MDunlink and no bulk"
2217 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2218 skip "need at least 2.8.50 on OST" && return 0
2220 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2221 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2222 test_115_read 0x80000510 0x80000211
2224 run_test 115e "read: late Bulk MDunlink and no reply"
2227 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2228 skip "need at least 2.8.50 on OST" && return 0
2230 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2231 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2232 test_115_read 0x8000051b 0x80000211
2234 run_test 115f "read: late REQ MDunlink and no reply"
2237 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2238 skip "need at least 2.8.50 on OST" && return 0
2240 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2241 test_115_read 0x8000051c 0
2243 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2245 # parameters: fail_loc CMD RC
2252 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2253 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2254 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2255 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2258 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2259 [ "$1" = "CLEANUP" ] &&
2260 fail=0x80000320 && echo ", $1 cp first"
2261 [ "$1" = "REPLY" ] &&
2262 fail=0x80000321 && echo ", $1 cp first"
2263 [ "$1" = "DEADLOCK CLEANUP" ] &&
2264 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2265 [ "$1" = "DEADLOCK REPLY" ] &&
2266 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2268 if [ x"$2" = x"get" ]; then
2269 #for TEST lock, take a conflict in advance
2270 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2271 echo "** Taking conflict **"
2272 flocks_test 5 set read sleep 10 $DIR/$tfile &
2278 $LCTL set_param fail_loc=$fail
2280 flocks_test 5 $2 write $DIR/$tfile &
2284 echo "** Evicting and re-connecting client **"
2289 if [ x"$2" = x"get" ]; then
2296 # check if the return value is allowed
2297 [ $rc -eq $3 ] && rc=0
2299 $LCTL set_param fail_loc=0
2303 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2304 # the ORIGINAL lock.
2309 flocks_test 5 set write sleep 4 $DIR/$tfile &
2313 # let unlock to sleep in CP CB
2314 $LCTL set_param fail_loc=$1
2317 # let cleanup to cleep in CP CB
2325 $LCTL set_param fail_loc=0
2330 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2333 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2334 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2335 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2337 test_120_reply "REPLY" set 5 || error "SET race failed"
2338 test_120_reply "REPLY" get 5 || error "GET race failed"
2339 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2342 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2343 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2345 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2347 run_test 120 "flock race: completion vs. evict"
2350 local BEFORE=$(date +%s)
2353 # modify dir so that next revalidate would not obtain UPDATE lock
2356 # drop 1 reply with UPDATE lock,
2357 # resend should not create 2nd lock on server
2358 mcreate $DIR/$tfile || error "mcreate failed: $?"
2359 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2361 # 2 BL AST will be sent to client, both must find the same lock,
2362 # race them to not get EINVAL for 2nd BL AST
2363 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2364 $LCTL set_param fail_loc=0x8000031f
2366 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2367 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2368 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2370 # let the client reconnect
2372 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2373 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2375 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2377 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2381 test_mkdir -p $DIR/$tdir
2383 # Prevent interference from layout intent RPCs due to
2384 # asynchronous writeback. These will be tested in 130c below.
2385 do_nodes ${CLIENTS:-$HOSTNAME} sync
2387 # get only LOOKUP lock on $tdir
2388 cancel_lru_locks mdc
2389 ls $DIR/$tdir/$tfile 2>/dev/null
2391 # get getattr by fid on $tdir
2393 # we need to race with unlink, unlink must complete before we will
2394 # take a DLM lock, otherwise unlink will wait until getattr will
2395 # complete; but later than getattr starts so that getattr found
2397 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2398 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2405 # drop the reply so that resend happens on an unlinked file.
2406 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2407 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2411 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2414 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2417 run_test 130a "enqueue resend on not existing file"
2420 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2422 # let the reply to be dropped
2425 #define OBD_FAIL_SRV_ENOENT 0x217
2426 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2428 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2431 run_test 130b "enqueue resend on a stale inode"
2434 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2436 do_nodes ${CLIENTS:-$HOSTNAME} sync
2437 echo XXX > $DIR/$tfile
2439 cancel_lru_locks mdc
2441 # Trigger writeback on $tfile.
2443 # we need to race with unlink, unlink must complete before we will
2444 # take a DLM lock, otherwise unlink will wait until intent will
2445 # complete; but later than intent starts so that intent found
2447 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2448 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2455 # drop the reply so that resend happens on an unlinked file.
2456 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2457 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2459 # let the reply to be dropped
2462 #define OBD_FAIL_SRV_ENOENT 0x217
2463 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2469 run_test 130c "layout intent resend on a stale inode"
2472 local before=$(date +%s)
2475 mount_client $MOUNT2 || error "mount filed"
2478 # get a lock on client so that export would reach the stale list
2479 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2480 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2483 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2484 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2486 $TRUNCATE $DIR/$tfile 100 &
2489 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2493 umount_client $MOUNT2
2495 evict=$(do_facet client $LCTL get_param \
2496 osc.$FSNAME-OST0000-osc-*/state |
2497 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2499 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2500 (do_facet client $LCTL get_param \
2501 osc.$FSNAME-OST0000-osc-*/state;
2502 error "eviction happened: $evict before:$before")
2504 run_test 132 "long punch"
2507 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2510 # get a lock on client so that export would reach the stale list
2511 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2512 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2514 # another IO under the same lock
2515 #define OBD_FAIL_OSC_DELAY_IO 0x414
2516 $LCTL set_param fail_loc=0x80000414
2517 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2521 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2522 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2526 wait $pid && error "dd succeeded"
2529 run_test 131 "IO vs evict results to IO under staled lock"
2532 check_and_cleanup_lustre