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)
209 workdir="${DIR}/${tdir}"
210 mkdir -p ${workdir} || error "can't create workdir $?"
211 stat ${workdir} > /dev/null ||
212 error "failed to stat ${workdir}: $?"
213 mdtidx=$($LFS getdirstripe -i ${workdir})
214 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
215 awk '{sub("_UUID", "", $2); print $2;}')
217 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
218 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
219 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
221 drop_bl_callback_once "chmod 0777 ${workdir}" &
226 # force client reconnect
227 $LCTL set_param "${mdcpath}"
229 # wait client reconnect
233 evict=$($LCTL get_param mdc.${mdccli}.state |
234 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
236 [[ $evict -le $before ]] ||
237 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
238 error "eviction happened: $EVICT before:$BEFORE" )
240 [ $rc -eq 0 ] || error "chmod must finished OK"
241 checkstat -v -p 0777 "${workdir}" ||
242 error "client checkstat failed: $?"
244 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
247 local before=$(date +%s)
250 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
251 skip "Need MDS version at least 2.6.90" && return
253 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
256 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
261 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
262 echo -n hello > $DIR1/$tfile
264 stat $DIR2/$tfile >& /dev/null
265 $LCTL set_param fail_err=71
266 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
270 cmp $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
271 cmp $DIR1/$tfile $TMP/$tfile || error "wrong content found"
273 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
275 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
277 [[ $evict -gt $before ]] ||
278 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
279 error "no eviction: $evict before:$before")
281 $LCTL set_param fail_err=0
283 umount_client $MOUNT2
285 run_test 10d "test failed blocking ast"
288 # wake up a thread waiting for completion after eviction
290 do_facet client $MULTIOP $DIR/$tfile Ow ||
291 { error "multiop write failed: $?"; return 1; }
292 do_facet client $MULTIOP $DIR/$tfile or ||
293 { error "multiop read failed: $?"; return 2; }
297 do_facet client $MULTIOP $DIR/$tfile or ||
298 { error "multiop read failed: $?"; return 3; }
299 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
300 echo "evicted as expected"
302 do_facet client munlink $DIR/$tfile ||
303 { error "munlink failed: $?"; return 4; }
304 # allow recovery to complete
305 client_up || client_up || sleep $TIMEOUT
307 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
311 $LCTL mark $MULTIOP $DIR/$tfile OS_c
312 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
313 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
314 multiop_bg_pause $DIR/$tfile OS_c ||
315 { error "multiop failed: $?"; return 1; }
317 #define OBD_FAIL_MDS_CLOSE_NET 0x115
319 echo "waiting for multiop $PID"
320 wait $PID || { error "wait for multiop faile: $?"; return 2; }
321 do_facet client munlink $DIR/$tfile ||
322 { error "client munlink failed: $?"; return 3; }
323 # allow recovery to complete
324 client_up || client_up || sleep $TIMEOUT
326 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
328 # Bug 113, check that readdir lost recv timeout works.
330 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
331 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
332 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
333 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
334 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
335 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
336 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
338 run_test 13 "mdc_readpage restart test (bug 1138)"
340 # Bug 113, check that readdir lost send timeout works.
343 touch $DIR/$tdir/newentry
344 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
345 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
346 ls $DIR/$tdir || return 1
347 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
349 run_test 14 "mdc_readpage resend test (bug 1138)"
352 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
353 touch $DIR/$tfile && return 1
356 run_test 15 "failed open (-ENOMEM)"
358 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
360 lctl set_param -n llite.*.max_read_ahead_mb 0
364 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
368 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
370 do_facet_random_file client $TMP/$tfile 100K ||
371 { error_noexit "Create random file $TMP/$T" ; return 0; }
372 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
373 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
377 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
378 do_facet ost1 "lctl set_param fail_loc=0x80000504"
380 # OST bulk will time out here, client resends
381 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
382 do_facet ost1 lctl set_param fail_loc=0
383 # give recovery a chance to finish (shouldn't take long)
385 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
389 run_test 16 "timeout bulk put, don't evict client (2732)"
394 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
396 local SAMPLE_FILE=$TMP/$tfile
397 do_facet_random_file client $SAMPLE_FILE 20K ||
398 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
400 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
401 if at_is_enabled; then
402 at_max_saved=$(at_max_get ost1)
403 at_max_set $TIMEOUT ost1
406 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
407 # OST bulk will time out here, client retries
408 do_facet ost1 lctl set_param fail_loc=0x80000503
409 # need to ensure we send an RPC
410 do_facet client cp $SAMPLE_FILE $DIR/$tfile
413 # with AT, client will wait adaptive_max*factor+net_latency before
414 # expiring the req, hopefully timeout*2 is enough
415 sleep $(($TIMEOUT*2))
417 do_facet ost1 lctl set_param fail_loc=0
418 do_facet client "df $DIR"
419 # expect cmp to succeed, client resent bulk
420 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
421 do_facet client "rm $DIR/$tfile" || return 4
422 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
425 run_test 17 "timeout bulk get, don't evict client (2732)"
428 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
430 do_facet_create_file client $TMP/$tfile 20K ||
431 { error_noexit "Create file $TMP/$tfile" ; return 0; }
433 do_facet client mkdir -p $DIR/$tdir
437 pgcache_empty || return 1
440 $LFS setstripe -i 1 -c 1 $f
441 stripe_index=$($LFS getstripe -i $f)
442 if [ $stripe_index -ne 1 ]; then
444 error "$f: stripe_index $stripe_index != 1" && return
447 do_facet client cp $TMP/$tfile $f
449 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
450 $LCTL --device $osc2dev deactivate || return 3
451 # my understanding is that there should be nothing in the page
452 # cache after the client reconnects?
454 pgcache_empty || rc=2
455 $LCTL --device $osc2dev activate
459 run_test 18a "manual ost invalidate clears page cache immediately"
462 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
464 do_facet_create_file client $TMP/$tfile 20K ||
465 { error_noexit "Create file $TMP/$tfile" ; return 0; }
467 do_facet client mkdir -p $DIR/$tdir
471 pgcache_empty || return 1
473 $LFS setstripe -i 0 -c 1 $f
474 stripe_index=$($LFS getstripe -i $f)
475 if [ $stripe_index -ne 0 ]; then
477 error "$f: stripe_index $stripe_index != 0" && return
480 do_facet client cp $TMP/$tfile $f
483 # allow recovery to complete
484 sleep $((TIMEOUT + 2))
485 # my understanding is that there should be nothing in the page
486 # cache after the client reconnects?
488 pgcache_empty || rc=2
492 run_test 18b "eviction and reconnect clears page cache (2766)"
495 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
497 do_facet_create_file client $TMP/$tfile 20K ||
498 { error_noexit "Create file $TMP/$tfile" ; return 0; }
500 do_facet client mkdir -p $DIR/$tdir
504 pgcache_empty || return 1
506 $LFS setstripe -i 0 -c 1 $f
507 stripe_index=$($LFS getstripe -i $f)
508 if [ $stripe_index -ne 0 ]; then
510 error "$f: stripe_index $stripe_index != 0" && return
513 do_facet client cp $TMP/$tfile $f
517 # OBD_FAIL_OST_CONNECT_NET2
518 # lost reply to connect request
519 do_facet ost1 lctl set_param fail_loc=0x80000225
522 df $MOUNT > /dev/null 2>&1
524 # my understanding is that there should be nothing in the page
525 # cache after the client reconnects?
527 pgcache_empty || rc=2
531 run_test 18c "Dropped connect reply after eviction handing (14755)"
534 local BEFORE=`date +%s`
537 mount_client $DIR2 || error "failed to mount $DIR2"
539 # cancel cached locks from OST to avoid eviction from it
542 do_facet client "stat $DIR > /dev/null" ||
543 error "failed to stat $DIR: $?"
544 drop_ldlm_cancel "chmod 0777 $DIR2" ||
545 error "failed to chmod $DIR2"
549 # let the client reconnect
551 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
552 awk -F"[ [,]" '/EVICTED ]$/ \
553 { if (mx<$5) {mx=$5;} } END { print mx }')
555 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
556 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
557 error "no eviction: $EVICT before:$BEFORE")
559 run_test 19a "test expired_lock_main on mds (2867)"
562 local BEFORE=`date +%s`
565 mount_client $DIR2 || error "failed to mount $DIR2: $?"
567 # cancel cached locks from MDT to avoid eviction from it
570 do_facet client $MULTIOP $DIR/$tfile Ow ||
571 error "failed to run multiop: $?"
572 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
573 error "failed to ldlm_cancel: $?"
575 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
576 do_facet client munlink $DIR/$tfile ||
577 error "failed to unlink $DIR/$tfile: $?"
579 # let the client reconnect
581 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
582 awk -F"[ [,]" '/EVICTED ]$/ \
583 { if (mx < $5) {mx = $5;} } END { print mx }')
585 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
586 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
587 error "no eviction: $EVICT before:$BEFORE")
589 run_test 19b "test expired_lock_main on ost (2867)"
592 local BEFORE=`date +%s`
595 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
597 mkdir -p $DIR1/$tfile
600 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
601 do_facet mds $LCTL set_param fail_loc=0x80000516
603 touch $DIR2/$tfile/file1 &
605 # let touch to get blocked on the server
609 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
612 # let the client reconnect
614 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
615 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
617 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
619 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
621 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
622 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
625 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
626 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
629 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
630 do_facet ost1 lctl set_param fail_loc=0x80000308
631 kill -USR1 $MULTI_PID
634 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
636 run_test 20a "ldlm_handle_enqueue error (should return error)"
638 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
639 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
642 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
644 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
645 do_facet ost1 lctl set_param fail_loc=0x80000308
646 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
647 error "didn't fail open enqueue" || true
649 run_test 20b "ldlm_handle_enqueue error (should return error)"
652 mkdir -p $DIR/$tdir-1
653 mkdir -p $DIR/$tdir-2
654 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
657 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
658 $MULTIOP $DIR/$tdir-2/f Oc &
661 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
663 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
664 kill -USR1 $close_pid
666 wait $close_pid || return 1
667 wait $open_pid || return 2
668 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
670 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
671 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
675 run_test 21a "drop close request while close and open are both in flight"
678 mkdir -p $DIR/$tdir-1
679 mkdir -p $DIR/$tdir-2
680 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
683 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
684 mcreate $DIR/$tdir-2/f &
687 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
689 kill -USR1 $close_pid
691 wait $close_pid || return 1
692 wait $open_pid || return 3
694 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
695 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
698 run_test 21b "drop open request while close and open are both in flight"
701 mkdir -p $DIR/$tdir-1
702 mkdir -p $DIR/$tdir-2
703 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
706 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
707 mcreate $DIR/$tdir-2/f &
710 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
712 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
713 kill -USR1 $close_pid
715 wait $close_pid || return 1
716 wait $open_pid || return 2
718 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
720 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
721 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
724 run_test 21c "drop both request while close and open are both in flight"
727 mkdir -p $DIR/$tdir-1
728 mkdir -p $DIR/$tdir-2
729 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
732 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
733 $MULTIOP $DIR/$tdir-2/f Oc &
735 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
737 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
740 wait $pid || return 1
741 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
743 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
744 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
748 run_test 21d "drop close reply while close and open are both in flight"
751 mkdir -p $DIR/$tdir-1
752 mkdir -p $DIR/$tdir-2
753 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
756 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
757 touch $DIR/$tdir-2/f &
759 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
763 wait $pid || return 1
766 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
767 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
770 run_test 21e "drop open reply while close and open are both in flight"
773 mkdir -p $DIR/$tdir-1
774 mkdir -p $DIR/$tdir-2
775 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
778 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
779 touch $DIR/$tdir-2/f &
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
783 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
786 wait $pid || return 1
787 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
789 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
790 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
793 run_test 21f "drop both reply while close and open are both in flight"
796 mkdir -p $DIR/$tdir-1
797 mkdir -p $DIR/$tdir-2
798 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
801 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
802 touch $DIR/$tdir-2/f &
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
806 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
809 wait $pid || return 1
810 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
812 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
813 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
816 run_test 21g "drop open reply and close request while close and open are both in flight"
819 mkdir -p $DIR/$tdir-1
820 mkdir -p $DIR/$tdir-2
821 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
824 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
825 touch $DIR/$tdir-2/f &
828 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
830 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
833 wait $pid || return 1
834 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
836 wait $touch_pid || return 2
838 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
839 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
842 run_test 21h "drop open request and close reply while close and open are both in flight"
844 # bug 3462 - multiple MDC requests
849 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
854 $MULTIOP $f1 msu || return 1
857 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
859 wait $close_pid || return 2
860 rm -rf $f2 || return 4
862 run_test 22 "drop close request and do mknod"
865 multiop_bg_pause $DIR/$tfile O_c || return 1
867 # give a chance for open
871 drop_request "kill -USR1 $pid"
874 wait $pid || return 1
877 run_test 23 "client hang when close a file after mds crash"
879 test_24a() { # bug 11710 details correct fsync() behavior
880 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
883 $LFS setstripe -i 0 -c 1 $DIR/$tdir
885 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
888 kill -USR1 $MULTI_PID
891 lctl set_param fail_loc=0x0
894 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
896 run_test 24a "fsync error (should return error)"
898 wait_client_evicted () {
901 local varsvc=${facet}_svc
903 wait_update $(facet_active_host $facet) \
904 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
909 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
913 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
915 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
916 error "mulitop Ow8192_yc failed"
919 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
920 error "mulitop Ow8192_c failed"
925 kill -USR1 $MULTI_PID1
928 kill -USR1 $MULTI_PID2
931 lctl set_param fail_loc=0x0
933 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
934 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
937 dmesg | grep "dirty page discard:" ||
938 error "no discarded dirty page found!"
940 run_test 24b "test dirty page discard due to client eviction"
942 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
943 # this test can only run from a client on a separate node.
944 remote_ost || { skip "local OST" && return 0; }
945 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
946 remote_mds || { skip "local MDS" && return 0; }
948 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
949 skip "msg and ost1 are at the same node"
953 check_timeout || return 1
955 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
957 echo starting with $OST_NEXP OST exports
958 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
959 do_facet client lctl set_param fail_loc=0x505
960 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
961 # But if there's a race to start the evictor from various obds,
962 # the loser might have to wait for the next ping.
965 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
967 do_facet client lctl set_param fail_loc=0x0
968 [ $rc -eq 0 ] || error "client not evicted from OST"
970 run_test 26a "evict dead exports"
972 test_26b() { # bug 10140 - evict dead exports by pinger
973 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
975 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
976 skip "msg and ost1 are at the same node"
980 check_timeout || return 1
982 zconf_mount `hostname` $MOUNT2 ||
983 { error "Failed to mount $MOUNT2"; return 2; }
984 sleep 1 # wait connections being established
986 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
987 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
989 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
991 zconf_umount `hostname` $MOUNT2 -f
993 # PING_INTERVAL max(obd_timeout / 4, 1U)
994 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
996 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
997 # But if there's a race to start the evictor from various obds,
998 # the loser might have to wait for the next ping.
999 # = 9 * PING_INTERVAL + PING_INTERVAL
1000 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1001 # let's wait $((TIMEOUT * 3)) # bug 19887
1003 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1004 error "Client was not evicted by ost" rc=1
1005 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1006 error "Client was not evicted by mds"
1008 run_test 26b "evict dead exports"
1012 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1015 local save_FAILURE_MODE=$FAILURE_MODE
1017 facet_failover $SINGLEMDS
1018 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1019 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1020 # need to wait for reconnect
1021 echo waiting for fail_loc
1022 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1023 facet_failover $SINGLEMDS
1024 #no crashes allowed!
1025 kill -USR1 $CLIENT_PID
1028 FAILURE_MODE=$save_FAILURE_MODE
1030 run_test 27 "fail LOV while using OSC's"
1032 test_28() { # bug 6086 - error adding new clients
1033 do_facet client mcreate $DIR/$tfile || return 1
1034 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1035 echo "evicted as expected"
1036 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1037 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1038 # fail once (evicted), reconnect fail (fail_loc), ok
1039 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1041 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1043 run_test 28 "handle error adding new clients (bug 6086)"
1045 test_29a() { # bug 22273 - error adding new clients
1046 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1047 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1048 # fail abort so client will be new again
1049 fail_abort $SINGLEMDS
1050 client_up || error "reconnect failed"
1051 wait_osc_import_state $SINGLEMDS ost FULL
1054 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1056 test_29b() { # bug 22273 - error adding new clients
1057 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1058 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1059 # fail abort so client will be new again
1061 client_up || error "reconnect failed"
1064 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1068 # put a load of file creates/writes/deletes
1069 writemany -q $DIR/$tdir/$tfile 0 5 &
1071 echo writemany pid $CLIENT_PID
1075 # wait for client to reconnect to MDS
1080 # client process should see no problems even though MDS went down
1082 kill -USR1 $CLIENT_PID
1085 echo writemany returned $rc
1086 #these may fail because of eviction due to slow AST response.
1088 error_ignore bz13652 "writemany returned rc $rc" || true
1090 run_test 50 "failover MDS under load"
1093 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1094 do_facet ost1 lctl set_param fail_loc=0x00001310
1097 # put a load of file creates/writes/deletes
1098 writemany -q $DIR/$tdir/$tfile 0 5 &
1102 facet_failover $SINGLEMDS
1103 # failover at various points during recovery
1104 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1105 echo will failover at $SEQ
1108 #echo failover in $i sec
1109 log "test_$testnum: failover in $i sec"
1111 facet_failover $SINGLEMDS
1113 # client process should see no problems even though MDS went down
1114 # and recovery was interrupted
1116 kill -USR1 $CLIENT_PID
1119 echo writemany returned $rc
1121 error_ignore bz13652 "writemany returned rc $rc" || true
1123 run_test 51 "failover MDS during recovery"
1126 do_facet client "mkdir -p $DIR/$tdir"
1127 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1129 echo writemany pid $CLIENT_PID
1134 wait $CLIENT_PID || rc=$?
1135 # active client process should see an EIO for down OST
1136 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1137 # but timing or failover setup may allow success
1138 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1139 echo "writemany returned $rc"
1144 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1149 [ $rc -ne 0 ] && { return $rc; }
1150 # wait for client to reconnect to OST
1154 [ $rc -ne 0 ] && { return $rc; }
1161 run_test 52 "failover OST under load"
1163 # test of open reconstruct
1166 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1169 run_test 53 "touch: drop rep"
1172 zconf_mount `hostname` $MOUNT2
1174 touch $DIR2/$tfile.1
1176 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1179 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1180 [ x"$ERROR" == x ] || error "back in time occured"
1182 run_test 54 "back in time"
1184 # bug 11330 - liblustre application death during I/O locks up OST
1186 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1190 # Minimum pass speed is 2MBps
1192 # LU-2887/LU-3089 - set min pass speed to 500KBps
1193 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1195 # first dd should be finished quickly
1196 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1197 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1200 echo "step1: testing ......"
1201 while kill -0 $DDPID 2> /dev/null; do
1203 if [ $count -gt $ddtimeout ]; then
1204 error "dd should be finished!"
1208 echo "(dd_pid=$DDPID, time=$count)successful"
1210 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1211 #define OBD_FAIL_OST_DROP_REQ 0x21d
1212 do_facet ost1 lctl set_param fail_loc=0x0000021d
1213 # second dd will be never finished
1214 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1217 echo "step2: testing ......"
1218 while [ $count -le $ddtimeout ]; do
1219 if ! kill -0 $DDPID 2> /dev/null; then
1221 error "dd shouldn't be finished! (time=$count)"
1226 echo "(dd_pid=$DDPID, time=$count)successful"
1228 #Recover fail_loc and dd will finish soon
1229 do_facet ost1 lctl set_param fail_loc=0
1231 echo "step3: testing ......"
1232 while kill -0 $DDPID 2> /dev/null; do
1234 if [ $count -gt $((ddtimeout + 440)) ]; then
1235 error "dd should be finished!"
1239 echo "(dd_pid=$DDPID, time=$count)successful"
1243 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1245 test_56() { # b=11277
1246 #define OBD_FAIL_MDS_RESEND 0x136
1248 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1249 stat $DIR/$tfile || error "stat failed"
1250 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1253 run_test 56 "do not fail on getattr resend"
1256 # no oscs means no client or mdt
1257 while lctl get_param osc.*.* > /dev/null 2>&1; do
1258 : # loop until proc file is removed
1262 test_57() { # bug 10866
1266 #define OBD_FAIL_LPROC_REMOVE 0xB00
1267 lctl set_param fail_loc=0x80000B00
1268 zconf_umount `hostname` $DIR
1269 lctl set_param fail_loc=0x80000B00
1270 fail_abort $SINGLEMDS
1272 lctl set_param fail_loc=0
1274 do_facet client "df $DIR"
1276 run_test 57 "read procfs entries causes kernel crash"
1278 test_58() { # bug 11546
1279 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1282 lctl set_param fail_loc=0x80000801
1283 cp $DIR/$tfile /dev/null &
1286 lctl set_param fail_loc=0
1287 drop_bl_callback_once rm -f $DIR/$tfile
1289 # the first 'df' could tigger the eviction caused by
1290 # 'drop_bl_callback_once', and it's normal case.
1291 # but the next 'df' should return successfully.
1292 do_facet client "df $DIR" || do_facet client "df $DIR"
1294 run_test 58 "Eviction in the middle of open RPC reply processing"
1296 test_59() { # bug 10589
1297 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1298 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1299 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1300 lctl set_param fail_loc=0x311
1301 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1302 [ $? = 0 ] || error "dd write failed"
1303 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1304 lctl set_param fail_loc=0
1306 zconf_umount `hostname` $MOUNT2 -f
1307 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1308 [ $? = 0 ] || error "dd read failed"
1309 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1310 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1312 run_test 59 "Read cancel race on client eviction"
1315 # we assume that all md changes are in the MDT0 changelog
1316 if [ $MDSCOUNT -gt 1 ]; then
1317 error_ignore bz17935 $*
1324 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1325 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1330 # Register (and start) changelog
1331 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1332 echo "Registered as $MDT0 changelog user $USER"
1334 # Generate a large number of changelog entries
1335 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1339 # Unlink files in the background
1340 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1344 # Failover the MDS while unlinks are happening
1345 facet_failover $SINGLEMDS
1347 # Wait for unlinkmany to finish
1350 # Check if all the create/unlink events were recorded
1352 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1353 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1354 echo "$cl_count unlinks in $MDT0 changelog"
1356 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1357 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1358 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1359 if [ $USERS -eq 0 ]; then
1360 [ $cl_count -eq $NUM_FILES ] || \
1361 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1362 # Also make sure we can clear large changelogs
1363 cl_count=$($LFS changelog $FSNAME | wc -l)
1364 [ $cl_count -le 2 ] || \
1365 error "Changelog not empty: $cl_count entries"
1367 # If there are other users, there may be other unlinks in the log
1368 [ $cl_count -ge $NUM_FILES ] || \
1369 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1370 echo "$USERS other changelog users; can't verify clear"
1373 run_test 60 "Add Changelog entries during MDS failover"
1377 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1378 mdtosc=${mdtosc/-MDT*/-MDT\*}
1379 local cflags="osc.$mdtosc.connect_flags"
1380 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1381 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1383 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1384 # Set the default stripe of $DIR/$tdir to put the files to ost1
1385 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1387 replay_barrier $SINGLEMDS
1388 createmany -o $DIR/$tdir/$tfile-%d 10
1389 local oid=$(do_facet ost1 "lctl get_param -n \
1390 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1392 fail_abort $SINGLEMDS
1394 touch $DIR/$tdir/$tfile
1395 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1396 awk '$1 == 0 { print $2 }')
1397 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1402 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1404 # test_62 as seen it b2_1 please do not reuse test_62
1407 # zconf_umount `hostname` $DIR
1408 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1409 # lctl set_param fail_loc=0x516
1412 #run_test 62 "Verify connection flags race - bug LU-1716"
1416 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1417 { skip "Need MDS version at least 2.7.51"; return 0; }
1419 local list=$(comma_list $(osts_nodes))
1421 # modify dir so that next revalidate would not obtain UPDATE lock
1424 # drop 1 reply with UPDATE lock
1425 mcreate $DIR/$tfile || error "mcreate failed: $?"
1426 drop_ldlm_reply_once "stat $DIR/$tfile" &
1429 # make the re-sent lock to sleep
1430 #define OBD_FAIL_MDS_RESEND 0x136
1431 do_nodes $list $LCTL set_param fail_loc=0x80000136
1433 #initiate the re-connect & re-send
1434 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1435 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1436 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1439 #initiate the client eviction while enqueue re-send is in progress
1445 run_test 66 "lock enqueue re-send vs client eviction"
1450 #grant lock1, export2
1451 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1452 $MULTIOP $DIR2/$tfile Ow || return 2
1454 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1455 do_facet ost $LCTL set_param fail_loc=0x31e
1456 #get waiting lock2, export1
1457 $MULTIOP $DIR/$tfile Ow &
1459 # let enqueue to get asleep
1463 $MULTIOP $DIR2/$tfile Ow &
1471 do_facet ost $LCTL set_param fail_loc=0
1478 run_test 65 "lock enqueue for destroyed export"
1480 check_cli_ir_state()
1482 local NODE=${1:-$HOSTNAME}
1484 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1485 awk '/imperative_recovery:/ { print \\\$2}'")
1486 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1487 error "Error state $st, must be ENABLED or DISABLED"
1491 check_target_ir_state()
1494 local name=${target}_svc
1495 local recovery_proc=obdfilter.${!name}.recovery_status
1498 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1499 awk '/IR:/{ print \\\$2}'")
1500 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1501 error "Error state $st, must be ENABLED or DISABLED"
1507 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1512 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1513 awk '/state:/{ print \\\$2 }'")
1517 nidtbl_version_mgs()
1519 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1520 awk '/nidtbl_version:/{ print \\\$2 }'")
1524 # nidtbl_version_client <mds1|client> [node]
1525 nidtbl_version_client()
1528 local node=${2:-$HOSTNAME}
1530 if [ X$cli = Xclient ]; then
1533 local obdtype=${cli/%[0-9]*/}
1534 [ $obdtype != mds ] && error "wrong parameters $cli"
1536 node=$(facet_active_host $cli)
1541 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1542 awk "/$cli/{print \$6}" |sort -u)
1544 # in case there are multiple mounts on the client node
1546 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1550 nidtbl_versions_match()
1552 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1555 target_instance_match()
1561 obdtype=${srv/%[0-9]*/}
1572 error "invalid target type" $srv
1577 local target=${srv}_svc
1578 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1579 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1580 awk '/instance/{ print $2 }' | head -n1)
1582 return $([ $si -eq $ci ])
1587 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1588 { skip "MGS without IR support"; return 0; }
1590 # MDT was just restarted in the previous test, make sure everything
1593 while [ $cnt -gt 0 ]; do
1594 nidtbl_versions_match && break
1600 set_ir_status disabled
1602 local prev_ver=$(nidtbl_version_client client)
1604 local saved_FAILURE_MODE=$FAILURE_MODE
1605 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1609 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1610 error "version must not change due to IR disabled"
1611 target_instance_match ost1 || error "instance mismatch"
1615 FAILURE_MODE=$saved_FAILURE_MODE
1617 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1621 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1622 { skip "MGS without IR support"; return 0; }
1626 local OST1_IMP=$(get_osc_import_name client ost1)
1628 # disable pinger recovery
1629 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1633 target_instance_match ost1 || error "instance mismatch"
1634 nidtbl_versions_match || error "version must match"
1636 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1638 run_test 101 "IR: Make sure IR works w/o normal recovery"
1642 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1643 { skip "MGS without IR support"; return 0; }
1645 local clients=${CLIENTS:-$HOSTNAME}
1652 # let's have a new nidtbl version
1655 # sleep for a while so that clients can see the failure of ost
1656 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1657 # int mgc_request.c:
1658 # define MGC_TIMEOUT_MIN_SECONDS 5
1659 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1660 local count=30 # 20 seconds at most
1661 while [ $count -gt 0 ]; do
1662 nidtbl_versions_match && break
1667 nidtbl_versions_match || error "nidtbl mismatch"
1670 old_version=$(nidtbl_version_client client)
1672 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1675 combined_mgs_mds && mgsdev=mds1
1676 remount_facet $mgsdev
1679 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1682 new_version=$(nidtbl_version_client client)
1683 [ $new_version -lt $old_version ] &&
1684 error "nidtbl version wrong after mgs restarts"
1687 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1691 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1692 { skip "MGS without IR support"; return 0; }
1694 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1696 # workaround solution to generate config log on the mds
1702 # We need this test because mds is like a client in IR context.
1703 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1704 error "MDS should start w/o mgs"
1706 # start mgs and remount mds w/ ir
1707 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1710 # remount client so that fsdb will be created on the MGS
1711 umount_client $MOUNT || error "umount failed"
1712 mount_client $MOUNT || error "mount failed"
1714 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1716 while [ $count -gt 0 ]; do
1717 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1722 # after a while, mds should be able to reconnect to mgs and fetch
1723 # up-to-date nidtbl version
1724 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1729 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1733 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1734 { skip "MGS without IR support"; return 0; }
1739 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1740 error "OST1 cannot start"
1743 local ir_state=$(check_target_ir_state ost1)
1744 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1745 error "ir status on ost1 should be DISABLED"
1747 run_test 104 "IR: ost can disable IR voluntarily"
1751 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1752 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1753 { skip "MGS without IR support"; return 0; }
1757 # get one of the clients from client list
1758 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1760 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1761 zconf_umount $rcli $MOUNT || error "umount failed"
1762 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1764 # make sure lustre mount at $rcli disabling IR
1765 local ir_state=$(check_cli_ir_state $rcli)
1766 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1767 error "IR state must be DISABLED at $rcli"
1769 # Since the client just mounted, its last_rcvd entry is not on disk.
1770 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1771 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1772 $SETSTRIPE -i 0 $DIR/$tfile
1773 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1775 # make sure MGS's state is Partial
1776 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1779 # make sure IR on ost1 is DISABLED
1780 local ir_state=$(check_target_ir_state ost1)
1781 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1782 error "IR status on ost1 should be DISABLED"
1784 # remount with the default MOUNT_OPTS
1785 zconf_umount $rcli $MOUNT || error "umount failed"
1786 zconf_mount $rcli $MOUNT || error "mount failed"
1788 # make sure MGS's state is full
1789 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1792 # make sure IR on ost1 is ENABLED
1793 local ir_state=$(check_target_ir_state ost1)
1794 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1795 error "IR status on ost1 should be ENABLED"
1799 run_test 105 "IR: NON IR clients support"
1807 test_106() { # LU-1789
1808 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1809 { skip "Need MDS version at least 2.3.50"; return 0; }
1811 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1812 $LCTL set_param fail_loc=0x805
1815 trap cleanup_106 EXIT
1817 # enable lightweight flag on mdc connection
1820 local MDS_NEXP=$(do_facet $SINGLEMDS \
1821 lctl get_param -n mdt.${mds1_svc}.num_exports |
1823 $LCTL set_param fail_loc=0
1825 touch $DIR2/$tfile || error "failed to create empty file"
1826 replay_barrier $SINGLEMDS
1828 $LCTL set_param debug=console
1830 facet_failover $SINGLEMDS
1832 # lightweight connection must be evicted
1833 touch -c $DIR2/$tfile || true
1834 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1835 evicted=`awk '/This client was evicted by .*MDT0000/ {
1837 }' $TMP/lustre-log-$TESTNAME.log`
1838 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1840 # and all operations performed by lightweight client should be
1841 # synchronous, so the file created before mds restart should be there
1842 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1847 run_test 106 "lightweight connection support"
1854 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1855 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1856 multiop $DIR/$tdir D_c &
1858 mkdir $DIR/$tdir/dir_106 &
1860 do_facet $SINGLEMDS lctl set_param fail_loc=0
1863 wait $CLIENT_PID || rc=$?
1864 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1866 kill -USR1 $close_pid
1867 wait $close_pid || return 2
1871 run_test 107 "drop reint reply, then restart MDT"
1875 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1877 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
1885 client_up || error "reconnect failed"
1886 rm -f $DIR/$tdir/$tfile
1888 run_test 108 "client eviction don't crash"
1891 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1892 local remote_dir=$DIR/$tdir/remote_dir
1896 #prepare for 110 test, which need set striped dir on remote MDT.
1897 for num in $(seq $MDSCOUNT); do
1899 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1904 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1905 error "lfs mkdir failed"
1906 local diridx=$($GETSTRIPE -M $remote_dir)
1907 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1909 rm -rf $DIR/$tdir || error "rmdir failed"
1911 run_test 110a "create remote directory: drop client req"
1914 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1915 local remote_dir=$DIR/$tdir/remote_dir
1919 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1920 error "lfs mkdir failed"
1922 diridx=$($GETSTRIPE -M $remote_dir)
1923 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1925 rm -rf $DIR/$tdir || error "rmdir failed"
1927 run_test 110b "create remote directory: drop Master rep"
1930 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1931 local remote_dir=$DIR/$tdir/remote_dir
1935 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1936 error "lfs mkdir failed"
1938 diridx=$($GETSTRIPE -M $remote_dir)
1939 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1941 rm -rf $DIR/$tdir || error "rmdir failed"
1943 run_test 110c "create remote directory: drop update rep on slave MDT"
1946 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1947 local remote_dir=$DIR/$tdir/remote_dir
1951 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1953 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1955 rm -rf $DIR/$tdir || error "rmdir failed"
1959 run_test 110d "remove remote directory: drop client req"
1962 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1963 local remote_dir=$DIR/$tdir/remote_dir
1967 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1968 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1970 rm -rf $DIR/$tdir || error "rmdir failed"
1974 run_test 110e "remove remote directory: drop master rep"
1977 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1978 local remote_dir=$DIR/$tdir/remote_dir
1982 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1983 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1984 error "rm remote dir failed"
1986 rm -rf $DIR/$tdir || error "rmdir failed"
1988 run_test 110f "remove remote directory: drop slave rep"
1991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1992 local remote_dir=$DIR/$tdir/remote_dir
1995 mkdir -p $remote_dir
1997 createmany -o $remote_dir/f 100
1999 #define OBD_FAIL_MIGRATE_NET_REP 0x1800
2000 do_facet mds$MDTIDX lctl set_param fail_loc=0x1800
2001 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
2002 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
2004 for file in $(find $remote_dir); do
2005 mdt_index=$($LFS getstripe -M $file)
2006 [ $mdt_index == $MDTIDX ] ||
2007 error "$file is not on MDT${MDTIDX}"
2010 rm -rf $DIR/$tdir || error "rmdir failed"
2012 run_test 110g "drop reply during migration"
2015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2016 local src_dir=$DIR/$tdir/source_dir
2017 local tgt_dir=$DIR/$tdir/target_dir
2021 $LFS mkdir -i $MDTIDX $tgt_dir
2023 dd if=/etc/hosts of=$src_dir/src_file
2024 touch $tgt_dir/tgt_file
2025 drop_update_reply $MDTIDX \
2026 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2027 error "mrename failed"
2029 $CHECKSTAT -t file $src_dir/src_file &&
2030 error "src_file present after rename"
2032 diff /etc/hosts $tgt_dir/tgt_file ||
2033 error "file changed after rename"
2036 run_test 110h "drop update reply during cross-MDT file rename"
2039 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2040 local src_dir=$DIR/$tdir/source_dir
2041 local tgt_dir=$DIR/$tdir/target_dir
2045 $LFS mkdir -i $MDTIDX $tgt_dir
2047 mkdir $src_dir/src_dir
2048 touch $src_dir/src_dir/a
2049 mkdir $tgt_dir/tgt_dir
2050 drop_update_reply $MDTIDX \
2051 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2052 error "mrename failed"
2054 $CHECKSTAT -t dir $src_dir/src_dir &&
2055 error "src_dir present after rename"
2057 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2058 error "tgt_dir not present after rename"
2060 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2061 error "a not present after rename"
2063 run_test 110i "drop update reply during cross-MDT dir rename"
2066 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2067 local remote_dir=$DIR/$tdir/remote_dir
2068 local local_dir=$DIR/$tdir/local_dir
2072 mkdir $DIR/$tdir/local_dir
2073 $LFS mkdir -i $MDTIDX $remote_dir
2075 touch $local_dir/local_file
2076 drop_update_reply $MDTIDX \
2077 "ln $local_dir/local_file $remote_dir/remote_file" ||
2080 $CHECKSTAT -t file $remote_dir/remote_file ||
2081 error "remote not present after ln"
2083 run_test 110j "drop update reply during cross-MDT ln"
2085 # LU-2844 mdt prepare fail should not cause umount oops
2088 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2089 { skip "Need MDS version at least 2.3.62"; return 0; }
2091 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2092 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2093 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2094 stop $SINGLEMDS || error "stop MDS failed"
2095 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2096 do_facet $SINGLEMDS lctl set_param fail_loc=0
2097 start $SINGLEMDS $mdsdev || error "start MDS failed"
2099 run_test 111 "mdd setup fail should not cause umount oops"
2103 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2105 do_facet_random_file client $TMP/$tfile 100K ||
2106 error_noexit "Create random file $TMP/$tfile"
2108 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2109 error_noexit "Can't pause_bulk copy"
2112 # expect cmp to succeed, client resent bulk
2113 cmp $TMP/$tfile $DIR/$tfile ||
2114 error_noexit "Wrong data has been written"
2116 error_noexit "Can't remove file"
2119 run_test 112a "bulk resend while orignal request is in progress"
2121 # parameters: fail_loc CMD RC
2128 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2129 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2130 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2131 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2134 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2135 [ "$1" = "CLEANUP" ] &&
2136 fail=0x80000320 && echo ", $1 cp first"
2137 [ "$1" = "REPLY" ] &&
2138 fail=0x80000321 && echo ", $1 cp first"
2139 [ "$1" = "DEADLOCK CLEANUP" ] &&
2140 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2141 [ "$1" = "DEADLOCK REPLY" ] &&
2142 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2144 if [ x"$2" = x"get" ]; then
2145 #for TEST lock, take a conflict in advance
2146 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2147 echo "** Taking conflict **"
2148 flocks_test 5 set read sleep 10 $DIR/$tfile &
2154 $LCTL set_param fail_loc=$fail
2156 flocks_test 5 $2 write $DIR/$tfile &
2160 echo "** Evicting and re-connecting client **"
2165 if [ x"$2" = x"get" ]; then
2172 # check if the return value is allowed
2173 [ $rc -eq $3 ] && rc=0
2175 $LCTL set_param fail_loc=0
2179 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2180 # the ORIGINAL lock.
2185 flocks_test 5 set write sleep 4 $DIR/$tfile &
2189 # let unlock to sleep in CP CB
2190 $LCTL set_param fail_loc=$1
2193 # let cleanup to cleep in CP CB
2201 $LCTL set_param fail_loc=0
2206 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2209 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2210 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2211 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2213 test_120_reply "REPLY" set 5 || error "SET race failed"
2214 test_120_reply "REPLY" get 5 || error "GET race failed"
2215 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2218 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2219 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2221 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2223 run_test 120 "flock race: completion vs. evict"
2226 local BEFORE=$(date +%s)
2229 # modify dir so that next revalidate would not obtain UPDATE lock
2232 # drop 1 reply with UPDATE lock,
2233 # resend should not create 2nd lock on server
2234 mcreate $DIR/$tfile || error "mcreate failed: $?"
2235 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2237 # 2 BL AST will be sent to client, both must find the same lock,
2238 # race them to not get EINVAL for 2nd BL AST
2239 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2240 $LCTL set_param fail_loc=0x8000031f
2242 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2243 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2244 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2246 # let the client reconnect
2248 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2249 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2251 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2253 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2256 check_and_cleanup_lustre