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
19 # 1 2.5 2.5 4 4 (min)"
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW="17 26a 26b 50 51 57"
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)
203 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
204 skip "Need MDS version at least 2.6.90" && return
206 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
209 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
214 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
215 echo -n hello > $DIR1/$tfile
217 stat $DIR2/$tfile >& /dev/null
218 $LCTL set_param fail_err=71
219 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
223 cmp $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
224 cmp $DIR1/$tfile $TMP/$tfile || error "wrong content found"
226 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
228 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
230 [[ $evict -gt $before ]] ||
231 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
232 error "no eviction: $evict before:$before")
235 umount_client $MOUNT2
237 run_test 10d "test failed blocking ast"
240 # wake up a thread waiting for completion after eviction
242 do_facet client $MULTIOP $DIR/$tfile Ow ||
243 { error "multiop write failed: $?"; return 1; }
244 do_facet client $MULTIOP $DIR/$tfile or ||
245 { error "multiop read failed: $?"; return 2; }
249 do_facet client $MULTIOP $DIR/$tfile or ||
250 { error "multiop read failed: $?"; return 3; }
251 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
252 echo "evicted as expected"
254 do_facet client munlink $DIR/$tfile ||
255 { error "munlink failed: $?"; return 4; }
256 # allow recovery to complete
257 client_up || client_up || sleep $TIMEOUT
259 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
263 $LCTL mark $MULTIOP $DIR/$tfile OS_c
264 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
265 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
266 multiop_bg_pause $DIR/$tfile OS_c ||
267 { error "multiop failed: $?"; return 1; }
269 #define OBD_FAIL_MDS_CLOSE_NET 0x115
271 echo "waiting for multiop $PID"
272 wait $PID || { error "wait for multiop faile: $?"; return 2; }
273 do_facet client munlink $DIR/$tfile ||
274 { error "client munlink failed: $?"; return 3; }
275 # allow recovery to complete
276 client_up || client_up || sleep $TIMEOUT
278 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
280 # Bug 113, check that readdir lost recv timeout works.
282 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
283 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
284 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
285 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
286 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
287 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
288 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
290 run_test 13 "mdc_readpage restart test (bug 1138)"
292 # Bug 113, check that readdir lost send timeout works.
295 touch $DIR/$tdir/newentry
296 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
297 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
298 ls $DIR/$tdir || return 1
299 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
301 run_test 14 "mdc_readpage resend test (bug 1138)"
304 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
305 touch $DIR/$tfile && return 1
308 run_test 15 "failed open (-ENOMEM)"
310 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
312 lctl set_param -n llite.*.max_read_ahead_mb 0
316 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
320 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
322 do_facet_random_file client $TMP/$tfile 100K ||
323 { error_noexit "Create random file $TMP/$T" ; return 0; }
324 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
325 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
329 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
330 do_facet ost1 "lctl set_param fail_loc=0x80000504"
332 # OST bulk will time out here, client resends
333 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
334 do_facet ost1 lctl set_param fail_loc=0
335 # give recovery a chance to finish (shouldn't take long)
337 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
341 run_test 16 "timeout bulk put, don't evict client (2732)"
346 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
348 local SAMPLE_FILE=$TMP/$tfile
349 do_facet_random_file client $SAMPLE_FILE 20K ||
350 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
352 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
353 if at_is_enabled; then
354 at_max_saved=$(at_max_get ost1)
355 at_max_set $TIMEOUT ost1
358 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
359 # OST bulk will time out here, client retries
360 do_facet ost1 lctl set_param fail_loc=0x80000503
361 # need to ensure we send an RPC
362 do_facet client cp $SAMPLE_FILE $DIR/$tfile
365 # with AT, client will wait adaptive_max*factor+net_latency before
366 # expiring the req, hopefully timeout*2 is enough
367 sleep $(($TIMEOUT*2))
369 do_facet ost1 lctl set_param fail_loc=0
370 do_facet client "df $DIR"
371 # expect cmp to succeed, client resent bulk
372 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
373 do_facet client "rm $DIR/$tfile" || return 4
374 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
377 run_test 17 "timeout bulk get, don't evict client (2732)"
380 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
382 do_facet_create_file client $TMP/$tfile 20K ||
383 { error_noexit "Create file $TMP/$tfile" ; return 0; }
385 do_facet client mkdir -p $DIR/$tdir
389 pgcache_empty || return 1
392 $LFS setstripe -i 1 -c 1 $f
393 stripe_index=$($LFS getstripe -i $f)
394 if [ $stripe_index -ne 1 ]; then
396 error "$f: stripe_index $stripe_index != 1" && return
399 do_facet client cp $TMP/$tfile $f
401 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
402 $LCTL --device $osc2dev deactivate || return 3
403 # my understanding is that there should be nothing in the page
404 # cache after the client reconnects?
406 pgcache_empty || rc=2
407 $LCTL --device $osc2dev activate
411 run_test 18a "manual ost invalidate clears page cache immediately"
414 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
416 do_facet_create_file client $TMP/$tfile 20K ||
417 { error_noexit "Create file $TMP/$tfile" ; return 0; }
419 do_facet client mkdir -p $DIR/$tdir
423 pgcache_empty || return 1
425 $LFS setstripe -i 0 -c 1 $f
426 stripe_index=$($LFS getstripe -i $f)
427 if [ $stripe_index -ne 0 ]; then
429 error "$f: stripe_index $stripe_index != 0" && return
432 do_facet client cp $TMP/$tfile $f
435 # allow recovery to complete
436 sleep $((TIMEOUT + 2))
437 # my understanding is that there should be nothing in the page
438 # cache after the client reconnects?
440 pgcache_empty || rc=2
444 run_test 18b "eviction and reconnect clears page cache (2766)"
447 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
449 do_facet_create_file client $TMP/$tfile 20K ||
450 { error_noexit "Create file $TMP/$tfile" ; return 0; }
452 do_facet client mkdir -p $DIR/$tdir
456 pgcache_empty || return 1
458 $LFS setstripe -i 0 -c 1 $f
459 stripe_index=$($LFS getstripe -i $f)
460 if [ $stripe_index -ne 0 ]; then
462 error "$f: stripe_index $stripe_index != 0" && return
465 do_facet client cp $TMP/$tfile $f
469 # OBD_FAIL_OST_CONNECT_NET2
470 # lost reply to connect request
471 do_facet ost1 lctl set_param fail_loc=0x80000225
474 df $MOUNT > /dev/null 2>&1
476 # my understanding is that there should be nothing in the page
477 # cache after the client reconnects?
479 pgcache_empty || rc=2
483 run_test 18c "Dropped connect reply after eviction handing (14755)"
486 local BEFORE=`date +%s`
489 mount_client $DIR2 || error "failed to mount $DIR2"
491 # cancel cached locks from OST to avoid eviction from it
494 do_facet client "stat $DIR > /dev/null" ||
495 error "failed to stat $DIR: $?"
496 drop_ldlm_cancel "chmod 0777 $DIR2" ||
497 error "failed to chmod $DIR2"
501 # let the client reconnect
503 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
504 awk -F"[ [,]" '/EVICTED ]$/ \
505 { if (mx<$5) {mx=$5;} } END { print mx }')
507 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
508 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
509 error "no eviction: $EVICT before:$BEFORE")
511 run_test 19a "test expired_lock_main on mds (2867)"
514 local BEFORE=`date +%s`
517 mount_client $DIR2 || error "failed to mount $DIR2: $?"
519 # cancel cached locks from MDT to avoid eviction from it
522 do_facet client $MULTIOP $DIR/$tfile Ow ||
523 error "failed to run multiop: $?"
524 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
525 error "failed to ldlm_cancel: $?"
527 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
528 do_facet client munlink $DIR/$tfile ||
529 error "failed to unlink $DIR/$tfile: $?"
531 # let the client reconnect
533 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
534 awk -F"[ [,]" '/EVICTED ]$/ \
535 { if (mx < $5) {mx = $5;} } END { print mx }')
537 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
538 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
539 error "no eviction: $EVICT before:$BEFORE")
541 run_test 19b "test expired_lock_main on ost (2867)"
544 local BEFORE=`date +%s`
547 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
549 mkdir -p $DIR1/$tfile
552 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
553 do_facet mds $LCTL set_param fail_loc=0x80000516
555 touch $DIR2/$tfile/file1 &
557 # let touch to get blocked on the server
561 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
564 # let the client reconnect
566 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
567 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
569 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
571 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
573 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
574 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
577 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
578 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
581 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
582 do_facet ost1 lctl set_param fail_loc=0x80000308
583 kill -USR1 $MULTI_PID
586 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
588 run_test 20a "ldlm_handle_enqueue error (should return error)"
590 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
591 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
594 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
596 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
597 do_facet ost1 lctl set_param fail_loc=0x80000308
598 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
599 error "didn't fail open enqueue" || true
601 run_test 20b "ldlm_handle_enqueue error (should return error)"
604 mkdir -p $DIR/$tdir-1
605 mkdir -p $DIR/$tdir-2
606 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
609 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
610 $MULTIOP $DIR/$tdir-2/f Oc &
613 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
615 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
616 kill -USR1 $close_pid
618 wait $close_pid || return 1
619 wait $open_pid || return 2
620 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
622 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
623 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
627 run_test 21a "drop close request while close and open are both in flight"
630 mkdir -p $DIR/$tdir-1
631 mkdir -p $DIR/$tdir-2
632 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
635 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
636 mcreate $DIR/$tdir-2/f &
639 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
641 kill -USR1 $close_pid
643 wait $close_pid || return 1
644 wait $open_pid || return 3
646 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
647 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
650 run_test 21b "drop open request while close and open are both in flight"
653 mkdir -p $DIR/$tdir-1
654 mkdir -p $DIR/$tdir-2
655 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
658 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
659 mcreate $DIR/$tdir-2/f &
662 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
664 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
665 kill -USR1 $close_pid
667 wait $close_pid || return 1
668 wait $open_pid || return 2
670 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
672 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
673 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
676 run_test 21c "drop both request while close and open are both in flight"
679 mkdir -p $DIR/$tdir-1
680 mkdir -p $DIR/$tdir-2
681 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
684 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
685 $MULTIOP $DIR/$tdir-2/f Oc &
687 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
689 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
692 wait $pid || return 1
693 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
695 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
696 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
700 run_test 21d "drop close reply 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=0x80000119"
709 touch $DIR/$tdir-2/f &
711 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
715 wait $pid || return 1
718 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
719 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
722 run_test 21e "drop open reply 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=0x80000119"
731 touch $DIR/$tdir-2/f &
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
745 run_test 21f "drop both reply while close and open are both in flight"
748 mkdir -p $DIR/$tdir-1
749 mkdir -p $DIR/$tdir-2
750 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
753 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
754 touch $DIR/$tdir-2/f &
756 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
758 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
761 wait $pid || return 1
762 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
764 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
765 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
768 run_test 21g "drop open reply and close request 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=0x80000107"
777 touch $DIR/$tdir-2/f &
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
782 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
785 wait $pid || return 1
786 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
788 wait $touch_pid || return 2
790 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
791 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
794 run_test 21h "drop open request and close reply while close and open are both in flight"
796 # bug 3462 - multiple MDC requests
801 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
806 $MULTIOP $f1 msu || return 1
809 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
811 wait $close_pid || return 2
812 rm -rf $f2 || return 4
814 run_test 22 "drop close request and do mknod"
817 multiop_bg_pause $DIR/$tfile O_c || return 1
819 # give a chance for open
823 drop_request "kill -USR1 $pid"
826 wait $pid || return 1
829 run_test 23 "client hang when close a file after mds crash"
831 test_24a() { # bug 11710 details correct fsync() behavior
832 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
835 $LFS setstripe -i 0 -c 1 $DIR/$tdir
837 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
840 kill -USR1 $MULTI_PID
843 lctl set_param fail_loc=0x0
846 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
848 run_test 24a "fsync error (should return error)"
850 wait_client_evicted () {
853 local varsvc=${facet}_svc
855 wait_update $(facet_active_host $facet) \
856 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
861 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
865 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
867 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
868 error "mulitop Ow8192_yc failed"
871 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
872 error "mulitop Ow8192_c failed"
877 kill -USR1 $MULTI_PID1
880 kill -USR1 $MULTI_PID2
883 lctl set_param fail_loc=0x0
885 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
886 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
889 dmesg | grep "dirty page discard:" ||
890 error "no discarded dirty page found!"
892 run_test 24b "test dirty page discard due to client eviction"
894 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
895 # this test can only run from a client on a separate node.
896 remote_ost || { skip "local OST" && return 0; }
897 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
898 remote_mds || { skip "local MDS" && return 0; }
900 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
901 skip "msg and ost1 are at the same node"
905 check_timeout || return 1
907 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
909 echo starting with $OST_NEXP OST exports
910 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
911 do_facet client lctl set_param fail_loc=0x505
912 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
913 # But if there's a race to start the evictor from various obds,
914 # the loser might have to wait for the next ping.
917 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
919 do_facet client lctl set_param fail_loc=0x0
920 [ $rc -eq 0 ] || error "client not evicted from OST"
922 run_test 26a "evict dead exports"
924 test_26b() { # bug 10140 - evict dead exports by pinger
925 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
927 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
928 skip "msg and ost1 are at the same node"
932 check_timeout || return 1
934 zconf_mount `hostname` $MOUNT2 ||
935 { error "Failed to mount $MOUNT2"; return 2; }
936 sleep 1 # wait connections being established
938 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
939 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
941 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
943 zconf_umount `hostname` $MOUNT2 -f
945 # PING_INTERVAL max(obd_timeout / 4, 1U)
946 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
948 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
949 # But if there's a race to start the evictor from various obds,
950 # the loser might have to wait for the next ping.
951 # = 9 * PING_INTERVAL + PING_INTERVAL
952 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
953 # let's wait $((TIMEOUT * 3)) # bug 19887
955 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
956 error "Client was not evicted by ost" rc=1
957 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
958 error "Client was not evicted by mds"
960 run_test 26b "evict dead exports"
964 writemany -q -a $DIR/$tdir/$tfile 0 5 &
967 local save_FAILURE_MODE=$FAILURE_MODE
969 facet_failover $SINGLEMDS
970 #define OBD_FAIL_OSC_SHUTDOWN 0x407
971 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
972 # need to wait for reconnect
973 echo waiting for fail_loc
974 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
975 facet_failover $SINGLEMDS
977 kill -USR1 $CLIENT_PID
980 FAILURE_MODE=$save_FAILURE_MODE
982 run_test 27 "fail LOV while using OSC's"
984 test_28() { # bug 6086 - error adding new clients
985 do_facet client mcreate $DIR/$tfile || return 1
986 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
987 echo "evicted as expected"
988 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
989 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
990 # fail once (evicted), reconnect fail (fail_loc), ok
991 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
993 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
995 run_test 28 "handle error adding new clients (bug 6086)"
997 test_29a() { # bug 22273 - error adding new clients
998 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
999 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1000 # fail abort so client will be new again
1001 fail_abort $SINGLEMDS
1002 client_up || error "reconnect failed"
1003 wait_osc_import_state $SINGLEMDS ost FULL
1006 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1008 test_29b() { # bug 22273 - error adding new clients
1009 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1010 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1011 # fail abort so client will be new again
1013 client_up || error "reconnect failed"
1016 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1020 # put a load of file creates/writes/deletes
1021 writemany -q $DIR/$tdir/$tfile 0 5 &
1023 echo writemany pid $CLIENT_PID
1027 # wait for client to reconnect to MDS
1032 # client process should see no problems even though MDS went down
1034 kill -USR1 $CLIENT_PID
1037 echo writemany returned $rc
1038 #these may fail because of eviction due to slow AST response.
1040 error_ignore bz13652 "writemany returned rc $rc" || true
1042 run_test 50 "failover MDS under load"
1045 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1046 do_facet ost1 lctl set_param fail_loc=0x00001310
1049 # put a load of file creates/writes/deletes
1050 writemany -q $DIR/$tdir/$tfile 0 5 &
1054 facet_failover $SINGLEMDS
1055 # failover at various points during recovery
1056 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1057 echo will failover at $SEQ
1060 #echo failover in $i sec
1061 log "test_$testnum: failover in $i sec"
1063 facet_failover $SINGLEMDS
1065 # client process should see no problems even though MDS went down
1066 # and recovery was interrupted
1068 kill -USR1 $CLIENT_PID
1071 echo writemany returned $rc
1073 error_ignore bz13652 "writemany returned rc $rc" || true
1075 run_test 51 "failover MDS during recovery"
1078 do_facet client "mkdir -p $DIR/$tdir"
1079 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1081 echo writemany pid $CLIENT_PID
1086 wait $CLIENT_PID || rc=$?
1087 # active client process should see an EIO for down OST
1088 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1089 # but timing or failover setup may allow success
1090 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1091 echo "writemany returned $rc"
1096 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1101 [ $rc -ne 0 ] && { return $rc; }
1102 # wait for client to reconnect to OST
1106 [ $rc -ne 0 ] && { return $rc; }
1113 run_test 52 "failover OST under load"
1115 # test of open reconstruct
1118 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1121 run_test 53 "touch: drop rep"
1124 zconf_mount `hostname` $MOUNT2
1126 touch $DIR2/$tfile.1
1128 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1131 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1132 [ x"$ERROR" == x ] || error "back in time occured"
1134 run_test 54 "back in time"
1136 # bug 11330 - liblustre application death during I/O locks up OST
1138 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1142 # Minimum pass speed is 2MBps
1144 # LU-2887/LU-3089 - set min pass speed to 500KBps
1145 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1147 # first dd should be finished quickly
1148 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1149 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1152 echo "step1: testing ......"
1153 while kill -0 $DDPID 2> /dev/null; do
1155 if [ $count -gt $ddtimeout ]; then
1156 error "dd should be finished!"
1160 echo "(dd_pid=$DDPID, time=$count)successful"
1162 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1163 #define OBD_FAIL_OST_DROP_REQ 0x21d
1164 do_facet ost1 lctl set_param fail_loc=0x0000021d
1165 # second dd will be never finished
1166 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1169 echo "step2: testing ......"
1170 while [ $count -le $ddtimeout ]; do
1171 if ! kill -0 $DDPID 2> /dev/null; then
1173 error "dd shouldn't be finished! (time=$count)"
1178 echo "(dd_pid=$DDPID, time=$count)successful"
1180 #Recover fail_loc and dd will finish soon
1181 do_facet ost1 lctl set_param fail_loc=0
1183 echo "step3: testing ......"
1184 while kill -0 $DDPID 2> /dev/null; do
1186 if [ $count -gt $((ddtimeout + 440)) ]; then
1187 error "dd should be finished!"
1191 echo "(dd_pid=$DDPID, time=$count)successful"
1195 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1197 test_56() { # b=11277
1198 #define OBD_FAIL_MDS_RESEND 0x136
1200 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1201 stat $DIR/$tfile || error "stat failed"
1202 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1205 run_test 56 "do not fail on getattr resend"
1208 # no oscs means no client or mdt
1209 while lctl get_param osc.*.* > /dev/null 2>&1; do
1210 : # loop until proc file is removed
1214 test_57() { # bug 10866
1218 #define OBD_FAIL_LPROC_REMOVE 0xB00
1219 lctl set_param fail_loc=0x80000B00
1220 zconf_umount `hostname` $DIR
1221 lctl set_param fail_loc=0x80000B00
1222 fail_abort $SINGLEMDS
1224 lctl set_param fail_loc=0
1226 do_facet client "df $DIR"
1228 run_test 57 "read procfs entries causes kernel crash"
1230 test_58() { # bug 11546
1231 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1234 lctl set_param fail_loc=0x80000801
1235 cp $DIR/$tfile /dev/null &
1238 lctl set_param fail_loc=0
1239 drop_bl_callback_once rm -f $DIR/$tfile
1241 # the first 'df' could tigger the eviction caused by
1242 # 'drop_bl_callback_once', and it's normal case.
1243 # but the next 'df' should return successfully.
1244 do_facet client "df $DIR" || do_facet client "df $DIR"
1246 run_test 58 "Eviction in the middle of open RPC reply processing"
1248 test_59() { # bug 10589
1249 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1250 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1251 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1252 lctl set_param fail_loc=0x311
1253 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1254 [ $? = 0 ] || error "dd write failed"
1255 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1256 lctl set_param fail_loc=0
1258 zconf_umount `hostname` $MOUNT2 -f
1259 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1260 [ $? = 0 ] || error "dd read failed"
1261 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1262 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1264 run_test 59 "Read cancel race on client eviction"
1267 # we assume that all md changes are in the MDT0 changelog
1268 if [ $MDSCOUNT -gt 1 ]; then
1269 error_ignore bz17935 $*
1276 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1277 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1282 # Register (and start) changelog
1283 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1284 echo "Registered as $MDT0 changelog user $USER"
1286 # Generate a large number of changelog entries
1287 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1291 # Unlink files in the background
1292 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1296 # Failover the MDS while unlinks are happening
1297 facet_failover $SINGLEMDS
1299 # Wait for unlinkmany to finish
1302 # Check if all the create/unlink events were recorded
1304 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1305 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1306 echo "$cl_count unlinks in $MDT0 changelog"
1308 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1309 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1310 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1311 if [ $USERS -eq 0 ]; then
1312 [ $cl_count -eq $NUM_FILES ] || \
1313 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1314 # Also make sure we can clear large changelogs
1315 cl_count=$($LFS changelog $FSNAME | wc -l)
1316 [ $cl_count -le 2 ] || \
1317 error "Changelog not empty: $cl_count entries"
1319 # If there are other users, there may be other unlinks in the log
1320 [ $cl_count -ge $NUM_FILES ] || \
1321 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1322 echo "$USERS other changelog users; can't verify clear"
1325 run_test 60 "Add Changelog entries during MDS failover"
1329 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1330 mdtosc=${mdtosc/-MDT*/-MDT\*}
1331 local cflags="osc.$mdtosc.connect_flags"
1332 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1333 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1335 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1336 # Set the default stripe of $DIR/$tdir to put the files to ost1
1337 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1339 replay_barrier $SINGLEMDS
1340 createmany -o $DIR/$tdir/$tfile-%d 10
1341 local oid=$(do_facet ost1 "lctl get_param -n \
1342 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1344 fail_abort $SINGLEMDS
1346 touch $DIR/$tdir/$tfile
1347 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1348 awk '$1 == 0 { print $2 }')
1349 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1354 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1356 # test_62 as seen it b2_1 please do not reuse test_62
1359 # zconf_umount `hostname` $DIR
1360 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1361 # lctl set_param fail_loc=0x516
1364 #run_test 62 "Verify connection flags race - bug LU-1716"
1368 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1369 { skip "Need MDS version at least 2.7.51"; return 0; }
1371 local list=$(comma_list $(osts_nodes))
1373 # modify dir so that next revalidate would not obtain UPDATE lock
1376 # drop 1 reply with UPDATE lock
1377 mcreate $DIR/$tfile || error "mcreate failed: $?"
1378 drop_ldlm_reply_once "stat $DIR/$tfile" &
1381 # make the re-sent lock to sleep
1382 #define OBD_FAIL_MDS_RESEND 0x136
1383 do_nodes $list $LCTL set_param fail_loc=0x80000136
1385 #initiate the re-connect & re-send
1386 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1387 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1388 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1391 #initiate the client eviction while enqueue re-send is in progress
1397 run_test 66 "lock enqueue re-send vs client eviction"
1402 #grant lock1, export2
1403 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1404 $MULTIOP $DIR2/$tfile Ow || return 2
1406 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1407 do_facet ost $LCTL set_param fail_loc=0x31e
1408 #get waiting lock2, export1
1409 $MULTIOP $DIR/$tfile Ow &
1411 # let enqueue to get asleep
1415 $MULTIOP $DIR2/$tfile Ow &
1423 do_facet ost $LCTL set_param fail_loc=0
1430 run_test 65 "lock enqueue for destroyed export"
1432 check_cli_ir_state()
1434 local NODE=${1:-$HOSTNAME}
1436 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1437 awk '/imperative_recovery:/ { print \\\$2}'")
1438 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1439 error "Error state $st, must be ENABLED or DISABLED"
1443 check_target_ir_state()
1446 local name=${target}_svc
1447 local recovery_proc=obdfilter.${!name}.recovery_status
1450 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1451 awk '/IR:/{ print \\\$2}'")
1452 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1453 error "Error state $st, must be ENABLED or DISABLED"
1459 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1464 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1465 awk '/state:/{ print \\\$2 }'")
1469 nidtbl_version_mgs()
1471 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1472 awk '/nidtbl_version:/{ print \\\$2 }'")
1476 # nidtbl_version_client <mds1|client> [node]
1477 nidtbl_version_client()
1480 local node=${2:-$HOSTNAME}
1482 if [ X$cli = Xclient ]; then
1485 local obdtype=${cli/%[0-9]*/}
1486 [ $obdtype != mds ] && error "wrong parameters $cli"
1488 node=$(facet_active_host $cli)
1493 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1494 awk "/$cli/{print \$6}" |sort -u)
1496 # in case there are multiple mounts on the client node
1498 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1502 nidtbl_versions_match()
1504 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1507 target_instance_match()
1513 obdtype=${srv/%[0-9]*/}
1524 error "invalid target type" $srv
1529 local target=${srv}_svc
1530 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1531 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1532 awk '/instance/{ print $2 }' | head -n1)
1534 return $([ $si -eq $ci ])
1539 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1540 { skip "MGS without IR support"; return 0; }
1542 # MDT was just restarted in the previous test, make sure everything
1545 while [ $cnt -gt 0 ]; do
1546 nidtbl_versions_match && break
1552 set_ir_status disabled
1554 local prev_ver=$(nidtbl_version_client client)
1556 local saved_FAILURE_MODE=$FAILURE_MODE
1557 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1561 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1562 error "version must not change due to IR disabled"
1563 target_instance_match ost1 || error "instance mismatch"
1567 FAILURE_MODE=$saved_FAILURE_MODE
1569 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1573 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1574 { skip "MGS without IR support"; return 0; }
1578 local OST1_IMP=$(get_osc_import_name client ost1)
1580 # disable pinger recovery
1581 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1585 target_instance_match ost1 || error "instance mismatch"
1586 nidtbl_versions_match || error "version must match"
1588 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1590 run_test 101 "IR: Make sure IR works w/o normal recovery"
1594 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1595 { skip "MGS without IR support"; return 0; }
1597 local clients=${CLIENTS:-$HOSTNAME}
1604 # let's have a new nidtbl version
1607 # sleep for a while so that clients can see the failure of ost
1608 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1609 # int mgc_request.c:
1610 # define MGC_TIMEOUT_MIN_SECONDS 5
1611 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1612 local count=30 # 20 seconds at most
1613 while [ $count -gt 0 ]; do
1614 nidtbl_versions_match && break
1619 nidtbl_versions_match || error "nidtbl mismatch"
1622 old_version=$(nidtbl_version_client client)
1624 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1627 combined_mgs_mds && mgsdev=mds1
1628 remount_facet $mgsdev
1631 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1634 new_version=$(nidtbl_version_client client)
1635 [ $new_version -lt $old_version ] &&
1636 error "nidtbl version wrong after mgs restarts"
1639 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1643 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1644 { skip "MGS without IR support"; return 0; }
1646 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1648 # workaround solution to generate config log on the mds
1654 # We need this test because mds is like a client in IR context.
1655 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1656 error "MDS should start w/o mgs"
1658 # start mgs and remount mds w/ ir
1659 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1662 # remount client so that fsdb will be created on the MGS
1663 umount_client $MOUNT || error "umount failed"
1664 mount_client $MOUNT || error "mount failed"
1666 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1668 while [ $count -gt 0 ]; do
1669 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1674 # after a while, mds should be able to reconnect to mgs and fetch
1675 # up-to-date nidtbl version
1676 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1681 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1685 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1686 { skip "MGS without IR support"; return 0; }
1691 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1692 error "OST1 cannot start"
1695 local ir_state=$(check_target_ir_state ost1)
1696 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1697 error "ir status on ost1 should be DISABLED"
1699 run_test 104 "IR: ost can disable IR voluntarily"
1703 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1704 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1705 { skip "MGS without IR support"; return 0; }
1709 # get one of the clients from client list
1710 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1712 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1713 zconf_umount $rcli $MOUNT || error "umount failed"
1714 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1716 # make sure lustre mount at $rcli disabling IR
1717 local ir_state=$(check_cli_ir_state $rcli)
1718 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1719 error "IR state must be DISABLED at $rcli"
1721 # Since the client just mounted, its last_rcvd entry is not on disk.
1722 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1723 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1724 $SETSTRIPE -i 0 $DIR/$tfile
1725 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1727 # make sure MGS's state is Partial
1728 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1731 # make sure IR on ost1 is DISABLED
1732 local ir_state=$(check_target_ir_state ost1)
1733 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1734 error "IR status on ost1 should be DISABLED"
1736 # remount with the default MOUNT_OPTS
1737 zconf_umount $rcli $MOUNT || error "umount failed"
1738 zconf_mount $rcli $MOUNT || error "mount failed"
1740 # make sure MGS's state is full
1741 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1744 # make sure IR on ost1 is ENABLED
1745 local ir_state=$(check_target_ir_state ost1)
1746 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1747 error "IR status on ost1 should be ENABLED"
1751 run_test 105 "IR: NON IR clients support"
1759 test_106() { # LU-1789
1760 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1761 { skip "Need MDS version at least 2.3.50"; return 0; }
1763 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1764 $LCTL set_param fail_loc=0x805
1767 trap cleanup_106 EXIT
1769 # enable lightweight flag on mdc connection
1772 local MDS_NEXP=$(do_facet $SINGLEMDS \
1773 lctl get_param -n mdt.${mds1_svc}.num_exports |
1775 $LCTL set_param fail_loc=0
1777 touch $DIR2/$tfile || error "failed to create empty file"
1778 replay_barrier $SINGLEMDS
1780 $LCTL set_param debug=console
1782 facet_failover $SINGLEMDS
1784 # lightweight connection must be evicted
1785 touch -c $DIR2/$tfile || true
1786 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1787 evicted=`awk '/This client was evicted by .*MDT0000/ {
1789 }' $TMP/lustre-log-$TESTNAME.log`
1790 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1792 # and all operations performed by lightweight client should be
1793 # synchronous, so the file created before mds restart should be there
1794 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1799 run_test 106 "lightweight connection support"
1806 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1807 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1808 multiop $DIR/$tdir D_c &
1810 mkdir $DIR/$tdir/dir_106 &
1812 do_facet $SINGLEMDS lctl set_param fail_loc=0
1815 wait $CLIENT_PID || rc=$?
1816 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1818 kill -USR1 $close_pid
1819 wait $close_pid || return 2
1823 run_test 107 "drop reint reply, then restart MDT"
1827 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1829 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
1837 client_up || error "reconnect failed"
1838 rm -f $DIR/$tdir/$tfile
1840 run_test 108 "client eviction don't crash"
1843 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1844 local remote_dir=$DIR/$tdir/remote_dir
1848 #prepare for 110 test, which need set striped dir on remote MDT.
1849 for num in $(seq $MDSCOUNT); do
1851 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1856 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1857 error "lfs mkdir failed"
1858 local diridx=$($GETSTRIPE -M $remote_dir)
1859 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1861 rm -rf $DIR/$tdir || error "rmdir failed"
1863 run_test 110a "create remote directory: drop client req"
1866 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1867 local remote_dir=$DIR/$tdir/remote_dir
1871 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1872 error "lfs mkdir failed"
1874 diridx=$($GETSTRIPE -M $remote_dir)
1875 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1877 rm -rf $DIR/$tdir || error "rmdir failed"
1879 run_test 110b "create remote directory: drop Master rep"
1882 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1883 local remote_dir=$DIR/$tdir/remote_dir
1887 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1888 error "lfs mkdir failed"
1890 diridx=$($GETSTRIPE -M $remote_dir)
1891 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1893 rm -rf $DIR/$tdir || error "rmdir failed"
1895 run_test 110c "create remote directory: drop update rep on slave MDT"
1898 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1899 local remote_dir=$DIR/$tdir/remote_dir
1903 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1905 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1907 rm -rf $DIR/$tdir || error "rmdir failed"
1911 run_test 110d "remove remote directory: drop client req"
1914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1915 local remote_dir=$DIR/$tdir/remote_dir
1919 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1920 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1922 rm -rf $DIR/$tdir || error "rmdir failed"
1926 run_test 110e "remove remote directory: drop master rep"
1929 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1930 local remote_dir=$DIR/$tdir/remote_dir
1934 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1935 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1936 error "rm remote dir failed"
1938 rm -rf $DIR/$tdir || error "rmdir failed"
1940 run_test 110f "remove remote directory: drop slave rep"
1943 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1944 local remote_dir=$DIR/$tdir/remote_dir
1947 mkdir -p $remote_dir
1949 createmany -o $remote_dir/f 100
1951 #define OBD_FAIL_MIGRATE_NET_REP 0x1702
1952 do_facet mds$MDTIDX lctl set_param fail_loc=0x1702
1953 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
1954 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
1956 for file in $(find $remote_dir); do
1957 mdt_index=$($LFS getstripe -M $file)
1958 [ $mdt_index == $MDTIDX ] ||
1959 error "$file is not on MDT${MDTIDX}"
1962 rm -rf $DIR/$tdir || error "rmdir failed"
1964 run_test 110g "drop reply during migration"
1967 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1968 local src_dir=$DIR/$tdir/source_dir
1969 local tgt_dir=$DIR/$tdir/target_dir
1973 $LFS mkdir -i $MDTIDX $tgt_dir
1975 dd if=/etc/hosts of=$src_dir/src_file
1976 touch $tgt_dir/tgt_file
1977 drop_update_reply $MDTIDX \
1978 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
1979 error "mrename failed"
1981 $CHECKSTAT -t file $src_dir/src_file &&
1982 error "src_file present after rename"
1984 diff /etc/hosts $tgt_dir/tgt_file ||
1985 error "file changed after rename"
1988 run_test 110h "drop update reply during cross-MDT file rename"
1991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1992 local src_dir=$DIR/$tdir/source_dir
1993 local tgt_dir=$DIR/$tdir/target_dir
1997 $LFS mkdir -i $MDTIDX $tgt_dir
1999 mkdir $src_dir/src_dir
2000 touch $src_dir/src_dir/a
2001 mkdir $tgt_dir/tgt_dir
2002 drop_update_reply $MDTIDX \
2003 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2004 error "mrename failed"
2006 $CHECKSTAT -t dir $src_dir/src_dir &&
2007 error "src_dir present after rename"
2009 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2010 error "tgt_dir not present after rename"
2012 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2013 error "a not present after rename"
2015 run_test 110i "drop update reply during cross-MDT dir rename"
2018 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2019 local remote_dir=$DIR/$tdir/remote_dir
2020 local local_dir=$DIR/$tdir/local_dir
2024 mkdir $DIR/$tdir/local_dir
2025 $LFS mkdir -i $MDTIDX $remote_dir
2027 touch $local_dir/local_file
2028 drop_update_reply $MDTIDX \
2029 "ln $local_dir/local_file $remote_dir/remote_file" ||
2032 $CHECKSTAT -t file $remote_dir/remote_file ||
2033 error "remote not present after ln"
2035 run_test 110j "drop update reply during cross-MDT ln"
2037 # LU-2844 mdt prepare fail should not cause umount oops
2040 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2041 { skip "Need MDS version at least 2.3.62"; return 0; }
2043 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2044 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2045 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2046 stop $SINGLEMDS || error "stop MDS failed"
2047 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0
2049 start $SINGLEMDS $mdsdev || error "start MDS failed"
2051 run_test 111 "mdd setup fail should not cause umount oops"
2055 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2057 do_facet_random_file client $TMP/$tfile 100K ||
2058 error_noexit "Create random file $TMP/$tfile"
2060 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2061 error_noexit "Can't pause_bulk copy"
2064 # expect cmp to succeed, client resent bulk
2065 cmp $TMP/$tfile $DIR/$tfile ||
2066 error_noexit "Wrong data has been written"
2068 error_noexit "Can't remove file"
2071 run_test 112a "bulk resend while orignal request is in progress"
2073 # parameters: fail_loc CMD RC
2080 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2081 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2082 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2083 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2086 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2087 [ "$1" = "CLEANUP" ] &&
2088 fail=0x80000320 && echo ", $1 cp first"
2089 [ "$1" = "REPLY" ] &&
2090 fail=0x80000321 && echo ", $1 cp first"
2091 [ "$1" = "DEADLOCK CLEANUP" ] &&
2092 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2093 [ "$1" = "DEADLOCK REPLY" ] &&
2094 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2096 if [ x"$2" = x"get" ]; then
2097 #for TEST lock, take a conflict in advance
2098 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2099 echo "** Taking conflict **"
2100 flocks_test 5 set read sleep 10 $DIR/$tfile &
2106 $LCTL set_param fail_loc=$fail
2108 flocks_test 5 $2 write $DIR/$tfile &
2112 echo "** Evicting and re-connecting client **"
2117 if [ x"$2" = x"get" ]; then
2124 # check if the return value is allowed
2125 [ $rc -eq $3 ] && rc=0
2127 $LCTL set_param fail_loc=0
2131 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2132 # the ORIGINAL lock.
2137 flocks_test 5 set write sleep 4 $DIR/$tfile &
2141 # let unlock to sleep in CP CB
2142 $LCTL set_param fail_loc=$1
2145 # let cleanup to cleep in CP CB
2153 $LCTL set_param fail_loc=0
2158 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2161 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2162 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2163 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2165 test_120_reply "REPLY" set 5 || error "SET race failed"
2166 test_120_reply "REPLY" get 5 || error "GET race failed"
2167 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2170 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2171 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2173 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2175 run_test 120 "flock race: completion vs. evict"
2178 local BEFORE=$(date +%s)
2181 # modify dir so that next revalidate would not obtain UPDATE lock
2184 # drop 1 reply with UPDATE lock,
2185 # resend should not create 2nd lock on server
2186 mcreate $DIR/$tfile || error "mcreate failed: $?"
2187 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2189 # 2 BL AST will be sent to client, both must find the same lock,
2190 # race them to not get EINVAL for 2nd BL AST
2191 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2192 $LCTL set_param fail_loc=0x8000031f
2194 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2195 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2196 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2198 # let the client reconnect
2200 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2201 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2203 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2205 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2208 check_and_cleanup_lustre