5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
11 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT "
15 require_dsh_mds || exit 0
17 # Allow us to override the setup if we already have a mounted system by
18 # setting SETUP=" " and CLEANUP=" "
20 CLEANUP=${CLEANUP:-""}
22 check_and_setup_lustre
25 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
28 local f1="$DIR/$tfile"
29 local f2="$DIR/$tfile.2"
31 drop_request "mcreate $f1" ||
32 error_noexit "create '$f1': drop req"
34 drop_reint_reply "mcreate $f2" ||
35 error_noexit "create '$f2': drop rep"
37 drop_request "tchmod 111 $f2" ||
38 error_noexit "chmod '$f2': drop req"
40 drop_reint_reply "tchmod 666 $f2" ||
41 error_noexit "chmod '$f2': drop rep"
43 drop_request "statone $f2" ||
44 error_noexit "stat '$f2': drop req"
46 drop_reply "statone $f2" ||
47 error_noexit "stat '$f2': drop rep"
49 run_test 1 "create, chmod, stat: drop req, drop rep"
53 do_facet_create_file client $t 10K ||
54 error_noexit "Create file $t"
56 drop_request "cat $t > /dev/null" ||
57 error_noexit "Open request for $t file"
59 drop_reply "cat $t > /dev/null" ||
60 error_noexit "Open replay for $t file"
62 run_test 4 "open: drop req, drop rep"
67 local RR="$T-renamed-again"
68 do_facet_create_file client $T 10K ||
69 error_noexit "Create file $T"
71 drop_request "mv $T $R" ||
72 error_noexit "Rename $T"
74 drop_reint_reply "mv $R $RR" ||
75 error_noexit "Failed rename replay on $R"
77 do_facet client "checkstat -v $RR" ||
78 error_noexit "checkstat error on $RR"
80 do_facet client "rm $RR" ||
81 error_noexit "Can't remove file $RR"
83 run_test 5 "rename: drop req, drop rep"
87 local LINK1=$DIR/$tfile.link1
88 local LINK2=$DIR/$tfile.link2
90 do_facet_create_file client $T 10K ||
91 error_noexit "Create file $T"
93 drop_request "mlink $T $LINK1" ||
94 error_noexit "mlink request for $T"
96 drop_reint_reply "mlink $T $LINK2" ||
97 error_noexit "mlink reply for $T"
99 drop_request "munlink $LINK1" ||
100 error_noexit "munlink request for $T"
102 drop_reint_reply "munlink $LINK2" ||
103 error_noexit "munlink reply for $T"
105 do_facet client "rm $T" ||
106 error_noexit "Can't remove file $T"
108 run_test 6 "link, unlink: drop req, drop rep"
112 drop_reint_reply "touch $DIR/$tfile" || return 1
114 run_test 8 "touch: drop rep (bug 1423)"
118 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
122 do_facet_random_file client $TMP/$tfile 1K ||
123 error_noexit "Create random file $TMP/$tfile"
124 # make this big, else test 9 doesn't wait for bulk -- bz 5595
125 do_facet_create_file client $TMP/$t1 4M ||
126 error_noexit "Create file $TMP/$t1"
127 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
128 error_noexit "Can't copy to $DIR/$t1 file"
129 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
130 error_noexit "Can't pause_bulk copy"
131 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
132 error_noexit "Can't copy file"
133 do_facet client "sync"
134 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
135 error_noexit "Can't remove files"
136 do_facet client "rm $TMP/$t1 $TMP/$tfile"
138 run_test 9 "pause bulk on OST (bug 1420)"
142 local before=$(date +%s)
145 do_facet client "stat $DIR > /dev/null" ||
146 error "failed to stat $DIR: $?"
147 drop_bl_callback "chmod 0777 $DIR" ||
148 error "failed to chmod $DIR: $?"
150 # let the client reconnect
152 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
153 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
154 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
155 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
156 error "no eviction: $evict before:$before")
158 do_facet client checkstat -v -p 0777 $DIR ||
159 error "client checkstat failed: $?"
161 run_test 10a "finish request on server after client eviction (bug 1521)"
164 local before=$(date +%s)
167 [[ "$MDS1_VERSION" -lt $(version_code 2.6.53) ]] &&
168 skip "Need MDS version at least 2.6.53"
169 do_facet client "stat $DIR > /dev/null" ||
170 error "failed to stat $DIR: $?"
171 drop_bl_callback_once "chmod 0777 $DIR" ||
172 error "failed to chmod $DIR: $?"
174 # let the client reconnect
176 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
177 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
179 [ -z "$evict" ] || [[ $evict -le $before ]] ||
180 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
181 error "eviction happened: $evict before:$before")
183 do_facet client checkstat -v -p 0777 $DIR ||
184 error "client checkstat failed: $?"
186 run_test 10b "re-send BL AST"
189 local before=$(date +%s)
198 workdir="${DIR}/${tdir}"
199 mkdir -p ${workdir} || error "can't create workdir $?"
200 stat ${workdir} > /dev/null ||
201 error "failed to stat ${workdir}: $?"
202 mdtidx=$($LFS getdirstripe -i ${workdir})
203 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
204 awk '{sub("_UUID", "", $2); print $2;}')
206 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
207 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
208 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
210 drop_bl_callback_once "chmod 0777 ${workdir}" &
215 # force client reconnect
216 $LCTL set_param "${mdcpath}"
218 # wait client reconnect
222 evict=$($LCTL get_param mdc.${mdccli}.state |
223 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
225 [[ $evict -le $before ]] ||
226 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
227 error "eviction happened: $EVICT before:$BEFORE" )
229 [ $rc -eq 0 ] || error "chmod must finished OK"
230 checkstat -v -p 0777 "${workdir}" ||
231 error "client checkstat failed: $?"
233 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
236 local before=$(date +%s)
239 [[ "$MDS1_VERSION" -lt $(version_code 2.6.90) ]] &&
240 skip "Need MDS version at least 2.6.90"
242 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
245 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
247 remount_client $MOUNT
251 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
252 echo -n hello | dd of=$DIR1/$tfile bs=5
254 stat $DIR2/$tfile >& /dev/null
255 $LCTL set_param fail_err=71
256 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
261 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
262 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
264 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
266 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
268 [[ $evict -gt $before ]] ||
269 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
270 error "no eviction: $evict before:$before")
272 $LCTL set_param fail_err=0
274 umount_client $MOUNT2
276 run_test 10d "test failed blocking ast"
280 [[ "$OST1_VERSION" -le $(version_code 2.8.58) ]] &&
281 skip "Need OST version at least 2.8.59"
282 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients"
283 [ $(facet_host client) == $(facet_host ost1) ] &&
284 skip "need ost1 and client on different nodes"
285 local -a clients=(${CLIENTS//,/ })
286 local client1=${clients[0]}
287 local client2=${clients[1]}
289 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
290 $MULTIOP $DIR/$tfile-1 Ow1048576c
292 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
293 $LCTL set_param fail_loc=0x80000305
295 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
296 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
297 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
298 # 1. to return ENOTCONN from ldlm_handle_enqueue0
299 # 2. to pause reconnect handling between resend and setting
300 # import to LUSTRE_IMP_FULL state
301 do_facet ost1 "$LCTL set_param fail_val=3"
303 # client1 fails ro respond to bl ast
304 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
307 # ost1 returns error on enqueue, which causes client1 to reconnect
308 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
309 error "multiop failed"
312 do_facet ost1 "$LCTL set_param fail_loc=0"
313 do_facet ost1 "$LCTL set_param fail_val=0"
315 run_test 10e "re-send BL AST vs reconnect race 2"
318 # wake up a thread waiting for completion after eviction
320 do_facet client $MULTIOP $DIR/$tfile Ow ||
321 { error "multiop write failed: $?"; return 1; }
322 do_facet client $MULTIOP $DIR/$tfile or ||
323 { error "multiop read failed: $?"; return 2; }
327 do_facet client $MULTIOP $DIR/$tfile or ||
328 { error "multiop read failed: $?"; return 3; }
329 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
330 echo "evicted as expected"
332 do_facet client munlink $DIR/$tfile ||
333 { error "munlink failed: $?"; return 4; }
334 # allow recovery to complete
335 client_up || client_up || sleep $TIMEOUT
337 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
341 $LCTL mark $MULTIOP $DIR/$tfile OS_c
342 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
343 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
344 multiop_bg_pause $DIR/$tfile OS_c ||
345 { error "multiop failed: $?"; return 1; }
347 #define OBD_FAIL_MDS_CLOSE_NET 0x115
349 echo "waiting for multiop $PID"
350 wait $PID || { error "wait for multiop faile: $?"; return 2; }
351 do_facet client munlink $DIR/$tfile ||
352 { error "client munlink failed: $?"; return 3; }
353 # allow recovery to complete
354 client_up || client_up || sleep $TIMEOUT
356 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
358 # Bug 113, check that readdir lost recv timeout works.
360 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
361 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
362 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
363 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
364 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
365 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
366 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
368 run_test 13 "mdc_readpage restart test (bug 1138)"
370 # Bug 113, check that readdir lost send timeout works.
373 touch $DIR/$tdir/newentry
374 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
375 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
376 ls $DIR/$tdir || return 1
377 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
379 run_test 14 "mdc_readpage resend test (bug 1138)"
382 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
383 touch $DIR/$tfile && return 1
386 run_test 15 "failed open (-ENOMEM)"
388 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
390 lctl set_param -n llite.*.max_read_ahead_mb 0
394 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
398 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
400 do_facet_random_file client $TMP/$tfile 100K ||
401 { error_noexit "Create random file $TMP/$T" ; return 0; }
402 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
403 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
407 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
408 do_facet ost1 "lctl set_param fail_loc=0x80000504"
410 # OST bulk will time out here, client resends
411 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
412 do_facet ost1 lctl set_param fail_loc=0
413 # give recovery a chance to finish (shouldn't take long)
415 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
419 run_test 16 "timeout bulk put, don't evict client (2732)"
424 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
426 local SAMPLE_FILE=$TMP/$tfile
427 do_facet_random_file client $SAMPLE_FILE 20K ||
428 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
430 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
431 if at_is_enabled; then
432 at_max_saved=$(at_max_get ost1)
433 at_max_set $TIMEOUT ost1
436 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
437 # OST bulk will time out here, client retries
438 do_facet ost1 lctl set_param fail_loc=0x80000503
439 # need to ensure we send an RPC
440 do_facet client cp $SAMPLE_FILE $DIR/$tfile
443 # with AT, client will wait adaptive_max*factor+net_latency before
444 # expiring the req, hopefully timeout*2 is enough
445 sleep $(($TIMEOUT*2))
447 do_facet ost1 lctl set_param fail_loc=0
448 do_facet client "df $DIR"
449 # expect cmp to succeed, client resent bulk
450 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
451 do_facet client "rm $DIR/$tfile" || return 4
452 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
455 run_test 17a "timeout bulk get, don't evict client (2732)"
458 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
460 # get one of the clients from client list
461 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
462 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
463 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
464 [ -z "$ldlm_enqueue_min" ] &&
465 skip "missing /sys/.../ldlm_enqueue_min" && return 0
467 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
468 error "setstripe failed"
469 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
470 error "setstripe 2 failed"
472 save_lustre_params ost1 "at_history" > $p
473 save_lustre_params ost1 "bulk_timeout" >> $p
474 local dev="${FSNAME}-OST0000"
475 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
476 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
478 local new_at_history=15
480 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
481 do_facet ost1 "$LCTL set_param bulk_timeout=30"
482 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
484 # brw_size is required to be 4m so that bulk transfer timeout
485 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
486 local brw_size=$($LCTL get_param -n \
487 osc.$FSNAME-OST0000-osc-[^M]*.import |
488 awk '/max_brw_size/{print $2}')
489 if [ $brw_size -ne 4194304 ]
491 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
492 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
493 remount_client $MOUNT
496 # get service estimate expanded
497 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
498 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
499 echo "delay rpc servicing by 35 seconds"
500 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
503 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
504 awk '/portal 6/ {print $5}')
505 echo "service estimates increased to $estimate"
507 # let current worst service estimate to get closer to obliteration
508 sleep $((new_at_history / 3))
510 # start i/o and simulate bulk transfer loss
511 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
512 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
513 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
516 # start lock conflict handling
517 sleep $((new_at_history / 3))
518 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
521 # obliterate the worst service estimate
522 sleep $((new_at_history / 3 + 1))
523 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
525 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
526 awk '/portal 6/ {print $5}')
527 echo "service estimate dropped to $estimate"
530 [[ $? == 0 ]] || error "write failed"
532 [[ $? == 0 ]] || error "read failed"
534 restore_lustre_params <$p
535 if [ $brw_size -ne 4194304 ]
537 remount_client $MOUNT || error "remount_client failed"
539 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
541 run_test 17b "timeout bulk get, dont evict client (3582)"
544 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
546 do_facet_create_file client $TMP/$tfile 20K ||
547 { error_noexit "Create file $TMP/$tfile" ; return 0; }
549 do_facet client mkdir -p $DIR/$tdir
553 pgcache_empty || return 1
556 $LFS setstripe -i 1 -c 1 $f
557 stripe_index=$($LFS getstripe -i $f)
558 if [ $stripe_index -ne 1 ]; then
560 error "$f: stripe_index $stripe_index != 1" && return
563 do_facet client cp $TMP/$tfile $f
565 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
566 $LCTL --device $osc2dev deactivate || return 3
567 # my understanding is that there should be nothing in the page
568 # cache after the client reconnects?
570 pgcache_empty || rc=2
571 $LCTL --device $osc2dev activate
575 run_test 18a "manual ost invalidate clears page cache immediately"
578 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
580 do_facet_create_file client $TMP/$tfile 20K ||
581 { error_noexit "Create file $TMP/$tfile" ; return 0; }
583 do_facet client mkdir -p $DIR/$tdir
587 pgcache_empty || return 1
589 $LFS setstripe -i 0 -c 1 $f
590 stripe_index=$($LFS getstripe -i $f)
591 if [ $stripe_index -ne 0 ]; then
593 error "$f: stripe_index $stripe_index != 0" && return
596 do_facet client cp $TMP/$tfile $f
599 # allow recovery to complete
600 sleep $((TIMEOUT + 2))
601 # my understanding is that there should be nothing in the page
602 # cache after the client reconnects?
604 pgcache_empty || rc=2
608 run_test 18b "eviction and reconnect clears page cache (2766)"
611 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
613 do_facet_create_file client $TMP/$tfile 20K ||
614 { error_noexit "Create file $TMP/$tfile" ; return 0; }
616 do_facet client mkdir -p $DIR/$tdir
620 pgcache_empty || return 1
622 $LFS setstripe -i 0 -c 1 $f
623 stripe_index=$($LFS getstripe -i $f)
624 if [ $stripe_index -ne 0 ]; then
626 error "$f: stripe_index $stripe_index != 0" && return
629 do_facet client cp $TMP/$tfile $f
633 # OBD_FAIL_OST_CONNECT_NET2
634 # lost reply to connect request
635 do_facet ost1 lctl set_param fail_loc=0x80000225
638 $LFS df $MOUNT > /dev/null 2>&1
640 # my understanding is that there should be nothing in the page
641 # cache after the client reconnects?
643 pgcache_empty || rc=2
647 run_test 18c "Dropped connect reply after eviction handing (14755)"
650 local BEFORE=`date +%s`
653 mount_client $DIR2 || error "failed to mount $DIR2"
655 # cancel cached locks from OST to avoid eviction from it
658 do_facet client "stat $DIR > /dev/null" ||
659 error "failed to stat $DIR: $?"
660 drop_ldlm_cancel "chmod 0777 $DIR2" ||
661 error "failed to chmod $DIR2"
665 # let the client reconnect
667 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
668 awk -F"[ [,]" '/EVICTED ]$/ \
669 { if (mx<$5) {mx=$5;} } END { print mx }')
671 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
672 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
673 error "no eviction: $EVICT before:$BEFORE")
675 run_test 19a "test expired_lock_main on mds (2867)"
678 local BEFORE=`date +%s`
681 mount_client $DIR2 || error "failed to mount $DIR2: $?"
683 # cancel cached locks from MDT to avoid eviction from it
686 do_facet client $MULTIOP $DIR/$tfile Ow ||
687 error "failed to run multiop: $?"
688 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
689 error "failed to ldlm_cancel: $?"
691 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
692 do_facet client munlink $DIR/$tfile ||
693 error "failed to unlink $DIR/$tfile: $?"
695 # let the client reconnect
697 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
698 awk -F"[ [,]" '/EVICTED ]$/ \
699 { if (mx < $5) {mx = $5;} } END { print mx }')
701 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
702 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
703 error "no eviction: $EVICT before:$BEFORE")
705 run_test 19b "test expired_lock_main on ost (2867)"
708 local BEFORE=`date +%s`
711 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
713 mkdir -p $DIR1/$tfile
716 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
717 do_facet mds $LCTL set_param fail_loc=0x80000516
719 touch $DIR2/$tfile/file1 &
721 # let touch to get blocked on the server
725 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
728 # let the client reconnect
730 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
731 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
733 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
735 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
737 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
738 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
741 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
742 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
745 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
746 do_facet ost1 lctl set_param fail_loc=0x80000308
747 kill -USR1 $MULTI_PID
750 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
752 run_test 20a "ldlm_handle_enqueue error (should return error)"
754 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
755 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
758 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
760 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
761 do_facet ost1 lctl set_param fail_loc=0x80000308
762 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
763 error "didn't fail open enqueue" || true
765 run_test 20b "ldlm_handle_enqueue error (should return error)"
768 mkdir -p $DIR/$tdir-1
769 mkdir -p $DIR/$tdir-2
770 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
773 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
774 $MULTIOP $DIR/$tdir-2/f Oc &
777 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
779 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
780 kill -USR1 $close_pid
782 wait $close_pid || return 1
783 wait $open_pid || return 2
784 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
786 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
787 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
791 run_test 21a "drop close request while close and open are both in flight"
794 mkdir -p $DIR/$tdir-1
795 mkdir -p $DIR/$tdir-2
796 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
799 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
800 mcreate $DIR/$tdir-2/f &
803 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
805 kill -USR1 $close_pid
807 wait $close_pid || return 1
808 wait $open_pid || return 3
810 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
811 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
814 run_test 21b "drop open request while close and open are both in flight"
817 mkdir -p $DIR/$tdir-1
818 mkdir -p $DIR/$tdir-2
819 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
822 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
823 mcreate $DIR/$tdir-2/f &
826 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
828 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
829 kill -USR1 $close_pid
831 wait $close_pid || return 1
832 wait $open_pid || return 2
834 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
836 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
837 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
840 run_test 21c "drop both request while close and open are both in flight"
843 mkdir -p $DIR/$tdir-1
844 mkdir -p $DIR/$tdir-2
845 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
848 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
849 $MULTIOP $DIR/$tdir-2/f Oc &
851 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
853 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
856 wait $pid || return 1
857 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
859 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
860 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
864 run_test 21d "drop close reply while close and open are both in flight"
867 mkdir -p $DIR/$tdir-1
868 mkdir -p $DIR/$tdir-2
869 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
872 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
873 touch $DIR/$tdir-2/f &
875 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
879 wait $pid || return 1
882 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
883 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
886 run_test 21e "drop open reply while close and open are both in flight"
889 mkdir -p $DIR/$tdir-1
890 mkdir -p $DIR/$tdir-2
891 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
894 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
895 touch $DIR/$tdir-2/f &
897 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
899 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
902 wait $pid || return 1
903 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
905 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
906 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
909 run_test 21f "drop both reply while close and open are both in flight"
912 mkdir -p $DIR/$tdir-1
913 mkdir -p $DIR/$tdir-2
914 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
917 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
918 touch $DIR/$tdir-2/f &
920 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
922 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
925 wait $pid || return 1
926 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
928 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
929 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
932 run_test 21g "drop open reply and close request while close and open are both in flight"
935 mkdir -p $DIR/$tdir-1
936 mkdir -p $DIR/$tdir-2
937 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
940 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
941 touch $DIR/$tdir-2/f &
944 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
946 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
949 wait $pid || return 1
950 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
952 wait $touch_pid || return 2
954 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
955 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
958 run_test 21h "drop open request and close reply while close and open are both in flight"
960 # bug 3462 - multiple MDC requests
965 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
970 $MULTIOP $f1 msu || return 1
973 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
975 wait $close_pid || return 2
976 rm -rf $f2 || return 4
978 run_test 22 "drop close request and do mknod"
981 multiop_bg_pause $DIR/$tfile O_c || return 1
983 # give a chance for open
987 drop_request "kill -USR1 $pid"
990 wait $pid || return 1
993 run_test 23 "client hang when close a file after mds crash"
995 test_24a() { # bug 11710 details correct fsync() behavior
996 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
999 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1000 cancel_lru_locks osc
1001 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1004 kill -USR1 $MULTI_PID
1007 lctl set_param fail_loc=0x0
1010 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1012 run_test 24a "fsync error (should return error)"
1014 wait_client_evicted () {
1017 local varsvc=${facet}_svc
1019 wait_update $(facet_active_host $facet) \
1020 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1025 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1027 dmesg -c > /dev/null
1029 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1030 error "$LFS setstripe failed"
1031 cancel_lru_locks osc
1032 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1033 error "mulitop Ow8192_yc failed"
1036 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1037 error "mulitop Ow8192_c failed"
1042 kill -USR1 $MULTI_PID1
1045 kill -USR1 $MULTI_PID2
1048 lctl set_param fail_loc=0x0
1050 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1051 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1054 dmesg | grep "dirty page discard:" ||
1055 error "no discarded dirty page found!"
1057 run_test 24b "test dirty page discard due to client eviction"
1059 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1060 # this test can only run from a client on a separate node.
1061 remote_ost || { skip "local OST" && return 0; }
1062 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1063 remote_mds || { skip "local MDS" && return 0; }
1065 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1066 skip "msg and ost1 are at the same node"
1070 check_timeout || return 1
1072 # make sure all imports are connected and not IDLE
1073 do_facet client lfs df > /dev/null
1074 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1075 do_facet client lctl set_param fail_loc=0x505
1076 local before=$(date +%s)
1079 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1080 # But if there's a race to start the evictor from various obds,
1081 # the loser might have to wait for the next ping.
1082 sleep $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1083 do_facet client lctl set_param fail_loc=0x0
1084 do_facet client lfs df > /dev/null
1086 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1087 check_clients_evicted $before ${oscs[@]}
1088 check_clients_full 10 ${oscs[@]}
1090 run_test 26a "evict dead exports"
1092 test_26b() { # bug 10140 - evict dead exports by pinger
1093 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1095 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1096 skip "msg and ost1 are at the same node"
1100 check_timeout || return 1
1102 zconf_mount `hostname` $MOUNT2 ||
1103 { error "Failed to mount $MOUNT2"; return 2; }
1104 sleep 1 # wait connections being established
1106 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1107 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1109 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1111 zconf_umount `hostname` $MOUNT2 -f
1113 # PING_INTERVAL max(obd_timeout / 4, 1U)
1114 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1116 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1117 # But if there's a race to start the evictor from various obds,
1118 # the loser might have to wait for the next ping.
1119 # = 9 * PING_INTERVAL + PING_INTERVAL
1120 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1121 # let's wait $((TIMEOUT * 3)) # bug 19887
1122 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) ||
1123 error "Client was not evicted by ost"
1124 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) ||
1125 error "Client was not evicted by mds"
1127 run_test 26b "evict dead exports"
1131 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1134 local save_FAILURE_MODE=$FAILURE_MODE
1136 facet_failover $SINGLEMDS
1137 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1138 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1139 # need to wait for reconnect
1140 echo waiting for fail_loc
1141 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1142 facet_failover $SINGLEMDS
1143 #no crashes allowed!
1144 kill -USR1 $CLIENT_PID
1147 FAILURE_MODE=$save_FAILURE_MODE
1149 run_test 27 "fail LOV while using OSC's"
1151 test_28() { # bug 6086 - error adding new clients
1152 do_facet client mcreate $DIR/$tfile || return 1
1153 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1154 echo "evicted as expected"
1155 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1156 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1157 # fail once (evicted), reconnect fail (fail_loc), ok
1158 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1160 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1162 run_test 28 "handle error adding new clients (bug 6086)"
1164 test_29a() { # bug 22273 - error adding new clients
1165 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1166 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1167 # fail abort so client will be new again
1168 fail_abort $SINGLEMDS
1169 client_up || error "reconnect failed"
1170 wait_osc_import_state $SINGLEMDS ost FULL
1173 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1175 test_29b() { # bug 22273 - error adding new clients
1176 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1177 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1178 # fail abort so client will be new again
1180 client_up || error "reconnect failed"
1183 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1187 # put a load of file creates/writes/deletes
1188 writemany -q $DIR/$tdir/$tfile 0 5 &
1190 echo writemany pid $CLIENT_PID
1194 # wait for client to reconnect to MDS
1199 # client process should see no problems even though MDS went down
1201 kill -USR1 $CLIENT_PID
1204 echo writemany returned $rc
1205 #these may fail because of eviction due to slow AST response.
1207 error_ignore bz13652 "writemany returned rc $rc" || true
1209 run_test 50 "failover MDS under load"
1212 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1213 do_facet ost1 lctl set_param fail_loc=0x00001310
1216 # put a load of file creates/writes/deletes
1217 writemany -q $DIR/$tdir/$tfile 0 5 &
1221 facet_failover $SINGLEMDS
1222 # failover at various points during recovery
1223 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1224 echo will failover at $SEQ
1227 #echo failover in $i sec
1228 log "$TESTNAME: failover in $i sec"
1230 facet_failover $SINGLEMDS
1232 # client process should see no problems even though MDS went down
1233 # and recovery was interrupted
1235 kill -USR1 $CLIENT_PID
1238 echo writemany returned $rc
1240 error_ignore bz13652 "writemany returned rc $rc" || true
1242 run_test 51 "failover MDS during recovery"
1245 do_facet client "mkdir -p $DIR/$tdir"
1246 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1248 echo writemany pid $CLIENT_PID
1253 wait $CLIENT_PID || rc=$?
1254 # active client process should see an EIO for down OST
1255 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1256 # but timing or failover setup may allow success
1257 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1258 echo "writemany returned $rc"
1263 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1268 [ $rc -ne 0 ] && { return $rc; }
1269 # wait for client to reconnect to OST
1273 [ $rc -ne 0 ] && { return $rc; }
1280 run_test 52 "failover OST under load"
1282 # test of open reconstruct
1285 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1288 run_test 53 "touch: drop rep"
1291 zconf_mount $(hostname) $MOUNT2
1293 touch $DIR2/$tfile.1
1295 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1298 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1299 grep "went back in time")
1300 [ x"$ERROR" == x ] || error "back in time occured"
1302 run_test 54 "back in time"
1304 # bug 11330 - liblustre application death during I/O locks up OST
1306 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1310 # This test assumes relatively small max_dirty_mb setting
1311 # which we want to walk away from, so just for it we will
1312 # temporarily lower the value
1313 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1314 lctl set_param -n osc.*.max_dirty_mb=32
1315 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1317 # Minimum pass speed is 2MBps
1319 # LU-2887/LU-3089 - set min pass speed to 500KBps
1320 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1322 # first dd should be finished quickly
1323 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1324 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1327 echo "step1: testing ......"
1328 while kill -0 $DDPID 2> /dev/null; do
1330 if [ $count -gt $ddtimeout ]; then
1331 error "dd should be finished!"
1335 echo "(dd_pid=$DDPID, time=$count)successful"
1337 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1338 #define OBD_FAIL_OST_DROP_REQ 0x21d
1339 do_facet ost1 lctl set_param fail_loc=0x0000021d
1340 # second dd will be never finished
1341 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1344 echo "step2: testing ......"
1345 while [ $count -le $ddtimeout ]; do
1346 if ! kill -0 $DDPID 2> /dev/null; then
1348 error "dd shouldn't be finished! (time=$count)"
1353 echo "(dd_pid=$DDPID, time=$count)successful"
1355 #Recover fail_loc and dd will finish soon
1356 do_facet ost1 lctl set_param fail_loc=0
1358 echo "step3: testing ......"
1359 while kill -0 $DDPID 2> /dev/null; do
1361 if [ $count -gt $((ddtimeout + 440)) ]; then
1362 error "dd should be finished!"
1366 echo "(dd_pid=$DDPID, time=$count)successful"
1370 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1372 test_56() { # b=11277
1373 #define OBD_FAIL_MDS_RESEND 0x136
1375 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1376 stat $DIR/$tfile || error "stat failed"
1377 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1380 run_test 56 "do not fail on getattr resend"
1383 # no oscs means no client or mdt
1384 while lctl get_param osc.*.* > /dev/null 2>&1; do
1385 : # loop until proc file is removed
1389 test_57() { # bug 10866
1393 #define OBD_FAIL_LPROC_REMOVE 0xB00
1394 lctl set_param fail_loc=0x80000B00
1395 zconf_umount `hostname` $DIR
1396 lctl set_param fail_loc=0x80000B00
1397 fail_abort $SINGLEMDS
1399 lctl set_param fail_loc=0
1401 do_facet client "df $DIR"
1403 run_test 57 "read procfs entries causes kernel crash"
1405 test_58() { # bug 11546
1406 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1409 lctl set_param fail_loc=0x80000801
1410 cp $DIR/$tfile /dev/null &
1413 lctl set_param fail_loc=0
1414 drop_bl_callback_once rm -f $DIR/$tfile
1416 # the first 'df' could tigger the eviction caused by
1417 # 'drop_bl_callback_once', and it's normal case.
1418 # but the next 'df' should return successfully.
1419 do_facet client "df $DIR" || do_facet client "df $DIR"
1421 run_test 58 "Eviction in the middle of open RPC reply processing"
1423 test_59() { # bug 10589
1424 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1425 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1426 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1427 lctl set_param fail_loc=0x311
1428 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1429 [ $? = 0 ] || error "dd write failed"
1430 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1431 lctl set_param fail_loc=0
1433 zconf_umount `hostname` $MOUNT2 -f
1434 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1435 [ $? = 0 ] || error "dd read failed"
1436 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1437 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1439 run_test 59 "Read cancel race on client eviction"
1442 local num_files=${COUNT:-5000}
1443 test_mkdir $DIR/$tdir
1445 # Register (and start) changelog
1446 changelog_register || error "changelog_register failed"
1448 # Generate a large number of changelog entries
1449 createmany -o $DIR/$tdir/$tfile $num_files
1453 # Unlink files in the background
1454 unlinkmany $DIR/$tdir/$tfile $num_files &
1458 # Failover the MDS while unlinks are happening
1459 facet_failover $SINGLEMDS
1461 # Wait for unlinkmany to finish
1464 # Check if all the create/unlink events were recorded
1466 local cl_count=$(changelog_dump | grep -c UNLNK)
1467 echo "$cl_count unlinks in changelog"
1469 changelog_deregister || error "changelog_deregister failed"
1470 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1471 [ $cl_count -eq $num_files ] ||
1472 error "Recorded $cl_count of $num_files unlinks"
1473 # Also make sure we can clear large changelogs
1474 cl_count=$(changelog_dump | wc -l)
1475 [ $cl_count -le 2 ] ||
1476 error "Changelog not empty: $cl_count entries"
1477 else # If other users, there may be other unlinks in the log
1478 [ $cl_count -ge $num_files ] ||
1479 error "Recorded $cl_count of $num_files unlinks"
1480 changelog_users $SINGLEMDS
1481 echo "other changelog users; can't verify clear"
1484 run_test 60 "Add Changelog entries during MDS failover"
1488 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1489 mdtosc=${mdtosc/-MDT*/-MDT\*}
1490 local cflags="osc.$mdtosc.connect_flags"
1491 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1492 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1494 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1495 # Set the default stripe of $DIR/$tdir to put the files to ost1
1496 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1498 replay_barrier $SINGLEMDS
1499 createmany -o $DIR/$tdir/$tfile-%d 10
1500 local oid=$(do_facet ost1 "lctl get_param -n \
1501 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1503 fail_abort $SINGLEMDS
1505 touch $DIR/$tdir/$tfile
1506 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1507 awk '$1 == 0 { print $2 }')
1508 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1513 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1515 # test_62 as seen it b2_1 please do not reuse test_62
1518 # zconf_umount `hostname` $DIR
1519 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1520 # lctl set_param fail_loc=0x516
1523 #run_test 62 "Verify connection flags race - bug LU-1716"
1528 #grant lock1, export2
1529 $LFS setstripe -i -0 $DIR2/$tfile || error "setstripe failed"
1530 $MULTIOP $DIR2/$tfile Ow || error "multiop failed"
1532 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1533 do_facet ost $LCTL set_param fail_loc=0x31e
1534 #get waiting lock2, export1
1535 $MULTIOP $DIR/$tfile Ow &
1537 # let enqueue to get asleep
1541 $MULTIOP $DIR2/$tfile Ow &
1549 do_facet ost $LCTL set_param fail_loc=0
1556 run_test 65 "lock enqueue for destroyed export"
1560 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1561 skip "Need MDS version at least 2.7.51"
1563 local list=$(comma_list $(osts_nodes))
1565 # modify dir so that next revalidate would not obtain UPDATE lock
1568 # drop 1 reply with UPDATE lock
1569 mcreate $DIR/$tfile || error "mcreate failed: $?"
1570 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1573 # make the re-sent lock to sleep
1574 #define OBD_FAIL_MDS_RESEND 0x136
1575 do_nodes $list $LCTL set_param fail_loc=0x80000136
1577 #initiate the re-connect & re-send
1578 local mdtname="MDT0000"
1579 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1580 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1581 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1584 #initiate the client eviction while enqueue re-send is in progress
1590 run_test 66 "lock enqueue re-send vs client eviction"
1594 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1595 $LCTL set_param fail_loc=0x80000531
1597 local mdtname="MDT0000"
1598 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1599 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1600 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1609 run_test 67 "connect vs import invalidate race"
1611 check_cli_ir_state()
1613 local NODE=${1:-$HOSTNAME}
1615 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1616 awk '/imperative_recovery:/ { print \\\$2}'")
1617 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1618 error "Error state $st, must be ENABLED or DISABLED"
1622 check_target_ir_state()
1625 local name=${target}_svc
1626 local recovery_proc=obdfilter.${!name}.recovery_status
1630 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1631 awk '/status:/{ print \\\$2}'")
1632 [ x$st = xRECOVERING ] || break
1634 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1635 awk '/IR:/{ print \\\$2}'")
1636 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1637 error "Error state $st, must be ENABLED or DISABLED"
1643 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1648 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1649 awk '/state:/{ print \\\$2 }'")
1653 nidtbl_version_mgs()
1655 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1656 awk '/nidtbl_version:/{ print \\\$2 }'")
1660 # nidtbl_version_client <mds1|client> [node]
1661 nidtbl_version_client()
1664 local node=${2:-$HOSTNAME}
1666 if [ X$cli = Xclient ]; then
1669 local obdtype=${cli/%[0-9]*/}
1670 [ $obdtype != mds ] && error "wrong parameters $cli"
1672 node=$(facet_active_host $cli)
1677 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1678 awk "/$cli/{print \$6}" |sort -u)
1680 # in case there are multiple mounts on the client node
1682 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1686 nidtbl_versions_match()
1688 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1691 target_instance_match()
1697 obdtype=${srv/%[0-9]*/}
1708 error "invalid target type" $srv
1713 local target=${srv}_svc
1714 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1715 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1716 awk '/instance/{ print $2 }' | head -n1)
1718 return $([ $si -eq $ci ])
1723 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1724 { skip "MGS without IR support"; return 0; }
1726 # MDT was just restarted in the previous test, make sure everything
1729 while [ $cnt -gt 0 ]; do
1730 nidtbl_versions_match && break
1736 set_ir_status disabled
1738 local prev_ver=$(nidtbl_version_client client)
1740 local saved_FAILURE_MODE=$FAILURE_MODE
1741 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1745 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1746 error "version must not change due to IR disabled"
1747 target_instance_match ost1 || error "instance mismatch"
1751 FAILURE_MODE=$saved_FAILURE_MODE
1753 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1757 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1758 skip "MGS without IR support"
1762 local ost1_imp=$(get_osc_import_name client ost1)
1764 # disable pinger recovery
1765 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1766 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1770 target_instance_match ost1 || error "instance mismatch"
1771 nidtbl_versions_match || error "version must match"
1773 run_test 101a "IR: Make sure IR works w/o normal recovery"
1777 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1778 skip "MGS without IR support"
1782 local ost1_imp=$(get_osc_import_name client ost1)
1784 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1785 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1786 # disable pinger recovery
1787 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1788 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1790 #OST may return EAGAIN if it is not configured yet
1793 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1797 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1798 { skip "MGS without IR support"; return 0; }
1800 local clients=${CLIENTS:-$HOSTNAME}
1807 # let's have a new nidtbl version
1810 # sleep for a while so that clients can see the failure of ost
1811 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1812 # int mgc_request.c:
1813 # define MGC_TIMEOUT_MIN_SECONDS 5
1814 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1815 local count=30 # 20 seconds at most
1816 while [ $count -gt 0 ]; do
1817 nidtbl_versions_match && break
1822 nidtbl_versions_match || error "nidtbl mismatch"
1825 old_version=$(nidtbl_version_client client)
1827 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1830 combined_mgs_mds && mgsdev=mds1
1831 remount_facet $mgsdev
1834 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1837 new_version=$(nidtbl_version_client client)
1838 [ $new_version -lt $old_version ] &&
1839 error "nidtbl version wrong after mgs restarts"
1842 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1846 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1847 { skip "MGS without IR support"; return 0; }
1849 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1851 # workaround solution to generate config log on the mds
1857 # We need this test because mds is like a client in IR context.
1858 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1859 error "MDS should start w/o mgs"
1861 # start mgs and remount mds w/ ir
1862 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1865 # remount client so that fsdb will be created on the MGS
1866 umount_client $MOUNT || error "umount failed"
1867 mount_client $MOUNT || error "mount failed"
1869 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1871 while [ $count -gt 0 ]; do
1872 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1877 # after a while, mds should be able to reconnect to mgs and fetch
1878 # up-to-date nidtbl version
1879 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1884 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1888 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1889 { skip "MGS without IR support"; return 0; }
1894 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1895 error "OST1 cannot start"
1898 local ir_state=$(check_target_ir_state ost1)
1899 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1900 error "ir status on ost1 should be DISABLED"
1902 run_test 104 "IR: ost can disable IR voluntarily"
1906 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1907 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1908 { skip "MGS without IR support"; return 0; }
1912 # get one of the clients from client list
1913 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1915 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1916 zconf_umount $rcli $MOUNT || error "umount failed"
1917 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1919 # make sure lustre mount at $rcli disabling IR
1920 local ir_state=$(check_cli_ir_state $rcli)
1921 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1922 error "IR state must be DISABLED at $rcli"
1924 # Since the client just mounted, its last_rcvd entry is not on disk.
1925 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1926 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1927 $LFS setstripe -i 0 $DIR/$tfile
1928 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1930 # make sure MGS's state is Partial
1931 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1934 # make sure IR on ost1 is DISABLED
1935 local ir_state=$(check_target_ir_state ost1)
1936 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1937 error "IR status on ost1 should be DISABLED"
1939 # remount with the default MOUNT_OPTS
1940 zconf_umount $rcli $MOUNT || error "umount failed"
1941 zconf_mount $rcli $MOUNT || error "mount failed"
1943 # make sure MGS's state is full
1944 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1947 # make sure IR on ost1 is ENABLED
1948 local ir_state=$(check_target_ir_state ost1)
1949 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1950 error "IR status on ost1 should be ENABLED"
1954 run_test 105 "IR: NON IR clients support"
1962 test_106() { # LU-1789
1963 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1964 skip "Need MDS version at least 2.3.50"
1966 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1967 $LCTL set_param fail_loc=0x805
1970 trap cleanup_106 EXIT
1972 # enable lightweight flag on mdc connection
1975 local MDS_NEXP=$(do_facet $SINGLEMDS \
1976 lctl get_param -n mdt.${mds1_svc}.num_exports |
1978 $LCTL set_param fail_loc=0
1980 touch $DIR2/$tfile || error "failed to create empty file"
1981 replay_barrier $SINGLEMDS
1983 $LCTL set_param debug=ha
1985 facet_failover $SINGLEMDS
1987 # lightweight goes through LUSTRE_IMP_RECOVER during failover
1988 touch -c $DIR2/$tfile || true
1989 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1990 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
1991 $TMP/lustre-log-$TESTNAME.log)
1992 [ -z "$recovered" ] && error "lightweight client was not recovered"
1994 # and all operations performed by lightweight client should be
1995 # synchronous, so the file created before mds restart should be there
1996 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2001 run_test 106 "lightweight connection support"
2008 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2009 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2010 multiop $DIR/$tdir D_c &
2012 mkdir $DIR/$tdir/dir_106 &
2014 do_facet $SINGLEMDS lctl set_param fail_loc=0
2017 wait $CLIENT_PID || rc=$?
2018 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2020 kill -USR1 $close_pid
2021 wait $close_pid || return 2
2025 run_test 107 "drop reint reply, then restart MDT"
2029 $LFS setstripe -c 1 -i 0 $DIR/$tdir
2031 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2039 client_up || error "reconnect failed"
2040 rm -f $DIR/$tdir/$tfile
2042 run_test 108 "client eviction don't crash"
2045 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2046 local remote_dir=$DIR/$tdir/remote_dir
2050 #prepare for 110 test, which need set striped dir on remote MDT.
2051 for num in $(seq $MDSCOUNT); do
2053 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2058 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2059 error "lfs mkdir failed"
2060 local diridx=$($LFS getstripe -m $remote_dir)
2061 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2063 rm -rf $DIR/$tdir || error "rmdir failed"
2065 run_test 110a "create remote directory: drop client req"
2068 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2069 local remote_dir=$DIR/$tdir/remote_dir
2073 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2074 error "lfs mkdir failed"
2076 diridx=$($LFS getstripe -m $remote_dir)
2077 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2079 rm -rf $DIR/$tdir || error "rmdir failed"
2081 run_test 110b "create remote directory: drop Master rep"
2084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2085 local remote_dir=$DIR/$tdir/remote_dir
2089 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2090 error "lfs mkdir failed"
2092 diridx=$($LFS getstripe -m $remote_dir)
2093 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2095 rm -rf $DIR/$tdir || error "rmdir failed"
2097 run_test 110c "create remote directory: drop update rep on slave MDT"
2100 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2101 local remote_dir=$DIR/$tdir/remote_dir
2105 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2107 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2109 rm -rf $DIR/$tdir || error "rmdir failed"
2113 run_test 110d "remove remote directory: drop client req"
2116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2117 local remote_dir=$DIR/$tdir/remote_dir
2121 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2122 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2124 rm -rf $DIR/$tdir || error "rmdir failed"
2128 run_test 110e "remove remote directory: drop master rep"
2131 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2132 local remote_dir=$DIR/$tdir/remote_dir
2136 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2137 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2138 error "rm remote dir failed"
2140 rm -rf $DIR/$tdir || error "rmdir failed"
2142 run_test 110f "remove remote directory: drop slave rep"
2145 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2146 skip "Need MDS version at least 2.11.0"
2148 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2151 touch $DIR/$tdir/$tfile
2153 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2154 do_facet mds1 $LCTL set_param fail_loc=0x119
2155 $LFS migrate -m 1 $DIR/$tdir &
2158 do_facet mds1 $LCTL set_param fail_loc=0
2162 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2163 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2164 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2165 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2167 rm -rf $DIR/$tdir || error "rmdir failed"
2169 run_test 110g "drop reply during migration"
2172 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2173 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2174 skip "Need MDS version at least 2.7.56"
2176 local src_dir=$DIR/$tdir/source_dir
2177 local tgt_dir=$DIR/$tdir/target_dir
2181 $LFS mkdir -i $MDTIDX $tgt_dir
2183 dd if=/etc/hosts of=$src_dir/src_file
2184 touch $tgt_dir/tgt_file
2185 drop_update_reply $MDTIDX \
2186 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2187 error "mrename failed"
2189 $CHECKSTAT -t file $src_dir/src_file &&
2190 error "src_file present after rename"
2192 diff /etc/hosts $tgt_dir/tgt_file ||
2193 error "file changed after rename"
2196 run_test 110h "drop update reply during cross-MDT file rename"
2199 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2200 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2201 skip "Need MDS version at least 2.7.56"
2203 local src_dir=$DIR/$tdir/source_dir
2204 local tgt_dir=$DIR/$tdir/target_dir
2208 $LFS mkdir -i $MDTIDX $tgt_dir
2210 mkdir $src_dir/src_dir
2211 touch $src_dir/src_dir/a
2212 mkdir $tgt_dir/tgt_dir
2213 drop_update_reply $MDTIDX \
2214 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2215 error "mrename failed"
2217 $CHECKSTAT -t dir $src_dir/src_dir &&
2218 error "src_dir present after rename"
2220 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2221 error "tgt_dir not present after rename"
2223 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2224 error "a not present after rename"
2226 run_test 110i "drop update reply during cross-MDT dir rename"
2229 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2230 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2231 skip "Need MDS version at least 2.7.56"
2233 local remote_dir=$DIR/$tdir/remote_dir
2234 local local_dir=$DIR/$tdir/local_dir
2238 mkdir $DIR/$tdir/local_dir
2239 $LFS mkdir -i $MDTIDX $remote_dir
2241 touch $local_dir/local_file
2242 drop_update_reply $MDTIDX \
2243 "ln $local_dir/local_file $remote_dir/remote_file" ||
2246 $CHECKSTAT -t file $remote_dir/remote_file ||
2247 error "remote not present after ln"
2249 run_test 110j "drop update reply during cross-MDT ln"
2252 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2253 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2254 skip "Need MDS version at least 2.12.55"
2256 stop mds2 || error "stop mds2 failed"
2259 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2260 do_facet mds2 lctl set_param fail_loc=0x1103
2261 local OPTS="$MDS_MOUNT_OPTS -o abort_recovery"
2262 start mds2 $(mdsdevname 2) $OPTS ||
2263 error "start MDS with abort_recovery should succeed"
2264 do_facet mds2 lctl set_param fail_loc=0
2267 stop mds2 || error "cleanup: stop mds2 failed"
2268 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS ||
2269 error "cleanup: start mds2 failed"
2270 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2271 client_up || error "post-failover df failed"
2273 run_test 110k "FID_QUERY failed during recovery"
2275 # LU-2844 mdt prepare fail should not cause umount oops
2278 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2279 skip "Need MDS version at least 2.3.62"
2281 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2282 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2283 stop $SINGLEMDS || error "stop MDS failed"
2284 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS &&
2285 error "start MDS should fail"
2286 do_facet $SINGLEMDS lctl set_param fail_loc=0
2287 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2288 error "start MDS failed"
2290 run_test 111 "mdd setup fail should not cause umount oops"
2294 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2296 do_facet_random_file client $TMP/$tfile 100K ||
2297 error_noexit "Create random file $TMP/$tfile"
2299 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2300 error_noexit "Can't pause_bulk copy"
2303 # expect cmp to succeed, client resent bulk
2304 cmp $TMP/$tfile $DIR/$tfile ||
2305 error_noexit "Wrong data has been written"
2307 error_noexit "Can't remove file"
2310 run_test 112a "bulk resend while orignal request is in progress"
2317 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2318 cancel_lru_locks osc
2321 $LCTL set_param fail_loc=$fail1 fail_val=3
2322 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2326 set_nodes_failloc "$(osts_nodes)" $fail2
2328 wait $pid || error "dd failed"
2336 local fail_val2=${4:-0}
2342 $LCTL set_param fail_loc=$fail1 fail_val=4
2343 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2348 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2352 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2353 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2358 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2359 skip "need at least 2.8.50 on OST"
2361 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2362 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2363 test_115_read 0x8000051b 0x8000051a
2365 run_test 115a "read: late REQ MDunlink and no bulk"
2368 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2369 skip "need at least 2.8.50 on OST"
2371 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2372 #define OBD_FAIL_OST_ENOSPC 0x215
2374 # pass $OSTCOUNT for the fail_loc to be caught
2375 # appropriately by the IO thread
2376 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2378 run_test 115b "write: late REQ MDunlink and no bulk"
2381 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2382 skip "need at least 2.8.50 on OST"
2384 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2385 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2386 test_115_read 0x8000050f 0x8000051a
2388 run_test 115c "read: late Reply MDunlink and no bulk"
2391 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2392 skip "need at least 2.8.50 on OST"
2394 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2395 #define OBD_FAIL_OST_ENOSPC 0x215
2396 test_115_write 0x8000050f 0x80000215 0
2398 run_test 115d "write: late Reply MDunlink and no bulk"
2401 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2402 skip "need at least 2.8.50 on OST"
2404 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2405 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2406 test_115_read 0x80000510 0x80000211
2408 run_test 115e "read: late Bulk MDunlink and no reply"
2411 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2412 skip "need at least 2.8.50 on OST"
2414 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2415 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2416 test_115_read 0x8000051b 0x80000211
2418 run_test 115f "read: late REQ MDunlink and no reply"
2421 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2422 skip "need at least 2.8.50 on OST"
2424 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2425 test_115_read 0x8000051c 0
2427 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2429 # parameters: fail_loc CMD RC
2436 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2437 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2438 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2439 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2442 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2443 [ "$1" = "CLEANUP" ] &&
2444 fail=0x80000320 && echo ", $1 cp first"
2445 [ "$1" = "REPLY" ] &&
2446 fail=0x80000321 && echo ", $1 cp first"
2447 [ "$1" = "DEADLOCK CLEANUP" ] &&
2448 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2449 [ "$1" = "DEADLOCK REPLY" ] &&
2450 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2452 if [ x"$2" = x"get" ]; then
2453 #for TEST lock, take a conflict in advance
2454 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2455 echo "** Taking conflict **"
2456 flocks_test 5 set read sleep 10 $DIR/$tfile &
2462 $LCTL set_param fail_loc=$fail
2464 flocks_test 5 $2 write $DIR/$tfile &
2468 echo "** Evicting and re-connecting client **"
2473 if [ x"$2" = x"get" ]; then
2480 # check if the return value is allowed
2481 [ $rc -eq $3 ] && rc=0
2483 $LCTL set_param fail_loc=0
2487 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2488 # the ORIGINAL lock.
2493 flocks_test 5 set write sleep 4 $DIR/$tfile &
2497 # let unlock to sleep in CP CB
2498 $LCTL set_param fail_loc=$1
2501 # let cleanup to cleep in CP CB
2509 $LCTL set_param fail_loc=0
2514 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2517 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2518 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2519 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2521 test_120_reply "REPLY" set 5 || error "SET race failed"
2522 test_120_reply "REPLY" get 5 || error "GET race failed"
2523 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2526 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2527 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2529 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2531 run_test 120 "flock race: completion vs. evict"
2534 local BEFORE=$(date +%s)
2537 # modify dir so that next revalidate would not obtain UPDATE lock
2540 # drop 1 reply with UPDATE lock,
2541 # resend should not create 2nd lock on server
2542 mcreate $DIR/$tfile || error "mcreate failed: $?"
2543 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2545 # 2 BL AST will be sent to client, both must find the same lock,
2546 # race them to not get EINVAL for 2nd BL AST
2547 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2548 $LCTL set_param fail_loc=0x8000031f
2550 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2551 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2552 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2554 # let the client reconnect
2556 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2557 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2559 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2561 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2565 test_mkdir -p $DIR/$tdir
2567 # Prevent interference from layout intent RPCs due to
2568 # asynchronous writeback. These will be tested in 130c below.
2569 do_nodes ${CLIENTS:-$HOSTNAME} sync
2571 # get only LOOKUP lock on $tdir
2572 cancel_lru_locks mdc
2573 ls $DIR/$tdir/$tfile 2>/dev/null
2575 # get getattr by fid on $tdir
2577 # we need to race with unlink, unlink must complete before we will
2578 # take a DLM lock, otherwise unlink will wait until getattr will
2579 # complete; but later than getattr starts so that getattr found
2581 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2582 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2589 # drop the reply so that resend happens on an unlinked file.
2590 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2591 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2595 remote_mds_nodsh && skip "remote MDS with nodsh"
2596 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2597 skip "Need server version newer than 2.7.1"
2601 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2604 run_test 130a "enqueue resend on not existing file"
2607 remote_mds_nodsh && skip "remote MDS with nodsh"
2608 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2609 skip "Need server version newer than 2.7.1"
2612 # let the reply to be dropped
2615 #define OBD_FAIL_SRV_ENOENT 0x217
2616 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2618 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2621 run_test 130b "enqueue resend on a stale inode"
2624 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2626 do_nodes ${CLIENTS:-$HOSTNAME} sync
2627 echo XXX > $DIR/$tfile
2629 cancel_lru_locks mdc
2631 # Trigger writeback on $tfile.
2633 # we need to race with unlink, unlink must complete before we will
2634 # take a DLM lock, otherwise unlink will wait until intent will
2635 # complete; but later than intent starts so that intent found
2637 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2638 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2645 # drop the reply so that resend happens on an unlinked file.
2646 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2647 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2649 # let the reply to be dropped
2652 #define OBD_FAIL_SRV_ENOENT 0x217
2653 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2659 run_test 130c "layout intent resend on a stale inode"
2662 local before=$(date +%s)
2665 mount_client $MOUNT2 || error "mount filed"
2668 # get a lock on client so that export would reach the stale list
2669 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2670 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2673 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2674 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2676 $TRUNCATE $DIR/$tfile 100 &
2679 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2683 umount_client $MOUNT2
2685 evict=$(do_facet client $LCTL get_param \
2686 osc.$FSNAME-OST0000-osc-*/state |
2687 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2689 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2690 (do_facet client $LCTL get_param \
2691 osc.$FSNAME-OST0000-osc-*/state;
2692 error "eviction happened: $evict before:$before")
2694 run_test 132 "long punch"
2697 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2700 # get a lock on client so that export would reach the stale list
2701 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2702 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2704 # another IO under the same lock
2705 #define OBD_FAIL_OSC_DELAY_IO 0x414
2706 $LCTL set_param fail_loc=0x80000414
2707 $LCTL set_param fail_val=4 fail_loc=0x80000414
2708 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2712 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2713 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2717 wait $pid && error "dd succeeded"
2720 run_test 131 "IO vs evict results to IO under staled lock"
2723 local list=$(comma_list $(mdts_nodes))
2725 local t=$((TIMEOUT * 2))
2728 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2730 multiop_bg_pause $DIR/$tfile O_jc || return 1
2733 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2734 do_nodes $list $LCTL set_param fail_loc=0x80000157
2736 echo "waiting for multiop $PID"
2737 wait $PID || return 2
2743 run_test 133 "don't fail on flock resend"
2746 [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
2747 [ $CLIENTCOUNT -lt 2 ] &&
2748 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2750 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2751 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2752 error "touch failed"
2753 zconf_umount_clients $CLIENTS $MOUNT
2754 zconf_mount_clients $CLIENTS $MOUNT
2756 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2757 # assume commit interval is 5
2758 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2760 local -a clients=(${CLIENTS//,/ })
2761 local client1=${clients[0]}
2762 local client2=${clients[1]}
2764 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2766 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2769 wait $rmpid || error "rm failed"
2770 wait $mvpid || error "mv failed"
2773 run_test 134 "race between failover and search for reply data free slot"
2776 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2777 skip "Need MDS version at least 2.12.51"
2780 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2781 # to have parent dir write lock before open/resend
2782 touch $DIR/$tdir/$tfile
2783 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2784 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2785 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2786 error "Failed to open DOM file"
2788 run_test 135 "DOM: open/create resend to return size"
2791 remote_mds_nodsh && skip "remote MDS with nodsh"
2792 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2793 skip "Need MDS version at least 2.12.52"
2795 local mdts=$(comma_list $(mdts_nodes))
2796 local MDT0=$(facet_svc $SINGLEMDS)
2798 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2799 [ -n "$clog" ] || error "changelog_register failed"
2800 cl_mask=$(do_facet mds1 $LCTL get_param \
2801 mdd.$MDT0.changelog_mask -n)
2802 changelog_chmask "ALL"
2804 # generate some changelog records to accumulate
2805 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2806 createmany -m $DIR/$tdir/$tfile 10000 ||
2807 error "create $DIR/$tdir/$tfile failed"
2809 local size1=$(do_facet $SINGLEMDS \
2810 $LCTL get_param -n mdd.$MDT0.changelog_size)
2811 echo "Changelog size $size1"
2813 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2814 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2816 # launch changelog_deregister in background on MDS
2817 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2818 > foo.out 2> foo.err < /dev/null &"
2819 # give time to reach fail_loc
2822 # fail_loc will make MDS sleep in the middle of changelog_deregister
2823 # take this opportunity to abruptly kill MDS
2824 FAILURE_MODE_save=$FAILURE_MODE
2827 FAILURE_MODE=$FAILURE_MODE_save
2829 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2831 local size2=$(do_facet $SINGLEMDS \
2832 $LCTL get_param -n mdd.$MDT0.changelog_size)
2833 echo "Changelog size $size2"
2834 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2835 mdd.$MDT0.changelog_users | grep $clog")
2836 echo "After crash, changelog user $clog2"
2838 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2839 error "changelog record count unchanged"
2841 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2843 run_test 136 "changelog_deregister leaving pending records"
2849 dd if=/dev/zero of=$DIR/d1/$tfile bs=4096 count=1
2850 dd if=/dev/zero of=$DIR/d2/$tfile bs=4096 count=1
2851 cancel_lru_locks osc
2853 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2854 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2856 # RPC1: any reply is to be delayed to disable last_xid logic
2857 ln $DIR/d1/$tfile $DIR/d1/f2 &
2860 # RPC2: setattr1 reply is delayed & resent
2861 # original reply comes to client; the resend get asleep
2862 chmod 666 $DIR/d2/$tfile
2864 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2865 chmod 777 $DIR/d2/$tfile
2867 # RPC2 resend wakes up
2869 [ $(stat -c "%a" $DIR/d2/$tfile) == 777 ] || error "resend got applied"
2871 run_test 137 "late resend must be skipped if already applied"
2874 remote_mds_nodsh && skip "remote MDS with nodsh"
2875 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2876 [[ "$MDS1_VERSION" -ge $(version_code 2.12.59) ]] ||
2877 skip "Need server version newer than 2.12.59"
2879 zconf_umount_clients $CLIENTS $MOUNT
2881 #define OBD_FAIL_TGT_RECOVERY_CONNECT 0x724
2882 #delay a first step of recovey when MDS waiting clients
2883 #and failing to get osp logs
2884 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x724 fail_val=5
2886 facet_failover $SINGLEMDS
2888 #waiting failover and recovery timer
2889 #the valuse is based on target_recovery_overseer() wait_event timeout
2891 stop $SINGLEMDS || error "stop MDS failed"
2892 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
2893 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) ||
2894 error "start MDS failed"
2895 zconf_mount_clients $CLIENTS $MOUNT
2897 run_test 138 "Umount MDT during recovery"
2900 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2901 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
2902 skip "Need MDS version at least 2.13.50"
2904 mdt_dev=$(mdsdevname 1)
2906 stop $SINGLEMDS || error "stop $SINGLEMDS failed"
2908 #define OBD_FAIL_OSP_INVALID_LOGID 0x2106
2909 do_facet $SINGLEMDS $LCTL set_param fail_val=0x68 fail_loc=0x80002106
2910 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
2912 run_test 139 "corrupted catid won't cause crash"
2915 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
2916 skip "Need MDS version at least 2.13.50"
2918 [ "$SHARED_KEY" = true ] &&
2919 skip "server local client incompatible with SSK keys installed"
2921 slr=$(do_facet mds1 \
2922 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
2923 stack_trap "do_facet mds1 $LCTL set_param \
2924 mdt.*.local_recovery=$slr" EXIT
2926 # disable recovery for local clients
2927 # so local clients should be marked with no_recovery flag
2928 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
2932 cnt=$(do_facet mds1 $LCTL get_param "mdt.*.exports.*.export" |
2933 grep export_flags.*no_recovery | wc -l)
2934 echo "$cnt clients with recovery disabled"
2936 [ $cnt -eq 0 ] && error "no clients with recovery disabled"
2938 # enable recovery for local clients
2939 # so no local clients should be marked with no_recovery flag
2940 do_facet mds1 $LCTL set_param mdt.*.local_recovery=1
2943 cnt=$(do_facet mds1 $LCTL get_param "mdt.*.exports.*.export" |
2944 grep export_flags.*no_recovery | wc -l)
2945 echo "$cnt clients with recovery disabled"
2947 [ $cnt -eq 0 ] || error "$cnt clients with recovery disabled"
2949 run_test 140a "local mount is flagged properly"
2952 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
2953 skip "Need MDS version at least 2.13.50"
2955 [ "$SHARED_KEY" = true ] &&
2956 skip "server local client incompatible with SSK keys installed"
2958 slr=$(do_facet mds1 \
2959 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
2960 stack_trap "do_facet mds1 $LCTL set_param \
2961 mdt.*.local_recovery=$slr" EXIT
2963 # disable recovery for local clients
2964 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
2970 # Lustre: tfs-MDT0000: Recovery over after 0:03, of 2 clients 2 rec...
2971 local recovery=$(do_facet mds1 dmesg |
2972 awk '/Recovery over after/ { print $6 }' | tail -1 |
2973 awk -F: '{ print $1 * 60 + $2 }')
2974 (( recovery < TIMEOUT * 2 + 5 )) ||
2975 error "recovery took too long $recovery > $((TIMEOUT * 2 + 5))"
2977 run_test 140b "local mount is excluded from recovery"
2983 [ $PARALLEL == "yes" ] && skip "skip parallel run"
2984 combined_mgs_mds || skip "needs combined MGS/MDT"
2985 ( local_mode || from_build_tree ) &&
2986 skip "cannot run in local mode or from build tree"
2988 # some get_param have a bug to handle dot in param name
2989 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
2990 oldc=$(do_facet $SINGLEMDS $LCTL get_param -n \
2991 'ldlm.namespaces.MGC*.lock_count')
2993 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
2994 newc=$(do_facet $SINGLEMDS $LCTL get_param -n \
2995 'ldlm.namespaces.MGC*.lock_count')
2997 [ $oldc -eq $newc ] || error "mgc lost locks ($oldc != $newc)"
3000 run_test 141 "do not lose locks on MGS restart"
3003 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
3004 skip "Need MDS version at least 2.11.56"
3006 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
3007 do_facet mds1 $LCTL set_param fail_loc=0x165
3008 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
3011 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
3013 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3014 error "MDD orphan cleanup thread not quit"
3016 run_test 142 "orphan name stub can be cleaned up in startup"
3019 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.13.00) ] &&
3020 skip "Need MDS version at least 2.13.00"
3021 [ $PARALLEL == "yes" ] && skip "skip parallel run"
3023 local mntpt=$(facet_mntpt $SINGLEMDS)
3025 mount_fstype $SINGLEMDS || error "mount as fstype $SINGLEMDS failed"
3026 do_facet $SINGLEMDS touch $mntpt/PENDING/$tfile
3027 unmount_fstype $SINGLEMDS
3028 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3030 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
3031 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3032 error "MDD orphan cleanup thread not quit"
3034 run_test 143 "orphan cleanup thread shouldn't be blocked even delete failed"
3037 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
3038 [ $(facet_active_host mds2) = $(facet_active_host mds3) ] &&
3039 skip "needs mds2 and mds3 on separate nodes"
3045 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
3046 echo block mds_connect from mds2
3047 do_facet mds2 "$LCTL set_param fail_loc=0x507"
3049 #define OBD_FAIL_OUT_UPDATE_DROP 0x1707
3050 echo block recovery updates from mds3
3051 do_facet mds3 "$LCTL set_param fail_loc=0x1707"
3053 local hard_timeout=\
3054 $(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard)
3058 local get_soft_timeout_cmd=\
3059 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_soft 2>/dev/null"
3061 echo wait until mds1 recovery_time_soft is $hard_timeout
3062 wait_update $(facet_host mds1) "$get_soft_timeout_cmd" \
3063 "$hard_timeout" $hard_timeout
3065 echo unblock mds_connect from mds2
3066 do_facet mds2 "$LCTL set_param fail_loc=0"
3068 echo upblock recovery updates from mds3
3069 do_facet mds3 "$LCTL set_param fail_loc=0"
3072 [ -f $DIR/$tfile ] || error "$DIR/$tfile does not exist"
3074 run_test 145 "connect mdtlovs and process update logs after recovery expire"
3077 local obd_timeout=200
3078 local old=$($LCTL get_param -n timeout)
3080 local connection_count
3082 $LFS setstripe -i 0 -c 1 $f
3083 stripe_index=$($LFS getstripe -i $f)
3084 if [ $stripe_index -ne 0 ]; then
3086 error "$f: stripe_index $stripe_index != 0" && return
3089 $LCTL set_param timeout=$obd_timeout
3090 stack_trap "$LCTL set_param timeout=$old && client_reconnect" EXIT
3092 # OBD_FAIL_OST_CONNECT_NET2
3093 # lost reply to connect request
3094 do_facet ost1 lctl set_param fail_loc=0x00000225 timeout=$obd_timeout
3095 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0 timeout=$old" EXIT
3100 $LFS df $MOUNT > /dev/null 2>&1 &
3101 sleep $((obd_timeout * 3 / 4))
3103 $LCTL get_param osc.$FSNAME-OST0000-osc-*.state
3104 connection_count=$($LCTL get_param osc.$FSNAME-OST0000-osc-*.state |
3105 tac | sed "/FULL/,$ d" | grep CONNECTING | wc -l)
3107 echo $connection_count
3108 (($connection_count >= 6)) || error "Client reconnected too slow"
3110 run_test 147 "Check client reconnect"
3113 local wce_param="obdfilter.$FSNAME-OST0000.writethrough_cache_enable"
3114 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3115 local amc=$(at_max_get client)
3116 local amo=$(at_max_get ost1)
3121 timeout=$(request_timeout client)
3123 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3124 # save old r/o cache settings
3125 save_lustre_params ost1 $wce_param > $p
3128 do_facet ost1 "$LCTL set_param -n $wce_param=0"
3131 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3132 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
3133 cp $DIR/$tfile $TMP/$tfile
3134 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3135 do_facet ost1 $LCTL set_param fail_loc=0x80000227
3136 do_facet ost1 $LCTL set_param fail_val=$((timeout+2))
3137 dd if=/dev/urandom of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3138 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3140 cancel_lru_locks osc
3141 cmp -b $DIR/$tfile $TMP/$tfile || error "wrong data"
3143 rm -f $DIR/$tfile $TMP/$tfile
3145 at_max_set $amc client
3146 at_max_set $amo ost1
3148 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3149 # restore initial r/o cache settings
3150 restore_lustre_params < $p
3155 run_test 148 "data corruption through resend"
3158 check_and_cleanup_lustre