6 ALWAYS_EXCEPT="52 60 $RECOVERY_SMALL_EXCEPT"
8 export MULTIOP=${MULTIOP:-multiop}
9 PTLDEBUG=${PTLDEBUG:--1}
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 require_dsh_mds || exit 0
18 # also long tests: 19, 21a, 21e, 21f, 23, 27
20 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
24 # Allow us to override the setup if we already have a mounted system by
25 # setting SETUP=" " and CLEANUP=" "
27 CLEANUP=${CLEANUP:-""}
29 check_and_setup_lustre
32 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
35 local f1="$DIR/$tfile"
36 local f2="$DIR/$tfile.2"
38 drop_request "mcreate $f1" ||
39 error_noexit "create '$f1': drop req"
41 drop_reint_reply "mcreate $f2" ||
42 error_noexit "create '$f2': drop rep"
44 drop_request "tchmod 111 $f2" ||
45 error_noexit "chmod '$f2': drop req"
47 drop_reint_reply "tchmod 666 $f2" ||
48 error_noexit "chmod '$f2': drop rep"
50 drop_request "statone $f2" ||
51 error_noexit "stat '$f2': drop req"
53 drop_reply "statone $f2" ||
54 error_noexit "stat '$f2': drop rep"
56 run_test 1 "create, chmod, stat: drop req, drop rep"
60 do_facet_create_file client $t 10K ||
61 error_noexit "Create file $t"
63 drop_request "cat $t > /dev/null" ||
64 error_noexit "Open request for $t file"
66 drop_reply "cat $t > /dev/null" ||
67 error_noexit "Open replay for $t file"
69 run_test 4 "open: drop req, drop rep"
74 local RR="$T-renamed-again"
75 do_facet_create_file client $T 10K ||
76 error_noexit "Create file $T"
78 drop_request "mv $T $R" ||
79 error_noexit "Rename $T"
81 drop_reint_reply "mv $R $RR" ||
82 error_noexit "Failed rename replay on $R"
84 do_facet client "checkstat -v $RR" ||
85 error_noexit "checkstat error on $RR"
87 do_facet client "rm $RR" ||
88 error_noexit "Can't remove file $RR"
90 run_test 5 "rename: drop req, drop rep"
94 local LINK1=$DIR/$tfile.link1
95 local LINK2=$DIR/$tfile.link2
97 do_facet_create_file client $T 10K ||
98 error_noexit "Create file $T"
100 drop_request "mlink $T $LINK1" ||
101 error_noexit "mlink request for $T"
103 drop_reint_reply "mlink $T $LINK2" ||
104 error_noexit "mlink reply for $T"
106 drop_request "munlink $LINK1" ||
107 error_noexit "munlink request for $T"
109 drop_reint_reply "munlink $LINK2" ||
110 error_noexit "munlink reply for $T"
112 do_facet client "rm $T" ||
113 error_noexit "Can't remove file $T"
115 run_test 6 "link, unlink: drop req, drop rep"
119 drop_reint_reply "touch $DIR/$tfile" || return 1
121 run_test 8 "touch: drop rep (bug 1423)"
125 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
129 do_facet_random_file client $TMP/$tfile 1K ||
130 error_noexit "Create random file $TMP/$tfile"
131 # make this big, else test 9 doesn't wait for bulk -- bz 5595
132 do_facet_create_file client $TMP/$t1 4M ||
133 error_noexit "Create file $TMP/$t1"
134 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
135 error_noexit "Can't copy to $DIR/$t1 file"
136 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
137 error_noexit "Can't pause_bulk copy"
138 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
139 error_noexit "Can't copy file"
140 do_facet client "sync"
141 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
142 error_noexit "Can't remove files"
143 do_facet client "rm $TMP/$t1 $TMP/$tfile"
145 run_test 9 "pause bulk on OST (bug 1420)"
149 local before=$(date +%s)
152 do_facet client "stat $DIR > /dev/null" ||
153 error "failed to stat $DIR: $?"
154 drop_bl_callback "chmod 0777 $DIR" ||
155 error "failed to chmod $DIR: $?"
157 # let the client reconnect
159 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
160 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
161 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
162 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
163 error "no eviction: $evict before:$before")
165 do_facet client checkstat -v -p 0777 $DIR ||
166 error "client checkstat failed: $?"
168 run_test 10a "finish request on server after client eviction (bug 1521)"
171 local before=$(date +%s)
174 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
175 skip "Need MDS version at least 2.6.53" && return
176 do_facet client "stat $DIR > /dev/null" ||
177 error "failed to stat $DIR: $?"
178 drop_bl_callback_once "chmod 0777 $DIR" ||
179 error "failed to chmod $DIR: $?"
181 # let the client reconnect
183 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
184 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
186 [ -z "$evict" ] || [[ $evict -le $before ]] ||
187 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
188 error "eviction happened: $evict before:$before")
190 do_facet client checkstat -v -p 0777 $DIR ||
191 error "client checkstat failed: $?"
193 run_test 10b "re-send BL AST"
196 local before=$(date +%s)
205 workdir="${DIR}/${tdir}"
206 mkdir -p ${workdir} || error "can't create workdir $?"
207 stat ${workdir} > /dev/null ||
208 error "failed to stat ${workdir}: $?"
209 mdtidx=$($LFS getdirstripe -i ${workdir})
210 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
211 awk '{sub("_UUID", "", $2); print $2;}')
213 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
214 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
215 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
217 drop_bl_callback_once "chmod 0777 ${workdir}" &
222 # force client reconnect
223 $LCTL set_param "${mdcpath}"
225 # wait client reconnect
229 evict=$($LCTL get_param mdc.${mdccli}.state |
230 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
232 [[ $evict -le $before ]] ||
233 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
234 error "eviction happened: $EVICT before:$BEFORE" )
236 [ $rc -eq 0 ] || error "chmod must finished OK"
237 checkstat -v -p 0777 "${workdir}" ||
238 error "client checkstat failed: $?"
240 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
243 local before=$(date +%s)
246 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
247 skip "Need MDS version at least 2.6.90" && return
249 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
252 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
254 remount_client $MOUNT
258 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
259 echo -n hello | dd of=$DIR1/$tfile bs=5
261 stat $DIR2/$tfile >& /dev/null
262 $LCTL set_param fail_err=71
263 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
268 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
269 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
271 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
273 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
275 [[ $evict -gt $before ]] ||
276 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
277 error "no eviction: $evict before:$before")
279 $LCTL set_param fail_err=0
281 umount_client $MOUNT2
283 run_test 10d "test failed blocking ast"
287 [[ $(lustre_version_code ost1) -le $(version_code 2.8.58) ]] &&
288 skip "Need OST version at least 2.8.59" && return 0
289 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients" && return 0
290 [ $(facet_host client) == $(facet_host ost1) ] &&
291 skip "need ost1 and client on different nodes" && return 0
292 local -a clients=(${CLIENTS//,/ })
293 local client1=${clients[0]}
294 local client2=${clients[1]}
296 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
297 $MULTIOP $DIR/$tfile-1 Ow1048576c
299 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
300 $LCTL set_param fail_loc=0x80000305
302 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
303 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
304 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
305 # 1. to return ENOTCONN from ldlm_handle_enqueue0
306 # 2. to pause reconnect handling between resend and setting
307 # import to LUSTRE_IMP_FULL state
308 do_facet ost1 "$LCTL set_param fail_val=3"
310 # client1 fails ro respond to bl ast
311 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
314 # ost1 returns error on enqueue, which causes client1 to reconnect
315 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
316 error "multiop failed"
319 do_facet ost1 "$LCTL set_param fail_loc=0"
320 do_facet ost1 "$LCTL set_param fail_val=0"
322 run_test 10e "re-send BL AST vs reconnect race 2"
325 # wake up a thread waiting for completion after eviction
327 do_facet client $MULTIOP $DIR/$tfile Ow ||
328 { error "multiop write failed: $?"; return 1; }
329 do_facet client $MULTIOP $DIR/$tfile or ||
330 { error "multiop read failed: $?"; return 2; }
334 do_facet client $MULTIOP $DIR/$tfile or ||
335 { error "multiop read failed: $?"; return 3; }
336 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
337 echo "evicted as expected"
339 do_facet client munlink $DIR/$tfile ||
340 { error "munlink failed: $?"; return 4; }
341 # allow recovery to complete
342 client_up || client_up || sleep $TIMEOUT
344 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
348 $LCTL mark $MULTIOP $DIR/$tfile OS_c
349 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
350 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
351 multiop_bg_pause $DIR/$tfile OS_c ||
352 { error "multiop failed: $?"; return 1; }
354 #define OBD_FAIL_MDS_CLOSE_NET 0x115
356 echo "waiting for multiop $PID"
357 wait $PID || { error "wait for multiop faile: $?"; return 2; }
358 do_facet client munlink $DIR/$tfile ||
359 { error "client munlink failed: $?"; return 3; }
360 # allow recovery to complete
361 client_up || client_up || sleep $TIMEOUT
363 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
365 # Bug 113, check that readdir lost recv timeout works.
367 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
368 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
369 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
370 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
371 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
372 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
373 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
375 run_test 13 "mdc_readpage restart test (bug 1138)"
377 # Bug 113, check that readdir lost send timeout works.
380 touch $DIR/$tdir/newentry
381 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
382 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
383 ls $DIR/$tdir || return 1
384 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
386 run_test 14 "mdc_readpage resend test (bug 1138)"
389 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
390 touch $DIR/$tfile && return 1
393 run_test 15 "failed open (-ENOMEM)"
395 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
397 lctl set_param -n llite.*.max_read_ahead_mb 0
401 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
405 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
407 do_facet_random_file client $TMP/$tfile 100K ||
408 { error_noexit "Create random file $TMP/$T" ; return 0; }
409 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
410 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
414 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
415 do_facet ost1 "lctl set_param fail_loc=0x80000504"
417 # OST bulk will time out here, client resends
418 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
419 do_facet ost1 lctl set_param fail_loc=0
420 # give recovery a chance to finish (shouldn't take long)
422 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
426 run_test 16 "timeout bulk put, don't evict client (2732)"
431 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
433 local SAMPLE_FILE=$TMP/$tfile
434 do_facet_random_file client $SAMPLE_FILE 20K ||
435 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
437 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
438 if at_is_enabled; then
439 at_max_saved=$(at_max_get ost1)
440 at_max_set $TIMEOUT ost1
443 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
444 # OST bulk will time out here, client retries
445 do_facet ost1 lctl set_param fail_loc=0x80000503
446 # need to ensure we send an RPC
447 do_facet client cp $SAMPLE_FILE $DIR/$tfile
450 # with AT, client will wait adaptive_max*factor+net_latency before
451 # expiring the req, hopefully timeout*2 is enough
452 sleep $(($TIMEOUT*2))
454 do_facet ost1 lctl set_param fail_loc=0
455 do_facet client "df $DIR"
456 # expect cmp to succeed, client resent bulk
457 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
458 do_facet client "rm $DIR/$tfile" || return 4
459 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
462 run_test 17 "timeout bulk get, don't evict client (2732)"
465 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
467 do_facet_create_file client $TMP/$tfile 20K ||
468 { error_noexit "Create file $TMP/$tfile" ; return 0; }
470 do_facet client mkdir -p $DIR/$tdir
474 pgcache_empty || return 1
477 $LFS setstripe -i 1 -c 1 $f
478 stripe_index=$($LFS getstripe -i $f)
479 if [ $stripe_index -ne 1 ]; then
481 error "$f: stripe_index $stripe_index != 1" && return
484 do_facet client cp $TMP/$tfile $f
486 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
487 $LCTL --device $osc2dev deactivate || return 3
488 # my understanding is that there should be nothing in the page
489 # cache after the client reconnects?
491 pgcache_empty || rc=2
492 $LCTL --device $osc2dev activate
496 run_test 18a "manual ost invalidate clears page cache immediately"
499 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
501 do_facet_create_file client $TMP/$tfile 20K ||
502 { error_noexit "Create file $TMP/$tfile" ; return 0; }
504 do_facet client mkdir -p $DIR/$tdir
508 pgcache_empty || return 1
510 $LFS setstripe -i 0 -c 1 $f
511 stripe_index=$($LFS getstripe -i $f)
512 if [ $stripe_index -ne 0 ]; then
514 error "$f: stripe_index $stripe_index != 0" && return
517 do_facet client cp $TMP/$tfile $f
520 # allow recovery to complete
521 sleep $((TIMEOUT + 2))
522 # my understanding is that there should be nothing in the page
523 # cache after the client reconnects?
525 pgcache_empty || rc=2
529 run_test 18b "eviction and reconnect clears page cache (2766)"
532 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
534 do_facet_create_file client $TMP/$tfile 20K ||
535 { error_noexit "Create file $TMP/$tfile" ; return 0; }
537 do_facet client mkdir -p $DIR/$tdir
541 pgcache_empty || return 1
543 $LFS setstripe -i 0 -c 1 $f
544 stripe_index=$($LFS getstripe -i $f)
545 if [ $stripe_index -ne 0 ]; then
547 error "$f: stripe_index $stripe_index != 0" && return
550 do_facet client cp $TMP/$tfile $f
554 # OBD_FAIL_OST_CONNECT_NET2
555 # lost reply to connect request
556 do_facet ost1 lctl set_param fail_loc=0x80000225
559 $LFS df $MOUNT > /dev/null 2>&1
561 # my understanding is that there should be nothing in the page
562 # cache after the client reconnects?
564 pgcache_empty || rc=2
568 run_test 18c "Dropped connect reply after eviction handing (14755)"
571 local BEFORE=`date +%s`
574 mount_client $DIR2 || error "failed to mount $DIR2"
576 # cancel cached locks from OST to avoid eviction from it
579 do_facet client "stat $DIR > /dev/null" ||
580 error "failed to stat $DIR: $?"
581 drop_ldlm_cancel "chmod 0777 $DIR2" ||
582 error "failed to chmod $DIR2"
586 # let the client reconnect
588 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
589 awk -F"[ [,]" '/EVICTED ]$/ \
590 { if (mx<$5) {mx=$5;} } END { print mx }')
592 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
593 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
594 error "no eviction: $EVICT before:$BEFORE")
596 run_test 19a "test expired_lock_main on mds (2867)"
599 local BEFORE=`date +%s`
602 mount_client $DIR2 || error "failed to mount $DIR2: $?"
604 # cancel cached locks from MDT to avoid eviction from it
607 do_facet client $MULTIOP $DIR/$tfile Ow ||
608 error "failed to run multiop: $?"
609 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
610 error "failed to ldlm_cancel: $?"
612 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
613 do_facet client munlink $DIR/$tfile ||
614 error "failed to unlink $DIR/$tfile: $?"
616 # let the client reconnect
618 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
619 awk -F"[ [,]" '/EVICTED ]$/ \
620 { if (mx < $5) {mx = $5;} } END { print mx }')
622 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
623 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
624 error "no eviction: $EVICT before:$BEFORE")
626 run_test 19b "test expired_lock_main on ost (2867)"
629 local BEFORE=`date +%s`
632 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
634 mkdir -p $DIR1/$tfile
637 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
638 do_facet mds $LCTL set_param fail_loc=0x80000516
640 touch $DIR2/$tfile/file1 &
642 # let touch to get blocked on the server
646 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
649 # let the client reconnect
651 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
652 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
654 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
656 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
658 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
659 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
662 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
663 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
666 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
667 do_facet ost1 lctl set_param fail_loc=0x80000308
668 kill -USR1 $MULTI_PID
671 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
673 run_test 20a "ldlm_handle_enqueue error (should return error)"
675 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
676 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
679 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
681 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
682 do_facet ost1 lctl set_param fail_loc=0x80000308
683 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
684 error "didn't fail open enqueue" || true
686 run_test 20b "ldlm_handle_enqueue error (should return error)"
689 mkdir -p $DIR/$tdir-1
690 mkdir -p $DIR/$tdir-2
691 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
694 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
695 $MULTIOP $DIR/$tdir-2/f Oc &
698 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
700 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
701 kill -USR1 $close_pid
703 wait $close_pid || return 1
704 wait $open_pid || return 2
705 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
707 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
708 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
712 run_test 21a "drop close request while close and open are both in flight"
715 mkdir -p $DIR/$tdir-1
716 mkdir -p $DIR/$tdir-2
717 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
720 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
721 mcreate $DIR/$tdir-2/f &
724 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
726 kill -USR1 $close_pid
728 wait $close_pid || return 1
729 wait $open_pid || return 3
731 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
732 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
735 run_test 21b "drop open request while close and open are both in flight"
738 mkdir -p $DIR/$tdir-1
739 mkdir -p $DIR/$tdir-2
740 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
743 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
744 mcreate $DIR/$tdir-2/f &
747 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
749 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
750 kill -USR1 $close_pid
752 wait $close_pid || return 1
753 wait $open_pid || return 2
755 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
757 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
758 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
761 run_test 21c "drop both request while close and open are both in flight"
764 mkdir -p $DIR/$tdir-1
765 mkdir -p $DIR/$tdir-2
766 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
769 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
770 $MULTIOP $DIR/$tdir-2/f Oc &
772 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
774 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
777 wait $pid || return 1
778 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
780 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
781 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
785 run_test 21d "drop close reply while close and open are both in flight"
788 mkdir -p $DIR/$tdir-1
789 mkdir -p $DIR/$tdir-2
790 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
793 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
794 touch $DIR/$tdir-2/f &
796 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
800 wait $pid || return 1
803 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
804 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
807 run_test 21e "drop open reply while close and open are both in flight"
810 mkdir -p $DIR/$tdir-1
811 mkdir -p $DIR/$tdir-2
812 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
815 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
816 touch $DIR/$tdir-2/f &
818 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
820 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
823 wait $pid || return 1
824 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
826 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
827 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
830 run_test 21f "drop both reply while close and open are both in flight"
833 mkdir -p $DIR/$tdir-1
834 mkdir -p $DIR/$tdir-2
835 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
838 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
839 touch $DIR/$tdir-2/f &
841 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
843 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
846 wait $pid || return 1
847 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
849 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
850 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
853 run_test 21g "drop open reply and close request while close and open are both in flight"
856 mkdir -p $DIR/$tdir-1
857 mkdir -p $DIR/$tdir-2
858 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
861 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
862 touch $DIR/$tdir-2/f &
865 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
867 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
870 wait $pid || return 1
871 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
873 wait $touch_pid || return 2
875 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
876 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
879 run_test 21h "drop open request and close reply while close and open are both in flight"
881 # bug 3462 - multiple MDC requests
886 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
891 $MULTIOP $f1 msu || return 1
894 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
896 wait $close_pid || return 2
897 rm -rf $f2 || return 4
899 run_test 22 "drop close request and do mknod"
902 multiop_bg_pause $DIR/$tfile O_c || return 1
904 # give a chance for open
908 drop_request "kill -USR1 $pid"
911 wait $pid || return 1
914 run_test 23 "client hang when close a file after mds crash"
916 test_24a() { # bug 11710 details correct fsync() behavior
917 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
920 $LFS setstripe -i 0 -c 1 $DIR/$tdir
922 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
925 kill -USR1 $MULTI_PID
928 lctl set_param fail_loc=0x0
931 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
933 run_test 24a "fsync error (should return error)"
935 wait_client_evicted () {
938 local varsvc=${facet}_svc
940 wait_update $(facet_active_host $facet) \
941 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
946 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
950 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
952 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
953 error "mulitop Ow8192_yc failed"
956 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
957 error "mulitop Ow8192_c failed"
962 kill -USR1 $MULTI_PID1
965 kill -USR1 $MULTI_PID2
968 lctl set_param fail_loc=0x0
970 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
971 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
974 dmesg | grep "dirty page discard:" ||
975 error "no discarded dirty page found!"
977 run_test 24b "test dirty page discard due to client eviction"
979 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
980 # this test can only run from a client on a separate node.
981 remote_ost || { skip "local OST" && return 0; }
982 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
983 remote_mds || { skip "local MDS" && return 0; }
985 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
986 skip "msg and ost1 are at the same node"
990 check_timeout || return 1
992 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
994 echo starting with $OST_NEXP OST exports
995 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
996 do_facet client lctl set_param fail_loc=0x505
997 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
998 # But if there's a race to start the evictor from various obds,
999 # the loser might have to wait for the next ping.
1002 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1004 do_facet client lctl set_param fail_loc=0x0
1005 [ $rc -eq 0 ] || error "client not evicted from OST"
1007 run_test 26a "evict dead exports"
1009 test_26b() { # bug 10140 - evict dead exports by pinger
1010 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1012 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1013 skip "msg and ost1 are at the same node"
1017 check_timeout || return 1
1019 zconf_mount `hostname` $MOUNT2 ||
1020 { error "Failed to mount $MOUNT2"; return 2; }
1021 sleep 1 # wait connections being established
1023 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1024 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1026 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1028 zconf_umount `hostname` $MOUNT2 -f
1030 # PING_INTERVAL max(obd_timeout / 4, 1U)
1031 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1033 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1034 # But if there's a race to start the evictor from various obds,
1035 # the loser might have to wait for the next ping.
1036 # = 9 * PING_INTERVAL + PING_INTERVAL
1037 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1038 # let's wait $((TIMEOUT * 3)) # bug 19887
1040 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1041 error "Client was not evicted by ost" rc=1
1042 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1043 error "Client was not evicted by mds"
1045 run_test 26b "evict dead exports"
1049 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1052 local save_FAILURE_MODE=$FAILURE_MODE
1054 facet_failover $SINGLEMDS
1055 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1056 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1057 # need to wait for reconnect
1058 echo waiting for fail_loc
1059 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1060 facet_failover $SINGLEMDS
1061 #no crashes allowed!
1062 kill -USR1 $CLIENT_PID
1065 FAILURE_MODE=$save_FAILURE_MODE
1067 run_test 27 "fail LOV while using OSC's"
1069 test_28() { # bug 6086 - error adding new clients
1070 do_facet client mcreate $DIR/$tfile || return 1
1071 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1072 echo "evicted as expected"
1073 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1074 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1075 # fail once (evicted), reconnect fail (fail_loc), ok
1076 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1078 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1080 run_test 28 "handle error adding new clients (bug 6086)"
1082 test_29a() { # bug 22273 - error adding new clients
1083 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1084 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1085 # fail abort so client will be new again
1086 fail_abort $SINGLEMDS
1087 client_up || error "reconnect failed"
1088 wait_osc_import_state $SINGLEMDS ost FULL
1091 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1093 test_29b() { # bug 22273 - error adding new clients
1094 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1095 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1096 # fail abort so client will be new again
1098 client_up || error "reconnect failed"
1101 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1105 # put a load of file creates/writes/deletes
1106 writemany -q $DIR/$tdir/$tfile 0 5 &
1108 echo writemany pid $CLIENT_PID
1112 # wait for client to reconnect to MDS
1117 # client process should see no problems even though MDS went down
1119 kill -USR1 $CLIENT_PID
1122 echo writemany returned $rc
1123 #these may fail because of eviction due to slow AST response.
1125 error_ignore bz13652 "writemany returned rc $rc" || true
1127 run_test 50 "failover MDS under load"
1130 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1131 do_facet ost1 lctl set_param fail_loc=0x00001310
1134 # put a load of file creates/writes/deletes
1135 writemany -q $DIR/$tdir/$tfile 0 5 &
1139 facet_failover $SINGLEMDS
1140 # failover at various points during recovery
1141 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1142 echo will failover at $SEQ
1145 #echo failover in $i sec
1146 log "test_$testnum: failover in $i sec"
1148 facet_failover $SINGLEMDS
1150 # client process should see no problems even though MDS went down
1151 # and recovery was interrupted
1153 kill -USR1 $CLIENT_PID
1156 echo writemany returned $rc
1158 error_ignore bz13652 "writemany returned rc $rc" || true
1160 run_test 51 "failover MDS during recovery"
1163 do_facet client "mkdir -p $DIR/$tdir"
1164 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1166 echo writemany pid $CLIENT_PID
1171 wait $CLIENT_PID || rc=$?
1172 # active client process should see an EIO for down OST
1173 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1174 # but timing or failover setup may allow success
1175 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1176 echo "writemany returned $rc"
1181 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1186 [ $rc -ne 0 ] && { return $rc; }
1187 # wait for client to reconnect to OST
1191 [ $rc -ne 0 ] && { return $rc; }
1198 run_test 52 "failover OST under load"
1200 # test of open reconstruct
1203 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1206 run_test 53 "touch: drop rep"
1209 zconf_mount `hostname` $MOUNT2
1211 touch $DIR2/$tfile.1
1213 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1216 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1217 [ x"$ERROR" == x ] || error "back in time occured"
1219 run_test 54 "back in time"
1221 # bug 11330 - liblustre application death during I/O locks up OST
1223 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1227 # Minimum pass speed is 2MBps
1229 # LU-2887/LU-3089 - set min pass speed to 500KBps
1230 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1232 # first dd should be finished quickly
1233 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1234 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1237 echo "step1: testing ......"
1238 while kill -0 $DDPID 2> /dev/null; do
1240 if [ $count -gt $ddtimeout ]; then
1241 error "dd should be finished!"
1245 echo "(dd_pid=$DDPID, time=$count)successful"
1247 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1248 #define OBD_FAIL_OST_DROP_REQ 0x21d
1249 do_facet ost1 lctl set_param fail_loc=0x0000021d
1250 # second dd will be never finished
1251 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1254 echo "step2: testing ......"
1255 while [ $count -le $ddtimeout ]; do
1256 if ! kill -0 $DDPID 2> /dev/null; then
1258 error "dd shouldn't be finished! (time=$count)"
1263 echo "(dd_pid=$DDPID, time=$count)successful"
1265 #Recover fail_loc and dd will finish soon
1266 do_facet ost1 lctl set_param fail_loc=0
1268 echo "step3: testing ......"
1269 while kill -0 $DDPID 2> /dev/null; do
1271 if [ $count -gt $((ddtimeout + 440)) ]; then
1272 error "dd should be finished!"
1276 echo "(dd_pid=$DDPID, time=$count)successful"
1280 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1282 test_56() { # b=11277
1283 #define OBD_FAIL_MDS_RESEND 0x136
1285 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1286 stat $DIR/$tfile || error "stat failed"
1287 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1290 run_test 56 "do not fail on getattr resend"
1293 # no oscs means no client or mdt
1294 while lctl get_param osc.*.* > /dev/null 2>&1; do
1295 : # loop until proc file is removed
1299 test_57() { # bug 10866
1303 #define OBD_FAIL_LPROC_REMOVE 0xB00
1304 lctl set_param fail_loc=0x80000B00
1305 zconf_umount `hostname` $DIR
1306 lctl set_param fail_loc=0x80000B00
1307 fail_abort $SINGLEMDS
1309 lctl set_param fail_loc=0
1311 do_facet client "df $DIR"
1313 run_test 57 "read procfs entries causes kernel crash"
1315 test_58() { # bug 11546
1316 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1319 lctl set_param fail_loc=0x80000801
1320 cp $DIR/$tfile /dev/null &
1323 lctl set_param fail_loc=0
1324 drop_bl_callback_once rm -f $DIR/$tfile
1326 # the first 'df' could tigger the eviction caused by
1327 # 'drop_bl_callback_once', and it's normal case.
1328 # but the next 'df' should return successfully.
1329 do_facet client "df $DIR" || do_facet client "df $DIR"
1331 run_test 58 "Eviction in the middle of open RPC reply processing"
1333 test_59() { # bug 10589
1334 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1335 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1336 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1337 lctl set_param fail_loc=0x311
1338 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1339 [ $? = 0 ] || error "dd write failed"
1340 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1341 lctl set_param fail_loc=0
1343 zconf_umount `hostname` $MOUNT2 -f
1344 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1345 [ $? = 0 ] || error "dd read failed"
1346 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1347 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1349 run_test 59 "Read cancel race on client eviction"
1352 # we assume that all md changes are in the MDT0 changelog
1353 if [ $MDSCOUNT -gt 1 ]; then
1354 error_ignore bz17935 $*
1361 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1362 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1367 # Register (and start) changelog
1368 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1369 echo "Registered as $MDT0 changelog user $USER"
1371 # Generate a large number of changelog entries
1372 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1376 # Unlink files in the background
1377 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1381 # Failover the MDS while unlinks are happening
1382 facet_failover $SINGLEMDS
1384 # Wait for unlinkmany to finish
1387 # Check if all the create/unlink events were recorded
1389 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1390 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1391 echo "$cl_count unlinks in $MDT0 changelog"
1393 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1394 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1395 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1396 if [ $USERS -eq 0 ]; then
1397 [ $cl_count -eq $NUM_FILES ] || \
1398 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1399 # Also make sure we can clear large changelogs
1400 cl_count=$($LFS changelog $FSNAME | wc -l)
1401 [ $cl_count -le 2 ] || \
1402 error "Changelog not empty: $cl_count entries"
1404 # If there are other users, there may be other unlinks in the log
1405 [ $cl_count -ge $NUM_FILES ] || \
1406 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1407 echo "$USERS other changelog users; can't verify clear"
1410 run_test 60 "Add Changelog entries during MDS failover"
1414 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1415 mdtosc=${mdtosc/-MDT*/-MDT\*}
1416 local cflags="osc.$mdtosc.connect_flags"
1417 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1418 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1420 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1421 # Set the default stripe of $DIR/$tdir to put the files to ost1
1422 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1424 replay_barrier $SINGLEMDS
1425 createmany -o $DIR/$tdir/$tfile-%d 10
1426 local oid=$(do_facet ost1 "lctl get_param -n \
1427 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1429 fail_abort $SINGLEMDS
1431 touch $DIR/$tdir/$tfile
1432 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1433 awk '$1 == 0 { print $2 }')
1434 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1439 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1441 # test_62 as seen it b2_1 please do not reuse test_62
1444 # zconf_umount `hostname` $DIR
1445 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1446 # lctl set_param fail_loc=0x516
1449 #run_test 62 "Verify connection flags race - bug LU-1716"
1453 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1454 { skip "Need MDS version at least 2.7.51"; return 0; }
1456 local list=$(comma_list $(osts_nodes))
1458 # modify dir so that next revalidate would not obtain UPDATE lock
1461 # drop 1 reply with UPDATE lock
1462 mcreate $DIR/$tfile || error "mcreate failed: $?"
1463 drop_ldlm_reply_once "stat $DIR/$tfile" &
1466 # make the re-sent lock to sleep
1467 #define OBD_FAIL_MDS_RESEND 0x136
1468 do_nodes $list $LCTL set_param fail_loc=0x80000136
1470 #initiate the re-connect & re-send
1471 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1472 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1473 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1476 #initiate the client eviction while enqueue re-send is in progress
1482 run_test 66 "lock enqueue re-send vs client eviction"
1487 #grant lock1, export2
1488 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1489 $MULTIOP $DIR2/$tfile Ow || return 2
1491 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1492 do_facet ost $LCTL set_param fail_loc=0x31e
1493 #get waiting lock2, export1
1494 $MULTIOP $DIR/$tfile Ow &
1496 # let enqueue to get asleep
1500 $MULTIOP $DIR2/$tfile Ow &
1508 do_facet ost $LCTL set_param fail_loc=0
1515 run_test 65 "lock enqueue for destroyed export"
1517 check_cli_ir_state()
1519 local NODE=${1:-$HOSTNAME}
1521 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1522 awk '/imperative_recovery:/ { print \\\$2}'")
1523 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1524 error "Error state $st, must be ENABLED or DISABLED"
1528 check_target_ir_state()
1531 local name=${target}_svc
1532 local recovery_proc=obdfilter.${!name}.recovery_status
1536 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1537 awk '/status:/{ print \\\$2}'")
1538 [ x$st = xRECOVERING ] || break
1540 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1541 awk '/IR:/{ print \\\$2}'")
1542 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1543 error "Error state $st, must be ENABLED or DISABLED"
1549 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1554 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1555 awk '/state:/{ print \\\$2 }'")
1559 nidtbl_version_mgs()
1561 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1562 awk '/nidtbl_version:/{ print \\\$2 }'")
1566 # nidtbl_version_client <mds1|client> [node]
1567 nidtbl_version_client()
1570 local node=${2:-$HOSTNAME}
1572 if [ X$cli = Xclient ]; then
1575 local obdtype=${cli/%[0-9]*/}
1576 [ $obdtype != mds ] && error "wrong parameters $cli"
1578 node=$(facet_active_host $cli)
1583 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1584 awk "/$cli/{print \$6}" |sort -u)
1586 # in case there are multiple mounts on the client node
1588 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1592 nidtbl_versions_match()
1594 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1597 target_instance_match()
1603 obdtype=${srv/%[0-9]*/}
1614 error "invalid target type" $srv
1619 local target=${srv}_svc
1620 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1621 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1622 awk '/instance/{ print $2 }' | head -n1)
1624 return $([ $si -eq $ci ])
1629 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1630 { skip "MGS without IR support"; return 0; }
1632 # MDT was just restarted in the previous test, make sure everything
1635 while [ $cnt -gt 0 ]; do
1636 nidtbl_versions_match && break
1642 set_ir_status disabled
1644 local prev_ver=$(nidtbl_version_client client)
1646 local saved_FAILURE_MODE=$FAILURE_MODE
1647 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1651 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1652 error "version must not change due to IR disabled"
1653 target_instance_match ost1 || error "instance mismatch"
1657 FAILURE_MODE=$saved_FAILURE_MODE
1659 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1663 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1664 { skip "MGS without IR support"; return 0; }
1668 local OST1_IMP=$(get_osc_import_name client ost1)
1670 # disable pinger recovery
1671 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1675 target_instance_match ost1 || error "instance mismatch"
1676 nidtbl_versions_match || error "version must match"
1678 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1680 run_test 101 "IR: Make sure IR works w/o normal recovery"
1684 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1685 { skip "MGS without IR support"; return 0; }
1687 local clients=${CLIENTS:-$HOSTNAME}
1694 # let's have a new nidtbl version
1697 # sleep for a while so that clients can see the failure of ost
1698 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1699 # int mgc_request.c:
1700 # define MGC_TIMEOUT_MIN_SECONDS 5
1701 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1702 local count=30 # 20 seconds at most
1703 while [ $count -gt 0 ]; do
1704 nidtbl_versions_match && break
1709 nidtbl_versions_match || error "nidtbl mismatch"
1712 old_version=$(nidtbl_version_client client)
1714 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1717 combined_mgs_mds && mgsdev=mds1
1718 remount_facet $mgsdev
1721 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1724 new_version=$(nidtbl_version_client client)
1725 [ $new_version -lt $old_version ] &&
1726 error "nidtbl version wrong after mgs restarts"
1729 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1733 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1734 { skip "MGS without IR support"; return 0; }
1736 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1738 # workaround solution to generate config log on the mds
1744 # We need this test because mds is like a client in IR context.
1745 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1746 error "MDS should start w/o mgs"
1748 # start mgs and remount mds w/ ir
1749 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1752 # remount client so that fsdb will be created on the MGS
1753 umount_client $MOUNT || error "umount failed"
1754 mount_client $MOUNT || error "mount failed"
1756 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1758 while [ $count -gt 0 ]; do
1759 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1764 # after a while, mds should be able to reconnect to mgs and fetch
1765 # up-to-date nidtbl version
1766 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1771 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1775 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1776 { skip "MGS without IR support"; return 0; }
1781 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1782 error "OST1 cannot start"
1785 local ir_state=$(check_target_ir_state ost1)
1786 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1787 error "ir status on ost1 should be DISABLED"
1789 run_test 104 "IR: ost can disable IR voluntarily"
1793 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1794 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1795 { skip "MGS without IR support"; return 0; }
1799 # get one of the clients from client list
1800 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1802 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1803 zconf_umount $rcli $MOUNT || error "umount failed"
1804 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1806 # make sure lustre mount at $rcli disabling IR
1807 local ir_state=$(check_cli_ir_state $rcli)
1808 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1809 error "IR state must be DISABLED at $rcli"
1811 # Since the client just mounted, its last_rcvd entry is not on disk.
1812 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1813 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1814 $SETSTRIPE -i 0 $DIR/$tfile
1815 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1817 # make sure MGS's state is Partial
1818 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1821 # make sure IR on ost1 is DISABLED
1822 local ir_state=$(check_target_ir_state ost1)
1823 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1824 error "IR status on ost1 should be DISABLED"
1826 # remount with the default MOUNT_OPTS
1827 zconf_umount $rcli $MOUNT || error "umount failed"
1828 zconf_mount $rcli $MOUNT || error "mount failed"
1830 # make sure MGS's state is full
1831 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1834 # make sure IR on ost1 is ENABLED
1835 local ir_state=$(check_target_ir_state ost1)
1836 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1837 error "IR status on ost1 should be ENABLED"
1841 run_test 105 "IR: NON IR clients support"
1849 test_106() { # LU-1789
1850 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1851 { skip "Need MDS version at least 2.3.50"; return 0; }
1853 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1854 $LCTL set_param fail_loc=0x805
1857 trap cleanup_106 EXIT
1859 # enable lightweight flag on mdc connection
1862 local MDS_NEXP=$(do_facet $SINGLEMDS \
1863 lctl get_param -n mdt.${mds1_svc}.num_exports |
1865 $LCTL set_param fail_loc=0
1867 touch $DIR2/$tfile || error "failed to create empty file"
1868 replay_barrier $SINGLEMDS
1870 $LCTL set_param debug=console
1872 facet_failover $SINGLEMDS
1874 # lightweight connection must be evicted
1875 touch -c $DIR2/$tfile || true
1876 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1877 evicted=`awk '/This client was evicted by .*MDT0000/ {
1879 }' $TMP/lustre-log-$TESTNAME.log`
1880 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1882 # and all operations performed by lightweight client should be
1883 # synchronous, so the file created before mds restart should be there
1884 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1889 run_test 106 "lightweight connection support"
1896 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1898 multiop $DIR/$tdir D_c &
1900 mkdir $DIR/$tdir/dir_106 &
1902 do_facet $SINGLEMDS lctl set_param fail_loc=0
1905 wait $CLIENT_PID || rc=$?
1906 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1908 kill -USR1 $close_pid
1909 wait $close_pid || return 2
1913 run_test 107 "drop reint reply, then restart MDT"
1917 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
1919 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
1927 client_up || error "reconnect failed"
1928 rm -f $DIR/$tdir/$tfile
1930 run_test 108 "client eviction don't crash"
1933 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1934 local remote_dir=$DIR/$tdir/remote_dir
1938 #prepare for 110 test, which need set striped dir on remote MDT.
1939 for num in $(seq $MDSCOUNT); do
1941 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1946 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1947 error "lfs mkdir failed"
1948 local diridx=$($GETSTRIPE -M $remote_dir)
1949 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1951 rm -rf $DIR/$tdir || error "rmdir failed"
1953 run_test 110a "create remote directory: drop client req"
1956 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1957 local remote_dir=$DIR/$tdir/remote_dir
1961 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1962 error "lfs mkdir failed"
1964 diridx=$($GETSTRIPE -M $remote_dir)
1965 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1967 rm -rf $DIR/$tdir || error "rmdir failed"
1969 run_test 110b "create remote directory: drop Master rep"
1972 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1973 local remote_dir=$DIR/$tdir/remote_dir
1977 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
1978 error "lfs mkdir failed"
1980 diridx=$($GETSTRIPE -M $remote_dir)
1981 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1983 rm -rf $DIR/$tdir || error "rmdir failed"
1985 run_test 110c "create remote directory: drop update rep on slave MDT"
1988 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1989 local remote_dir=$DIR/$tdir/remote_dir
1993 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
1995 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
1997 rm -rf $DIR/$tdir || error "rmdir failed"
2001 run_test 110d "remove remote directory: drop client req"
2004 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2005 local remote_dir=$DIR/$tdir/remote_dir
2009 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2010 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2012 rm -rf $DIR/$tdir || error "rmdir failed"
2016 run_test 110e "remove remote directory: drop master rep"
2019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2020 local remote_dir=$DIR/$tdir/remote_dir
2024 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2025 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2026 error "rm remote dir failed"
2028 rm -rf $DIR/$tdir || error "rmdir failed"
2030 run_test 110f "remove remote directory: drop slave rep"
2033 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2034 local remote_dir=$DIR/$tdir/remote_dir
2037 mkdir -p $remote_dir
2039 createmany -o $remote_dir/f 100
2041 #define OBD_FAIL_MIGRATE_NET_REP 0x1800
2042 do_facet mds$MDTIDX lctl set_param fail_loc=0x1800
2043 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
2044 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
2046 for file in $(find $remote_dir); do
2047 mdt_index=$($LFS getstripe -M $file)
2048 [ $mdt_index == $MDTIDX ] ||
2049 error "$file is not on MDT${MDTIDX}"
2052 rm -rf $DIR/$tdir || error "rmdir failed"
2054 run_test 110g "drop reply during migration"
2057 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2058 local src_dir=$DIR/$tdir/source_dir
2059 local tgt_dir=$DIR/$tdir/target_dir
2063 $LFS mkdir -i $MDTIDX $tgt_dir
2065 dd if=/etc/hosts of=$src_dir/src_file
2066 touch $tgt_dir/tgt_file
2067 drop_update_reply $MDTIDX \
2068 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2069 error "mrename failed"
2071 $CHECKSTAT -t file $src_dir/src_file &&
2072 error "src_file present after rename"
2074 diff /etc/hosts $tgt_dir/tgt_file ||
2075 error "file changed after rename"
2078 run_test 110h "drop update reply during cross-MDT file rename"
2081 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2082 local src_dir=$DIR/$tdir/source_dir
2083 local tgt_dir=$DIR/$tdir/target_dir
2087 $LFS mkdir -i $MDTIDX $tgt_dir
2089 mkdir $src_dir/src_dir
2090 touch $src_dir/src_dir/a
2091 mkdir $tgt_dir/tgt_dir
2092 drop_update_reply $MDTIDX \
2093 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2094 error "mrename failed"
2096 $CHECKSTAT -t dir $src_dir/src_dir &&
2097 error "src_dir present after rename"
2099 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2100 error "tgt_dir not present after rename"
2102 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2103 error "a not present after rename"
2105 run_test 110i "drop update reply during cross-MDT dir rename"
2108 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2109 local remote_dir=$DIR/$tdir/remote_dir
2110 local local_dir=$DIR/$tdir/local_dir
2114 mkdir $DIR/$tdir/local_dir
2115 $LFS mkdir -i $MDTIDX $remote_dir
2117 touch $local_dir/local_file
2118 drop_update_reply $MDTIDX \
2119 "ln $local_dir/local_file $remote_dir/remote_file" ||
2122 $CHECKSTAT -t file $remote_dir/remote_file ||
2123 error "remote not present after ln"
2125 run_test 110j "drop update reply during cross-MDT ln"
2127 # LU-2844 mdt prepare fail should not cause umount oops
2130 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2131 { skip "Need MDS version at least 2.3.62"; return 0; }
2133 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2134 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2135 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2136 stop $SINGLEMDS || error "stop MDS failed"
2137 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2138 do_facet $SINGLEMDS lctl set_param fail_loc=0
2139 start $SINGLEMDS $mdsdev || error "start MDS failed"
2141 run_test 111 "mdd setup fail should not cause umount oops"
2145 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2147 do_facet_random_file client $TMP/$tfile 100K ||
2148 error_noexit "Create random file $TMP/$tfile"
2150 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2151 error_noexit "Can't pause_bulk copy"
2154 # expect cmp to succeed, client resent bulk
2155 cmp $TMP/$tfile $DIR/$tfile ||
2156 error_noexit "Wrong data has been written"
2158 error_noexit "Can't remove file"
2161 run_test 112a "bulk resend while orignal request is in progress"
2168 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2169 cancel_lru_locks osc
2172 $LCTL set_param fail_loc=$fail1 fail_val=3
2173 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2177 set_nodes_failloc "$(osts_nodes)" $fail2
2179 wait $pid || error "dd failed"
2187 local fail_val2=${4:-0}
2193 $LCTL set_param fail_loc=$fail1 fail_val=4
2194 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2199 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2203 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2204 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2209 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2210 skip "need at least 2.8.50 on OST" && return 0
2212 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2213 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2214 test_115_read 0x8000051b 0x8000051a
2216 run_test 115a "read: late REQ MDunlink and no bulk"
2219 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2220 skip "need at least 2.8.50 on OST" && return 0
2222 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2223 #define OBD_FAIL_OST_ENOSPC 0x215
2225 # pass $OSTCOUNT for the fail_loc to be caught
2226 # appropriately by the IO thread
2227 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2229 run_test 115b "write: late REQ MDunlink and no bulk"
2232 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2233 skip "need at least 2.8.50 on OST" && return 0
2235 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2236 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2237 test_115_read 0x8000050f 0x8000051a
2239 run_test 115c "read: late Reply MDunlink and no bulk"
2242 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2243 skip "need at least 2.8.50 on OST" && return 0
2245 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2246 #define OBD_FAIL_OST_ENOSPC 0x215
2247 test_115_write 0x8000050f 0x80000215 0
2249 run_test 115d "write: late Reply MDunlink and no bulk"
2252 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2253 skip "need at least 2.8.50 on OST" && return 0
2255 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2256 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2257 test_115_read 0x80000510 0x80000211
2259 run_test 115e "read: late Bulk MDunlink and no reply"
2262 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2263 skip "need at least 2.8.50 on OST" && return 0
2265 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2266 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2267 test_115_read 0x8000051b 0x80000211
2269 run_test 115f "read: late REQ MDunlink and no reply"
2272 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2273 skip "need at least 2.8.50 on OST" && return 0
2275 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2276 test_115_read 0x8000051c 0
2278 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2280 # parameters: fail_loc CMD RC
2287 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2288 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2289 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2290 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2293 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2294 [ "$1" = "CLEANUP" ] &&
2295 fail=0x80000320 && echo ", $1 cp first"
2296 [ "$1" = "REPLY" ] &&
2297 fail=0x80000321 && echo ", $1 cp first"
2298 [ "$1" = "DEADLOCK CLEANUP" ] &&
2299 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2300 [ "$1" = "DEADLOCK REPLY" ] &&
2301 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2303 if [ x"$2" = x"get" ]; then
2304 #for TEST lock, take a conflict in advance
2305 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2306 echo "** Taking conflict **"
2307 flocks_test 5 set read sleep 10 $DIR/$tfile &
2313 $LCTL set_param fail_loc=$fail
2315 flocks_test 5 $2 write $DIR/$tfile &
2319 echo "** Evicting and re-connecting client **"
2324 if [ x"$2" = x"get" ]; then
2331 # check if the return value is allowed
2332 [ $rc -eq $3 ] && rc=0
2334 $LCTL set_param fail_loc=0
2338 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2339 # the ORIGINAL lock.
2344 flocks_test 5 set write sleep 4 $DIR/$tfile &
2348 # let unlock to sleep in CP CB
2349 $LCTL set_param fail_loc=$1
2352 # let cleanup to cleep in CP CB
2360 $LCTL set_param fail_loc=0
2365 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2368 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2369 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2370 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2372 test_120_reply "REPLY" set 5 || error "SET race failed"
2373 test_120_reply "REPLY" get 5 || error "GET race failed"
2374 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2377 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2378 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2380 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2382 run_test 120 "flock race: completion vs. evict"
2385 local BEFORE=$(date +%s)
2388 # modify dir so that next revalidate would not obtain UPDATE lock
2391 # drop 1 reply with UPDATE lock,
2392 # resend should not create 2nd lock on server
2393 mcreate $DIR/$tfile || error "mcreate failed: $?"
2394 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2396 # 2 BL AST will be sent to client, both must find the same lock,
2397 # race them to not get EINVAL for 2nd BL AST
2398 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2399 $LCTL set_param fail_loc=0x8000031f
2401 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2402 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2403 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2405 # let the client reconnect
2407 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2408 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2410 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2412 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2416 test_mkdir -p $DIR/$tdir
2418 # Prevent interference from layout intent RPCs due to
2419 # asynchronous writeback. These will be tested in 130c below.
2420 do_nodes ${CLIENTS:-$HOSTNAME} sync
2422 # get only LOOKUP lock on $tdir
2423 cancel_lru_locks mdc
2424 ls $DIR/$tdir/$tfile 2>/dev/null
2426 # get getattr by fid on $tdir
2428 # we need to race with unlink, unlink must complete before we will
2429 # take a DLM lock, otherwise unlink will wait until getattr will
2430 # complete; but later than getattr starts so that getattr found
2432 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2433 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2440 # drop the reply so that resend happens on an unlinked file.
2441 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2442 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2446 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2449 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2452 run_test 130a "enqueue resend on not existing file"
2455 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2457 # let the reply to be dropped
2460 #define OBD_FAIL_SRV_ENOENT 0x217
2461 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2463 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2466 run_test 130b "enqueue resend on a stale inode"
2469 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2471 do_nodes ${CLIENTS:-$HOSTNAME} sync
2472 echo XXX > $DIR/$tfile
2474 cancel_lru_locks mdc
2476 # Trigger writeback on $tfile.
2478 # we need to race with unlink, unlink must complete before we will
2479 # take a DLM lock, otherwise unlink will wait until intent will
2480 # complete; but later than intent starts so that intent found
2482 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2483 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2490 # drop the reply so that resend happens on an unlinked file.
2491 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2492 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2494 # let the reply to be dropped
2497 #define OBD_FAIL_SRV_ENOENT 0x217
2498 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2504 run_test 130c "layout intent resend on a stale inode"
2507 local before=$(date +%s)
2510 mount_client $MOUNT2 || error "mount filed"
2513 # get a lock on client so that export would reach the stale list
2514 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2515 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2518 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2519 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2521 $TRUNCATE $DIR/$tfile 100 &
2524 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2528 umount_client $MOUNT2
2530 evict=$(do_facet client $LCTL get_param \
2531 osc.$FSNAME-OST0000-osc-*/state |
2532 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2534 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2535 (do_facet client $LCTL get_param \
2536 osc.$FSNAME-OST0000-osc-*/state;
2537 error "eviction happened: $evict before:$before")
2539 run_test 132 "long punch"
2542 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2545 # get a lock on client so that export would reach the stale list
2546 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2547 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2549 # another IO under the same lock
2550 #define OBD_FAIL_OSC_DELAY_IO 0x414
2551 $LCTL set_param fail_loc=0x80000414
2552 $LCTL set_param fail_val=4 fail_loc=0x80000414
2553 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2557 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2558 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2562 wait $pid && error "dd succeeded"
2565 run_test 131 "IO vs evict results to IO under staled lock"
2568 local list=$(comma_list $(mdts_nodes))
2570 local t=$((TIMEOUT * 2))
2573 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2575 multiop_bg_pause $DIR/$tfile O_jc || return 1
2578 #define OBD_FAIL_LDLM_REPLY 0x30c
2579 do_nodes $list $LCTL set_param fail_loc=0x8000030c
2581 echo "waiting for multiop $PID"
2582 wait $PID || return 2
2588 run_test 133 "don't fail on flock resend"
2591 check_and_cleanup_lustre