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_on_mdt0 $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
431 # adaptive_timeout_max
432 if at_is_enabled; then
433 at_max_saved=$(at_max_get ost1)
434 at_max_set $TIMEOUT ost1
437 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
438 # OST bulk will time out here, client retries
439 do_facet ost1 lctl set_param fail_loc=0x80000503
440 # need to ensure we send an RPC
441 do_facet client cp $SAMPLE_FILE $DIR/$tfile
444 # with AT, client will wait adaptive_max*factor+net_latency before
445 # expiring the req, hopefully timeout*2 is enough
446 sleep $(($TIMEOUT*2))
448 do_facet ost1 lctl set_param fail_loc=0
449 do_facet client "df $DIR"
450 # expect cmp to succeed, client resent bulk
451 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
452 do_facet client "rm $DIR/$tfile" || return 4
453 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
456 run_test 17a "timeout bulk get, don't evict client (2732)"
459 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
461 # get one of the clients from client list
462 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
463 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
464 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
465 [ -z "$ldlm_enqueue_min" ] &&
466 skip "missing /sys/.../ldlm_enqueue_min" && return 0
468 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
469 error "setstripe failed"
470 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
471 error "setstripe 2 failed"
473 save_lustre_params ost1 "at_history" > $p
474 save_lustre_params ost1 "bulk_timeout" >> $p
475 local dev="${FSNAME}-OST0000"
476 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
477 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
479 local new_at_history=15
481 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
482 do_facet ost1 "$LCTL set_param bulk_timeout=30"
483 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
485 # brw_size is required to be 4m so that bulk transfer timeout
486 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
487 local brw_size=$($LCTL get_param -n \
488 osc.$FSNAME-OST0000-osc-[^M]*.import |
489 awk '/max_brw_size/{print $2}')
490 if [ $brw_size -ne 4194304 ]
492 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
493 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
494 remount_client $MOUNT
497 # get service estimate expanded
498 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
499 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
500 echo "delay rpc servicing by 35 seconds"
501 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
504 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
505 awk '/portal 6/ {print $5}')
506 echo "service estimates increased to $estimate"
508 # let current worst service estimate to get closer to obliteration
509 sleep $((new_at_history / 3))
511 # start i/o and simulate bulk transfer loss
512 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
513 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
514 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
517 # start lock conflict handling
518 sleep $((new_at_history / 3))
519 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
522 # obliterate the worst service estimate
523 sleep $((new_at_history / 3 + 1))
524 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
526 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
527 awk '/portal 6/ {print $5}')
528 echo "service estimate dropped to $estimate"
531 [[ $? == 0 ]] || error "write failed"
533 [[ $? == 0 ]] || error "read failed"
535 restore_lustre_params <$p
536 if [ $brw_size -ne 4194304 ]
538 remount_client $MOUNT || error "remount_client failed"
540 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
542 run_test 17b "timeout bulk get, dont evict client (3582)"
545 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
547 do_facet_create_file client $TMP/$tfile 20K ||
548 { error_noexit "Create file $TMP/$tfile" ; return 0; }
550 do_facet client mkdir -p $DIR/$tdir
554 pgcache_empty || return 1
557 $LFS setstripe -i 1 -c 1 $f
558 stripe_index=$($LFS getstripe -i $f)
559 if [ $stripe_index -ne 1 ]; then
561 error "$f: stripe_index $stripe_index != 1" && return
564 do_facet client cp $TMP/$tfile $f
566 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
567 $LCTL --device $osc2dev deactivate || return 3
568 # my understanding is that there should be nothing in the page
569 # cache after the client reconnects?
571 pgcache_empty || rc=2
572 $LCTL --device $osc2dev activate
576 run_test 18a "manual ost invalidate clears page cache immediately"
579 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
581 do_facet_create_file client $TMP/$tfile 20K ||
582 { error_noexit "Create file $TMP/$tfile" ; return 0; }
584 do_facet client mkdir -p $DIR/$tdir
588 pgcache_empty || return 1
590 $LFS setstripe -i 0 -c 1 $f
591 stripe_index=$($LFS getstripe -i $f)
592 if [ $stripe_index -ne 0 ]; then
594 error "$f: stripe_index $stripe_index != 0" && return
597 do_facet client cp $TMP/$tfile $f
600 # allow recovery to complete
601 sleep $((TIMEOUT + 2))
602 # my understanding is that there should be nothing in the page
603 # cache after the client reconnects?
605 pgcache_empty || rc=2
609 run_test 18b "eviction and reconnect clears page cache (2766)"
612 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
614 do_facet_create_file client $TMP/$tfile 20K ||
615 { error_noexit "Create file $TMP/$tfile" ; return 0; }
617 do_facet client mkdir -p $DIR/$tdir
621 pgcache_empty || return 1
623 $LFS setstripe -i 0 -c 1 $f
624 stripe_index=$($LFS getstripe -i $f)
625 if [ $stripe_index -ne 0 ]; then
627 error "$f: stripe_index $stripe_index != 0" && return
630 do_facet client cp $TMP/$tfile $f
634 # OBD_FAIL_OST_CONNECT_NET2
635 # lost reply to connect request
636 do_facet ost1 lctl set_param fail_loc=0x80000225
639 $LFS df $MOUNT > /dev/null 2>&1
641 # my understanding is that there should be nothing in the page
642 # cache after the client reconnects?
644 pgcache_empty || rc=2
648 run_test 18c "Dropped connect reply after eviction handing (14755)"
651 local BEFORE=`date +%s`
654 mount_client $DIR2 || error "failed to mount $DIR2"
656 # cancel cached locks from OST to avoid eviction from it
659 do_facet client "stat $DIR > /dev/null" ||
660 error "failed to stat $DIR: $?"
661 drop_ldlm_cancel "chmod 0777 $DIR2" ||
662 error "failed to chmod $DIR2"
666 # let the client reconnect
668 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
669 awk -F"[ [,]" '/EVICTED ]$/ \
670 { if (mx<$5) {mx=$5;} } END { print mx }')
672 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
673 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
674 error "no eviction: $EVICT before:$BEFORE")
676 run_test 19a "test expired_lock_main on mds (2867)"
679 local BEFORE=`date +%s`
682 mount_client $DIR2 || error "failed to mount $DIR2: $?"
684 # cancel cached locks from MDT to avoid eviction from it
687 do_facet client $MULTIOP $DIR/$tfile Ow ||
688 error "failed to run multiop: $?"
689 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
690 error "failed to ldlm_cancel: $?"
692 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
693 do_facet client munlink $DIR/$tfile ||
694 error "failed to unlink $DIR/$tfile: $?"
696 # let the client reconnect
698 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
699 awk -F"[ [,]" '/EVICTED ]$/ \
700 { if (mx < $5) {mx = $5;} } END { print mx }')
702 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
703 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
704 error "no eviction: $EVICT before:$BEFORE")
706 run_test 19b "test expired_lock_main on ost (2867)"
709 local BEFORE=`date +%s`
712 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
714 mkdir -p $DIR1/$tfile
717 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
718 do_facet mds $LCTL set_param fail_loc=0x80000516
720 touch $DIR2/$tfile/file1 &
722 # let touch to get blocked on the server
726 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
729 # let the client reconnect
731 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
732 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
734 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
736 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
738 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
739 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
742 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
743 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
746 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
747 do_facet ost1 lctl set_param fail_loc=0x80000308
748 kill -USR1 $MULTI_PID
751 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
753 run_test 20a "ldlm_handle_enqueue error (should return error)"
755 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
756 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
759 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
761 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
762 do_facet ost1 lctl set_param fail_loc=0x80000308
763 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
764 error "didn't fail open enqueue" || true
766 run_test 20b "ldlm_handle_enqueue error (should return error)"
769 mkdir -p $DIR/$tdir-1
770 mkdir -p $DIR/$tdir-2
771 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
774 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
775 $MULTIOP $DIR/$tdir-2/f Oc &
778 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
781 kill -USR1 $close_pid
783 wait $close_pid || return 1
784 wait $open_pid || return 2
785 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
787 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
788 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
792 run_test 21a "drop close request while close and open are both in flight"
795 mkdir -p $DIR/$tdir-1
796 mkdir -p $DIR/$tdir-2
797 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
800 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
801 mcreate $DIR/$tdir-2/f &
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
806 kill -USR1 $close_pid
808 wait $close_pid || return 1
809 wait $open_pid || return 3
811 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
812 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
815 run_test 21b "drop open request while close and open are both in flight"
818 mkdir -p $DIR/$tdir-1
819 mkdir -p $DIR/$tdir-2
820 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
823 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
824 mcreate $DIR/$tdir-2/f &
827 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
829 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
830 kill -USR1 $close_pid
832 wait $close_pid || return 1
833 wait $open_pid || return 2
835 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
837 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
838 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
841 run_test 21c "drop both request while close and open are both in flight"
844 mkdir -p $DIR/$tdir-1
845 mkdir -p $DIR/$tdir-2
846 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
849 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
850 $MULTIOP $DIR/$tdir-2/f Oc &
852 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
854 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
857 wait $pid || return 1
858 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
860 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
861 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
865 run_test 21d "drop close reply while close and open are both in flight"
868 mkdir -p $DIR/$tdir-1
869 mkdir -p $DIR/$tdir-2
870 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
873 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
874 touch $DIR/$tdir-2/f &
876 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
880 wait $pid || return 1
883 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
884 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
887 run_test 21e "drop open reply while close and open are both in flight"
890 mkdir -p $DIR/$tdir-1
891 mkdir -p $DIR/$tdir-2
892 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
895 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
896 touch $DIR/$tdir-2/f &
898 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
900 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
903 wait $pid || return 1
904 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
906 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
907 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
910 run_test 21f "drop both reply while close and open are both in flight"
913 mkdir -p $DIR/$tdir-1
914 mkdir -p $DIR/$tdir-2
915 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
918 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
919 touch $DIR/$tdir-2/f &
921 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
923 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
926 wait $pid || return 1
927 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
929 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
930 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
933 run_test 21g "drop open reply and close request while close and open are both in flight"
936 mkdir -p $DIR/$tdir-1
937 mkdir -p $DIR/$tdir-2
938 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
941 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
942 touch $DIR/$tdir-2/f &
945 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
947 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
950 wait $pid || return 1
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
953 wait $touch_pid || return 2
955 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
956 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
959 run_test 21h "drop open request and close reply while close and open are both in flight"
961 # bug 3462 - multiple MDC requests
966 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
971 $MULTIOP $f1 msu || return 1
974 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
976 wait $close_pid || return 2
977 rm -rf $f2 || return 4
979 run_test 22 "drop close request and do mknod"
982 multiop_bg_pause $DIR/$tfile O_c || return 1
984 # give a chance for open
988 drop_request "kill -USR1 $pid"
991 wait $pid || return 1
994 run_test 23 "client hang when close a file after mds crash"
996 test_24a() { # bug 11710 details correct fsync() behavior
997 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1000 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1001 cancel_lru_locks osc
1002 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1005 kill -USR1 $MULTI_PID
1008 lctl set_param fail_loc=0x0
1011 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1013 run_test 24a "fsync error (should return error)"
1015 wait_client_evicted () {
1018 local varsvc=${facet}_svc
1020 wait_update $(facet_active_host $facet) \
1021 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1026 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1028 dmesg -c > /dev/null
1030 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1031 error "$LFS setstripe failed"
1032 cancel_lru_locks osc
1033 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1034 error "mulitop Ow8192_yc failed"
1037 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1038 error "mulitop Ow8192_c failed"
1043 kill -USR1 $MULTI_PID1
1046 kill -USR1 $MULTI_PID2
1049 lctl set_param fail_loc=0x0
1051 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1052 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1055 dmesg | grep "dirty page discard:" ||
1056 error "no discarded dirty page found!"
1058 run_test 24b "test dirty page discard due to client eviction"
1060 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1061 # this test can only run from a client on a separate node.
1062 remote_ost || { skip "local OST" && return 0; }
1063 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1064 remote_mds || { skip "local MDS" && return 0; }
1066 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1067 skip "msg and ost1 are at the same node"
1071 check_timeout || return 1
1073 # make sure all imports are connected and not IDLE
1074 do_facet client lfs df > /dev/null
1075 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1076 do_facet client lctl set_param fail_loc=0x505
1077 local before=$(date +%s)
1080 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1081 # But if there's a race to start the evictor from various obds,
1082 # the loser might have to wait for the next ping.
1083 sleep $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1084 do_facet client lctl set_param fail_loc=0x0
1085 do_facet client lfs df > /dev/null
1087 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1088 check_clients_evicted "$before ${oscs[@]}"
1089 check_clients_full 10 "${oscs[@]}"
1091 run_test 26a "evict dead exports"
1093 test_26b() { # bug 10140 - evict dead exports by pinger
1094 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1096 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1097 skip "msg and ost1 are at the same node"
1101 check_timeout || return 1
1103 zconf_mount `hostname` $MOUNT2 ||
1104 { error "Failed to mount $MOUNT2"; return 2; }
1105 sleep 1 # wait connections being established
1107 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1108 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1110 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1112 zconf_umount `hostname` $MOUNT2 -f
1114 # PING_INTERVAL max(obd_timeout / 4, 1U)
1115 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1117 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1118 # But if there's a race to start the evictor from various obds,
1119 # the loser might have to wait for the next ping.
1120 # = 9 * PING_INTERVAL + PING_INTERVAL
1121 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1122 # let's wait $((TIMEOUT * 3)) # bug 19887
1123 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) ||
1124 error "Client was not evicted by ost"
1125 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) ||
1126 error "Client was not evicted by mds"
1128 run_test 26b "evict dead exports"
1131 mkdir_on_mdt0 $DIR/$tdir
1132 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1135 local save_FAILURE_MODE=$FAILURE_MODE
1137 facet_failover $SINGLEMDS
1138 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1139 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1140 # need to wait for reconnect
1141 echo waiting for fail_loc
1142 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1143 facet_failover $SINGLEMDS
1144 #no crashes allowed!
1145 kill -USR1 $CLIENT_PID
1148 FAILURE_MODE=$save_FAILURE_MODE
1150 run_test 27 "fail LOV while using OSC's"
1152 test_28() { # bug 6086 - error adding new clients
1153 do_facet client mcreate $DIR/$tfile || return 1
1154 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1155 echo "evicted as expected"
1156 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1157 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1158 # fail once (evicted), reconnect fail (fail_loc), ok
1159 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1161 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1163 run_test 28 "handle error adding new clients (bug 6086)"
1165 test_29a() { # bug 22273 - error adding new clients
1166 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1167 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1168 # fail abort so client will be new again
1169 fail_abort $SINGLEMDS
1170 client_up || error "reconnect failed"
1171 wait_osc_import_state $SINGLEMDS ost FULL
1174 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1176 test_29b() { # bug 22273 - error adding new clients
1177 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1178 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1179 # fail abort so client will be new again
1181 client_up || error "reconnect failed"
1184 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1188 # put a load of file creates/writes/deletes
1189 writemany -q $DIR/$tdir/$tfile 0 5 &
1191 echo writemany pid $CLIENT_PID
1195 # wait for client to reconnect to MDS
1200 # client process should see no problems even though MDS went down
1202 kill -USR1 $CLIENT_PID
1205 echo writemany returned $rc
1206 #these may fail because of eviction due to slow AST response.
1208 error_ignore bz13652 "writemany returned rc $rc" || true
1210 run_test 50 "failover MDS under load"
1213 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1214 do_facet ost1 lctl set_param fail_loc=0x00001310
1216 mkdir_on_mdt0 $DIR/$tdir
1217 # put a load of file creates/writes/deletes
1218 writemany -q $DIR/$tdir/$tfile 0 5 &
1222 facet_failover $SINGLEMDS
1223 # failover at various points during recovery
1224 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1225 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 53a "touch: drop rep"
1293 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1296 run_test 53b "touch: drop rep"
1301 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1304 run_test 53c "touch: drop rep"
1307 zconf_mount $(hostname) $MOUNT2
1309 touch $DIR2/$tfile.1
1311 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1314 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1315 grep "went back in time")
1316 [ x"$ERROR" == x ] || error "back in time occured"
1318 run_test 54 "back in time"
1320 # bug 11330 - liblustre application death during I/O locks up OST
1322 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1326 # This test assumes relatively small max_dirty_mb setting
1327 # which we want to walk away from, so just for it we will
1328 # temporarily lower the value
1329 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1330 lctl set_param -n osc.*.max_dirty_mb=32
1331 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1333 # Minimum pass speed is 2MBps
1335 # LU-2887/LU-3089 - set min pass speed to 500KBps
1336 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1338 # first dd should be finished quickly
1339 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1340 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1343 echo "step1: testing ......"
1344 while kill -0 $DDPID 2> /dev/null; do
1346 if [ $count -gt $ddtimeout ]; then
1347 error "dd should be finished!"
1351 echo "(dd_pid=$DDPID, time=$count)successful"
1353 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1354 #define OBD_FAIL_OST_DROP_REQ 0x21d
1355 do_facet ost1 lctl set_param fail_loc=0x0000021d
1356 # second dd will be never finished
1357 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1360 echo "step2: testing ......"
1361 while [ $count -le $ddtimeout ]; do
1362 if ! kill -0 $DDPID 2> /dev/null; then
1364 error "dd shouldn't be finished! (time=$count)"
1369 echo "(dd_pid=$DDPID, time=$count)successful"
1371 #Recover fail_loc and dd will finish soon
1372 do_facet ost1 lctl set_param fail_loc=0
1374 echo "step3: testing ......"
1375 while kill -0 $DDPID 2> /dev/null; do
1377 if [ $count -gt $((ddtimeout + 440)) ]; then
1378 error "dd should be finished!"
1382 echo "(dd_pid=$DDPID, time=$count)successful"
1386 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1388 test_56() { # b=11277
1389 #define OBD_FAIL_MDS_RESEND 0x136
1391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1392 stat $DIR/$tfile || error "stat failed"
1393 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1396 run_test 56 "do not fail on getattr resend"
1399 # no oscs means no client or mdt
1400 while lctl get_param osc.*.* > /dev/null 2>&1; do
1401 : # loop until proc file is removed
1405 test_57() { # bug 10866
1409 #define OBD_FAIL_LPROC_REMOVE 0xB00
1410 lctl set_param fail_loc=0x80000B00
1411 zconf_umount `hostname` $DIR
1412 lctl set_param fail_loc=0x80000B00
1413 fail_abort $SINGLEMDS
1415 lctl set_param fail_loc=0
1417 do_facet client "df $DIR"
1419 run_test 57 "read procfs entries causes kernel crash"
1421 test_58() { # bug 11546
1422 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1425 lctl set_param fail_loc=0x80000801
1426 cp $DIR/$tfile /dev/null &
1429 lctl set_param fail_loc=0
1430 drop_bl_callback_once rm -f $DIR/$tfile
1432 # the first 'df' could tigger the eviction caused by
1433 # 'drop_bl_callback_once', and it's normal case.
1434 # but the next 'df' should return successfully.
1435 do_facet client "df $DIR" || do_facet client "df $DIR"
1437 run_test 58 "Eviction in the middle of open RPC reply processing"
1439 test_59() { # bug 10589
1440 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1441 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1442 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1443 lctl set_param fail_loc=0x311
1444 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1445 [ $? = 0 ] || error "dd write failed"
1446 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1447 lctl set_param fail_loc=0
1449 zconf_umount `hostname` $MOUNT2 -f
1450 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1451 [ $? = 0 ] || error "dd read failed"
1452 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1453 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1455 run_test 59 "Read cancel race on client eviction"
1458 local num_files=${COUNT:-5000}
1459 test_mkdir $DIR/$tdir
1461 # Register (and start) changelog
1462 changelog_register || error "changelog_register failed"
1464 # Generate a large number of changelog entries
1465 createmany -o $DIR/$tdir/$tfile $num_files
1469 # Unlink files in the background
1470 unlinkmany $DIR/$tdir/$tfile $num_files &
1474 # Failover the MDS while unlinks are happening
1475 facet_failover $SINGLEMDS
1477 # Wait for unlinkmany to finish
1480 # Check if all the create/unlink events were recorded
1482 local cl_count=$(changelog_dump | grep -c UNLNK)
1483 echo "$cl_count unlinks in changelog"
1485 changelog_deregister || error "changelog_deregister failed"
1486 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1487 [ $cl_count -eq $num_files ] ||
1488 error "Recorded $cl_count of $num_files unlinks"
1489 # Also make sure we can clear large changelogs
1490 cl_count=$(changelog_dump | wc -l)
1491 [ $cl_count -le 2 ] ||
1492 error "Changelog not empty: $cl_count entries"
1493 else # If other users, there may be other unlinks in the log
1494 [ $cl_count -ge $num_files ] ||
1495 error "Recorded $cl_count of $num_files unlinks"
1496 changelog_users $SINGLEMDS
1497 echo "other changelog users; can't verify clear"
1500 run_test 60 "Add Changelog entries during MDS failover"
1504 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1505 mdtosc=${mdtosc/-MDT*/-MDT\*}
1506 local cflags="osc.$mdtosc.connect_flags"
1507 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1508 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1510 mkdir_on_mdt0 $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1511 # Set the default stripe of $DIR/$tdir to put the files to ost1
1512 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1514 replay_barrier $SINGLEMDS
1515 createmany -o $DIR/$tdir/$tfile-%d 10
1516 local oid=$(do_facet ost1 "lctl get_param -n \
1517 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1519 fail_abort $SINGLEMDS
1521 touch $DIR/$tdir/$tfile
1522 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1523 awk '$1 == 0 { print $2 }')
1524 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1529 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1531 # test_62 as seen it b2_1 please do not reuse test_62
1534 # zconf_umount `hostname` $DIR
1535 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1536 # lctl set_param fail_loc=0x516
1539 #run_test 62 "Verify connection flags race - bug LU-1716"
1544 #grant lock1, export2
1545 $LFS setstripe -i -0 $DIR2/$tfile || error "setstripe failed"
1546 $MULTIOP $DIR2/$tfile Ow || error "multiop failed"
1548 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1549 do_facet ost $LCTL set_param fail_loc=0x31e
1550 #get waiting lock2, export1
1551 $MULTIOP $DIR/$tfile Ow &
1553 # let enqueue to get asleep
1557 $MULTIOP $DIR2/$tfile Ow &
1565 do_facet ost $LCTL set_param fail_loc=0
1572 run_test 65 "lock enqueue for destroyed export"
1576 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1577 skip "Need MDS version at least 2.7.51"
1579 local list=$(comma_list $(osts_nodes))
1581 # modify dir so that next revalidate would not obtain UPDATE lock
1584 # drop 1 reply with UPDATE lock
1585 mcreate $DIR/$tfile || error "mcreate failed: $?"
1586 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1589 # make the re-sent lock to sleep
1590 #define OBD_FAIL_MDS_RESEND 0x136
1591 do_nodes $list $LCTL set_param fail_loc=0x80000136
1593 #initiate the re-connect & re-send
1594 local mdtname="MDT0000"
1595 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1596 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1597 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1600 #initiate the client eviction while enqueue re-send is in progress
1606 run_test 66 "lock enqueue re-send vs client eviction"
1610 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1611 $LCTL set_param fail_loc=0x80000531
1613 local mdtname="MDT0000"
1614 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1615 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1616 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1625 run_test 67 "connect vs import invalidate race"
1627 check_cli_ir_state()
1629 local NODE=${1:-$HOSTNAME}
1631 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1632 awk '/imperative_recovery:/ { print \\\$2}'")
1633 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1634 error "Error state $st, must be ENABLED or DISABLED"
1638 check_target_ir_state()
1641 local name=${target}_svc
1642 local recovery_proc=obdfilter.${!name}.recovery_status
1646 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1647 awk '/status:/{ print \\\$2}'")
1648 [ x$st = xRECOVERING ] || break
1650 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1651 awk '/IR:/{ print \\\$2}'")
1652 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1653 error "Error state $st, must be ENABLED or DISABLED"
1659 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1664 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1665 awk '/state:/{ print \\\$2 }'")
1669 nidtbl_version_mgs()
1671 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1672 awk '/nidtbl_version:/{ print \\\$2 }'")
1676 # nidtbl_version_client <mds1|client> [node]
1677 nidtbl_version_client()
1680 local node=${2:-$HOSTNAME}
1682 if [ X$cli = Xclient ]; then
1685 local obdtype=${cli/%[0-9]*/}
1686 [ $obdtype != mds ] && error "wrong parameters $cli"
1688 node=$(facet_active_host $cli)
1693 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1694 awk "/$cli/{print \$6}" |sort -u)
1696 # in case there are multiple mounts on the client node
1698 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1702 nidtbl_versions_match()
1704 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1707 target_instance_match()
1713 obdtype=${srv/%[0-9]*/}
1724 error "invalid target type" $srv
1729 local target=${srv}_svc
1730 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1731 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1732 awk '/instance/{ print $2 }' | head -n1)
1734 return $([ $si -eq $ci ])
1739 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1740 { skip "MGS without IR support"; return 0; }
1742 # MDT was just restarted in the previous test, make sure everything
1745 while [ $cnt -gt 0 ]; do
1746 nidtbl_versions_match && break
1752 set_ir_status disabled
1754 local prev_ver=$(nidtbl_version_client client)
1756 local saved_FAILURE_MODE=$FAILURE_MODE
1757 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1761 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1762 error "version must not change due to IR disabled"
1763 target_instance_match ost1 || error "instance mismatch"
1767 FAILURE_MODE=$saved_FAILURE_MODE
1769 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1773 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1774 skip "MGS without IR support"
1778 local ost1_imp=$(get_osc_import_name client ost1)
1780 # disable pinger recovery
1781 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1782 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1786 target_instance_match ost1 || error "instance mismatch"
1787 nidtbl_versions_match || error "version must match"
1789 run_test 101a "IR: Make sure IR works w/o normal recovery"
1793 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1794 skip "MGS without IR support"
1798 local ost1_imp=$(get_osc_import_name client ost1)
1800 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1801 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1802 # disable pinger recovery
1803 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1804 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1806 #OST may return EAGAIN if it is not configured yet
1809 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1813 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1814 { skip "MGS without IR support"; return 0; }
1816 local clients=${CLIENTS:-$HOSTNAME}
1823 # let's have a new nidtbl version
1826 # sleep for a while so that clients can see the failure of ost
1827 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1828 # int mgc_request.c:
1829 # define MGC_TIMEOUT_MIN_SECONDS 5
1830 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1831 local count=30 # 20 seconds at most
1832 while [ $count -gt 0 ]; do
1833 nidtbl_versions_match && break
1838 nidtbl_versions_match || error "nidtbl mismatch"
1841 old_version=$(nidtbl_version_client client)
1843 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1846 combined_mgs_mds && mgsdev=mds1
1847 remount_facet $mgsdev
1850 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1853 new_version=$(nidtbl_version_client client)
1854 [ $new_version -lt $old_version ] &&
1855 error "nidtbl version wrong after mgs restarts"
1858 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1862 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1863 { skip "MGS without IR support"; return 0; }
1865 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1867 # workaround solution to generate config log on the mds
1873 # We need this test because mds is like a client in IR context.
1874 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1875 error "MDS should start w/o mgs"
1877 # start mgs and remount mds w/ ir
1878 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1881 # remount client so that fsdb will be created on the MGS
1882 umount_client $MOUNT || error "umount failed"
1883 mount_client $MOUNT || error "mount failed"
1885 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1887 while [ $count -gt 0 ]; do
1888 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1893 # after a while, mds should be able to reconnect to mgs and fetch
1894 # up-to-date nidtbl version
1895 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1900 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1904 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1905 { skip "MGS without IR support"; return 0; }
1910 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1911 error "OST1 cannot start"
1914 local ir_state=$(check_target_ir_state ost1)
1916 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1917 error "ir status on ost1 should be DISABLED"
1919 run_test 104 "IR: ost can disable IR voluntarily"
1923 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1924 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1925 { skip "MGS without IR support"; return 0; }
1929 # get one of the clients from client list
1930 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1932 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1933 zconf_umount $rcli $MOUNT || error "umount failed"
1934 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1936 # make sure lustre mount at $rcli disabling IR
1937 local ir_state=$(check_cli_ir_state $rcli)
1938 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1939 error "IR state must be DISABLED at $rcli"
1941 # Since the client just mounted, its last_rcvd entry is not on disk.
1942 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1943 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1944 $LFS setstripe -i 0 $DIR/$tfile
1945 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1947 # make sure MGS's state is Partial
1948 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1951 # make sure IR on ost1 is DISABLED
1952 local ir_state=$(check_target_ir_state ost1)
1953 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1954 error "IR status on ost1 should be DISABLED"
1956 # remount with the default MOUNT_OPTS
1957 zconf_umount $rcli $MOUNT || error "umount failed"
1958 zconf_mount $rcli $MOUNT || error "mount failed"
1960 # make sure MGS's state is full
1961 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1964 # make sure IR on ost1 is ENABLED
1965 local ir_state=$(check_target_ir_state ost1)
1966 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1967 error "IR status on ost1 should be ENABLED"
1971 run_test 105 "IR: NON IR clients support"
1979 test_106() { # LU-1789
1980 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1981 skip "Need MDS version at least 2.3.50"
1983 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1984 $LCTL set_param fail_loc=0x805
1987 trap cleanup_106 EXIT
1989 # enable lightweight flag on mdc connection
1992 local MDS_NEXP=$(do_facet $SINGLEMDS \
1993 lctl get_param -n mdt.${mds1_svc}.num_exports |
1995 $LCTL set_param fail_loc=0
1997 touch $DIR2/$tfile || error "failed to create empty file"
1998 replay_barrier $SINGLEMDS
2000 $LCTL set_param debug=ha
2002 facet_failover $SINGLEMDS
2004 # lightweight goes through LUSTRE_IMP_RECOVER during failover
2005 touch -c $DIR2/$tfile || true
2006 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2007 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
2008 $TMP/lustre-log-$TESTNAME.log)
2009 [ -z "$recovered" ] && error "lightweight client was not recovered"
2011 # and all operations performed by lightweight client should be
2012 # synchronous, so the file created before mds restart should be there
2013 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2018 run_test 106 "lightweight connection support"
2024 mkdir_on_mdt0 $DIR/$tdir
2025 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2026 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2027 multiop $DIR/$tdir D_c &
2029 mkdir $DIR/$tdir/dir_106 &
2031 do_facet $SINGLEMDS lctl set_param fail_loc=0
2034 wait $CLIENT_PID || rc=$?
2035 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2037 kill -USR1 $close_pid
2038 wait $close_pid || return 2
2042 run_test 107 "drop reint reply, then restart MDT"
2046 $LFS setstripe -c 1 -i 0 $DIR/$tdir
2048 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2056 client_up || error "reconnect failed"
2057 rm -f $DIR/$tdir/$tfile
2059 run_test 108 "client eviction don't crash"
2062 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2063 local remote_dir=$DIR/$tdir/remote_dir
2067 #prepare for 110 test, which need set striped dir on remote MDT.
2068 for num in $(seq $MDSCOUNT); do
2070 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2074 mkdir_on_mdt0 $DIR/$tdir
2075 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2076 error "lfs mkdir failed"
2077 local diridx=$($LFS getstripe -m $remote_dir)
2078 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2080 rm -rf $DIR/$tdir || error "rmdir failed"
2082 run_test 110a "create remote directory: drop client req"
2085 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2086 local remote_dir=$DIR/$tdir/remote_dir
2089 mkdir_on_mdt0 $DIR/$tdir
2090 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2091 error "lfs mkdir failed"
2093 diridx=$($LFS getstripe -m $remote_dir)
2094 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2096 rm -rf $DIR/$tdir || error "rmdir failed"
2098 run_test 110b "create remote directory: drop Master rep"
2101 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2102 local remote_dir=$DIR/$tdir/remote_dir
2105 mkdir_on_mdt0 $DIR/$tdir
2106 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2107 error "lfs mkdir failed"
2109 diridx=$($LFS getstripe -m $remote_dir)
2110 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2112 rm -rf $DIR/$tdir || error "rmdir failed"
2114 run_test 110c "create remote directory: drop update rep on slave MDT"
2117 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2118 local remote_dir=$DIR/$tdir/remote_dir
2121 mkdir_on_mdt0 $DIR/$tdir
2122 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2124 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2126 rm -rf $DIR/$tdir || error "rmdir failed"
2130 run_test 110d "remove remote directory: drop client req"
2133 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2134 local remote_dir=$DIR/$tdir/remote_dir
2137 mkdir_on_mdt0 $DIR/$tdir
2138 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2139 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2141 rm -rf $DIR/$tdir || error "rmdir failed"
2145 run_test 110e "remove remote directory: drop master rep"
2148 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2149 local remote_dir=$DIR/$tdir/remote_dir
2152 mkdir_on_mdt0 $DIR/$tdir
2153 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2154 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2155 error "rm remote dir failed"
2157 rm -rf $DIR/$tdir || error "rmdir failed"
2159 run_test 110f "remove remote directory: drop slave rep"
2162 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2163 skip "Need MDS version at least 2.11.0"
2165 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2167 mkdir_on_mdt0 $DIR/$tdir
2168 touch $DIR/$tdir/$tfile
2170 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2171 do_facet mds1 $LCTL set_param fail_loc=0x119
2172 $LFS migrate -m 1 $DIR/$tdir &
2175 do_facet mds1 $LCTL set_param fail_loc=0
2179 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2180 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2181 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2182 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2184 rm -rf $DIR/$tdir || error "rmdir failed"
2186 run_test 110g "drop reply during migration"
2189 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2190 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2191 skip "Need MDS version at least 2.7.56"
2193 local src_dir=$DIR/$tdir/source_dir
2194 local tgt_dir=$DIR/$tdir/target_dir
2198 $LFS mkdir -i $MDTIDX $tgt_dir
2200 dd if=/etc/hosts of=$src_dir/src_file
2201 touch $tgt_dir/tgt_file
2202 drop_update_reply $MDTIDX \
2203 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2204 error "mrename failed"
2206 $CHECKSTAT -t file $src_dir/src_file &&
2207 error "src_file present after rename"
2209 diff /etc/hosts $tgt_dir/tgt_file ||
2210 error "file changed after rename"
2213 run_test 110h "drop update reply during cross-MDT file rename"
2216 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2217 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2218 skip "Need MDS version at least 2.7.56"
2220 local src_dir=$DIR/$tdir/source_dir
2221 local tgt_dir=$DIR/$tdir/target_dir
2225 $LFS mkdir -i $MDTIDX $tgt_dir
2227 mkdir $src_dir/src_dir
2228 touch $src_dir/src_dir/a
2229 mkdir $tgt_dir/tgt_dir
2230 drop_update_reply $MDTIDX \
2231 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2232 error "mrename failed"
2234 $CHECKSTAT -t dir $src_dir/src_dir &&
2235 error "src_dir present after rename"
2237 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2238 error "tgt_dir not present after rename"
2240 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2241 error "a not present after rename"
2243 run_test 110i "drop update reply during cross-MDT dir rename"
2246 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2247 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2248 skip "Need MDS version at least 2.7.56"
2250 local remote_dir=$DIR/$tdir/remote_dir
2251 local local_dir=$DIR/$tdir/local_dir
2254 mkdir_on_mdt0 $DIR/$tdir
2255 mkdir $DIR/$tdir/local_dir
2256 $LFS mkdir -i $MDTIDX $remote_dir
2258 touch $local_dir/local_file
2259 drop_update_reply $MDTIDX \
2260 "ln $local_dir/local_file $remote_dir/remote_file" ||
2263 $CHECKSTAT -t file $remote_dir/remote_file ||
2264 error "remote not present after ln"
2266 run_test 110j "drop update reply during cross-MDT ln"
2269 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2270 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2271 skip "Need MDS version at least 2.12.55"
2274 stop mds2 || error "stop mds2 failed"
2276 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2277 do_facet mds2 lctl set_param fail_loc=0x80001103
2278 local OPTS="$MDS_MOUNT_OPTS -o abort_recovery"
2279 start mds2 $(mdsdevname 2) $OPTS ||
2280 error "start MDS with abort_recovery should succeed"
2281 do_facet mds2 lctl set_param fail_loc=0
2284 stop mds2 || error "cleanup: stop mds2 failed"
2285 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS ||
2286 error "cleanup: start mds2 failed"
2287 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2288 client_up || error "post-failover df failed"
2291 run_test 110k "FID_QUERY failed during recovery"
2294 (( $(lustre_version_code $SINGLEMDS) >= $(version_code 2.14.52) )) ||
2295 skip "Need MDS version at least 2.14.52"
2296 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
2297 local remote_dir=$DIR/$tdir/remote_dir
2302 mkdir_on_mdt0 $DIR/$tdir
2304 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x0525
2305 do_facet mds1 $LCTL set_param fail_loc=0x80000525
2306 $LFS mkdir -i 1 -c2 $remote_dir &
2309 # initiate the re-connect & re-send
2310 mdccli=$(do_facet mds2 $LCTL dl |
2311 awk '/MDT0000-osp-MDT0001/ {print $4;}')
2312 uuid=$(do_facet mds2 $LCTL get_param -n osp.$mdccli.mdt_conn_uuid)
2313 echo "conn_uuid=$uuid"
2314 do_facet mds2 $LCTL set_param "osp.$mdccli.import=connection=$uuid"
2317 (( $? == 0 )) || error "mkdir failed"
2319 diridx=$($LFS getstripe -m $remote_dir)
2320 (( $diridx == 1 )) || error "$diridx != 1"
2321 rm -rf $DIR/$tdir || error "rmdir failed"
2323 run_test 110m "update resent vs original RPC race"
2325 # LU-2844 mdt prepare fail should not cause umount oops
2328 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2329 skip "Need MDS version at least 2.3.62"
2331 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2332 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2333 stop $SINGLEMDS || error "stop MDS failed"
2334 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS &&
2335 error "start MDS should fail"
2336 do_facet $SINGLEMDS lctl set_param fail_loc=0
2337 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2338 error "start MDS failed"
2340 run_test 111 "mdd setup fail should not cause umount oops"
2344 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2346 do_facet_random_file client $TMP/$tfile 100K ||
2347 error_noexit "Create random file $TMP/$tfile"
2349 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2350 error_noexit "Can't pause_bulk copy"
2353 # expect cmp to succeed, client resent bulk
2354 cmp $TMP/$tfile $DIR/$tfile ||
2355 error_noexit "Wrong data has been written"
2357 error_noexit "Can't remove file"
2360 run_test 112a "bulk resend while orignal request is in progress"
2367 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2368 cancel_lru_locks osc
2371 $LCTL set_param fail_loc=$fail1 fail_val=3
2372 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2376 set_nodes_failloc "$(osts_nodes)" $fail2
2378 wait $pid || error "dd failed"
2386 local fail_val2=${4:-0}
2392 $LCTL set_param fail_loc=$fail1 fail_val=4
2393 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2398 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2402 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2403 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2408 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2409 skip "need at least 2.8.50 on OST"
2411 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2412 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2413 test_115_read 0x8000051b 0x8000051a
2415 run_test 115a "read: late REQ MDunlink and no bulk"
2418 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2419 skip "need at least 2.8.50 on OST"
2421 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2422 #define OBD_FAIL_OST_ENOSPC 0x215
2424 # pass $OSTCOUNT for the fail_loc to be caught
2425 # appropriately by the IO thread
2426 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2428 run_test 115b "write: late REQ MDunlink and no bulk"
2431 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2432 skip "need at least 2.8.50 on OST"
2434 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2435 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2436 test_115_read 0x8000050f 0x8000051a
2438 run_test 115c "read: late Reply MDunlink and no bulk"
2441 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2442 skip "need at least 2.8.50 on OST"
2444 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2445 #define OBD_FAIL_OST_ENOSPC 0x215
2446 test_115_write 0x8000050f 0x80000215 0
2448 run_test 115d "write: late Reply MDunlink and no bulk"
2451 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2452 skip "need at least 2.8.50 on OST"
2454 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2455 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2456 test_115_read 0x80000510 0x80000211
2458 run_test 115e "read: late Bulk MDunlink and no reply"
2461 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2462 skip "need at least 2.8.50 on OST"
2464 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2465 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2466 test_115_read 0x8000051b 0x80000211
2468 run_test 115f "read: late REQ MDunlink and no reply"
2471 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2472 skip "need at least 2.8.50 on OST"
2474 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2475 test_115_read 0x8000051c 0
2477 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2479 # parameters: fail_loc CMD RC
2486 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2487 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2488 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2489 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2492 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2493 [ "$1" = "CLEANUP" ] &&
2494 fail=0x80000320 && echo ", $1 cp first"
2495 [ "$1" = "REPLY" ] &&
2496 fail=0x80000321 && echo ", $1 cp first"
2497 [ "$1" = "DEADLOCK CLEANUP" ] &&
2498 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2499 [ "$1" = "DEADLOCK REPLY" ] &&
2500 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2502 if [ x"$2" = x"get" ]; then
2503 #for TEST lock, take a conflict in advance
2504 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2505 echo "** Taking conflict **"
2506 flocks_test 5 set read sleep 10 $DIR/$tfile &
2512 $LCTL set_param fail_loc=$fail
2514 flocks_test 5 $2 write $DIR/$tfile &
2518 echo "** Evicting and re-connecting client **"
2523 if [ x"$2" = x"get" ]; then
2530 # check if the return value is allowed
2531 [ $rc -eq $3 ] && rc=0
2533 $LCTL set_param fail_loc=0
2537 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2538 # the ORIGINAL lock.
2543 flocks_test 5 set write sleep 4 $DIR/$tfile &
2547 # let unlock to sleep in CP CB
2548 $LCTL set_param fail_loc=$1
2551 # let cleanup to cleep in CP CB
2559 $LCTL set_param fail_loc=0
2564 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2567 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2568 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2569 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2571 test_120_reply "REPLY" set 5 || error "SET race failed"
2572 test_120_reply "REPLY" get 5 || error "GET race failed"
2573 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2576 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2577 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2579 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2581 run_test 120 "flock race: completion vs. evict"
2584 local BEFORE=$(date +%s)
2587 # modify dir so that next revalidate would not obtain UPDATE lock
2590 # drop 1 reply with UPDATE lock,
2591 # resend should not create 2nd lock on server
2592 mcreate $DIR/$tfile || error "mcreate failed: $?"
2593 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2595 # 2 BL AST will be sent to client, both must find the same lock,
2596 # race them to not get EINVAL for 2nd BL AST
2597 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2598 $LCTL set_param fail_loc=0x8000031f
2600 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2601 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2602 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2604 # let the client reconnect
2606 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2607 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2609 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2611 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2615 test_mkdir -p $DIR/$tdir
2617 # Prevent interference from layout intent RPCs due to
2618 # asynchronous writeback. These will be tested in 130c below.
2619 do_nodes ${CLIENTS:-$HOSTNAME} sync
2621 # get only LOOKUP lock on $tdir
2622 cancel_lru_locks mdc
2623 ls $DIR/$tdir/$tfile 2>/dev/null
2625 # get getattr by fid on $tdir
2627 # we need to race with unlink, unlink must complete before we will
2628 # take a DLM lock, otherwise unlink will wait until getattr will
2629 # complete; but later than getattr starts so that getattr found
2631 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2632 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2639 # drop the reply so that resend happens on an unlinked file.
2640 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2641 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2645 remote_mds_nodsh && skip "remote MDS with nodsh"
2646 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2647 skip "Need server version newer than 2.7.1"
2651 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2654 run_test 130a "enqueue resend on not existing file"
2657 remote_mds_nodsh && skip "remote MDS with nodsh"
2658 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2659 skip "Need server version newer than 2.7.1"
2662 # let the reply to be dropped
2665 #define OBD_FAIL_SRV_ENOENT 0x217
2666 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2668 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2671 run_test 130b "enqueue resend on a stale inode"
2674 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2676 do_nodes ${CLIENTS:-$HOSTNAME} sync
2677 echo XXX > $DIR/$tfile
2679 cancel_lru_locks mdc
2681 # Trigger writeback on $tfile.
2683 # we need to race with unlink, unlink must complete before we will
2684 # take a DLM lock, otherwise unlink will wait until intent will
2685 # complete; but later than intent starts so that intent found
2687 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2688 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2695 # drop the reply so that resend happens on an unlinked file.
2696 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2697 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2699 # let the reply to be dropped
2702 #define OBD_FAIL_SRV_ENOENT 0x217
2703 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2709 run_test 130c "layout intent resend on a stale inode"
2712 local before=$(date +%s)
2715 mount_client $MOUNT2 || error "mount filed"
2718 # get a lock on client so that export would reach the stale list
2719 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2720 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2723 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2724 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2726 $TRUNCATE $DIR/$tfile 100 &
2729 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2733 umount_client $MOUNT2
2735 evict=$(do_facet client $LCTL get_param \
2736 osc.$FSNAME-OST0000-osc-*/state |
2737 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2739 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2740 (do_facet client $LCTL get_param \
2741 osc.$FSNAME-OST0000-osc-*/state;
2742 error "eviction happened: $evict before:$before")
2744 run_test 132 "long punch"
2747 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2750 # get a lock on client so that export would reach the stale list
2751 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2752 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2754 # another IO under the same lock
2755 #define OBD_FAIL_OSC_DELAY_IO 0x414
2756 $LCTL set_param fail_loc=0x80000414
2757 $LCTL set_param fail_val=4 fail_loc=0x80000414
2758 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2762 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2763 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2767 wait $pid && error "dd succeeded"
2770 run_test 131 "IO vs evict results to IO under staled lock"
2773 local list=$(comma_list $(mdts_nodes))
2775 local t=$((TIMEOUT * 2))
2778 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2780 multiop_bg_pause $DIR/$tfile O_jc || return 1
2783 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2784 do_nodes $list $LCTL set_param fail_loc=0x80000157
2786 echo "waiting for multiop $PID"
2787 wait $PID || return 2
2793 run_test 133 "don't fail on flock resend"
2796 [ $CLIENTCOUNT -lt 2 ] &&
2797 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2799 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2800 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2801 error "touch failed"
2802 zconf_umount_clients $CLIENTS $MOUNT
2803 zconf_mount_clients $CLIENTS $MOUNT
2805 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2806 # assume commit interval is 5
2807 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2809 local -a clients=(${CLIENTS//,/ })
2810 local client1=${clients[0]}
2811 local client2=${clients[1]}
2813 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2815 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2818 wait $rmpid || error "rm failed"
2819 wait $mvpid || error "mv failed"
2822 run_test 134 "race between failover and search for reply data free slot"
2825 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2826 skip "Need MDS version at least 2.12.51"
2829 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2830 # to have parent dir write lock before open/resend
2831 touch $DIR/$tdir/$tfile
2832 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2833 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2834 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2835 error "Failed to open DOM file"
2837 run_test 135 "DOM: open/create resend to return size"
2840 remote_mds_nodsh && skip "remote MDS with nodsh"
2841 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2842 skip "Need MDS version at least 2.12.52"
2844 local mdts=$(comma_list $(mdts_nodes))
2845 local MDT0=$(facet_svc $SINGLEMDS)
2847 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2848 [ -n "$clog" ] || error "changelog_register failed"
2849 cl_mask=$(do_facet mds1 $LCTL get_param \
2850 mdd.$MDT0.changelog_mask -n)
2851 changelog_chmask "ALL"
2853 # generate some changelog records to accumulate
2854 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2855 createmany -m $DIR/$tdir/$tfile 10000 ||
2856 error "create $DIR/$tdir/$tfile failed"
2858 local size1=$(do_facet $SINGLEMDS \
2859 $LCTL get_param -n mdd.$MDT0.changelog_size)
2860 echo "Changelog size $size1"
2862 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2863 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2865 # launch changelog_deregister in background on MDS
2866 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2867 > foo.out 2> foo.err < /dev/null &"
2868 # give time to reach fail_loc
2871 # fail_loc will make MDS sleep in the middle of changelog_deregister
2872 # take this opportunity to abruptly kill MDS
2873 FAILURE_MODE_save=$FAILURE_MODE
2876 FAILURE_MODE=$FAILURE_MODE_save
2878 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2880 local size2=$(do_facet $SINGLEMDS \
2881 $LCTL get_param -n mdd.$MDT0.changelog_size)
2882 echo "Changelog size $size2"
2883 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2884 mdd.$MDT0.changelog_users | grep $clog")
2885 echo "After crash, changelog user $clog2"
2887 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2888 error "changelog record count unchanged"
2890 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2892 run_test 136 "changelog_deregister leaving pending records"
2896 mkdir_on_mdt0 $DIR/$tdir
2899 dd if=/dev/zero of=$DIR/$tdir/d1/$tfile bs=4096 count=1
2900 dd if=/dev/zero of=$DIR/$tdir/d2/$tfile bs=4096 count=1
2901 cancel_lru_locks osc
2903 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2904 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2906 # RPC1: any reply is to be delayed to disable last_xid logic
2907 ln $DIR/$tdir/d1/$tfile $DIR/$tdir/d1/f2 &
2910 # RPC2: setattr1 reply is delayed & resent
2911 # original reply comes to client; the resend get asleep
2912 chmod 666 $DIR/$tdir/d2/$tfile
2914 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2915 chmod 777 $DIR/$tdir/d2/$tfile
2917 # RPC2 resend wakes up
2919 [ $(stat -c "%a" $DIR/$tdir/d2/$tfile) == 777 ] ||
2920 error "resend got applied"
2922 run_test 137 "late resend must be skipped if already applied"
2925 remote_mds_nodsh && skip "remote MDS with nodsh"
2926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2927 [[ "$MDS1_VERSION" -ge $(version_code 2.12.59) ]] ||
2928 skip "Need server version newer than 2.12.59"
2930 zconf_umount_clients $CLIENTS $MOUNT
2932 #define OBD_FAIL_TGT_RECOVERY_CONNECT 0x724
2933 #delay a first step of recovey when MDS waiting clients
2934 #and failing to get osp logs
2935 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x724 fail_val=5
2937 facet_failover $SINGLEMDS
2939 #waiting failover and recovery timer
2940 #the valuse is based on target_recovery_overseer() wait_event timeout
2942 stop $SINGLEMDS || error "stop MDS failed"
2943 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
2944 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2945 error "start MDS failed"
2946 zconf_mount_clients $CLIENTS $MOUNT
2948 run_test 138 "Umount MDT during recovery"
2951 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2952 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
2953 skip "Need MDS version at least 2.13.50"
2955 mdt_dev=$(mdsdevname 1)
2957 stop $SINGLEMDS || error "stop $SINGLEMDS failed"
2959 #define OBD_FAIL_OSP_INVALID_LOGID 0x2106
2960 do_facet $SINGLEMDS $LCTL set_param fail_val=0x68 fail_loc=0x80002106
2961 start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
2963 run_test 139 "corrupted catid won't cause crash"
2966 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
2967 skip "Need MDS version at least 2.13.50"
2969 [ "$SHARED_KEY" = true ] &&
2970 skip "server local client incompatible with SSK keys installed"
2972 slr=$(do_facet mds1 \
2973 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
2974 stack_trap "do_facet mds1 $LCTL set_param \
2975 mdt.*.local_recovery=$slr" EXIT
2977 # disable recovery for local clients
2978 # so local clients should be marked with no_recovery flag
2979 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
2983 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
2984 grep export_flags.*no_recovery | wc -l)
2985 echo "$cnt clients with recovery disabled"
2987 [ $cnt -eq 0 ] && error "no clients with recovery disabled"
2989 # enable recovery for local clients
2990 # so no local clients should be marked with no_recovery flag
2991 do_facet mds1 $LCTL set_param mdt.*.local_recovery=1
2994 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
2995 grep export_flags.*no_recovery | wc -l)
2996 echo "$cnt clients with recovery disabled"
2998 [ $cnt -eq 0 ] || error "$cnt clients with recovery disabled"
3000 run_test 140a "local mount is flagged properly"
3003 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
3004 skip "Need MDS version at least 2.13.50"
3006 [ "$SHARED_KEY" = true ] &&
3007 skip "server local client incompatible with SSK keys installed"
3009 slr=$(do_facet mds1 \
3010 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
3011 stack_trap "do_facet mds1 $LCTL set_param \
3012 mdt.*.local_recovery=$slr" EXIT
3014 # disable recovery for local clients
3015 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
3021 # Lustre: tfs-MDT0000: Recovery over after 0:03, of 2 clients 2 rec...
3022 local recovery=$(do_facet mds1 dmesg |
3023 awk '/Recovery over after/ { print $6 }' | tail -1 |
3024 awk -F: '{ print $1 * 60 + $2 }')
3025 (( recovery < TIMEOUT * 2 + 5 )) ||
3026 error "recovery took too long $recovery > $((TIMEOUT * 2 + 5))"
3028 run_test 140b "local mount is excluded from recovery"
3034 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3035 combined_mgs_mds || skip "needs combined MGS/MDT"
3036 ( local_mode || from_build_tree ) &&
3037 skip "cannot run in local mode or from build tree"
3039 # some get_param have a bug to handle dot in param name
3040 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
3041 oldc=$(do_facet $SINGLEMDS $LCTL get_param -n \
3042 'ldlm.namespaces.MGC*.lock_count')
3044 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
3045 newc=$(do_facet $SINGLEMDS $LCTL get_param -n \
3046 'ldlm.namespaces.MGC*.lock_count')
3048 [ $oldc -eq $newc ] || error "mgc lost locks ($oldc != $newc)"
3051 run_test 141 "do not lose locks on MGS restart"
3054 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
3055 skip "Need MDS version at least 2.11.56"
3057 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
3058 do_facet mds1 $LCTL set_param fail_loc=0x165
3059 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
3062 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
3064 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3065 error "MDD orphan cleanup thread not quit"
3067 run_test 142 "orphan name stub can be cleaned up in startup"
3070 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.13.00) ] &&
3071 skip "Need MDS version at least 2.13.00"
3072 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3074 local mntpt=$(facet_mntpt $SINGLEMDS)
3076 mount_fstype $SINGLEMDS || error "mount as fstype $SINGLEMDS failed"
3077 do_facet $SINGLEMDS touch $mntpt/PENDING/$tfile
3078 unmount_fstype $SINGLEMDS
3079 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3081 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
3082 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3083 error "MDD orphan cleanup thread not quit"
3085 run_test 143 "orphan cleanup thread shouldn't be blocked even delete failed"
3088 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3089 skip "server does not support overstriping"
3098 large_xattr_enabled || skip_env "ea_inode feature disabled"
3099 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3100 stack_trap "rm -rf $DIR/$tdir" EXIT
3102 mds_timeout=$(do_facet mds1 $LCTL get_param -n timeout)
3103 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=300
3104 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=$mds_timeout" EXIT
3106 $LFS setstripe -i 0 -C $setcount $DIR/$tdir || error "setstripe failed"
3108 for (( i = 0; i < 50; i++)); do
3109 touch $DIR/$tdir/$tfile_$i &
3116 for pid in $pids; do
3117 kill -9 $pid >/dev/null 2>&1
3123 # here we measure MDT stop + MDT start time. For error case MDT stop takes
3124 # about obd_timeout-60 (240) seconds. Without error - less than 30s.
3125 # MDT start takes different time depends on a configuration, let's check
3127 diff=$((after - before))
3128 (( $diff < 240 )) || error "MDT failover took $diff seconds"
3130 run_test 144a "MDT failover should stop precreation threads"
3133 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
3134 [ $(facet_active_host mds2) = $(facet_active_host mds3) ] &&
3135 skip "needs mds2 and mds3 on separate nodes"
3141 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
3142 echo block mds_connect from mds2
3143 do_facet mds2 "$LCTL set_param fail_loc=0x507"
3145 #define OBD_FAIL_OUT_UPDATE_DROP 0x1707
3146 echo block recovery updates from mds3
3147 do_facet mds3 "$LCTL set_param fail_loc=0x1707"
3149 local hard_timeout=\
3150 $(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard)
3154 local get_soft_timeout_cmd=\
3155 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_soft 2>/dev/null"
3157 echo wait until mds1 recovery_time_soft is $hard_timeout
3158 wait_update $(facet_host mds1) "$get_soft_timeout_cmd" \
3159 "$hard_timeout" $hard_timeout
3161 echo unblock mds_connect from mds2
3162 do_facet mds2 "$LCTL set_param fail_loc=0"
3164 echo upblock recovery updates from mds3
3165 do_facet mds3 "$LCTL set_param fail_loc=0"
3168 [ -f $DIR/$tfile ] || error "$DIR/$tfile does not exist"
3170 run_test 145 "connect mdtlovs and process update logs after recovery expire"
3173 local obd_timeout=200
3174 local old=$($LCTL get_param -n timeout)
3176 local connection_count
3178 $LFS setstripe -i 0 -c 1 $f
3179 stripe_index=$($LFS getstripe -i $f)
3180 if [ $stripe_index -ne 0 ]; then
3182 error "$f: stripe_index $stripe_index != 0" && return
3185 $LCTL set_param timeout=$obd_timeout
3186 stack_trap "$LCTL set_param timeout=$old && client_reconnect" EXIT
3188 # OBD_FAIL_OST_CONNECT_NET2
3189 # lost reply to connect request
3190 do_facet ost1 lctl set_param fail_loc=0x00000225 timeout=$obd_timeout
3191 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0 timeout=$old" EXIT
3196 $LFS df $MOUNT > /dev/null 2>&1 &
3197 sleep $((obd_timeout * 3 / 4))
3199 $LCTL get_param osc.$FSNAME-OST0000-osc-*.state
3200 connection_count=$($LCTL get_param osc.$FSNAME-OST0000-osc-*.state |
3201 tac | sed "/FULL/,$ d" | grep CONNECTING | wc -l)
3203 echo $connection_count
3204 (($connection_count >= 6)) || error "Client reconnected too slow"
3206 run_test 147 "Check client reconnect"
3209 local wce_param="obdfilter.$FSNAME-OST0000.writethrough_cache_enable"
3210 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3211 local amc=$(at_max_get client)
3212 local amo=$(at_max_get ost1)
3217 timeout=$(request_timeout client)
3219 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3220 # save old r/o cache settings
3221 save_lustre_params ost1 $wce_param > $p
3224 do_facet ost1 "$LCTL set_param -n $wce_param=0"
3227 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3228 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
3229 cp $DIR/$tfile $TMP/$tfile
3230 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3231 do_facet ost1 $LCTL set_param fail_loc=0x80000227
3232 do_facet ost1 $LCTL set_param fail_val=$((timeout+2))
3233 dd if=/dev/urandom of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3234 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3236 cancel_lru_locks osc
3237 cmp -b $DIR/$tfile $TMP/$tfile || error "wrong data"
3239 rm -f $DIR/$tfile $TMP/$tfile
3241 at_max_set $amc client
3242 at_max_set $amo ost1
3244 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3245 # restore initial r/o cache settings
3246 restore_lustre_params < $p
3251 run_test 148 "data corruption through resend"
3254 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3256 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3258 # make an orphan striped dir
3259 $MULTIOP $DIR/$tdir D_c &
3262 rmdir $DIR/$tdir || error "can't rmdir"
3264 # stop a slave MDT where one ons stripe is located
3267 # stopping should not cause orphan as another MDT can
3271 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3272 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "mds1 start fail"
3280 run_test 149 "skip orphan removal at umount"
3283 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3287 lazystatfs=$($LCTL get_param -n llite.$FSNAME-*.lazystatfs | head -1)
3288 max=$($LCTL get_param -n llite.$FSNAME-*.statahead_max | head -1)
3290 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3291 $LCTL set_param llite.$FSNAME-*.statahead_max=0
3292 stack_trap "$LCTL set_param llite.$FSNAME-*.lazystatfs=$lazystatfs" EXIT
3293 stack_trap "$LCTL set_param llite.$FSNAME-*.statahead_max=$max" EXIT
3294 # stop a slave MDT where one ons stripe is located
3297 stack_trap "start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS && \
3298 wait_recovery_complete mds1 && clients_up && true" EXIT
3300 df $MOUNT || error "statfs failed"
3303 run_test 150 "statfs when MDT0 offline with lazystatfs option"
3306 check_and_cleanup_lustre