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 17a "timeout bulk get, don't evict client (2732)"
465 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
467 # get one of the clients from client list
468 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
469 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
470 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
471 [ -z "$ldlm_enqueue_min" ] &&
472 skip "missing /sys/.../ldlm_enqueue_min" && return 0
474 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
475 error "setstripe failed"
476 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
477 error "setstripe 2 failed"
479 save_lustre_params ost1 "at_history" > $p
480 save_lustre_params ost1 "bulk_timeout" >> $p
481 local dev="${FSNAME}-OST0000"
482 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
483 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
485 local new_at_history=15
487 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
488 do_facet ost1 "$LCTL set_param bulk_timeout=30"
489 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
491 # brw_size is required to be 4m so that bulk transfer timeout
492 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
493 local brw_size=$($LCTL get_param -n \
494 osc.$FSNAME-OST0000-osc-[^M]*.import |
495 awk '/max_brw_size/{print $2}')
496 if [ $brw_size -ne 4194304 ]
498 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
499 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
500 remount_client $MOUNT
503 # get service estimate expanded
504 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
505 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
506 echo "delay rpc servicing by 35 seconds"
507 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
510 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
511 awk '/portal 6/ {print $5}')
512 echo "service estimates increased to $estimate"
514 # let current worst service estimate to get closer to obliteration
515 sleep $((new_at_history / 3))
517 # start i/o and simulate bulk transfer loss
518 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
519 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
520 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
523 # start lock conflict handling
524 sleep $((new_at_history / 3))
525 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
528 # obliterate the worst service estimate
529 sleep $((new_at_history / 3 + 1))
530 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
532 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
533 awk '/portal 6/ {print $5}')
534 echo "service estimate dropped to $estimate"
537 [[ $? == 0 ]] || error "write failed"
539 [[ $? == 0 ]] || error "read failed"
541 restore_lustre_params <$p
542 if [ $brw_size -ne 4194304 ]
544 remount_client $MOUNT || error "remount_client failed"
546 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
548 run_test 17b "timeout bulk get, dont evict client (3582)"
551 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
553 do_facet_create_file client $TMP/$tfile 20K ||
554 { error_noexit "Create file $TMP/$tfile" ; return 0; }
556 do_facet client mkdir -p $DIR/$tdir
560 pgcache_empty || return 1
563 $LFS setstripe -i 1 -c 1 $f
564 stripe_index=$($LFS getstripe -i $f)
565 if [ $stripe_index -ne 1 ]; then
567 error "$f: stripe_index $stripe_index != 1" && return
570 do_facet client cp $TMP/$tfile $f
572 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
573 $LCTL --device $osc2dev deactivate || return 3
574 # my understanding is that there should be nothing in the page
575 # cache after the client reconnects?
577 pgcache_empty || rc=2
578 $LCTL --device $osc2dev activate
582 run_test 18a "manual ost invalidate clears page cache immediately"
585 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
587 do_facet_create_file client $TMP/$tfile 20K ||
588 { error_noexit "Create file $TMP/$tfile" ; return 0; }
590 do_facet client mkdir -p $DIR/$tdir
594 pgcache_empty || return 1
596 $LFS setstripe -i 0 -c 1 $f
597 stripe_index=$($LFS getstripe -i $f)
598 if [ $stripe_index -ne 0 ]; then
600 error "$f: stripe_index $stripe_index != 0" && return
603 do_facet client cp $TMP/$tfile $f
606 # allow recovery to complete
607 sleep $((TIMEOUT + 2))
608 # my understanding is that there should be nothing in the page
609 # cache after the client reconnects?
611 pgcache_empty || rc=2
615 run_test 18b "eviction and reconnect clears page cache (2766)"
618 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
620 do_facet_create_file client $TMP/$tfile 20K ||
621 { error_noexit "Create file $TMP/$tfile" ; return 0; }
623 do_facet client mkdir -p $DIR/$tdir
627 pgcache_empty || return 1
629 $LFS setstripe -i 0 -c 1 $f
630 stripe_index=$($LFS getstripe -i $f)
631 if [ $stripe_index -ne 0 ]; then
633 error "$f: stripe_index $stripe_index != 0" && return
636 do_facet client cp $TMP/$tfile $f
640 # OBD_FAIL_OST_CONNECT_NET2
641 # lost reply to connect request
642 do_facet ost1 lctl set_param fail_loc=0x80000225
645 $LFS df $MOUNT > /dev/null 2>&1
647 # my understanding is that there should be nothing in the page
648 # cache after the client reconnects?
650 pgcache_empty || rc=2
654 run_test 18c "Dropped connect reply after eviction handing (14755)"
657 local BEFORE=`date +%s`
660 mount_client $DIR2 || error "failed to mount $DIR2"
662 # cancel cached locks from OST to avoid eviction from it
665 do_facet client "stat $DIR > /dev/null" ||
666 error "failed to stat $DIR: $?"
667 drop_ldlm_cancel "chmod 0777 $DIR2" ||
668 error "failed to chmod $DIR2"
672 # let the client reconnect
674 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
675 awk -F"[ [,]" '/EVICTED ]$/ \
676 { if (mx<$5) {mx=$5;} } END { print mx }')
678 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
679 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
680 error "no eviction: $EVICT before:$BEFORE")
682 run_test 19a "test expired_lock_main on mds (2867)"
685 local BEFORE=`date +%s`
688 mount_client $DIR2 || error "failed to mount $DIR2: $?"
690 # cancel cached locks from MDT to avoid eviction from it
693 do_facet client $MULTIOP $DIR/$tfile Ow ||
694 error "failed to run multiop: $?"
695 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
696 error "failed to ldlm_cancel: $?"
698 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
699 do_facet client munlink $DIR/$tfile ||
700 error "failed to unlink $DIR/$tfile: $?"
702 # let the client reconnect
704 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
705 awk -F"[ [,]" '/EVICTED ]$/ \
706 { if (mx < $5) {mx = $5;} } END { print mx }')
708 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
709 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
710 error "no eviction: $EVICT before:$BEFORE")
712 run_test 19b "test expired_lock_main on ost (2867)"
715 local BEFORE=`date +%s`
718 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
720 mkdir -p $DIR1/$tfile
723 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
724 do_facet mds $LCTL set_param fail_loc=0x80000516
726 touch $DIR2/$tfile/file1 &
728 # let touch to get blocked on the server
732 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
735 # let the client reconnect
737 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
738 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
740 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
742 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
744 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
745 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
748 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
749 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
752 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
753 do_facet ost1 lctl set_param fail_loc=0x80000308
754 kill -USR1 $MULTI_PID
757 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
759 run_test 20a "ldlm_handle_enqueue error (should return error)"
761 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
762 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
765 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
767 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
768 do_facet ost1 lctl set_param fail_loc=0x80000308
769 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
770 error "didn't fail open enqueue" || true
772 run_test 20b "ldlm_handle_enqueue error (should return error)"
775 mkdir -p $DIR/$tdir-1
776 mkdir -p $DIR/$tdir-2
777 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
781 $MULTIOP $DIR/$tdir-2/f Oc &
784 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
786 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
787 kill -USR1 $close_pid
789 wait $close_pid || return 1
790 wait $open_pid || return 2
791 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
793 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
794 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
798 run_test 21a "drop close request while close and open are both in flight"
801 mkdir -p $DIR/$tdir-1
802 mkdir -p $DIR/$tdir-2
803 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
806 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
807 mcreate $DIR/$tdir-2/f &
810 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
812 kill -USR1 $close_pid
814 wait $close_pid || return 1
815 wait $open_pid || return 3
817 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
818 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
821 run_test 21b "drop open request while close and open are both in flight"
824 mkdir -p $DIR/$tdir-1
825 mkdir -p $DIR/$tdir-2
826 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
829 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
830 mcreate $DIR/$tdir-2/f &
833 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
835 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
836 kill -USR1 $close_pid
838 wait $close_pid || return 1
839 wait $open_pid || return 2
841 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
843 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
844 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
847 run_test 21c "drop both request while close and open are both in flight"
850 mkdir -p $DIR/$tdir-1
851 mkdir -p $DIR/$tdir-2
852 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
855 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
856 $MULTIOP $DIR/$tdir-2/f Oc &
858 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
860 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
863 wait $pid || return 1
864 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
866 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
867 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
871 run_test 21d "drop close reply while close and open are both in flight"
874 mkdir -p $DIR/$tdir-1
875 mkdir -p $DIR/$tdir-2
876 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
879 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
880 touch $DIR/$tdir-2/f &
882 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
886 wait $pid || return 1
889 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
890 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
893 run_test 21e "drop open reply while close and open are both in flight"
896 mkdir -p $DIR/$tdir-1
897 mkdir -p $DIR/$tdir-2
898 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
901 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
902 touch $DIR/$tdir-2/f &
904 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
906 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
909 wait $pid || return 1
910 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
912 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
913 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
916 run_test 21f "drop both reply while close and open are both in flight"
919 mkdir -p $DIR/$tdir-1
920 mkdir -p $DIR/$tdir-2
921 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
924 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
925 touch $DIR/$tdir-2/f &
927 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
929 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
932 wait $pid || return 1
933 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
935 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
936 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
939 run_test 21g "drop open reply and close request while close and open are both in flight"
942 mkdir -p $DIR/$tdir-1
943 mkdir -p $DIR/$tdir-2
944 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
947 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
948 touch $DIR/$tdir-2/f &
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
953 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
956 wait $pid || return 1
957 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
959 wait $touch_pid || return 2
961 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
962 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
965 run_test 21h "drop open request and close reply while close and open are both in flight"
967 # bug 3462 - multiple MDC requests
972 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
977 $MULTIOP $f1 msu || return 1
980 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
982 wait $close_pid || return 2
983 rm -rf $f2 || return 4
985 run_test 22 "drop close request and do mknod"
988 multiop_bg_pause $DIR/$tfile O_c || return 1
990 # give a chance for open
994 drop_request "kill -USR1 $pid"
997 wait $pid || return 1
1000 run_test 23 "client hang when close a file after mds crash"
1002 test_24a() { # bug 11710 details correct fsync() behavior
1003 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1006 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1007 cancel_lru_locks osc
1008 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1011 kill -USR1 $MULTI_PID
1014 lctl set_param fail_loc=0x0
1017 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1019 run_test 24a "fsync error (should return error)"
1021 wait_client_evicted () {
1024 local varsvc=${facet}_svc
1026 wait_update $(facet_active_host $facet) \
1027 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1032 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1034 dmesg -c > /dev/null
1036 lfs setstripe $DIR/$tdir -s 0 -i 0 -c 1
1037 cancel_lru_locks osc
1038 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1039 error "mulitop Ow8192_yc failed"
1042 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1043 error "mulitop Ow8192_c failed"
1048 kill -USR1 $MULTI_PID1
1051 kill -USR1 $MULTI_PID2
1054 lctl set_param fail_loc=0x0
1056 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1057 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1060 dmesg | grep "dirty page discard:" ||
1061 error "no discarded dirty page found!"
1063 run_test 24b "test dirty page discard due to client eviction"
1065 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1066 # this test can only run from a client on a separate node.
1067 remote_ost || { skip "local OST" && return 0; }
1068 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1069 remote_mds || { skip "local MDS" && return 0; }
1071 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1072 skip "msg and ost1 are at the same node"
1076 check_timeout || return 1
1078 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1080 echo starting with $OST_NEXP OST exports
1081 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1082 do_facet client lctl set_param fail_loc=0x505
1083 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1084 # But if there's a race to start the evictor from various obds,
1085 # the loser might have to wait for the next ping.
1088 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1090 do_facet client lctl set_param fail_loc=0x0
1091 [ $rc -eq 0 ] || error "client not evicted from OST"
1093 run_test 26a "evict dead exports"
1095 test_26b() { # bug 10140 - evict dead exports by pinger
1096 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1098 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1099 skip "msg and ost1 are at the same node"
1103 check_timeout || return 1
1105 zconf_mount `hostname` $MOUNT2 ||
1106 { error "Failed to mount $MOUNT2"; return 2; }
1107 sleep 1 # wait connections being established
1109 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1110 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1112 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1114 zconf_umount `hostname` $MOUNT2 -f
1116 # PING_INTERVAL max(obd_timeout / 4, 1U)
1117 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1119 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1120 # But if there's a race to start the evictor from various obds,
1121 # the loser might have to wait for the next ping.
1122 # = 9 * PING_INTERVAL + PING_INTERVAL
1123 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1124 # let's wait $((TIMEOUT * 3)) # bug 19887
1126 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1127 error "Client was not evicted by ost" rc=1
1128 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1129 error "Client was not evicted by mds"
1131 run_test 26b "evict dead exports"
1135 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1138 local save_FAILURE_MODE=$FAILURE_MODE
1140 facet_failover $SINGLEMDS
1141 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1142 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1143 # need to wait for reconnect
1144 echo waiting for fail_loc
1145 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1146 facet_failover $SINGLEMDS
1147 #no crashes allowed!
1148 kill -USR1 $CLIENT_PID
1151 FAILURE_MODE=$save_FAILURE_MODE
1153 run_test 27 "fail LOV while using OSC's"
1155 test_28() { # bug 6086 - error adding new clients
1156 do_facet client mcreate $DIR/$tfile || return 1
1157 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1158 echo "evicted as expected"
1159 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1160 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1161 # fail once (evicted), reconnect fail (fail_loc), ok
1162 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1164 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1166 run_test 28 "handle error adding new clients (bug 6086)"
1168 test_29a() { # bug 22273 - error adding new clients
1169 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1170 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1171 # fail abort so client will be new again
1172 fail_abort $SINGLEMDS
1173 client_up || error "reconnect failed"
1174 wait_osc_import_state $SINGLEMDS ost FULL
1177 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1179 test_29b() { # bug 22273 - error adding new clients
1180 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1181 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1182 # fail abort so client will be new again
1184 client_up || error "reconnect failed"
1187 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1191 # put a load of file creates/writes/deletes
1192 writemany -q $DIR/$tdir/$tfile 0 5 &
1194 echo writemany pid $CLIENT_PID
1198 # wait for client to reconnect to MDS
1203 # client process should see no problems even though MDS went down
1205 kill -USR1 $CLIENT_PID
1208 echo writemany returned $rc
1209 #these may fail because of eviction due to slow AST response.
1211 error_ignore bz13652 "writemany returned rc $rc" || true
1213 run_test 50 "failover MDS under load"
1216 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1217 do_facet ost1 lctl set_param fail_loc=0x00001310
1220 # put a load of file creates/writes/deletes
1221 writemany -q $DIR/$tdir/$tfile 0 5 &
1225 facet_failover $SINGLEMDS
1226 # failover at various points during recovery
1227 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1228 echo will failover at $SEQ
1231 #echo failover in $i sec
1232 log "test_$testnum: failover in $i sec"
1234 facet_failover $SINGLEMDS
1236 # client process should see no problems even though MDS went down
1237 # and recovery was interrupted
1239 kill -USR1 $CLIENT_PID
1242 echo writemany returned $rc
1244 error_ignore bz13652 "writemany returned rc $rc" || true
1246 run_test 51 "failover MDS during recovery"
1249 do_facet client "mkdir -p $DIR/$tdir"
1250 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1252 echo writemany pid $CLIENT_PID
1257 wait $CLIENT_PID || rc=$?
1258 # active client process should see an EIO for down OST
1259 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1260 # but timing or failover setup may allow success
1261 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1262 echo "writemany returned $rc"
1267 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1272 [ $rc -ne 0 ] && { return $rc; }
1273 # wait for client to reconnect to OST
1277 [ $rc -ne 0 ] && { return $rc; }
1284 run_test 52 "failover OST under load"
1286 # test of open reconstruct
1289 drop_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1292 run_test 53 "touch: drop rep"
1295 zconf_mount `hostname` $MOUNT2
1297 touch $DIR2/$tfile.1
1299 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1302 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1303 [ x"$ERROR" == x ] || error "back in time occured"
1305 run_test 54 "back in time"
1307 # bug 11330 - liblustre application death during I/O locks up OST
1309 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1313 # Minimum pass speed is 2MBps
1315 # LU-2887/LU-3089 - set min pass speed to 500KBps
1316 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1318 # first dd should be finished quickly
1319 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1320 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1323 echo "step1: testing ......"
1324 while kill -0 $DDPID 2> /dev/null; do
1326 if [ $count -gt $ddtimeout ]; then
1327 error "dd should be finished!"
1331 echo "(dd_pid=$DDPID, time=$count)successful"
1333 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1334 #define OBD_FAIL_OST_DROP_REQ 0x21d
1335 do_facet ost1 lctl set_param fail_loc=0x0000021d
1336 # second dd will be never finished
1337 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1340 echo "step2: testing ......"
1341 while [ $count -le $ddtimeout ]; do
1342 if ! kill -0 $DDPID 2> /dev/null; then
1344 error "dd shouldn't be finished! (time=$count)"
1349 echo "(dd_pid=$DDPID, time=$count)successful"
1351 #Recover fail_loc and dd will finish soon
1352 do_facet ost1 lctl set_param fail_loc=0
1354 echo "step3: testing ......"
1355 while kill -0 $DDPID 2> /dev/null; do
1357 if [ $count -gt $((ddtimeout + 440)) ]; then
1358 error "dd should be finished!"
1362 echo "(dd_pid=$DDPID, time=$count)successful"
1366 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1368 test_56() { # b=11277
1369 #define OBD_FAIL_MDS_RESEND 0x136
1371 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1372 stat $DIR/$tfile || error "stat failed"
1373 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1376 run_test 56 "do not fail on getattr resend"
1379 # no oscs means no client or mdt
1380 while lctl get_param osc.*.* > /dev/null 2>&1; do
1381 : # loop until proc file is removed
1385 test_57() { # bug 10866
1389 #define OBD_FAIL_LPROC_REMOVE 0xB00
1390 lctl set_param fail_loc=0x80000B00
1391 zconf_umount `hostname` $DIR
1392 lctl set_param fail_loc=0x80000B00
1393 fail_abort $SINGLEMDS
1395 lctl set_param fail_loc=0
1397 do_facet client "df $DIR"
1399 run_test 57 "read procfs entries causes kernel crash"
1401 test_58() { # bug 11546
1402 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1405 lctl set_param fail_loc=0x80000801
1406 cp $DIR/$tfile /dev/null &
1409 lctl set_param fail_loc=0
1410 drop_bl_callback_once rm -f $DIR/$tfile
1412 # the first 'df' could tigger the eviction caused by
1413 # 'drop_bl_callback_once', and it's normal case.
1414 # but the next 'df' should return successfully.
1415 do_facet client "df $DIR" || do_facet client "df $DIR"
1417 run_test 58 "Eviction in the middle of open RPC reply processing"
1419 test_59() { # bug 10589
1420 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1421 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1422 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1423 lctl set_param fail_loc=0x311
1424 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1425 [ $? = 0 ] || error "dd write failed"
1426 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1427 lctl set_param fail_loc=0
1429 zconf_umount `hostname` $MOUNT2 -f
1430 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1431 [ $? = 0 ] || error "dd read failed"
1432 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1433 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1435 run_test 59 "Read cancel race on client eviction"
1438 # we assume that all md changes are in the MDT0 changelog
1439 if [ $MDSCOUNT -gt 1 ]; then
1440 error_ignore bz17935 $*
1447 MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
1448 awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
1453 # Register (and start) changelog
1454 USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
1455 echo "Registered as $MDT0 changelog user $USER"
1457 # Generate a large number of changelog entries
1458 createmany -o $DIR/$tdir/$tfile $NUM_FILES
1462 # Unlink files in the background
1463 unlinkmany $DIR/$tdir/$tfile $NUM_FILES &
1467 # Failover the MDS while unlinks are happening
1468 facet_failover $SINGLEMDS
1470 # Wait for unlinkmany to finish
1473 # Check if all the create/unlink events were recorded
1475 $LFS changelog $MDT0 >> $DIR/$tdir/changelog
1476 local cl_count=$(grep UNLNK $DIR/$tdir/changelog | wc -l)
1477 echo "$cl_count unlinks in $MDT0 changelog"
1479 do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $USER
1480 USERS=$(( $(do_facet $SINGLEMDS lctl get_param -n \
1481 mdd.$MDT0.changelog_users | wc -l) - 2 ))
1482 if [ $USERS -eq 0 ]; then
1483 [ $cl_count -eq $NUM_FILES ] || \
1484 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1485 # Also make sure we can clear large changelogs
1486 cl_count=$($LFS changelog $FSNAME | wc -l)
1487 [ $cl_count -le 2 ] || \
1488 error "Changelog not empty: $cl_count entries"
1490 # If there are other users, there may be other unlinks in the log
1491 [ $cl_count -ge $NUM_FILES ] || \
1492 err17935 "Recorded ${cl_count} unlinks out of $NUM_FILES"
1493 echo "$USERS other changelog users; can't verify clear"
1496 run_test 60 "Add Changelog entries during MDS failover"
1500 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1501 mdtosc=${mdtosc/-MDT*/-MDT\*}
1502 local cflags="osc.$mdtosc.connect_flags"
1503 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1504 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1506 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1507 # Set the default stripe of $DIR/$tdir to put the files to ost1
1508 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1510 replay_barrier $SINGLEMDS
1511 createmany -o $DIR/$tdir/$tfile-%d 10
1512 local oid=$(do_facet ost1 "lctl get_param -n \
1513 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1515 fail_abort $SINGLEMDS
1517 touch $DIR/$tdir/$tfile
1518 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1519 awk '$1 == 0 { print $2 }')
1520 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1525 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1527 # test_62 as seen it b2_1 please do not reuse test_62
1530 # zconf_umount `hostname` $DIR
1531 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1532 # lctl set_param fail_loc=0x516
1535 #run_test 62 "Verify connection flags race - bug LU-1716"
1539 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1540 { skip "Need MDS version at least 2.7.51"; return 0; }
1542 local list=$(comma_list $(osts_nodes))
1544 # modify dir so that next revalidate would not obtain UPDATE lock
1547 # drop 1 reply with UPDATE lock
1548 mcreate $DIR/$tfile || error "mcreate failed: $?"
1549 drop_ldlm_reply_once "stat $DIR/$tfile" &
1552 # make the re-sent lock to sleep
1553 #define OBD_FAIL_MDS_RESEND 0x136
1554 do_nodes $list $LCTL set_param fail_loc=0x80000136
1556 #initiate the re-connect & re-send
1557 local mdccli=$($LCTL dl | awk '/-mdc-/ {print $4;}')
1558 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1559 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1562 #initiate the client eviction while enqueue re-send is in progress
1568 run_test 66 "lock enqueue re-send vs client eviction"
1573 #grant lock1, export2
1574 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1575 $MULTIOP $DIR2/$tfile Ow || return 2
1577 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1578 do_facet ost $LCTL set_param fail_loc=0x31e
1579 #get waiting lock2, export1
1580 $MULTIOP $DIR/$tfile Ow &
1582 # let enqueue to get asleep
1586 $MULTIOP $DIR2/$tfile Ow &
1594 do_facet ost $LCTL set_param fail_loc=0
1601 run_test 65 "lock enqueue for destroyed export"
1603 check_cli_ir_state()
1605 local NODE=${1:-$HOSTNAME}
1607 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1608 awk '/imperative_recovery:/ { print \\\$2}'")
1609 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1610 error "Error state $st, must be ENABLED or DISABLED"
1614 check_target_ir_state()
1617 local name=${target}_svc
1618 local recovery_proc=obdfilter.${!name}.recovery_status
1622 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1623 awk '/status:/{ print \\\$2}'")
1624 [ x$st = xRECOVERING ] || break
1626 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1627 awk '/IR:/{ print \\\$2}'")
1628 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1629 error "Error state $st, must be ENABLED or DISABLED"
1635 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1640 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1641 awk '/state:/{ print \\\$2 }'")
1645 nidtbl_version_mgs()
1647 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1648 awk '/nidtbl_version:/{ print \\\$2 }'")
1652 # nidtbl_version_client <mds1|client> [node]
1653 nidtbl_version_client()
1656 local node=${2:-$HOSTNAME}
1658 if [ X$cli = Xclient ]; then
1661 local obdtype=${cli/%[0-9]*/}
1662 [ $obdtype != mds ] && error "wrong parameters $cli"
1664 node=$(facet_active_host $cli)
1669 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1670 awk "/$cli/{print \$6}" |sort -u)
1672 # in case there are multiple mounts on the client node
1674 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1678 nidtbl_versions_match()
1680 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1683 target_instance_match()
1689 obdtype=${srv/%[0-9]*/}
1700 error "invalid target type" $srv
1705 local target=${srv}_svc
1706 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1707 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1708 awk '/instance/{ print $2 }' | head -n1)
1710 return $([ $si -eq $ci ])
1715 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1716 { skip "MGS without IR support"; return 0; }
1718 # MDT was just restarted in the previous test, make sure everything
1721 while [ $cnt -gt 0 ]; do
1722 nidtbl_versions_match && break
1728 set_ir_status disabled
1730 local prev_ver=$(nidtbl_version_client client)
1732 local saved_FAILURE_MODE=$FAILURE_MODE
1733 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1737 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1738 error "version must not change due to IR disabled"
1739 target_instance_match ost1 || error "instance mismatch"
1743 FAILURE_MODE=$saved_FAILURE_MODE
1745 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1749 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1750 { skip "MGS without IR support"; return 0; }
1754 local OST1_IMP=$(get_osc_import_name client ost1)
1756 # disable pinger recovery
1757 lctl set_param -n osc.$OST1_IMP.pinger_recov=0
1761 target_instance_match ost1 || error "instance mismatch"
1762 nidtbl_versions_match || error "version must match"
1764 lctl set_param -n osc.$OST1_IMP.pinger_recov=1
1766 run_test 101 "IR: Make sure IR works w/o normal recovery"
1770 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1771 { skip "MGS without IR support"; return 0; }
1773 local clients=${CLIENTS:-$HOSTNAME}
1780 # let's have a new nidtbl version
1783 # sleep for a while so that clients can see the failure of ost
1784 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1785 # int mgc_request.c:
1786 # define MGC_TIMEOUT_MIN_SECONDS 5
1787 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1788 local count=30 # 20 seconds at most
1789 while [ $count -gt 0 ]; do
1790 nidtbl_versions_match && break
1795 nidtbl_versions_match || error "nidtbl mismatch"
1798 old_version=$(nidtbl_version_client client)
1800 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1803 combined_mgs_mds && mgsdev=mds1
1804 remount_facet $mgsdev
1807 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1810 new_version=$(nidtbl_version_client client)
1811 [ $new_version -lt $old_version ] &&
1812 error "nidtbl version wrong after mgs restarts"
1815 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1819 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1820 { skip "MGS without IR support"; return 0; }
1822 combined_mgs_mds && skip "mgs and mds on the same target" && return 0
1824 # workaround solution to generate config log on the mds
1830 # We need this test because mds is like a client in IR context.
1831 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1832 error "MDS should start w/o mgs"
1834 # start mgs and remount mds w/ ir
1835 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1838 # remount client so that fsdb will be created on the MGS
1839 umount_client $MOUNT || error "umount failed"
1840 mount_client $MOUNT || error "mount failed"
1842 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1844 while [ $count -gt 0 ]; do
1845 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1850 # after a while, mds should be able to reconnect to mgs and fetch
1851 # up-to-date nidtbl version
1852 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1857 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1861 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1862 { skip "MGS without IR support"; return 0; }
1867 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1868 error "OST1 cannot start"
1871 local ir_state=$(check_target_ir_state ost1)
1872 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1873 error "ir status on ost1 should be DISABLED"
1875 run_test 104 "IR: ost can disable IR voluntarily"
1879 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1880 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1881 { skip "MGS without IR support"; return 0; }
1885 # get one of the clients from client list
1886 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1888 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1889 zconf_umount $rcli $MOUNT || error "umount failed"
1890 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1892 # make sure lustre mount at $rcli disabling IR
1893 local ir_state=$(check_cli_ir_state $rcli)
1894 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1895 error "IR state must be DISABLED at $rcli"
1897 # Since the client just mounted, its last_rcvd entry is not on disk.
1898 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1899 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1900 $SETSTRIPE -i 0 $DIR/$tfile
1901 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1903 # make sure MGS's state is Partial
1904 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1907 # make sure IR on ost1 is DISABLED
1908 local ir_state=$(check_target_ir_state ost1)
1909 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1910 error "IR status on ost1 should be DISABLED"
1912 # remount with the default MOUNT_OPTS
1913 zconf_umount $rcli $MOUNT || error "umount failed"
1914 zconf_mount $rcli $MOUNT || error "mount failed"
1916 # make sure MGS's state is full
1917 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1920 # make sure IR on ost1 is ENABLED
1921 local ir_state=$(check_target_ir_state ost1)
1922 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1923 error "IR status on ost1 should be ENABLED"
1927 run_test 105 "IR: NON IR clients support"
1935 test_106() { # LU-1789
1936 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1937 { skip "Need MDS version at least 2.3.50"; return 0; }
1939 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1940 $LCTL set_param fail_loc=0x805
1943 trap cleanup_106 EXIT
1945 # enable lightweight flag on mdc connection
1948 local MDS_NEXP=$(do_facet $SINGLEMDS \
1949 lctl get_param -n mdt.${mds1_svc}.num_exports |
1951 $LCTL set_param fail_loc=0
1953 touch $DIR2/$tfile || error "failed to create empty file"
1954 replay_barrier $SINGLEMDS
1956 $LCTL set_param debug=console
1958 facet_failover $SINGLEMDS
1960 # lightweight connection must be evicted
1961 touch -c $DIR2/$tfile || true
1962 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1963 evicted=`awk '/This client was evicted by .*MDT0000/ {
1965 }' $TMP/lustre-log-$TESTNAME.log`
1966 [ -z "$evicted" ] && error "lightweight client not evicted by mds"
1968 # and all operations performed by lightweight client should be
1969 # synchronous, so the file created before mds restart should be there
1970 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
1975 run_test 106 "lightweight connection support"
1982 # OBD_FAIL_MDS_REINT_NET_REP 0x119
1983 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1984 multiop $DIR/$tdir D_c &
1986 mkdir $DIR/$tdir/dir_106 &
1988 do_facet $SINGLEMDS lctl set_param fail_loc=0
1991 wait $CLIENT_PID || rc=$?
1992 checkstat -t dir $DIR/$tdir/dir_106 || return 1
1994 kill -USR1 $close_pid
1995 wait $close_pid || return 2
1999 run_test 107 "drop reint reply, then restart MDT"
2003 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
2005 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2013 client_up || error "reconnect failed"
2014 rm -f $DIR/$tdir/$tfile
2016 run_test 108 "client eviction don't crash"
2019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2020 local remote_dir=$DIR/$tdir/remote_dir
2024 #prepare for 110 test, which need set striped dir on remote MDT.
2025 for num in $(seq $MDSCOUNT); do
2027 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
2032 drop_request "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
2033 error "lfs mkdir failed"
2034 local diridx=$($GETSTRIPE -M $remote_dir)
2035 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2037 rm -rf $DIR/$tdir || error "rmdir failed"
2039 run_test 110a "create remote directory: drop client req"
2042 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2043 local remote_dir=$DIR/$tdir/remote_dir
2047 drop_reint_reply "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
2048 error "lfs mkdir failed"
2050 diridx=$($GETSTRIPE -M $remote_dir)
2051 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2053 rm -rf $DIR/$tdir || error "rmdir failed"
2055 run_test 110b "create remote directory: drop Master rep"
2058 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2059 local remote_dir=$DIR/$tdir/remote_dir
2063 drop_update_reply $MDTIDX "$LFS mkdir -i $MDTIDX -c2 $remote_dir" ||
2064 error "lfs mkdir failed"
2066 diridx=$($GETSTRIPE -M $remote_dir)
2067 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2069 rm -rf $DIR/$tdir || error "rmdir failed"
2071 run_test 110c "create remote directory: drop update rep on slave MDT"
2074 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2075 local remote_dir=$DIR/$tdir/remote_dir
2079 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2081 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2083 rm -rf $DIR/$tdir || error "rmdir failed"
2087 run_test 110d "remove remote directory: drop client req"
2090 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2091 local remote_dir=$DIR/$tdir/remote_dir
2095 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2096 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2098 rm -rf $DIR/$tdir || error "rmdir failed"
2102 run_test 110e "remove remote directory: drop master rep"
2105 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2106 local remote_dir=$DIR/$tdir/remote_dir
2110 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2111 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2112 error "rm remote dir failed"
2114 rm -rf $DIR/$tdir || error "rmdir failed"
2116 run_test 110f "remove remote directory: drop slave rep"
2119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2120 local remote_dir=$DIR/$tdir/remote_dir
2123 mkdir -p $remote_dir
2125 createmany -o $remote_dir/f 100
2127 #define OBD_FAIL_MIGRATE_NET_REP 0x1800
2128 do_facet mds$MDTIDX lctl set_param fail_loc=0x1800
2129 $LFS migrate -m $MDTIDX $remote_dir || error "migrate failed"
2130 do_facet mds$MDTIDX lctl set_param fail_loc=0x0
2132 for file in $(find $remote_dir); do
2133 mdt_index=$($LFS getstripe -M $file)
2134 [ $mdt_index == $MDTIDX ] ||
2135 error "$file is not on MDT${MDTIDX}"
2138 rm -rf $DIR/$tdir || error "rmdir failed"
2140 run_test 110g "drop reply during migration"
2143 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2144 local src_dir=$DIR/$tdir/source_dir
2145 local tgt_dir=$DIR/$tdir/target_dir
2149 $LFS mkdir -i $MDTIDX $tgt_dir
2151 dd if=/etc/hosts of=$src_dir/src_file
2152 touch $tgt_dir/tgt_file
2153 drop_update_reply $MDTIDX \
2154 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2155 error "mrename failed"
2157 $CHECKSTAT -t file $src_dir/src_file &&
2158 error "src_file present after rename"
2160 diff /etc/hosts $tgt_dir/tgt_file ||
2161 error "file changed after rename"
2164 run_test 110h "drop update reply during cross-MDT file rename"
2167 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2168 local src_dir=$DIR/$tdir/source_dir
2169 local tgt_dir=$DIR/$tdir/target_dir
2173 $LFS mkdir -i $MDTIDX $tgt_dir
2175 mkdir $src_dir/src_dir
2176 touch $src_dir/src_dir/a
2177 mkdir $tgt_dir/tgt_dir
2178 drop_update_reply $MDTIDX \
2179 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2180 error "mrename failed"
2182 $CHECKSTAT -t dir $src_dir/src_dir &&
2183 error "src_dir present after rename"
2185 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2186 error "tgt_dir not present after rename"
2188 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2189 error "a not present after rename"
2191 run_test 110i "drop update reply during cross-MDT dir rename"
2194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2195 local remote_dir=$DIR/$tdir/remote_dir
2196 local local_dir=$DIR/$tdir/local_dir
2200 mkdir $DIR/$tdir/local_dir
2201 $LFS mkdir -i $MDTIDX $remote_dir
2203 touch $local_dir/local_file
2204 drop_update_reply $MDTIDX \
2205 "ln $local_dir/local_file $remote_dir/remote_file" ||
2208 $CHECKSTAT -t file $remote_dir/remote_file ||
2209 error "remote not present after ln"
2211 run_test 110j "drop update reply during cross-MDT ln"
2213 # LU-2844 mdt prepare fail should not cause umount oops
2216 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2217 { skip "Need MDS version at least 2.3.62"; return 0; }
2219 local mdsdev=$(mdsdevname ${SINGLEMDS//mds/})
2220 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2221 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2222 stop $SINGLEMDS || error "stop MDS failed"
2223 start $SINGLEMDS $mdsdev && error "start MDS should fail"
2224 do_facet $SINGLEMDS lctl set_param fail_loc=0
2225 start $SINGLEMDS $mdsdev || error "start MDS failed"
2227 run_test 111 "mdd setup fail should not cause umount oops"
2231 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2233 do_facet_random_file client $TMP/$tfile 100K ||
2234 error_noexit "Create random file $TMP/$tfile"
2236 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2237 error_noexit "Can't pause_bulk copy"
2240 # expect cmp to succeed, client resent bulk
2241 cmp $TMP/$tfile $DIR/$tfile ||
2242 error_noexit "Wrong data has been written"
2244 error_noexit "Can't remove file"
2247 run_test 112a "bulk resend while orignal request is in progress"
2254 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2255 cancel_lru_locks osc
2258 $LCTL set_param fail_loc=$fail1 fail_val=3
2259 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2263 set_nodes_failloc "$(osts_nodes)" $fail2
2265 wait $pid || error "dd failed"
2273 local fail_val2=${4:-0}
2279 $LCTL set_param fail_loc=$fail1 fail_val=4
2280 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2285 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2289 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2290 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2295 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2296 skip "need at least 2.8.50 on OST" && return 0
2298 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2299 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2300 test_115_read 0x8000051b 0x8000051a
2302 run_test 115a "read: late REQ MDunlink and no bulk"
2305 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2306 skip "need at least 2.8.50 on OST" && return 0
2308 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2309 #define OBD_FAIL_OST_ENOSPC 0x215
2311 # pass $OSTCOUNT for the fail_loc to be caught
2312 # appropriately by the IO thread
2313 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2315 run_test 115b "write: late REQ MDunlink and no bulk"
2318 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2319 skip "need at least 2.8.50 on OST" && return 0
2321 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2322 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2323 test_115_read 0x8000050f 0x8000051a
2325 run_test 115c "read: late Reply MDunlink and no bulk"
2328 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2329 skip "need at least 2.8.50 on OST" && return 0
2331 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2332 #define OBD_FAIL_OST_ENOSPC 0x215
2333 test_115_write 0x8000050f 0x80000215 0
2335 run_test 115d "write: late Reply MDunlink and no bulk"
2338 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2339 skip "need at least 2.8.50 on OST" && return 0
2341 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2342 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2343 test_115_read 0x80000510 0x80000211
2345 run_test 115e "read: late Bulk MDunlink and no reply"
2348 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2349 skip "need at least 2.8.50 on OST" && return 0
2351 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2352 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2353 test_115_read 0x8000051b 0x80000211
2355 run_test 115f "read: late REQ MDunlink and no reply"
2358 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2359 skip "need at least 2.8.50 on OST" && return 0
2361 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2362 test_115_read 0x8000051c 0
2364 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2366 # parameters: fail_loc CMD RC
2373 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2374 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2375 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2376 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2379 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2380 [ "$1" = "CLEANUP" ] &&
2381 fail=0x80000320 && echo ", $1 cp first"
2382 [ "$1" = "REPLY" ] &&
2383 fail=0x80000321 && echo ", $1 cp first"
2384 [ "$1" = "DEADLOCK CLEANUP" ] &&
2385 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2386 [ "$1" = "DEADLOCK REPLY" ] &&
2387 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2389 if [ x"$2" = x"get" ]; then
2390 #for TEST lock, take a conflict in advance
2391 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2392 echo "** Taking conflict **"
2393 flocks_test 5 set read sleep 10 $DIR/$tfile &
2399 $LCTL set_param fail_loc=$fail
2401 flocks_test 5 $2 write $DIR/$tfile &
2405 echo "** Evicting and re-connecting client **"
2410 if [ x"$2" = x"get" ]; then
2417 # check if the return value is allowed
2418 [ $rc -eq $3 ] && rc=0
2420 $LCTL set_param fail_loc=0
2424 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2425 # the ORIGINAL lock.
2430 flocks_test 5 set write sleep 4 $DIR/$tfile &
2434 # let unlock to sleep in CP CB
2435 $LCTL set_param fail_loc=$1
2438 # let cleanup to cleep in CP CB
2446 $LCTL set_param fail_loc=0
2451 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2454 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2455 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2456 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2458 test_120_reply "REPLY" set 5 || error "SET race failed"
2459 test_120_reply "REPLY" get 5 || error "GET race failed"
2460 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2463 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2464 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2466 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2468 run_test 120 "flock race: completion vs. evict"
2471 local BEFORE=$(date +%s)
2474 # modify dir so that next revalidate would not obtain UPDATE lock
2477 # drop 1 reply with UPDATE lock,
2478 # resend should not create 2nd lock on server
2479 mcreate $DIR/$tfile || error "mcreate failed: $?"
2480 drop_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2482 # 2 BL AST will be sent to client, both must find the same lock,
2483 # race them to not get EINVAL for 2nd BL AST
2484 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2485 $LCTL set_param fail_loc=0x8000031f
2487 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2488 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2489 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2491 # let the client reconnect
2493 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2494 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2496 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2498 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2502 test_mkdir -p $DIR/$tdir
2504 # Prevent interference from layout intent RPCs due to
2505 # asynchronous writeback. These will be tested in 130c below.
2506 do_nodes ${CLIENTS:-$HOSTNAME} sync
2508 # get only LOOKUP lock on $tdir
2509 cancel_lru_locks mdc
2510 ls $DIR/$tdir/$tfile 2>/dev/null
2512 # get getattr by fid on $tdir
2514 # we need to race with unlink, unlink must complete before we will
2515 # take a DLM lock, otherwise unlink will wait until getattr will
2516 # complete; but later than getattr starts so that getattr found
2518 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2519 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2526 # drop the reply so that resend happens on an unlinked file.
2527 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2528 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2532 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2535 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2538 run_test 130a "enqueue resend on not existing file"
2541 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2543 # let the reply to be dropped
2546 #define OBD_FAIL_SRV_ENOENT 0x217
2547 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2549 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2552 run_test 130b "enqueue resend on a stale inode"
2555 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2557 do_nodes ${CLIENTS:-$HOSTNAME} sync
2558 echo XXX > $DIR/$tfile
2560 cancel_lru_locks mdc
2562 # Trigger writeback on $tfile.
2564 # we need to race with unlink, unlink must complete before we will
2565 # take a DLM lock, otherwise unlink will wait until intent will
2566 # complete; but later than intent starts so that intent found
2568 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2569 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2576 # drop the reply so that resend happens on an unlinked file.
2577 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2578 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2580 # let the reply to be dropped
2583 #define OBD_FAIL_SRV_ENOENT 0x217
2584 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2590 run_test 130c "layout intent resend on a stale inode"
2593 local before=$(date +%s)
2596 mount_client $MOUNT2 || error "mount filed"
2599 # get a lock on client so that export would reach the stale list
2600 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2601 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2604 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2605 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2607 $TRUNCATE $DIR/$tfile 100 &
2610 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2614 umount_client $MOUNT2
2616 evict=$(do_facet client $LCTL get_param \
2617 osc.$FSNAME-OST0000-osc-*/state |
2618 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2620 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2621 (do_facet client $LCTL get_param \
2622 osc.$FSNAME-OST0000-osc-*/state;
2623 error "eviction happened: $evict before:$before")
2625 run_test 132 "long punch"
2628 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2631 # get a lock on client so that export would reach the stale list
2632 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2633 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2635 # another IO under the same lock
2636 #define OBD_FAIL_OSC_DELAY_IO 0x414
2637 $LCTL set_param fail_loc=0x80000414
2638 $LCTL set_param fail_val=4 fail_loc=0x80000414
2639 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2643 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2644 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2648 wait $pid && error "dd succeeded"
2651 run_test 131 "IO vs evict results to IO under staled lock"
2654 local list=$(comma_list $(mdts_nodes))
2656 local t=$((TIMEOUT * 2))
2659 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2661 multiop_bg_pause $DIR/$tfile O_jc || return 1
2664 #define OBD_FAIL_LDLM_REPLY 0x30c
2665 do_nodes $list $LCTL set_param fail_loc=0x8000030c
2667 echo "waiting for multiop $PID"
2668 wait $PID || return 2
2674 run_test 133 "don't fail on flock resend"
2682 [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return 0
2683 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.59) ]] &&
2684 skip "Need MDS version at least 2.8.59" && return
2686 test_mkdir -p $DIR/$tdir
2687 file1="$DIR/$tdir/file1"
2688 file2="$DIR/$tdir/file2"
2690 #define OBD_FAIL_MDS_OSP_PRECREATE_WAIT 0x164
2691 # reserve stripe on ost1, block on ost2
2692 do_facet $SINGLEMDS \
2693 "lctl set_param fail_loc=0x80000164 fail_val=1"
2694 $SETSTRIPE -c 2 -o 0,1 $file1 &
2698 # initiate recovery with orphan cleanup on ost1
2701 # when OST1 recovery is over, the first setstripe should still
2702 # have the object reserved, but that should not block new creates
2704 $SETSTRIPE -c 1 -o 0 $file2 &
2706 for ((i=0;i<$((TIMEOUT/2));i++)); do
2707 if ! stat /proc/$pid2 >&/dev/null; then
2714 if let "i >= (TIMEOUT/2)"; then
2715 error "create seem to get blocked by recovery"
2721 run_test 134 "MDT<>OST recovery don't block multistripe file creation"
2724 check_and_cleanup_lustre