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=""
24 # Allow us to override the setup if we already have a mounted system by
25 # setting SETUP=" " and CLEANUP=" "
27 CLEANUP=${CLEANUP:-""}
29 check_and_setup_lustre
32 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
35 local f1="$DIR/$tfile"
36 local f2="$DIR/$tfile.2"
38 drop_request "mcreate $f1" ||
39 error_noexit "create '$f1': drop req"
41 drop_reint_reply "mcreate $f2" ||
42 error_noexit "create '$f2': drop rep"
44 drop_request "tchmod 111 $f2" ||
45 error_noexit "chmod '$f2': drop req"
47 drop_reint_reply "tchmod 666 $f2" ||
48 error_noexit "chmod '$f2': drop rep"
50 drop_request "statone $f2" ||
51 error_noexit "stat '$f2': drop req"
53 drop_reply "statone $f2" ||
54 error_noexit "stat '$f2': drop rep"
56 run_test 1 "create, chmod, stat: drop req, drop rep"
60 do_facet_create_file client $t 10K ||
61 error_noexit "Create file $t"
63 drop_request "cat $t > /dev/null" ||
64 error_noexit "Open request for $t file"
66 drop_reply "cat $t > /dev/null" ||
67 error_noexit "Open replay for $t file"
69 run_test 4 "open: drop req, drop rep"
74 local RR="$T-renamed-again"
75 do_facet_create_file client $T 10K ||
76 error_noexit "Create file $T"
78 drop_request "mv $T $R" ||
79 error_noexit "Rename $T"
81 drop_reint_reply "mv $R $RR" ||
82 error_noexit "Failed rename replay on $R"
84 do_facet client "checkstat -v $RR" ||
85 error_noexit "checkstat error on $RR"
87 do_facet client "rm $RR" ||
88 error_noexit "Can't remove file $RR"
90 run_test 5 "rename: drop req, drop rep"
94 local LINK1=$DIR/$tfile.link1
95 local LINK2=$DIR/$tfile.link2
97 do_facet_create_file client $T 10K ||
98 error_noexit "Create file $T"
100 drop_request "mlink $T $LINK1" ||
101 error_noexit "mlink request for $T"
103 drop_reint_reply "mlink $T $LINK2" ||
104 error_noexit "mlink reply for $T"
106 drop_request "munlink $LINK1" ||
107 error_noexit "munlink request for $T"
109 drop_reint_reply "munlink $LINK2" ||
110 error_noexit "munlink reply for $T"
112 do_facet client "rm $T" ||
113 error_noexit "Can't remove file $T"
115 run_test 6 "link, unlink: drop req, drop rep"
119 drop_reint_reply "touch $DIR/$tfile" || return 1
121 run_test 8 "touch: drop rep (bug 1423)"
125 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
129 do_facet_random_file client $TMP/$tfile 1K ||
130 error_noexit "Create random file $TMP/$tfile"
131 # make this big, else test 9 doesn't wait for bulk -- bz 5595
132 do_facet_create_file client $TMP/$t1 4M ||
133 error_noexit "Create file $TMP/$t1"
134 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
135 error_noexit "Can't copy to $DIR/$t1 file"
136 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
137 error_noexit "Can't pause_bulk copy"
138 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
139 error_noexit "Can't copy file"
140 do_facet client "sync"
141 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
142 error_noexit "Can't remove files"
143 do_facet client "rm $TMP/$t1 $TMP/$tfile"
145 run_test 9 "pause bulk on OST (bug 1420)"
149 local before=$(date +%s)
152 do_facet client "stat $DIR > /dev/null" ||
153 error "failed to stat $DIR: $?"
154 drop_bl_callback "chmod 0777 $DIR" ||
155 error "failed to chmod $DIR: $?"
157 # let the client reconnect
159 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
160 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
161 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
162 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
163 error "no eviction: $evict before:$before")
165 do_facet client checkstat -v -p 0777 $DIR ||
166 error "client checkstat failed: $?"
168 run_test 10a "finish request on server after client eviction (bug 1521)"
171 local before=$(date +%s)
174 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
175 skip "Need MDS version at least 2.6.53" && return
176 do_facet client "stat $DIR > /dev/null" ||
177 error "failed to stat $DIR: $?"
178 drop_bl_callback_once "chmod 0777 $DIR" ||
179 error "failed to chmod $DIR: $?"
181 # let the client reconnect
183 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
184 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
186 [ -z "$evict" ] || [[ $evict -le $before ]] ||
187 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
188 error "eviction happened: $evict before:$before")
190 do_facet client checkstat -v -p 0777 $DIR ||
191 error "client checkstat failed: $?"
193 run_test 10b "re-send BL AST"
196 local before=$(date +%s)
205 workdir="${DIR}/${tdir}"
206 mkdir -p ${workdir} || error "can't create workdir $?"
207 stat ${workdir} > /dev/null ||
208 error "failed to stat ${workdir}: $?"
209 mdtidx=$($LFS getdirstripe -i ${workdir})
210 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
211 awk '{sub("_UUID", "", $2); print $2;}')
213 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
214 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
215 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
217 drop_bl_callback_once "chmod 0777 ${workdir}" &
222 # force client reconnect
223 $LCTL set_param "${mdcpath}"
225 # wait client reconnect
229 evict=$($LCTL get_param mdc.${mdccli}.state |
230 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
232 [[ $evict -le $before ]] ||
233 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
234 error "eviction happened: $EVICT before:$BEFORE" )
236 [ $rc -eq 0 ] || error "chmod must finished OK"
237 checkstat -v -p 0777 "${workdir}" ||
238 error "client checkstat failed: $?"
240 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
243 local before=$(date +%s)
246 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
247 skip "Need MDS version at least 2.6.90" && return
249 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
252 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
254 remount_client $MOUNT
258 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
259 echo -n hello | dd of=$DIR1/$tfile bs=5
261 stat $DIR2/$tfile >& /dev/null
262 $LCTL set_param fail_err=71
263 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
268 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
269 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
271 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
273 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
275 [[ $evict -gt $before ]] ||
276 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
277 error "no eviction: $evict before:$before")
279 $LCTL set_param fail_err=0
281 umount_client $MOUNT2
283 run_test 10d "test failed blocking ast"
286 # wake up a thread waiting for completion after eviction
288 do_facet client $MULTIOP $DIR/$tfile Ow ||
289 { error "multiop write failed: $?"; return 1; }
290 do_facet client $MULTIOP $DIR/$tfile or ||
291 { error "multiop read failed: $?"; return 2; }
295 do_facet client $MULTIOP $DIR/$tfile or ||
296 { error "multiop read failed: $?"; return 3; }
297 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
298 echo "evicted as expected"
300 do_facet client munlink $DIR/$tfile ||
301 { error "munlink failed: $?"; return 4; }
302 # allow recovery to complete
303 client_up || client_up || sleep $TIMEOUT
305 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
309 $LCTL mark $MULTIOP $DIR/$tfile OS_c
310 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
311 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
312 multiop_bg_pause $DIR/$tfile OS_c ||
313 { error "multiop failed: $?"; return 1; }
315 #define OBD_FAIL_MDS_CLOSE_NET 0x115
317 echo "waiting for multiop $PID"
318 wait $PID || { error "wait for multiop faile: $?"; return 2; }
319 do_facet client munlink $DIR/$tfile ||
320 { error "client munlink failed: $?"; return 3; }
321 # allow recovery to complete
322 client_up || client_up || sleep $TIMEOUT
324 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
326 # Bug 113, check that readdir lost recv timeout works.
328 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
329 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
330 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
331 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
332 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
333 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
334 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
336 run_test 13 "mdc_readpage restart test (bug 1138)"
338 # Bug 113, check that readdir lost send timeout works.
341 touch $DIR/$tdir/newentry
342 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
343 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
344 ls $DIR/$tdir || return 1
345 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
347 run_test 14 "mdc_readpage resend test (bug 1138)"
350 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
351 touch $DIR/$tfile && return 1
354 run_test 15 "failed open (-ENOMEM)"
356 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
358 lctl set_param -n llite.*.max_read_ahead_mb 0
362 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
366 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
368 do_facet_random_file client $TMP/$tfile 100K ||
369 { error_noexit "Create random file $TMP/$T" ; return 0; }
370 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
371 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
375 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
376 do_facet ost1 "lctl set_param fail_loc=0x80000504"
378 # OST bulk will time out here, client resends
379 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
380 do_facet ost1 lctl set_param fail_loc=0
381 # give recovery a chance to finish (shouldn't take long)
383 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
387 run_test 16 "timeout bulk put, don't evict client (2732)"
392 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
394 local SAMPLE_FILE=$TMP/$tfile
395 do_facet_random_file client $SAMPLE_FILE 20K ||
396 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
398 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
399 if at_is_enabled; then
400 at_max_saved=$(at_max_get ost1)
401 at_max_set $TIMEOUT ost1
404 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
405 # OST bulk will time out here, client retries
406 do_facet ost1 lctl set_param fail_loc=0x80000503
407 # need to ensure we send an RPC
408 do_facet client cp $SAMPLE_FILE $DIR/$tfile
411 # with AT, client will wait adaptive_max*factor+net_latency before
412 # expiring the req, hopefully timeout*2 is enough
413 sleep $(($TIMEOUT*2))
415 do_facet ost1 lctl set_param fail_loc=0
416 do_facet client "df $DIR"
417 # expect cmp to succeed, client resent bulk
418 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
419 do_facet client "rm $DIR/$tfile" || return 4
420 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
423 run_test 17 "timeout bulk get, don't evict client (2732)"
426 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
428 do_facet_create_file client $TMP/$tfile 20K ||
429 { error_noexit "Create file $TMP/$tfile" ; return 0; }
431 do_facet client mkdir -p $DIR/$tdir
435 pgcache_empty || return 1
438 $LFS setstripe -i 1 -c 1 $f
439 stripe_index=$($LFS getstripe -i $f)
440 if [ $stripe_index -ne 1 ]; then
442 error "$f: stripe_index $stripe_index != 1" && return
445 do_facet client cp $TMP/$tfile $f
447 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
448 $LCTL --device $osc2dev deactivate || return 3
449 # my understanding is that there should be nothing in the page
450 # cache after the client reconnects?
452 pgcache_empty || rc=2
453 $LCTL --device $osc2dev activate
457 run_test 18a "manual ost invalidate clears page cache immediately"
460 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
462 do_facet_create_file client $TMP/$tfile 20K ||
463 { error_noexit "Create file $TMP/$tfile" ; return 0; }
465 do_facet client mkdir -p $DIR/$tdir
469 pgcache_empty || return 1
471 $LFS setstripe -i 0 -c 1 $f
472 stripe_index=$($LFS getstripe -i $f)
473 if [ $stripe_index -ne 0 ]; then
475 error "$f: stripe_index $stripe_index != 0" && return
478 do_facet client cp $TMP/$tfile $f
481 # allow recovery to complete
482 sleep $((TIMEOUT + 2))
483 # my understanding is that there should be nothing in the page
484 # cache after the client reconnects?
486 pgcache_empty || rc=2
490 run_test 18b "eviction and reconnect clears page cache (2766)"
493 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
495 do_facet_create_file client $TMP/$tfile 20K ||
496 { error_noexit "Create file $TMP/$tfile" ; return 0; }
498 do_facet client mkdir -p $DIR/$tdir
502 pgcache_empty || return 1
504 $LFS setstripe -i 0 -c 1 $f
505 stripe_index=$($LFS getstripe -i $f)
506 if [ $stripe_index -ne 0 ]; then
508 error "$f: stripe_index $stripe_index != 0" && return
511 do_facet client cp $TMP/$tfile $f
515 # OBD_FAIL_OST_CONNECT_NET2
516 # lost reply to connect request
517 do_facet ost1 lctl set_param fail_loc=0x80000225
520 $LFS df $MOUNT > /dev/null 2>&1
522 # my understanding is that there should be nothing in the page
523 # cache after the client reconnects?
525 pgcache_empty || rc=2
529 run_test 18c "Dropped connect reply after eviction handing (14755)"
532 local BEFORE=`date +%s`
535 mount_client $DIR2 || error "failed to mount $DIR2"
537 # cancel cached locks from OST to avoid eviction from it
540 do_facet client "stat $DIR > /dev/null" ||
541 error "failed to stat $DIR: $?"
542 drop_ldlm_cancel "chmod 0777 $DIR2" ||
543 error "failed to chmod $DIR2"
547 # let the client reconnect
549 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
550 awk -F"[ [,]" '/EVICTED ]$/ \
551 { if (mx<$5) {mx=$5;} } END { print mx }')
553 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
554 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
555 error "no eviction: $EVICT before:$BEFORE")
557 run_test 19a "test expired_lock_main on mds (2867)"
560 local BEFORE=`date +%s`
563 mount_client $DIR2 || error "failed to mount $DIR2: $?"
565 # cancel cached locks from MDT to avoid eviction from it
568 do_facet client $MULTIOP $DIR/$tfile Ow ||
569 error "failed to run multiop: $?"
570 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
571 error "failed to ldlm_cancel: $?"
573 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
574 do_facet client munlink $DIR/$tfile ||
575 error "failed to unlink $DIR/$tfile: $?"
577 # let the client reconnect
579 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
580 awk -F"[ [,]" '/EVICTED ]$/ \
581 { if (mx < $5) {mx = $5;} } END { print mx }')
583 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
584 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
585 error "no eviction: $EVICT before:$BEFORE")
587 run_test 19b "test expired_lock_main on ost (2867)"
590 local BEFORE=`date +%s`
593 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
595 mkdir -p $DIR1/$tfile
598 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
599 do_facet mds $LCTL set_param fail_loc=0x80000516
601 touch $DIR2/$tfile/file1 &
603 # let touch to get blocked on the server
607 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
610 # let the client reconnect
612 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
613 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
615 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
617 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
619 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
620 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
623 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
624 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
627 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
628 do_facet ost1 lctl set_param fail_loc=0x80000308
629 kill -USR1 $MULTI_PID
632 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
634 run_test 20a "ldlm_handle_enqueue error (should return error)"
636 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
637 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
640 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
642 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
643 do_facet ost1 lctl set_param fail_loc=0x80000308
644 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
645 error "didn't fail open enqueue" || true
647 run_test 20b "ldlm_handle_enqueue error (should return error)"
650 mkdir -p $DIR/$tdir-1
651 mkdir -p $DIR/$tdir-2
652 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
655 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
656 $MULTIOP $DIR/$tdir-2/f Oc &
659 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
661 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
662 kill -USR1 $close_pid
664 wait $close_pid || return 1
665 wait $open_pid || return 2
666 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
668 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
669 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
673 run_test 21a "drop close request while close and open are both in flight"
676 mkdir -p $DIR/$tdir-1
677 mkdir -p $DIR/$tdir-2
678 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
681 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
682 mcreate $DIR/$tdir-2/f &
685 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
687 kill -USR1 $close_pid
689 wait $close_pid || return 1
690 wait $open_pid || return 3
692 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
693 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
696 run_test 21b "drop open request while close and open are both in flight"
699 mkdir -p $DIR/$tdir-1
700 mkdir -p $DIR/$tdir-2
701 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
704 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
705 mcreate $DIR/$tdir-2/f &
708 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
710 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
711 kill -USR1 $close_pid
713 wait $close_pid || return 1
714 wait $open_pid || return 2
716 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
718 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
719 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
722 run_test 21c "drop both request while close and open are both in flight"
725 mkdir -p $DIR/$tdir-1
726 mkdir -p $DIR/$tdir-2
727 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
730 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
731 $MULTIOP $DIR/$tdir-2/f Oc &
733 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
735 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
738 wait $pid || return 1
739 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
741 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
742 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
746 run_test 21d "drop close reply while close and open are both in flight"
749 mkdir -p $DIR/$tdir-1
750 mkdir -p $DIR/$tdir-2
751 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
754 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
755 touch $DIR/$tdir-2/f &
757 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
761 wait $pid || return 1
764 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
765 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
768 run_test 21e "drop open reply while close and open are both in flight"
771 mkdir -p $DIR/$tdir-1
772 mkdir -p $DIR/$tdir-2
773 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
776 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
777 touch $DIR/$tdir-2/f &
779 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
784 wait $pid || return 1
785 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
787 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
788 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
791 run_test 21f "drop both reply while close and open are both in flight"
794 mkdir -p $DIR/$tdir-1
795 mkdir -p $DIR/$tdir-2
796 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
799 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
800 touch $DIR/$tdir-2/f &
802 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
807 wait $pid || return 1
808 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
810 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
811 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
814 run_test 21g "drop open reply and close request while close and open are both in flight"
817 mkdir -p $DIR/$tdir-1
818 mkdir -p $DIR/$tdir-2
819 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
822 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
823 touch $DIR/$tdir-2/f &
826 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
828 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
831 wait $pid || return 1
832 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
834 wait $touch_pid || return 2
836 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
837 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
840 run_test 21h "drop open request and close reply while close and open are both in flight"
842 # bug 3462 - multiple MDC requests
847 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
852 $MULTIOP $f1 msu || return 1
855 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
857 wait $close_pid || return 2
858 rm -rf $f2 || return 4
860 run_test 22 "drop close request and do mknod"
863 multiop_bg_pause $DIR/$tfile O_c || return 1
865 # give a chance for open
869 drop_request "kill -USR1 $pid"
872 wait $pid || return 1
875 run_test 23 "client hang when close a file after mds crash"
877 test_24a() { # bug 11710 details correct fsync() behavior
878 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
881 $LFS setstripe -i 0 -c 1 $DIR/$tdir
883 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
886 kill -USR1 $MULTI_PID
889 lctl set_param fail_loc=0x0
892 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
894 run_test 24a "fsync error (should return error)"
896 wait_client_evicted () {
899 local varsvc=${facet}_svc
901 wait_update $(facet_active_host $facet) \
902 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
907 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
911 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
913 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
914 error "mulitop Ow8192_yc failed"
917 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
918 error "mulitop Ow8192_c failed"
923 kill -USR1 $MULTI_PID1
926 kill -USR1 $MULTI_PID2
929 lctl set_param fail_loc=0x0
931 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
932 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
935 dmesg | grep "dirty page discard:" ||
936 error "no discarded dirty page found!"
938 run_test 24b "test dirty page discard due to client eviction"
940 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
941 # this test can only run from a client on a separate node.
942 remote_ost || { skip "local OST" && return 0; }
943 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
944 remote_mds || { skip "local MDS" && return 0; }
946 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
947 skip "msg and ost1 are at the same node"
951 check_timeout || return 1
953 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
955 echo starting with $OST_NEXP OST exports
956 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
957 do_facet client lctl set_param fail_loc=0x505
958 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
959 # But if there's a race to start the evictor from various obds,
960 # the loser might have to wait for the next ping.
963 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
965 do_facet client lctl set_param fail_loc=0x0
966 [ $rc -eq 0 ] || error "client not evicted from OST"
968 run_test 26a "evict dead exports"
970 test_26b() { # bug 10140 - evict dead exports by pinger
971 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
973 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
974 skip "msg and ost1 are at the same node"
978 check_timeout || return 1
980 zconf_mount `hostname` $MOUNT2 ||
981 { error "Failed to mount $MOUNT2"; return 2; }
982 sleep 1 # wait connections being established
984 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
985 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
987 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
989 zconf_umount `hostname` $MOUNT2 -f
991 # PING_INTERVAL max(obd_timeout / 4, 1U)
992 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
994 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
995 # But if there's a race to start the evictor from various obds,
996 # the loser might have to wait for the next ping.
997 # = 9 * PING_INTERVAL + PING_INTERVAL
998 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
999 # let's wait $((TIMEOUT * 3)) # bug 19887
1001 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1002 error "Client was not evicted by ost" rc=1
1003 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1004 error "Client was not evicted by mds"
1006 run_test 26b "evict dead exports"
1010 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1013 local save_FAILURE_MODE=$FAILURE_MODE
1015 facet_failover $SINGLEMDS
1016 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1017 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1018 # need to wait for reconnect
1019 echo waiting for fail_loc
1020 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1021 facet_failover $SINGLEMDS
1022 #no crashes allowed!
1023 kill -USR1 $CLIENT_PID
1026 FAILURE_MODE=$save_FAILURE_MODE
1028 run_test 27 "fail LOV while using OSC's"
1030 test_28() { # bug 6086 - error adding new clients
1031 do_facet client mcreate $DIR/$tfile || return 1
1032 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1033 echo "evicted as expected"
1034 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1035 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1036 # fail once (evicted), reconnect fail (fail_loc), ok
1037 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1039 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1041 run_test 28 "handle error adding new clients (bug 6086)"
1043 test_29a() { # bug 22273 - error adding new clients
1044 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1045 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1046 # fail abort so client will be new again
1047 fail_abort $SINGLEMDS
1048 client_up || error "reconnect failed"
1049 wait_osc_import_state $SINGLEMDS ost FULL
1052 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1054 test_29b() { # bug 22273 - error adding new clients
1055 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1056 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1057 # fail abort so client will be new again
1059 client_up || error "reconnect failed"
1062 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1066 # put a load of file creates/writes/deletes
1067 writemany -q $DIR/$tdir/$tfile 0 5 &
1069 echo writemany pid $CLIENT_PID
1073 # wait for client to reconnect to MDS
1078 # client process should see no problems even though MDS went down
1080 kill -USR1 $CLIENT_PID
1083 echo writemany returned $rc
1084 #these may fail because of eviction due to slow AST response.
1086 error_ignore bz13652 "writemany returned rc $rc" || true
1088 run_test 50 "failover MDS under load"
1091 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1092 do_facet ost1 lctl set_param fail_loc=0x00001310
1095 # put a load of file creates/writes/deletes
1096 writemany -q $DIR/$tdir/$tfile 0 5 &
1100 facet_failover $SINGLEMDS
1101 # failover at various points during recovery
1102 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1103 echo will failover at $SEQ
1106 #echo failover in $i sec
1107 log "test_$testnum: failover in $i sec"
1109 facet_failover $SINGLEMDS
1111 # client process should see no problems even though MDS went down
1112 # and recovery was interrupted
1114 kill -USR1 $CLIENT_PID
1117 echo writemany returned $rc
1119 error_ignore bz13652 "writemany returned rc $rc" || true
1121 run_test 51 "failover MDS during recovery"
1124 do_facet client "mkdir -p $DIR/$tdir"
1125 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1127 echo writemany pid $CLIENT_PID
1132 wait $CLIENT_PID || rc=$?
1133 # active client process should see an EIO for down OST
1134 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1135 # but timing or failover setup may allow success
1136 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1137 echo "writemany returned $rc"
1142 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1147 [ $rc -ne 0 ] && { return $rc; }
1148 # wait for client to reconnect to OST
1152 [ $rc -ne 0 ] && { return $rc; }
1159 run_test 52 "failover OST under load"
1161 # test of open reconstruct
1164 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1167 run_test 53 "touch: drop rep"
1170 zconf_mount `hostname` $MOUNT2
1172 touch $DIR2/$tfile.1
1174 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1177 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1178 [ x"$ERROR" == x ] || error "back in time occured"
1180 run_test 54 "back in time"
1182 # bug 11330 - liblustre application death during I/O locks up OST
1184 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1188 # Minimum pass speed is 2MBps
1190 # LU-2887/LU-3089 - set min pass speed to 500KBps
1191 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1193 # first dd should be finished quickly
1194 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1195 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1198 echo "step1: testing ......"
1199 while kill -0 $DDPID 2> /dev/null; do
1201 if [ $count -gt $ddtimeout ]; then
1202 error "dd should be finished!"
1206 echo "(dd_pid=$DDPID, time=$count)successful"
1208 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1209 #define OBD_FAIL_OST_DROP_REQ 0x21d
1210 do_facet ost1 lctl set_param fail_loc=0x0000021d
1211 # second dd will be never finished
1212 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1215 echo "step2: testing ......"
1216 while [ $count -le $ddtimeout ]; do
1217 if ! kill -0 $DDPID 2> /dev/null; then
1219 error "dd shouldn't be finished! (time=$count)"
1224 echo "(dd_pid=$DDPID, time=$count)successful"
1226 #Recover fail_loc and dd will finish soon
1227 do_facet ost1 lctl set_param fail_loc=0
1229 echo "step3: testing ......"
1230 while kill -0 $DDPID 2> /dev/null; do
1232 if [ $count -gt $((ddtimeout + 440)) ]; then
1233 error "dd should be finished!"
1237 echo "(dd_pid=$DDPID, time=$count)successful"
1241 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1243 test_56() { # b=11277
1244 #define OBD_FAIL_MDS_RESEND 0x136
1246 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1247 stat $DIR/$tfile || error "stat failed"
1248 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1251 run_test 56 "do not fail on getattr resend"
1254 # no oscs means no client or mdt
1255 while lctl get_param osc.*.* > /dev/null 2>&1; do
1256 : # loop until proc file is removed
1260 test_57() { # bug 10866
1264 #define OBD_FAIL_LPROC_REMOVE 0xB00
1265 lctl set_param fail_loc=0x80000B00
1266 zconf_umount `hostname` $DIR
1267 lctl set_param fail_loc=0x80000B00
1268 fail_abort $SINGLEMDS
1270 lctl set_param fail_loc=0
1272 do_facet client "df $DIR"
1274 run_test 57 "read procfs entries causes kernel crash"
1276 test_58() { # bug 11546
1277 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1280 lctl set_param fail_loc=0x80000801
1281 cp $DIR/$tfile /dev/null &
1284 lctl set_param fail_loc=0
1285 drop_bl_callback_once rm -f $DIR/$tfile
1287 # the first 'df' could tigger the eviction caused by
1288 # 'drop_bl_callback_once', and it's normal case.
1289 # but the next 'df' should return successfully.
1290 do_facet client "df $DIR" || do_facet client "df $DIR"
1292 run_test 58 "Eviction in the middle of open RPC reply processing"
1294 test_59() { # bug 10589
1295 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1296 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1297 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1298 lctl set_param fail_loc=0x311
1299 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1300 [ $? = 0 ] || error "dd write failed"
1301 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1302 lctl set_param fail_loc=0
1304 zconf_umount `hostname` $MOUNT2 -f
1305 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1306 [ $? = 0 ] || error "dd read failed"
1307 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1308 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1310 run_test 59 "Read cancel race on client eviction"
1313 # we assume that all md changes are in the MDT0 changelog
1314 if [ $MDSCOUNT -gt 1 ]; then
1315 error_ignore bz17935 $*
1322 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1323 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1328 # Register (and start) changelog
1329 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1330 echo "Registered as $MDT0 changelog user $USER"
1332 # Generate a large number of changelog entries
1333 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1337 # Unlink files in the background
1338 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1342 # Failover the MDS while unlinks are happening
1343 facet_failover $SINGLEMDS
1345 # Wait for unlinkmany to finish
1348 # Check if all the create/unlink events were recorded
1350 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1351 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1352 echo "$cl_count unlinks in $MDT0 changelog"
1354 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1355 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1356 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1357 if [ $USERS -eq 0 ]; then
1358 [ $cl_count -eq $NUM_FILES ] || \
1359 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1360 # Also make sure we can clear large changelogs
1361 cl_count=$($LFS changelog $FSNAME | wc -l)
1362 [ $cl_count -le 2 ] || \
1363 error "Changelog not empty: $cl_count entries"
1365 # If there are other users, there may be other unlinks in the log
1366 [ $cl_count -ge $NUM_FILES ] || \
1367 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1368 echo "$USERS other changelog users; can't verify clear"
1371 run_test 60 "Add Changelog entries during MDS failover"
1375 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1376 mdtosc=${mdtosc/-MDT*/-MDT\*}
1377 local cflags="osc.$mdtosc.connect_flags"
1378 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1379 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1381 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1382 # Set the default stripe of $DIR/$tdir to put the files to ost1
1383 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1385 replay_barrier $SINGLEMDS
1386 createmany -o $DIR/$tdir/$tfile-%d 10
1387 local oid=$(do_facet ost1 "lctl get_param -n \
1388 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1390 fail_abort $SINGLEMDS
1392 touch $DIR/$tdir/$tfile
1393 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1394 awk '$1 == 0 { print $2 }')
1395 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1400 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1402 # test_62 as seen it b2_1 please do not reuse test_62
1405 # zconf_umount `hostname` $DIR
1406 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1407 # lctl set_param fail_loc=0x516
1410 #run_test 62 "Verify connection flags race - bug LU-1716"
1414 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1415 { skip "Need MDS version at least 2.7.51"; return 0; }
1417 local list=$(comma_list $(osts_nodes))
1419 # modify dir so that next revalidate would not obtain UPDATE lock
1422 # drop 1 reply with UPDATE lock
1423 mcreate $DIR/$tfile || error "mcreate failed: $?"
1424 drop_ldlm_reply_once "stat $DIR/$tfile" &
1427 # make the re-sent lock to sleep
1428 #define OBD_FAIL_MDS_RESEND 0x136
1429 do_nodes $list $LCTL set_param fail_loc=0x80000136
1431 #initiate the re-connect & re-send
1432 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1433 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1434 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1437 #initiate the client eviction while enqueue re-send is in progress
1443 run_test 66 "lock enqueue re-send vs client eviction"
1448 #grant lock1, export2
1449 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1450 $MULTIOP $DIR2/$tfile Ow || return 2
1452 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1453 do_facet ost $LCTL set_param fail_loc=0x31e
1454 #get waiting lock2, export1
1455 $MULTIOP $DIR/$tfile Ow &
1457 # let enqueue to get asleep
1461 $MULTIOP $DIR2/$tfile Ow &
1469 do_facet ost $LCTL set_param fail_loc=0
1476 run_test 65 "lock enqueue for destroyed export"
1478 check_cli_ir_state()
1480 local NODE=${1:-$HOSTNAME}
1482 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1483 awk '/imperative_recovery:/ { print \\\$2}'")
1484 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1485 error "Error state $st, must be ENABLED or DISABLED"
1489 check_target_ir_state()
1492 local name=${target}_svc
1493 local recovery_proc=obdfilter.${!name}.recovery_status
1497 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1498 awk '/status:/{ print \\\$2}'")
1499 [ x$st = xRECOVERING ] || break
1501 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1502 awk '/IR:/{ print \\\$2}'")
1503 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1504 error "Error state $st, must be ENABLED or DISABLED"
1510 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1515 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1516 awk '/state:/{ print \\\$2 }'")
1520 nidtbl_version_mgs()
1522 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1523 awk '/nidtbl_version:/{ print \\\$2 }'")
1527 # nidtbl_version_client <mds1|client> [node]
1528 nidtbl_version_client()
1531 local node=${2:-$HOSTNAME}
1533 if [ X$cli = Xclient ]; then
1536 local obdtype=${cli/%[0-9]*/}
1537 [ $obdtype != mds ] && error "wrong parameters $cli"
1539 node=$(facet_active_host $cli)
1544 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1545 awk "/$cli/{print \$6}" |sort -u)
1547 # in case there are multiple mounts on the client node
1549 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1553 nidtbl_versions_match()
1555 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1558 target_instance_match()
1564 obdtype=${srv/%[0-9]*/}
1575 error "invalid target type" $srv
1580 local target=${srv}_svc
1581 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1582 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1583 awk '/instance/{ print $2 }' | head -n1)
1585 return $([ $si -eq $ci ])
1590 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1591 { skip "MGS without IR support"; return 0; }
1593 # MDT was just restarted in the previous test, make sure everything
1596 while [ $cnt -gt 0 ]; do
1597 nidtbl_versions_match && break
1603 set_ir_status disabled
1605 local prev_ver=$(nidtbl_version_client client)
1607 local saved_FAILURE_MODE=$FAILURE_MODE
1608 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1612 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1613 error "version must not change due to IR disabled"
1614 target_instance_match ost1 || error "instance mismatch"
1618 FAILURE_MODE=$saved_FAILURE_MODE
1620 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1624 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1625 { skip "MGS without IR support"; return 0; }
1629 local OST1_IMP=$(get_osc_import_name client ost1)
1631 # disable pinger recovery
1632 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1636 target_instance_match ost1 || error "instance mismatch"
1637 nidtbl_versions_match || error "version must match"
1639 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1641 run_test 101 "IR: Make sure IR works w/o normal recovery"
1645 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1646 { skip "MGS without IR support"; return 0; }
1648 local clients=${CLIENTS:-$HOSTNAME}
1655 # let's have a new nidtbl version
1658 # sleep for a while so that clients can see the failure of ost
1659 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1660 # int mgc_request.c:
1661 # define MGC_TIMEOUT_MIN_SECONDS 5
1662 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1663 local count=30 # 20 seconds at most
1664 while [ $count -gt 0 ]; do
1665 nidtbl_versions_match && break
1670 nidtbl_versions_match || error "nidtbl mismatch"
1673 old_version=$(nidtbl_version_client client)
1675 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1678 combined_mgs_mds && mgsdev=mds1
1679 remount_facet $mgsdev
1682 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1685 new_version=$(nidtbl_version_client client)
1686 [ $new_version -lt $old_version ] &&
1687 error "nidtbl version wrong after mgs restarts"
1690 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1694 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1695 { skip "MGS without IR support"; return 0; }
1697 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1699 # workaround solution to generate config log on the mds
1705 # We need this test because mds is like a client in IR context.
1706 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1707 error "MDS should start w/o mgs"
1709 # start mgs and remount mds w/ ir
1710 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1713 # remount client so that fsdb will be created on the MGS
1714 umount_client $MOUNT || error "umount failed"
1715 mount_client $MOUNT || error "mount failed"
1717 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1719 while [ $count -gt 0 ]; do
1720 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1725 # after a while, mds should be able to reconnect to mgs and fetch
1726 # up-to-date nidtbl version
1727 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1732 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1736 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1737 { skip "MGS without IR support"; return 0; }
1742 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1743 error "OST1 cannot start"
1746 local ir_state=$(check_target_ir_state ost1)
1747 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1748 error "ir status on ost1 should be DISABLED"
1750 run_test 104 "IR: ost can disable IR voluntarily"
1754 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1755 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1756 { skip "MGS without IR support"; return 0; }
1760 # get one of the clients from client list
1761 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1763 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1764 zconf_umount $rcli $MOUNT || error "umount failed"
1765 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1767 # make sure lustre mount at $rcli disabling IR
1768 local ir_state=$(check_cli_ir_state $rcli)
1769 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1770 error "IR state must be DISABLED at $rcli"
1772 # Since the client just mounted, its last_rcvd entry is not on disk.
1773 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1774 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1775 $SETSTRIPE -i 0 $DIR/$tfile
1776 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1778 # make sure MGS's state is Partial
1779 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1782 # make sure IR on ost1 is DISABLED
1783 local ir_state=$(check_target_ir_state ost1)
1784 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1785 error "IR status on ost1 should be DISABLED"
1787 # remount with the default MOUNT_OPTS
1788 zconf_umount $rcli $MOUNT || error "umount failed"
1789 zconf_mount $rcli $MOUNT || error "mount failed"
1791 # make sure MGS's state is full
1792 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1795 # make sure IR on ost1 is ENABLED
1796 local ir_state=$(check_target_ir_state ost1)
1797 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1798 error "IR status on ost1 should be ENABLED"
1802 run_test 105 "IR: NON IR clients support"
1810 test_106() { # LU-1789
1811 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1812 { skip "Need MDS version at least 2.3.50"; return 0; }
1814 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1815 $LCTL set_param fail_loc=0x805
1818 trap cleanup_106 EXIT
1820 # enable lightweight flag on mdc connection
1823 local MDS_NEXP=$(do_facet $SINGLEMDS \
1824 lctl get_param -n mdt.${mds1_svc}.num_exports |
1826 $LCTL set_param fail_loc=0
1828 touch $DIR2/$tfile || error "failed to create empty file"
1829 replay_barrier $SINGLEMDS
1831 $LCTL set_param debug=console
1833 facet_failover $SINGLEMDS
1835 # lightweight connection must be evicted
1836 touch -c $DIR2/$tfile || true
1837 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1838 evicted=`awk '/This client was evicted by .*MDT0000/ {
1840 }' $TMP/lustre-log-$TESTNAME.log`
1841 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1843 # and all operations performed by lightweight client should be
1844 # synchronous, so the file created before mds restart should be there
1845 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1850 run_test 106 "lightweight connection support"
1857 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1858 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1859 multiop $DIR/$tdir D_c &
1861 mkdir $DIR/$tdir/dir_106 &
1863 do_facet $SINGLEMDS lctl set_param fail_loc=0
1866 wait $CLIENT_PID || rc=$?
1867 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1869 kill -USR1 $close_pid
1870 wait $close_pid || return 2
1874 run_test 107 "drop reint reply, then restart MDT"
1878 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1880 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
1888 client_up || error "reconnect failed"
1889 rm -f $DIR/$tdir/$tfile
1891 run_test 108 "client eviction don't crash"
1894 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1895 local remote_dir=$DIR/$tdir/remote_dir
1899 #prepare for 110 test, which need set striped dir on remote MDT.
1900 for num in $(seq $MDSCOUNT); do
1902 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1907 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1908 error "lfs mkdir failed"
1909 local diridx=$($GETSTRIPE -M $remote_dir)
1910 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1912 rm -rf $DIR/$tdir || error "rmdir failed"
1914 run_test 110a "create remote directory: drop client req"
1917 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1918 local remote_dir=$DIR/$tdir/remote_dir
1922 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1923 error "lfs mkdir failed"
1925 diridx=$($GETSTRIPE -M $remote_dir)
1926 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1928 rm -rf $DIR/$tdir || error "rmdir failed"
1930 run_test 110b "create remote directory: drop Master rep"
1933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1934 local remote_dir=$DIR/$tdir/remote_dir
1938 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1939 error "lfs mkdir failed"
1941 diridx=$($GETSTRIPE -M $remote_dir)
1942 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1944 rm -rf $DIR/$tdir || error "rmdir failed"
1946 run_test 110c "create remote directory: drop update rep on slave MDT"
1949 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1950 local remote_dir=$DIR/$tdir/remote_dir
1954 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1956 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1958 rm -rf $DIR/$tdir || error "rmdir failed"
1962 run_test 110d "remove remote directory: drop client req"
1965 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1966 local remote_dir=$DIR/$tdir/remote_dir
1970 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1971 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1973 rm -rf $DIR/$tdir || error "rmdir failed"
1977 run_test 110e "remove remote directory: drop master rep"
1980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1981 local remote_dir=$DIR/$tdir/remote_dir
1985 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1986 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1987 error "rm remote dir failed"
1989 rm -rf $DIR/$tdir || error "rmdir failed"
1991 run_test 110f "remove remote directory: drop slave rep"
1994 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1995 local remote_dir=$DIR/$tdir/remote_dir
1998 mkdir -p $remote_dir
2000 createmany -o $remote_dir/f 100
2002 #define OBD_FAIL_MIGRATE_NET_REP 0x1800
2003 do_facet mds$MDTIDX lctl set_param fail_loc=0x1800
2004 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
2005 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
2007 for file in $(find $remote_dir); do
2008 mdt_index=$($LFS getstripe -M $file)
2009 [ $mdt_index == $MDTIDX ] ||
2010 error "$file is not on MDT${MDTIDX}"
2013 rm -rf $DIR/$tdir || error "rmdir failed"
2015 run_test 110g "drop reply during migration"
2018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2019 local src_dir=$DIR/$tdir/source_dir
2020 local tgt_dir=$DIR/$tdir/target_dir
2024 $LFS mkdir -i $MDTIDX $tgt_dir
2026 dd if=/etc/hosts of=$src_dir/src_file
2027 touch $tgt_dir/tgt_file
2028 drop_update_reply $MDTIDX \
2029 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2030 error "mrename failed"
2032 $CHECKSTAT -t file $src_dir/src_file &&
2033 error "src_file present after rename"
2035 diff /etc/hosts $tgt_dir/tgt_file ||
2036 error "file changed after rename"
2039 run_test 110h "drop update reply during cross-MDT file rename"
2042 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2043 local src_dir=$DIR/$tdir/source_dir
2044 local tgt_dir=$DIR/$tdir/target_dir
2048 $LFS mkdir -i $MDTIDX $tgt_dir
2050 mkdir $src_dir/src_dir
2051 touch $src_dir/src_dir/a
2052 mkdir $tgt_dir/tgt_dir
2053 drop_update_reply $MDTIDX \
2054 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2055 error "mrename failed"
2057 $CHECKSTAT -t dir $src_dir/src_dir &&
2058 error "src_dir present after rename"
2060 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2061 error "tgt_dir not present after rename"
2063 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2064 error "a not present after rename"
2066 run_test 110i "drop update reply during cross-MDT dir rename"
2069 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2070 local remote_dir=$DIR/$tdir/remote_dir
2071 local local_dir=$DIR/$tdir/local_dir
2075 mkdir $DIR/$tdir/local_dir
2076 $LFS mkdir -i $MDTIDX $remote_dir
2078 touch $local_dir/local_file
2079 drop_update_reply $MDTIDX \
2080 "ln $local_dir/local_file $remote_dir/remote_file" ||
2083 $CHECKSTAT -t file $remote_dir/remote_file ||
2084 error "remote not present after ln"
2086 run_test 110j "drop update reply during cross-MDT ln"
2088 # LU-2844 mdt prepare fail should not cause umount oops
2091 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2092 { skip "Need MDS version at least 2.3.62"; return 0; }
2094 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2095 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2096 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2097 stop $SINGLEMDS || error "stop MDS failed"
2098 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2099 do_facet $SINGLEMDS lctl set_param fail_loc=0
2100 start $SINGLEMDS $mdsdev || error "start MDS failed"
2102 run_test 111 "mdd setup fail should not cause umount oops"
2106 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2108 do_facet_random_file client $TMP/$tfile 100K ||
2109 error_noexit "Create random file $TMP/$tfile"
2111 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2112 error_noexit "Can't pause_bulk copy"
2115 # expect cmp to succeed, client resent bulk
2116 cmp $TMP/$tfile $DIR/$tfile ||
2117 error_noexit "Wrong data has been written"
2119 error_noexit "Can't remove file"
2122 run_test 112a "bulk resend while orignal request is in progress"
2129 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2130 cancel_lru_locks osc
2133 $LCTL set_param fail_loc=$fail1 fail_val=3
2134 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2138 set_nodes_failloc "$(osts_nodes)" $fail2
2140 wait $pid || error "dd failed"
2148 local fail_val2=${4:-0}
2154 $LCTL set_param fail_loc=$fail1 fail_val=4
2155 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2160 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2164 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2165 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2170 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2171 skip "need at least 2.8.50 on OST" && return 0
2173 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2174 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2175 test_115_read 0x8000051b 0x8000051a
2177 run_test 115a "read: late REQ MDunlink and no bulk"
2180 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2181 skip "need at least 2.8.50 on OST" && return 0
2183 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2184 #define OBD_FAIL_OST_ENOSPC 0x215
2186 # pass $OSTCOUNT for the fail_loc to be caught
2187 # appropriately by the IO thread
2188 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2190 run_test 115b "write: late REQ MDunlink and no bulk"
2193 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2194 skip "need at least 2.8.50 on OST" && return 0
2196 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2197 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2198 test_115_read 0x8000050f 0x8000051a
2200 run_test 115c "read: late Reply MDunlink and no bulk"
2203 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2204 skip "need at least 2.8.50 on OST" && return 0
2206 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2207 #define OBD_FAIL_OST_ENOSPC 0x215
2208 test_115_write 0x8000050f 0x80000215 0
2210 run_test 115d "write: late Reply MDunlink and no bulk"
2213 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2214 skip "need at least 2.8.50 on OST" && return 0
2216 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2217 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2218 test_115_read 0x80000510 0x80000211
2220 run_test 115e "read: late Bulk MDunlink and no reply"
2223 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2224 skip "need at least 2.8.50 on OST" && return 0
2226 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2227 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2228 test_115_read 0x8000051b 0x80000211
2230 run_test 115f "read: late REQ MDunlink and no reply"
2233 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2234 skip "need at least 2.8.50 on OST" && return 0
2236 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2237 test_115_read 0x8000051c 0
2239 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2241 # parameters: fail_loc CMD RC
2248 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2249 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2250 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2251 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2254 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2255 [ "$1" = "CLEANUP" ] &&
2256 fail=0x80000320 && echo ", $1 cp first"
2257 [ "$1" = "REPLY" ] &&
2258 fail=0x80000321 && echo ", $1 cp first"
2259 [ "$1" = "DEADLOCK CLEANUP" ] &&
2260 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2261 [ "$1" = "DEADLOCK REPLY" ] &&
2262 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2264 if [ x"$2" = x"get" ]; then
2265 #for TEST lock, take a conflict in advance
2266 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2267 echo "** Taking conflict **"
2268 flocks_test 5 set read sleep 10 $DIR/$tfile &
2274 $LCTL set_param fail_loc=$fail
2276 flocks_test 5 $2 write $DIR/$tfile &
2280 echo "** Evicting and re-connecting client **"
2285 if [ x"$2" = x"get" ]; then
2292 # check if the return value is allowed
2293 [ $rc -eq $3 ] && rc=0
2295 $LCTL set_param fail_loc=0
2299 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2300 # the ORIGINAL lock.
2305 flocks_test 5 set write sleep 4 $DIR/$tfile &
2309 # let unlock to sleep in CP CB
2310 $LCTL set_param fail_loc=$1
2313 # let cleanup to cleep in CP CB
2321 $LCTL set_param fail_loc=0
2326 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2329 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2330 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2331 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2333 test_120_reply "REPLY" set 5 || error "SET race failed"
2334 test_120_reply "REPLY" get 5 || error "GET race failed"
2335 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2338 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2339 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2341 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2343 run_test 120 "flock race: completion vs. evict"
2346 local BEFORE=$(date +%s)
2349 # modify dir so that next revalidate would not obtain UPDATE lock
2352 # drop 1 reply with UPDATE lock,
2353 # resend should not create 2nd lock on server
2354 mcreate $DIR/$tfile || error "mcreate failed: $?"
2355 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2357 # 2 BL AST will be sent to client, both must find the same lock,
2358 # race them to not get EINVAL for 2nd BL AST
2359 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2360 $LCTL set_param fail_loc=0x8000031f
2362 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2363 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2364 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2366 # let the client reconnect
2368 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2369 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2371 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2373 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2377 test_mkdir -p $DIR/$tdir
2379 # Prevent interference from layout intent RPCs due to
2380 # asynchronous writeback. These will be tested in 130c below.
2381 do_nodes ${CLIENTS:-$HOSTNAME} sync
2383 # get only LOOKUP lock on $tdir
2384 cancel_lru_locks mdc
2385 ls $DIR/$tdir/$tfile 2>/dev/null
2387 # get getattr by fid on $tdir
2389 # we need to race with unlink, unlink must complete before we will
2390 # take a DLM lock, otherwise unlink will wait until getattr will
2391 # complete; but later than getattr starts so that getattr found
2393 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2394 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2401 # drop the reply so that resend happens on an unlinked file.
2402 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2403 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2407 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2410 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2413 run_test 130a "enqueue resend on not existing file"
2416 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2418 # let the reply to be dropped
2421 #define OBD_FAIL_SRV_ENOENT 0x217
2422 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2424 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2427 run_test 130b "enqueue resend on a stale inode"
2430 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2432 do_nodes ${CLIENTS:-$HOSTNAME} sync
2433 echo XXX > $DIR/$tfile
2435 cancel_lru_locks mdc
2437 # Trigger writeback on $tfile.
2439 # we need to race with unlink, unlink must complete before we will
2440 # take a DLM lock, otherwise unlink will wait until intent will
2441 # complete; but later than intent starts so that intent found
2443 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2444 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2451 # drop the reply so that resend happens on an unlinked file.
2452 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2453 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2455 # let the reply to be dropped
2458 #define OBD_FAIL_SRV_ENOENT 0x217
2459 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2465 run_test 130c "layout intent resend on a stale inode"
2468 local before=$(date +%s)
2471 mount_client $MOUNT2 || error "mount filed"
2474 # get a lock on client so that export would reach the stale list
2475 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2476 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2479 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2480 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2482 $TRUNCATE $DIR/$tfile 100 &
2485 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2489 umount_client $MOUNT2
2491 evict=$(do_facet client $LCTL get_param \
2492 osc.$FSNAME-OST0000-osc-*/state |
2493 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2495 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2496 (do_facet client $LCTL get_param \
2497 osc.$FSNAME-OST0000-osc-*/state;
2498 error "eviction happened: $evict before:$before")
2500 run_test 132 "long punch"
2503 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2506 # get a lock on client so that export would reach the stale list
2507 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2508 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2510 # another IO under the same lock
2511 #define OBD_FAIL_OSC_DELAY_IO 0x414
2512 $LCTL set_param fail_loc=0x80000414
2513 $LCTL set_param fail_val=4 fail_loc=0x80000414
2514 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2518 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2519 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2523 wait $pid && error "dd succeeded"
2526 run_test 131 "IO vs evict results to IO under staled lock"
2529 local list=$(comma_list $(mdts_nodes))
2531 local t=$((TIMEOUT * 2))
2534 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2536 multiop_bg_pause $DIR/$tfile O_jc || return 1
2539 #define OBD_FAIL_LDLM_REPLY 0x30c
2540 do_nodes $list $LCTL set_param fail_loc=0x8000030c
2542 echo "waiting for multiop $PID"
2543 wait $PID || return 2
2549 run_test 133 "don't fail on flock resend"
2552 check_and_cleanup_lustre