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-2194 LU-2547
24 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 19b 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)
202 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
205 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
209 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
210 echo -n hello > $DIR1/$tfile
212 stat $DIR2/$tfile >& /dev/null
213 $LCTL set_param fail_err=71
214 drop_bl_callback_once "echo -n \\\", world\\\" >> $DIR2/$tfile"
218 cmp $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
219 cmp $DIR1/$tfile $TMP/$tfile || error "wrong content found"
221 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
223 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
225 [[ $evict -gt $before ]] ||
226 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
227 error "no eviction: $evict before:$before")
230 umount_client $MOUNT2
232 run_test 10d "test failed blocking ast"
235 # wake up a thread waiting for completion after eviction
237 do_facet client $MULTIOP $DIR/$tfile Ow ||
238 { error "multiop write failed: $?"; return 1; }
239 do_facet client $MULTIOP $DIR/$tfile or ||
240 { error "multiop read failed: $?"; return 2; }
244 do_facet client $MULTIOP $DIR/$tfile or ||
245 { error "multiop read failed: $?"; return 3; }
246 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
247 echo "evicted as expected"
249 do_facet client munlink $DIR/$tfile ||
250 { error "munlink failed: $?"; return 4; }
251 # allow recovery to complete
252 client_up || client_up || sleep $TIMEOUT
254 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
258 $LCTL mark $MULTIOP $DIR/$tfile OS_c
259 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
260 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
261 multiop_bg_pause $DIR/$tfile OS_c ||
262 { error "multiop failed: $?"; return 1; }
264 #define OBD_FAIL_MDS_CLOSE_NET 0x115
266 echo "waiting for multiop $PID"
267 wait $PID || { error "wait for multiop faile: $?"; return 2; }
268 do_facet client munlink $DIR/$tfile ||
269 { error "client munlink failed: $?"; return 3; }
270 # allow recovery to complete
271 client_up || client_up || sleep $TIMEOUT
273 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
275 # Bug 113, check that readdir lost recv timeout works.
277 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
278 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
279 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
280 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
281 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
282 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
283 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
285 run_test 13 "mdc_readpage restart test (bug 1138)"
287 # Bug 113, check that readdir lost send timeout works.
290 touch $DIR/$tdir/newentry
291 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
292 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
293 ls $DIR/$tdir || return 1
294 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
296 run_test 14 "mdc_readpage resend test (bug 1138)"
299 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
300 touch $DIR/$tfile && return 1
303 run_test 15 "failed open (-ENOMEM)"
305 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
307 lctl set_param -n llite.*.max_read_ahead_mb 0
311 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
315 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
317 do_facet_random_file client $TMP/$tfile 100K ||
318 { error_noexit "Create random file $TMP/$T" ; return 0; }
319 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
320 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
324 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
325 do_facet ost1 "lctl set_param fail_loc=0x80000504"
327 # OST bulk will time out here, client resends
328 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
329 do_facet ost1 lctl set_param fail_loc=0
330 # give recovery a chance to finish (shouldn't take long)
332 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
336 run_test 16 "timeout bulk put, don't evict client (2732)"
341 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
343 local SAMPLE_FILE=$TMP/$tfile
344 do_facet_random_file client $SAMPLE_FILE 20K ||
345 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
347 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
348 if at_is_enabled; then
349 at_max_saved=$(at_max_get ost1)
350 at_max_set $TIMEOUT ost1
353 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
354 # OST bulk will time out here, client retries
355 do_facet ost1 lctl set_param fail_loc=0x80000503
356 # need to ensure we send an RPC
357 do_facet client cp $SAMPLE_FILE $DIR/$tfile
360 # with AT, client will wait adaptive_max*factor+net_latency before
361 # expiring the req, hopefully timeout*2 is enough
362 sleep $(($TIMEOUT*2))
364 do_facet ost1 lctl set_param fail_loc=0
365 do_facet client "df $DIR"
366 # expect cmp to succeed, client resent bulk
367 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
368 do_facet client "rm $DIR/$tfile" || return 4
369 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
372 run_test 17 "timeout bulk get, don't evict client (2732)"
375 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
377 do_facet_create_file client $TMP/$tfile 20K ||
378 { error_noexit "Create file $TMP/$tfile" ; return 0; }
380 do_facet client mkdir -p $DIR/$tdir
384 pgcache_empty || return 1
387 $LFS setstripe -i 1 -c 1 $f
388 stripe_index=$($LFS getstripe -i $f)
389 if [ $stripe_index -ne 1 ]; then
391 error "$f: stripe_index $stripe_index != 1" && return
394 do_facet client cp $TMP/$tfile $f
396 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
397 $LCTL --device $osc2dev deactivate || return 3
398 # my understanding is that there should be nothing in the page
399 # cache after the client reconnects?
401 pgcache_empty || rc=2
402 $LCTL --device $osc2dev activate
406 run_test 18a "manual ost invalidate clears page cache immediately"
409 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
411 do_facet_create_file client $TMP/$tfile 20K ||
412 { error_noexit "Create file $TMP/$tfile" ; return 0; }
414 do_facet client mkdir -p $DIR/$tdir
418 pgcache_empty || return 1
420 $LFS setstripe -i 0 -c 1 $f
421 stripe_index=$($LFS getstripe -i $f)
422 if [ $stripe_index -ne 0 ]; then
424 error "$f: stripe_index $stripe_index != 0" && return
427 do_facet client cp $TMP/$tfile $f
430 # allow recovery to complete
431 sleep $((TIMEOUT + 2))
432 # my understanding is that there should be nothing in the page
433 # cache after the client reconnects?
435 pgcache_empty || rc=2
439 run_test 18b "eviction and reconnect clears page cache (2766)"
442 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
444 do_facet_create_file client $TMP/$tfile 20K ||
445 { error_noexit "Create file $TMP/$tfile" ; return 0; }
447 do_facet client mkdir -p $DIR/$tdir
451 pgcache_empty || return 1
453 $LFS setstripe -i 0 -c 1 $f
454 stripe_index=$($LFS getstripe -i $f)
455 if [ $stripe_index -ne 0 ]; then
457 error "$f: stripe_index $stripe_index != 0" && return
460 do_facet client cp $TMP/$tfile $f
464 # OBD_FAIL_OST_CONNECT_NET2
465 # lost reply to connect request
466 do_facet ost1 lctl set_param fail_loc=0x80000225
469 df $MOUNT > /dev/null 2>&1
471 # my understanding is that there should be nothing in the page
472 # cache after the client reconnects?
474 pgcache_empty || rc=2
478 run_test 18c "Dropped connect reply after eviction handing (14755)"
481 local BEFORE=`date +%s`
484 mount_client $DIR2 || error "failed to mount $DIR2"
486 # cancel cached locks from OST to avoid eviction from it
489 do_facet client "stat $DIR > /dev/null" ||
490 error "failed to stat $DIR: $?"
491 drop_ldlm_cancel "chmod 0777 $DIR2" ||
492 error "failed to chmod $DIR2"
496 # let the client reconnect
498 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
499 awk -F"[ [,]" '/EVICTED ]$/ \
500 { if (mx<$5) {mx=$5;} } END { print mx }')
502 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
503 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
504 error "no eviction: $EVICT before:$BEFORE")
506 run_test 19a "test expired_lock_main on mds (2867)"
509 local BEFORE=`date +%s`
512 mount_client $DIR2 || error "failed to mount $DIR2: $?"
514 # cancel cached locks from MDT to avoid eviction from it
517 do_facet client $MULTIOP $DIR/$tfile Ow ||
518 error "failed to run multiop: $?"
519 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
520 error "failed to ldlm_cancel: $?"
522 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
523 do_facet client munlink $DIR/$tfile ||
524 error "failed to unlink $DIR/$tfile: $?"
526 # let the client reconnect
528 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
529 awk -F"[ [,]" '/EVICTED ]$/ \
530 { if (mx < $5) {mx = $5;} } END { print mx }')
532 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
533 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
534 error "no eviction: $EVICT before:$BEFORE")
536 run_test 19b "test expired_lock_main on ost (2867)"
539 local BEFORE=`date +%s`
542 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
544 mkdir -p $DIR1/$tfile
547 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
548 do_facet mds $LCTL set_param fail_loc=0x80000516
550 touch $DIR2/$tfile/file1 &
552 # let touch to get blocked on the server
556 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
559 # let the client reconnect
561 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
562 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
564 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
566 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
568 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
569 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
572 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
573 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
576 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
577 do_facet ost1 lctl set_param fail_loc=0x80000308
578 kill -USR1 $MULTI_PID
581 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
583 run_test 20a "ldlm_handle_enqueue error (should return error)"
585 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
586 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
589 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
591 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
592 do_facet ost1 lctl set_param fail_loc=0x80000308
593 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
594 error "didn't fail open enqueue" || true
596 run_test 20b "ldlm_handle_enqueue error (should return error)"
599 mkdir -p $DIR/$tdir-1
600 mkdir -p $DIR/$tdir-2
601 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
604 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
605 $MULTIOP $DIR/$tdir-2/f Oc &
608 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
610 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
611 kill -USR1 $close_pid
613 wait $close_pid || return 1
614 wait $open_pid || return 2
615 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
617 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
618 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
622 run_test 21a "drop close request while close and open are both in flight"
625 mkdir -p $DIR/$tdir-1
626 mkdir -p $DIR/$tdir-2
627 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
630 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
631 mcreate $DIR/$tdir-2/f &
634 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
636 kill -USR1 $close_pid
638 wait $close_pid || return 1
639 wait $open_pid || return 3
641 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
642 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
645 run_test 21b "drop open request while close and open are both in flight"
648 mkdir -p $DIR/$tdir-1
649 mkdir -p $DIR/$tdir-2
650 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
653 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
654 mcreate $DIR/$tdir-2/f &
657 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
659 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
660 kill -USR1 $close_pid
662 wait $close_pid || return 1
663 wait $open_pid || return 2
665 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
667 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
668 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
671 run_test 21c "drop both request while close and open are both in flight"
674 mkdir -p $DIR/$tdir-1
675 mkdir -p $DIR/$tdir-2
676 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
679 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
680 $MULTIOP $DIR/$tdir-2/f Oc &
682 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
684 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
687 wait $pid || return 1
688 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
690 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
691 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
695 run_test 21d "drop close reply while close and open are both in flight"
698 mkdir -p $DIR/$tdir-1
699 mkdir -p $DIR/$tdir-2
700 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
703 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
704 touch $DIR/$tdir-2/f &
706 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
710 wait $pid || return 1
713 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
714 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
717 run_test 21e "drop open reply while close and open are both in flight"
720 mkdir -p $DIR/$tdir-1
721 mkdir -p $DIR/$tdir-2
722 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
725 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
726 touch $DIR/$tdir-2/f &
728 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
730 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
733 wait $pid || return 1
734 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
736 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
737 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
740 run_test 21f "drop both reply while close and open are both in flight"
743 mkdir -p $DIR/$tdir-1
744 mkdir -p $DIR/$tdir-2
745 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
748 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
749 touch $DIR/$tdir-2/f &
751 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
753 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
756 wait $pid || return 1
757 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
759 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
760 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
763 run_test 21g "drop open reply and close request while close and open are both in flight"
766 mkdir -p $DIR/$tdir-1
767 mkdir -p $DIR/$tdir-2
768 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
771 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
772 touch $DIR/$tdir-2/f &
775 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
777 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
780 wait $pid || return 1
781 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
783 wait $touch_pid || return 2
785 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
786 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
789 run_test 21h "drop open request and close reply while close and open are both in flight"
791 # bug 3462 - multiple MDC requests
796 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
801 $MULTIOP $f1 msu || return 1
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
806 wait $close_pid || return 2
807 rm -rf $f2 || return 4
809 run_test 22 "drop close request and do mknod"
812 multiop_bg_pause $DIR/$tfile O_c || return 1
814 # give a chance for open
818 drop_request "kill -USR1 $pid"
821 wait $pid || return 1
824 run_test 23 "client hang when close a file after mds crash"
826 test_24a() { # bug 11710 details correct fsync() behavior
827 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
830 $LFS setstripe -i 0 -c 1 $DIR/$tdir
832 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
835 kill -USR1 $MULTI_PID
838 lctl set_param fail_loc=0x0
841 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
843 run_test 24a "fsync error (should return error)"
845 wait_client_evicted () {
848 local varsvc=${facet}_svc
850 wait_update $(facet_active_host $facet) \
851 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
856 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
860 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
862 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
863 error "mulitop Ow8192_yc failed"
866 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
867 error "mulitop Ow8192_c failed"
872 kill -USR1 $MULTI_PID1
875 kill -USR1 $MULTI_PID2
878 lctl set_param fail_loc=0x0
880 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
881 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
884 dmesg | grep "dirty page discard:" ||
885 error "no discarded dirty page found!"
887 run_test 24b "test dirty page discard due to client eviction"
889 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
890 # this test can only run from a client on a separate node.
891 remote_ost || { skip "local OST" && return 0; }
892 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
893 remote_mds || { skip "local MDS" && return 0; }
895 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
896 skip "msg and ost1 are at the same node"
900 check_timeout || return 1
902 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
904 echo starting with $OST_NEXP OST exports
905 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
906 do_facet client lctl set_param fail_loc=0x505
907 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
908 # But if there's a race to start the evictor from various obds,
909 # the loser might have to wait for the next ping.
912 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
914 do_facet client lctl set_param fail_loc=0x0
915 [ $rc -eq 0 ] || error "client not evicted from OST"
917 run_test 26a "evict dead exports"
919 test_26b() { # bug 10140 - evict dead exports by pinger
920 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
922 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
923 skip "msg and ost1 are at the same node"
927 check_timeout || return 1
929 zconf_mount `hostname` $MOUNT2 ||
930 { error "Failed to mount $MOUNT2"; return 2; }
931 sleep 1 # wait connections being established
933 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
934 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
936 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
938 zconf_umount `hostname` $MOUNT2 -f
940 # PING_INTERVAL max(obd_timeout / 4, 1U)
941 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
943 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
944 # But if there's a race to start the evictor from various obds,
945 # the loser might have to wait for the next ping.
946 # = 9 * PING_INTERVAL + PING_INTERVAL
947 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
948 # let's wait $((TIMEOUT * 3)) # bug 19887
950 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
951 error "Client was not evicted by ost" rc=1
952 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
953 error "Client was not evicted by mds"
955 run_test 26b "evict dead exports"
959 writemany -q -a $DIR/$tdir/$tfile 0 5 &
962 local save_FAILURE_MODE=$FAILURE_MODE
964 facet_failover $SINGLEMDS
965 #define OBD_FAIL_OSC_SHUTDOWN 0x407
966 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
967 # need to wait for reconnect
968 echo waiting for fail_loc
969 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
970 facet_failover $SINGLEMDS
972 kill -USR1 $CLIENT_PID
975 FAILURE_MODE=$save_FAILURE_MODE
977 run_test 27 "fail LOV while using OSC's"
979 test_28() { # bug 6086 - error adding new clients
980 do_facet client mcreate $DIR/$tfile || return 1
981 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
982 echo "evicted as expected"
983 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
984 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
985 # fail once (evicted), reconnect fail (fail_loc), ok
986 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
988 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
990 run_test 28 "handle error adding new clients (bug 6086)"
992 test_29a() { # bug 22273 - error adding new clients
993 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
994 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
995 # fail abort so client will be new again
996 fail_abort $SINGLEMDS
997 client_up || error "reconnect failed"
998 wait_osc_import_state $SINGLEMDS ost FULL
1001 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1003 test_29b() { # bug 22273 - error adding new clients
1004 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1005 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1006 # fail abort so client will be new again
1008 client_up || error "reconnect failed"
1011 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1015 # put a load of file creates/writes/deletes
1016 writemany -q $DIR/$tdir/$tfile 0 5 &
1018 echo writemany pid $CLIENT_PID
1022 # wait for client to reconnect to MDS
1027 # client process should see no problems even though MDS went down
1029 kill -USR1 $CLIENT_PID
1032 echo writemany returned $rc
1033 #these may fail because of eviction due to slow AST response.
1035 error_ignore bz13652 "writemany returned rc $rc" || true
1037 run_test 50 "failover MDS under load"
1040 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1041 do_facet ost1 lctl set_param fail_loc=0x00001310
1044 # put a load of file creates/writes/deletes
1045 writemany -q $DIR/$tdir/$tfile 0 5 &
1049 facet_failover $SINGLEMDS
1050 # failover at various points during recovery
1051 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1052 echo will failover at $SEQ
1055 #echo failover in $i sec
1056 log "test_$testnum: failover in $i sec"
1058 facet_failover $SINGLEMDS
1060 # client process should see no problems even though MDS went down
1061 # and recovery was interrupted
1063 kill -USR1 $CLIENT_PID
1066 echo writemany returned $rc
1068 error_ignore bz13652 "writemany returned rc $rc" || true
1070 run_test 51 "failover MDS during recovery"
1073 do_facet client "mkdir -p $DIR/$tdir"
1074 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1076 echo writemany pid $CLIENT_PID
1081 wait $CLIENT_PID || rc=$?
1082 # active client process should see an EIO for down OST
1083 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1084 # but timing or failover setup may allow success
1085 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1086 echo "writemany returned $rc"
1091 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1096 [ $rc -ne 0 ] && { return $rc; }
1097 # wait for client to reconnect to OST
1101 [ $rc -ne 0 ] && { return $rc; }
1108 run_test 52 "failover OST under load"
1110 # test of open reconstruct
1113 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1116 run_test 53 "touch: drop rep"
1119 zconf_mount `hostname` $MOUNT2
1121 touch $DIR2/$tfile.1
1123 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1126 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1127 [ x"$ERROR" == x ] || error "back in time occured"
1129 run_test 54 "back in time"
1131 # bug 11330 - liblustre application death during I/O locks up OST
1133 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1137 # Minimum pass speed is 2MBps
1139 # LU-2887/LU-3089 - set min pass speed to 500KBps
1140 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1142 # first dd should be finished quickly
1143 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1144 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1147 echo "step1: testing ......"
1148 while kill -0 $DDPID 2> /dev/null; do
1150 if [ $count -gt $ddtimeout ]; then
1151 error "dd should be finished!"
1155 echo "(dd_pid=$DDPID, time=$count)successful"
1157 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1158 #define OBD_FAIL_OST_DROP_REQ 0x21d
1159 do_facet ost1 lctl set_param fail_loc=0x0000021d
1160 # second dd will be never finished
1161 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1164 echo "step2: testing ......"
1165 while [ $count -le $ddtimeout ]; do
1166 if ! kill -0 $DDPID 2> /dev/null; then
1168 error "dd shouldn't be finished! (time=$count)"
1173 echo "(dd_pid=$DDPID, time=$count)successful"
1175 #Recover fail_loc and dd will finish soon
1176 do_facet ost1 lctl set_param fail_loc=0
1178 echo "step3: testing ......"
1179 while kill -0 $DDPID 2> /dev/null; do
1181 if [ $count -gt $((ddtimeout + 440)) ]; then
1182 error "dd should be finished!"
1186 echo "(dd_pid=$DDPID, time=$count)successful"
1190 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1192 test_56() { # b=11277
1193 #define OBD_FAIL_MDS_RESEND 0x136
1195 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1196 stat $DIR/$tfile || error "stat failed"
1197 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1200 run_test 56 "do not fail on getattr resend"
1203 # no oscs means no client or mdt
1204 while lctl get_param osc.*.* > /dev/null 2>&1; do
1205 : # loop until proc file is removed
1209 test_57() { # bug 10866
1213 #define OBD_FAIL_LPROC_REMOVE 0xB00
1214 lctl set_param fail_loc=0x80000B00
1215 zconf_umount `hostname` $DIR
1216 lctl set_param fail_loc=0x80000B00
1217 fail_abort $SINGLEMDS
1219 lctl set_param fail_loc=0
1221 do_facet client "df $DIR"
1223 run_test 57 "read procfs entries causes kernel crash"
1225 test_58() { # bug 11546
1226 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1229 lctl set_param fail_loc=0x80000801
1230 cp $DIR/$tfile /dev/null &
1233 lctl set_param fail_loc=0
1234 drop_bl_callback_once rm -f $DIR/$tfile
1236 # the first 'df' could tigger the eviction caused by
1237 # 'drop_bl_callback_once', and it's normal case.
1238 # but the next 'df' should return successfully.
1239 do_facet client "df $DIR" || do_facet client "df $DIR"
1241 run_test 58 "Eviction in the middle of open RPC reply processing"
1243 test_59() { # bug 10589
1244 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1245 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1246 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1247 lctl set_param fail_loc=0x311
1248 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1249 [ $? = 0 ] || error "dd write failed"
1250 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1251 lctl set_param fail_loc=0
1253 zconf_umount `hostname` $MOUNT2 -f
1254 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1255 [ $? = 0 ] || error "dd read failed"
1256 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1257 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1259 run_test 59 "Read cancel race on client eviction"
1262 # we assume that all md changes are in the MDT0 changelog
1263 if [ $MDSCOUNT -gt 1 ]; then
1264 error_ignore bz17935 $*
1271 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1272 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1277 # Register (and start) changelog
1278 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1279 echo "Registered as $MDT0 changelog user $USER"
1281 # Generate a large number of changelog entries
1282 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1286 # Unlink files in the background
1287 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1291 # Failover the MDS while unlinks are happening
1292 facet_failover $SINGLEMDS
1294 # Wait for unlinkmany to finish
1297 # Check if all the create/unlink events were recorded
1299 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1300 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1301 echo "$cl_count unlinks in $MDT0 changelog"
1303 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1304 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1305 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1306 if [ $USERS -eq 0 ]; then
1307 [ $cl_count -eq $NUM_FILES ] || \
1308 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1309 # Also make sure we can clear large changelogs
1310 cl_count=$($LFS changelog $FSNAME | wc -l)
1311 [ $cl_count -le 2 ] || \
1312 error "Changelog not empty: $cl_count entries"
1314 # If there are other users, there may be other unlinks in the log
1315 [ $cl_count -ge $NUM_FILES ] || \
1316 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1317 echo "$USERS other changelog users; can't verify clear"
1320 run_test 60 "Add Changelog entries during MDS failover"
1324 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1325 mdtosc=${mdtosc/-MDT*/-MDT\*}
1326 local cflags="osc.$mdtosc.connect_flags"
1327 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1328 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1330 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1331 # Set the default stripe of $DIR/$tdir to put the files to ost1
1332 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1334 replay_barrier $SINGLEMDS
1335 createmany -o $DIR/$tdir/$tfile-%d 10
1336 local oid=`do_facet ost1 "lctl get_param -n obdfilter.${ost1_svc}.last_id"`
1338 fail_abort $SINGLEMDS
1340 touch $DIR/$tdir/$tfile
1341 local id=`$LFS getstripe $DIR/$tdir/$tfile | awk '$1 == 0 { print $2 }'`
1342 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1347 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1349 # test_62 as seen it b2_1 please do not reuse test_62
1352 # zconf_umount `hostname` $DIR
1353 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1354 # lctl set_param fail_loc=0x516
1357 #run_test 62 "Verify connection flags race - bug LU-1716"
1359 check_cli_ir_state()
1361 local NODE=${1:-$HOSTNAME}
1363 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1364 awk '/imperative_recovery:/ { print \\\$2}'")
1365 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1366 error "Error state $st, must be ENABLED or DISABLED"
1370 check_target_ir_state()
1373 local name=${target}_svc
1374 local recovery_proc=obdfilter.${!name}.recovery_status
1377 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1378 awk '/IR:/{ print \\\$2}'")
1379 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1380 error "Error state $st, must be ENABLED or DISABLED"
1386 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1391 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1392 awk '/state:/{ print \\\$2 }'")
1396 nidtbl_version_mgs()
1398 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1399 awk '/nidtbl_version:/{ print \\\$2 }'")
1403 # nidtbl_version_client <mds1|client> [node]
1404 nidtbl_version_client()
1407 local node=${2:-$HOSTNAME}
1409 if [ X$cli = Xclient ]; then
1412 local obdtype=${cli/%[0-9]*/}
1413 [ $obdtype != mds ] && error "wrong parameters $cli"
1415 node=$(facet_active_host $cli)
1420 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1421 awk "/$cli/{print \$6}" |sort -u)
1423 # in case there are multiple mounts on the client node
1425 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1429 nidtbl_versions_match()
1431 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1434 target_instance_match()
1440 obdtype=${srv/%[0-9]*/}
1451 error "invalid target type" $srv
1456 local target=${srv}_svc
1457 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1458 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1459 awk '/instance/{ print $2 }' | head -n1)
1461 return $([ $si -eq $ci ])
1466 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1467 { skip "MGS without IR support"; return 0; }
1469 # MDT was just restarted in the previous test, make sure everything
1472 while [ $cnt -gt 0 ]; do
1473 nidtbl_versions_match && break
1479 set_ir_status disabled
1481 local prev_ver=$(nidtbl_version_client client)
1483 local saved_FAILURE_MODE=$FAILURE_MODE
1484 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1488 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1489 error "version must not change due to IR disabled"
1490 target_instance_match ost1 || error "instance mismatch"
1494 FAILURE_MODE=$saved_FAILURE_MODE
1496 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1500 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1501 { skip "MGS without IR support"; return 0; }
1505 local OST1_IMP=$(get_osc_import_name client ost1)
1507 # disable pinger recovery
1508 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1512 target_instance_match ost1 || error "instance mismatch"
1513 nidtbl_versions_match || error "version must match"
1515 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1517 run_test 101 "IR: Make sure IR works w/o normal recovery"
1521 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1522 { skip "MGS without IR support"; return 0; }
1524 local clients=${CLIENTS:-$HOSTNAME}
1531 # let's have a new nidtbl version
1534 # sleep for a while so that clients can see the failure of ost
1535 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1536 # int mgc_request.c:
1537 # define MGC_TIMEOUT_MIN_SECONDS 5
1538 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1539 local count=30 # 20 seconds at most
1540 while [ $count -gt 0 ]; do
1541 nidtbl_versions_match && break
1546 nidtbl_versions_match || error "nidtbl mismatch"
1549 old_version=$(nidtbl_version_client client)
1551 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1554 combined_mgs_mds && mgsdev=mds1
1555 remount_facet $mgsdev
1558 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1561 new_version=$(nidtbl_version_client client)
1562 [ $new_version -lt $old_version ] &&
1563 error "nidtbl version wrong after mgs restarts"
1566 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1570 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1571 { skip "MGS without IR support"; return 0; }
1573 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1575 # workaround solution to generate config log on the mds
1581 # We need this test because mds is like a client in IR context.
1582 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1583 error "MDS should start w/o mgs"
1585 # start mgs and remount mds w/ ir
1586 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1589 # remount client so that fsdb will be created on the MGS
1590 umount_client $MOUNT || error "umount failed"
1591 mount_client $MOUNT || error "mount failed"
1593 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1595 while [ $count -gt 0 ]; do
1596 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1601 # after a while, mds should be able to reconnect to mgs and fetch
1602 # up-to-date nidtbl version
1603 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1608 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1612 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1613 { skip "MGS without IR support"; return 0; }
1618 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1619 error "OST1 cannot start"
1622 local ir_state=$(check_target_ir_state ost1)
1623 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1624 error "ir status on ost1 should be DISABLED"
1626 run_test 104 "IR: ost can disable IR voluntarily"
1630 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1631 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1632 { skip "MGS without IR support"; return 0; }
1636 # get one of the clients from client list
1637 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1639 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1640 zconf_umount $rcli $MOUNT || error "umount failed"
1641 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1643 # make sure lustre mount at $rcli disabling IR
1644 local ir_state=$(check_cli_ir_state $rcli)
1645 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1646 error "IR state must be DISABLED at $rcli"
1648 # Since the client just mounted, its last_rcvd entry is not on disk.
1649 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1650 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1651 $SETSTRIPE -i 0 $DIR/$tfile
1652 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1654 # make sure MGS's state is Partial
1655 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1658 # make sure IR on ost1 is DISABLED
1659 local ir_state=$(check_target_ir_state ost1)
1660 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1661 error "IR status on ost1 should be DISABLED"
1663 # remount with the default MOUNT_OPTS
1664 zconf_umount $rcli $MOUNT || error "umount failed"
1665 zconf_mount $rcli $MOUNT || error "mount failed"
1667 # make sure MGS's state is full
1668 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1671 # make sure IR on ost1 is ENABLED
1672 local ir_state=$(check_target_ir_state ost1)
1673 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1674 error "IR status on ost1 should be ENABLED"
1678 run_test 105 "IR: NON IR clients support"
1686 test_106() { # LU-1789
1687 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1688 { skip "Need MDS version at least 2.3.50"; return 0; }
1690 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1691 $LCTL set_param fail_loc=0x805
1694 trap cleanup_106 EXIT
1696 # enable lightweight flag on mdc connection
1699 local MDS_NEXP=$(do_facet $SINGLEMDS \
1700 lctl get_param -n mdt.${mds1_svc}.num_exports |
1702 $LCTL set_param fail_loc=0
1704 touch $DIR2/$tfile || error "failed to create empty file"
1705 replay_barrier $SINGLEMDS
1707 $LCTL set_param debug=console
1709 facet_failover $SINGLEMDS
1711 # lightweight connection must be evicted
1712 touch -c $DIR2/$tfile || true
1713 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1714 evicted=`awk '/This client was evicted by .*MDT0000/ {
1716 }' $TMP/lustre-log-$TESTNAME.log`
1717 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1719 # and all operations performed by lightweight client should be
1720 # synchronous, so the file created before mds restart should be there
1721 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1726 run_test 106 "lightweight connection support"
1733 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1734 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1735 multiop $DIR/$tdir D_c &
1737 mkdir $DIR/$tdir/dir_106 &
1739 do_facet $SINGLEMDS lctl set_param fail_loc=0
1742 wait $CLIENT_PID || rc=$?
1743 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1745 kill -USR1 $close_pid
1746 wait $close_pid || return 2
1750 run_test 107 "drop reint reply, then restart MDT"
1753 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1754 local remote_dir=$DIR/$tdir/remote_dir
1758 #prepare for 110 test, which need set striped dir on remote MDT.
1759 for num in $(seq $MDSCOUNT); do
1761 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1766 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1767 error "lfs mkdir failed"
1768 local diridx=$($GETSTRIPE -M $remote_dir)
1769 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1771 rm -rf $DIR/$tdir || error "rmdir failed"
1773 run_test 110a "create remote directory: drop client req"
1776 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1777 local remote_dir=$DIR/$tdir/remote_dir
1781 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1782 error "lfs mkdir failed"
1784 diridx=$($GETSTRIPE -M $remote_dir)
1785 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1787 rm -rf $DIR/$tdir || error "rmdir failed"
1789 run_test 110b "create remote directory: drop Master rep"
1792 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1793 local remote_dir=$DIR/$tdir/remote_dir
1797 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1798 error "lfs mkdir failed"
1800 diridx=$($GETSTRIPE -M $remote_dir)
1801 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1803 rm -rf $DIR/$tdir || error "rmdir failed"
1805 run_test 110c "create remote directory: drop update rep on slave MDT"
1808 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1809 local remote_dir=$DIR/$tdir/remote_dir
1813 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1815 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1817 rm -rf $DIR/$tdir || error "rmdir failed"
1821 run_test 110d "remove remote directory: drop client req"
1824 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1825 local remote_dir=$DIR/$tdir/remote_dir
1829 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1830 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
1832 rm -rf $DIR/$tdir || error "rmdir failed"
1836 run_test 110e "remove remote directory: drop master rep"
1839 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1840 local remote_dir=$DIR/$tdir/remote_dir
1844 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1845 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
1846 error "rm remote dir failed"
1848 rm -rf $DIR/$tdir || error "rmdir failed"
1850 run_test 110f "remove remote directory: drop slave rep"
1853 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1854 local remote_dir=$DIR/$tdir/remote_dir
1857 mkdir -p $remote_dir
1859 createmany -o $remote_dir/f 100
1861 #define OBD_FAIL_MIGRATE_NET_REP 0x1702
1862 do_facet mds$MDTIDX lctl set_param fail_loc=0x1702
1863 $LFS mv -M $MDTIDX $remote_dir || error "migrate failed"
1864 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
1866 for file in $(find $remote_dir); do
1867 mdt_index=$($LFS getstripe -M $file)
1868 [ $mdt_index == $MDTIDX ] ||
1869 error "$file is not on MDT${MDTIDX}"
1872 rm -rf $DIR/$tdir || error "rmdir failed"
1874 run_test 110g "drop reply during migration"
1876 # LU-2844 mdt prepare fail should not cause umount oops
1879 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
1880 { skip "Need MDS version at least 2.3.62"; return 0; }
1882 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
1883 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
1884 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
1885 stop $SINGLEMDS || error "stop MDS failed"
1886 start $SINGLEMDS $mdsdev && error "start MDS should fail"
1887 do_facet $SINGLEMDS lctl set_param fail_loc=0
1888 start $SINGLEMDS $mdsdev || error "start MDS failed"
1890 run_test 111 "mdd setup fail should not cause umount oops"
1894 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1896 do_facet_random_file client $TMP/$tfile 100K ||
1897 error_noexit "Create random file $TMP/$tfile"
1899 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
1900 error_noexit "Can't pause_bulk copy"
1903 # expect cmp to succeed, client resent bulk
1904 cmp $TMP/$tfile $DIR/$tfile ||
1905 error_noexit "Wrong data has been written"
1907 error_noexit "Can't remove file"
1910 run_test 112a "bulk resend while orignal request is in progress"
1912 # parameters: fail_loc CMD RC
1919 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
1920 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
1921 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
1922 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
1925 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
1926 [ "$1" = "CLEANUP" ] &&
1927 fail=0x80000320 && echo ", $1 cp first"
1928 [ "$1" = "REPLY" ] &&
1929 fail=0x80000321 && echo ", $1 cp first"
1930 [ "$1" = "DEADLOCK CLEANUP" ] &&
1931 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
1932 [ "$1" = "DEADLOCK REPLY" ] &&
1933 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
1935 if [ x"$2" = x"get" ]; then
1936 #for TEST lock, take a conflict in advance
1937 # sleep longer than evictor to not confuse fail_loc: 2+2+4
1938 echo "** Taking conflict **"
1939 flocks_test 5 set read sleep 10 $DIR/$tfile &
1945 $LCTL set_param fail_loc=$fail
1947 flocks_test 5 $2 write $DIR/$tfile &
1951 echo "** Evicting and re-connecting client **"
1956 if [ x"$2" = x"get" ]; then
1963 # check if the return value is allowed
1964 [ $rc -eq $3 ] && rc=0
1966 $LCTL set_param fail_loc=0
1970 # a lock is taken, unlock vs. cleanup_resource() race for destroying
1971 # the ORIGINAL lock.
1976 flocks_test 5 set write sleep 4 $DIR/$tfile &
1980 # let unlock to sleep in CP CB
1981 $LCTL set_param fail_loc=$1
1984 # let cleanup to cleep in CP CB
1992 $LCTL set_param fail_loc=0
1997 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2000 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2001 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2002 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2004 test_120_reply "REPLY" set 5 || error "SET race failed"
2005 test_120_reply "REPLY" get 5 || error "GET race failed"
2006 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2009 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2010 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2012 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2014 run_test 120 "flock race: completion vs. evict"
2017 local BEFORE=$(date +%s)
2020 # modify dir so that next revalidate would not obtain UPDATE lock
2023 # drop 1 reply with UPDATE lock,
2024 # resend should not create 2nd lock on server
2025 mcreate $DIR/$tfile || error "mcreate failed: $?"
2026 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2028 # 2 BL AST will be sent to client, both must find the same lock,
2029 # race them to not get EINVAL for 2nd BL AST
2030 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2031 $LCTL set_param fail_loc=0x8000031f
2033 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2034 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2035 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2037 # let the client reconnect
2039 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2040 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2042 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2044 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2047 check_and_cleanup_lustre