5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
11 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT "
14 always_except LU-17141 133
19 require_dsh_mds || exit 0
21 # Allow us to override the setup if we already have a mounted system by
22 # setting SETUP=" " and CLEANUP=" "
24 CLEANUP=${CLEANUP:-""}
26 check_and_setup_lustre
29 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
31 # new sequence needed for MDS < v2_15_61-226-gf00d2467fc
32 if (( $MDS1_VERSION < $(version_code 2.15.61.226) )); then
37 local f1="$DIR/$tfile"
38 local f2="$DIR/$tfile.2"
40 drop_request "mcreate $f1" ||
41 error_noexit "create '$f1': drop req"
43 drop_reint_reply "mcreate $f2" ||
44 error_noexit "create '$f2': drop rep"
46 drop_request "tchmod 111 $f2" ||
47 error_noexit "chmod '$f2': drop req"
49 drop_reint_reply "tchmod 666 $f2" ||
50 error_noexit "chmod '$f2': drop rep"
52 drop_request "statone $f2" ||
53 error_noexit "stat '$f2': drop req"
55 drop_reply "statone $f2" ||
56 error_noexit "stat '$f2': drop rep"
58 run_test 1 "create, chmod, stat: drop req, drop rep"
62 do_facet_create_file client $t 10K ||
63 error_noexit "Create file $t"
65 drop_request "cat $t > /dev/null" ||
66 error_noexit "Open request for $t file"
68 drop_reply "cat $t > /dev/null" ||
69 error_noexit "Open replay for $t file"
71 run_test 4 "open: drop req, drop rep"
76 local RR="$T-renamed-again"
77 do_facet_create_file client $T 10K ||
78 error_noexit "Create file $T"
80 drop_request "mv $T $R" ||
81 error_noexit "Rename $T"
83 drop_reint_reply "mv $R $RR" ||
84 error_noexit "Failed rename replay on $R"
86 do_facet client "checkstat -v $RR" ||
87 error_noexit "checkstat error on $RR"
89 do_facet client "rm $RR" ||
90 error_noexit "Can't remove file $RR"
92 run_test 5 "rename: drop req, drop rep"
96 local LINK1=$DIR/$tfile.link1
97 local LINK2=$DIR/$tfile.link2
99 do_facet_create_file client $T 10K || error_noexit "Create file $T"
100 drop_request "link $T $LINK1" || error_noexit "link request for $T"
101 drop_reint_reply "link $T $LINK2" || error_noexit "link reply for $T"
102 drop_request "unlink $LINK1" || error_noexit "unlink request for $T"
103 drop_reint_reply "unlink $LINK2" || error_noexit "unlink reply for $T"
104 do_facet client "rm $T" || error_noexit "Can't remove file $T"
106 run_test 6 "link, unlink: drop req, drop rep"
110 drop_reint_reply "touch $DIR/$tfile" || return 1
112 run_test 8 "touch: drop rep (bug 1423)"
116 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
120 do_facet_random_file client $TMP/$tfile 1K ||
121 error_noexit "Create random file $TMP/$tfile"
122 # make this big, else test 9 doesn't wait for bulk -- bz 5595
123 do_facet_create_file client $TMP/$t1 4M ||
124 error_noexit "Create file $TMP/$t1"
125 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
126 error_noexit "Can't copy to $DIR/$t1 file"
127 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
128 error_noexit "Can't pause_bulk copy"
129 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
130 error_noexit "Can't copy file"
131 do_facet client "sync"
132 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
133 error_noexit "Can't remove files"
134 do_facet client "rm $TMP/$t1 $TMP/$tfile"
136 run_test 9 "pause bulk on OST (bug 1420)"
140 local before=$(date +%s)
142 local lru_param="ldlm.namespaces.*mdc*.lru_max_age"
143 local old_max_age=($($LCTL get_param -n $lru_param))
144 local old_ratelimit=$($LCTL get_param console_ratelimit)
146 $LCTL set_param $lru_param=3900s console_ratelimit=0
147 stack_trap "$LCTL set_param $lru_param=$old_max_age $old_ratelimit"
149 do_facet client "stat $DIR > /dev/null" ||
150 error "failed to stat $DIR: $?"
151 drop_bl_callback "chmod 0777 $DIR" ||
152 error "failed to chmod $DIR: $?"
154 # let the client reconnect
156 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
157 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
158 [[ -n "$evict" ]] && (( $evict > $before )) ||
159 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
160 error "no eviction: $evict before:$before")
162 do_facet client checkstat -v -p 0777 $DIR ||
163 error "client checkstat failed: $?"
165 # console messages may be ratelimited on later iterations
166 (( ONLY_REPEAT_ITER == 1 )) || return 0
168 # check that the thread watchdog is working properly
169 do_facet mds1 dmesg | tac | sed "/${TESTNAME/_/ }/,$ d" |
170 grep "[Ss]ervice thread pid .* was inactive" ||
171 error "no service thread inactive message for ${TESTNAME/_/ }"
173 # can't check for "completed" message where it was removed
174 (( $MDS1_VERSION > $(version_code v2_12_50-83-gfc9de679a4) &&
175 $MDS1_VERSION < $(version_code 2.15.62.59) )) ||
176 do_facet mds1 dmesg | tac | sed "/${TESTNAME/_/ }/,$ d" |
177 grep "[Ss]ervice thread pid .* completed after" ||
178 error "no service thread completed message for ${TESTNAME/_/ }"
180 run_test 10a "finish request on server after client eviction (bug 1521)"
183 local before=$(date +%s)
186 [[ "$MDS1_VERSION" -lt $(version_code 2.6.53) ]] &&
187 skip "Need MDS version at least 2.6.53"
188 do_facet client "stat $DIR > /dev/null" ||
189 error "failed to stat $DIR: $?"
190 drop_bl_callback_once "chmod 0777 $DIR" ||
191 error "failed to chmod $DIR: $?"
193 # let the client reconnect
195 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
196 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
198 [ -z "$evict" ] || [[ $evict -le $before ]] ||
199 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
200 error "eviction happened: $evict before:$before")
202 do_facet client checkstat -v -p 0777 $DIR ||
203 error "client checkstat failed: $?"
205 run_test 10b "re-send BL AST"
208 local before=$(date +%s)
217 workdir="${DIR}/${tdir}"
218 mkdir -p ${workdir} || error "can't create workdir $?"
219 stat ${workdir} > /dev/null ||
220 error "failed to stat ${workdir}: $?"
221 mdtidx=$($LFS getdirstripe -i ${workdir})
222 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
223 awk '{sub("_UUID", "", $2); print $2;}')
225 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
226 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
227 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
229 drop_bl_callback_once "chmod 0777 ${workdir}" &
234 # force client reconnect
235 $LCTL set_param "${mdcpath}"
237 # wait client reconnect
241 evict=$($LCTL get_param mdc.${mdccli}.state |
242 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
244 [[ $evict -le $before ]] ||
245 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
246 error "eviction happened: $EVICT before:$BEFORE" )
248 [ $rc -eq 0 ] || error "chmod must finished OK"
249 checkstat -v -p 0777 "${workdir}" ||
250 error "client checkstat failed: $?"
252 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
255 local before=$(date +%s)
258 [[ "$MDS1_VERSION" -lt $(version_code 2.6.90) ]] &&
259 skip "Need MDS version at least 2.6.90"
261 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
264 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
266 remount_client $MOUNT
270 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
271 echo -n hello | dd of=$DIR1/$tfile bs=5
273 stat $DIR2/$tfile >& /dev/null
274 $LCTL set_param fail_err=71
275 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
280 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
281 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
283 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
285 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
287 [[ $evict -gt $before ]] ||
288 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
289 error "no eviction: $evict before:$before")
291 $LCTL set_param fail_err=0
293 umount_client $MOUNT2
295 run_test 10d "test failed blocking ast"
299 [[ "$OST1_VERSION" -le $(version_code 2.8.58) ]] &&
300 skip "Need OST version at least 2.8.59"
301 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients"
302 [ $(facet_host client) == $(facet_host ost1) ] &&
303 skip "need ost1 and client on different nodes"
304 local -a clients=(${CLIENTS//,/ })
305 local client1=${clients[0]}
306 local client2=${clients[1]}
308 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
309 $MULTIOP $DIR/$tfile-1 Ow1048576c
311 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
312 $LCTL set_param fail_loc=0x80000305
314 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
315 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
316 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
317 # 1. to return ENOTCONN from ldlm_handle_enqueue0
318 # 2. to pause reconnect handling between resend and setting
319 # import to LUSTRE_IMP_FULL state
320 do_facet ost1 "$LCTL set_param fail_val=3"
322 # client1 fails ro respond to bl ast
323 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
326 # ost1 returns error on enqueue, which causes client1 to reconnect
327 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
328 error "multiop failed"
331 do_facet ost1 "$LCTL set_param fail_loc=0"
332 do_facet ost1 "$LCTL set_param fail_val=0"
334 run_test 10e "re-send BL AST vs reconnect race 2"
337 # wake up a thread waiting for completion after eviction
339 do_facet client $MULTIOP $DIR/$tfile Ow ||
340 { error "multiop write failed: $?"; return 1; }
341 do_facet client $MULTIOP $DIR/$tfile or ||
342 { error "multiop read failed: $?"; return 2; }
346 do_facet client $MULTIOP $DIR/$tfile or ||
347 { error "multiop read failed: $?"; return 3; }
348 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
349 echo "evicted as expected"
351 do_facet client unlink $DIR/$tfile ||
352 { error "unlink failed: $?"; return 4; }
353 # allow recovery to complete
354 client_up || client_up || sleep $TIMEOUT
356 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
360 $LCTL mark $MULTIOP $DIR/$tfile OS_c
361 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
362 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
363 multiop_bg_pause $DIR/$tfile OS_c ||
364 { error "multiop failed: $?"; return 1; }
366 #define OBD_FAIL_MDS_CLOSE_NET 0x115
368 echo "waiting for multiop $PID"
369 wait $PID || { error "wait for multiop faile: $?"; return 2; }
370 do_facet client unlink $DIR/$tfile ||
371 { error "client unlink failed: $?"; return 3; }
372 # allow recovery to complete
373 client_up || client_up || sleep $TIMEOUT
375 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
377 # Bug 113, check that readdir lost recv timeout works.
379 mkdir_on_mdt0 $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
380 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
381 # OBD_FAIL_MDS_READPAGE_NET|CFS_FAIL_ONCE
382 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
383 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
384 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
385 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
387 run_test 13 "mdc_readpage restart test (bug 1138)"
389 # Bug 113, check that readdir lost send timeout works.
391 mkdir_on_mdt0 $DIR/$tdir
392 touch $DIR/$tdir/newentry
393 # OBD_FAIL_MDS_SENDPAGE|CFS_FAIL_ONCE
394 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
395 ls $DIR/$tdir || return 1
396 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
398 run_test 14 "mdc_readpage resend test (bug 1138)"
401 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
402 touch $DIR/$tfile && return 1
405 run_test 15 "failed open (-ENOMEM)"
407 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
409 lctl set_param -n llite.*.max_read_ahead_mb 0
413 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
417 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
419 do_facet_random_file client $TMP/$tfile 100K ||
420 { error_noexit "Create random file $TMP/$T" ; return 0; }
421 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
422 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
426 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | CFS_FAIL_ONCE
427 do_facet ost1 "lctl set_param fail_loc=0x80000504"
429 # OST bulk will time out here, client resends
430 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
431 do_facet ost1 lctl set_param fail_loc=0
432 # give recovery a chance to finish (shouldn't take long)
434 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
438 run_test 16 "timeout bulk put, don't evict client (2732)"
443 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
445 local SAMPLE_FILE=$TMP/$tfile
446 do_facet_random_file client $SAMPLE_FILE 20K ||
447 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
449 # With adaptive timeouts, bulk_get won't expire until
450 # adaptive_timeout_max
451 if at_is_enabled; then
452 at_max_saved=$(at_max_get ost1)
453 at_max_set $TIMEOUT ost1
456 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | CFS_FAIL_ONCE
457 # OST bulk will time out here, client retries
458 do_facet ost1 lctl set_param fail_loc=0x80000503
459 # need to ensure we send an RPC
460 do_facet client cp $SAMPLE_FILE $DIR/$tfile
463 # with AT, client will wait adaptive_max*factor+net_latency before
464 # expiring the req, hopefully timeout*2 is enough
465 sleep $(($TIMEOUT*2))
467 do_facet ost1 lctl set_param fail_loc=0
468 do_facet client "df $DIR"
469 # expect cmp to succeed, client resent bulk
470 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
471 do_facet client "rm $DIR/$tfile" || return 4
472 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
475 run_test 17a "timeout bulk get, don't evict client (2732)"
478 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
480 # get one of the clients from client list
481 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
482 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
483 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
484 [ -z "$ldlm_enqueue_min" ] &&
485 skip "missing /sys/.../ldlm_enqueue_min" && return 0
487 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
488 error "setstripe failed"
489 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
490 error "setstripe 2 failed"
492 save_lustre_params ost1 "at_history" > $p
493 save_lustre_params ost1 "bulk_timeout" >> $p
494 local dev="${FSNAME}-OST0000"
495 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
496 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
498 local new_at_history=15
500 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
501 do_facet ost1 "$LCTL set_param bulk_timeout=30"
502 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
504 # brw_size is required to be 4m so that bulk transfer timeout
505 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
506 local brw_size=$($LCTL get_param -n \
507 osc.$FSNAME-OST0000-osc-[^M]*.import |
508 awk '/max_brw_size/{print $2}')
509 if [ $brw_size -ne 4194304 ]
511 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
512 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
513 remount_client $MOUNT
516 # get service estimate expanded
517 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
518 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
519 echo "delay rpc servicing by 35 seconds"
520 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
523 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
524 awk '/portal 6/ {print $5}')
525 echo "service estimates increased to $estimate"
527 # let current worst service estimate to get closer to obliteration
528 sleep $((new_at_history / 3))
530 # start i/o and simulate bulk transfer loss
531 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
532 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
533 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
536 # start lock conflict handling
537 sleep $((new_at_history / 3))
538 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
541 # obliterate the worst service estimate
542 sleep $((new_at_history / 3 + 1))
543 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
545 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
546 awk '/portal 6/ {print $5}')
547 echo "service estimate dropped to $estimate"
550 [[ $? == 0 ]] || error "write failed"
552 [[ $? == 0 ]] || error "read failed"
554 restore_lustre_params <$p
555 if [ $brw_size -ne 4194304 ]
557 remount_client $MOUNT || error "remount_client failed"
559 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
561 run_test 17b "timeout bulk get, dont evict client (3582)"
564 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
566 do_facet_create_file client $TMP/$tfile 20K ||
567 { error_noexit "Create file $TMP/$tfile" ; return 0; }
569 do_facet client mkdir -p $DIR/$tdir
573 pgcache_empty || return 1
576 $LFS setstripe -i 1 -c 1 $f
577 stripe_index=$($LFS getstripe -i $f)
578 if [ $stripe_index -ne 1 ]; then
580 error "$f: stripe_index $stripe_index != 1" && return
583 do_facet client cp $TMP/$tfile $f
585 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
586 $LCTL --device $osc2dev deactivate || return 3
587 # my understanding is that there should be nothing in the page
588 # cache after the client reconnects?
590 pgcache_empty || rc=2
591 $LCTL --device $osc2dev activate
595 run_test 18a "manual ost invalidate clears page cache immediately"
598 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
600 do_facet_create_file client $TMP/$tfile 20K ||
601 { error_noexit "Create file $TMP/$tfile" ; return 0; }
603 do_facet client mkdir -p $DIR/$tdir
607 pgcache_empty || return 1
609 $LFS setstripe -i 0 -c 1 $f
610 stripe_index=$($LFS getstripe -i $f)
611 if [ $stripe_index -ne 0 ]; then
613 error "$f: stripe_index $stripe_index != 0" && return
616 do_facet client cp $TMP/$tfile $f
619 # allow recovery to complete
620 sleep $((TIMEOUT + 2))
621 # my understanding is that there should be nothing in the page
622 # cache after the client reconnects?
624 pgcache_empty || rc=2
628 run_test 18b "eviction and reconnect clears page cache (2766)"
631 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
633 do_facet_create_file client $TMP/$tfile 20K ||
634 { error_noexit "Create file $TMP/$tfile" ; return 0; }
636 do_facet client mkdir -p $DIR/$tdir
640 pgcache_empty || return 1
642 $LFS setstripe -i 0 -c 1 $f
643 stripe_index=$($LFS getstripe -i $f)
644 if [ $stripe_index -ne 0 ]; then
646 error "$f: stripe_index $stripe_index != 0" && return
649 do_facet client cp $TMP/$tfile $f
653 # OBD_FAIL_OST_CONNECT_NET2
654 # lost reply to connect request
655 do_facet ost1 lctl set_param fail_loc=0x80000225
658 $LFS df $MOUNT > /dev/null 2>&1
660 # my understanding is that there should be nothing in the page
661 # cache after the client reconnects?
663 pgcache_empty || rc=2
667 run_test 18c "Dropped connect reply after eviction handing (14755)"
670 local before=$(date +%s)
673 mount_client $DIR2 || error "failed to mount $DIR2"
675 # cancel cached locks from OST to avoid eviction from it
678 do_facet client "stat $DIR > /dev/null" ||
679 error "failed to stat $DIR: $?"
680 drop_ldlm_cancel "chmod 0777 $DIR2" ||
681 error "failed to chmod $DIR2"
685 # let the client reconnect
687 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
688 awk -F"[ [,]" '/EVICTED ]$/ \
689 { if (mx<$5) {mx=$5;} } END { print mx }')
691 [[ -n "$evict" ]] && (( $evict >= $before )) ||
692 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
693 error "no eviction: $evict < before: $before")
695 run_test 19a "test expired_lock_main on mds (2867)"
698 local before=$(date +%s)
701 mount_client $DIR2 || error "failed to mount $DIR2: $?"
703 # cancel cached locks from MDT to avoid eviction from it
706 do_facet client $MULTIOP $DIR/$tfile Ow ||
707 error "failed to run multiop: $?"
708 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
709 error "failed to ldlm_cancel: $?"
711 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
712 do_facet client unlink $DIR/$tfile ||
713 error "failed to unlink $DIR/$tfile: $?"
715 # let the client reconnect
717 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
718 awk -F"[ [,]" '/EVICTED ]$/ \
719 { if (mx < $5) {mx = $5;} } END { print mx }')
721 [[ -n "$evict" ]] && (( $evict >= $before )) ||
722 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
723 error "no eviction: $evict < before: $before")
725 run_test 19b "test expired_lock_main on ost (2867)"
728 local BEFORE=`date +%s`
731 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
733 mkdir -p $DIR1/$tfile
736 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
737 do_facet mds $LCTL set_param fail_loc=0x80000516
739 touch $DIR2/$tfile/file1 &
741 # let touch to get blocked on the server
745 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
748 # let the client reconnect
750 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
751 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
753 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
755 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
757 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
758 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
761 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
762 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
765 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
766 do_facet ost1 lctl set_param fail_loc=0x80000308
767 kill -USR1 $MULTI_PID
770 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
772 run_test 20a "ldlm_handle_enqueue error (should return error)"
774 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
775 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
778 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
780 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
781 do_facet ost1 lctl set_param fail_loc=0x80000308
782 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
783 error "didn't fail open enqueue" || true
785 run_test 20b "ldlm_handle_enqueue error (should return error)"
788 mkdir_on_mdt0 $DIR/$tdir-1
789 mkdir_on_mdt0 $DIR/$tdir-2
790 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
793 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
794 $MULTIOP $DIR/$tdir-2/f Oc &
797 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
799 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
800 kill -USR1 $close_pid
802 wait $close_pid || return 1
803 wait $open_pid || return 2
804 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
806 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
807 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
811 run_test 21a "drop close request while close and open are both in flight"
814 mkdir_on_mdt0 $DIR/$tdir-1
815 mkdir_on_mdt0 $DIR/$tdir-2
816 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
819 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
820 mcreate $DIR/$tdir-2/f &
823 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
825 kill -USR1 $close_pid
827 wait $close_pid || return 1
828 wait $open_pid || return 3
830 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
831 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
834 run_test 21b "drop open request while close and open are both in flight"
837 mkdir_on_mdt0 $DIR/$tdir-1
838 mkdir_on_mdt0 $DIR/$tdir-2
839 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
842 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
843 mcreate $DIR/$tdir-2/f &
846 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
848 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
849 kill -USR1 $close_pid
851 wait $close_pid || return 1
852 wait $open_pid || return 2
854 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
856 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
857 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
860 run_test 21c "drop both request while close and open are both in flight"
863 mkdir_on_mdt0 $DIR/$tdir-1
864 mkdir_on_mdt0 $DIR/$tdir-2
865 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
868 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
869 $MULTIOP $DIR/$tdir-2/f Oc &
871 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
873 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
876 wait $pid || return 1
877 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
879 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
880 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
884 run_test 21d "drop close reply while close and open are both in flight"
887 mkdir_on_mdt0 $DIR/$tdir-1
888 mkdir_on_mdt0 $DIR/$tdir-2
889 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
892 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
893 touch $DIR/$tdir-2/f &
895 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
899 wait $pid || return 1
902 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
903 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
906 run_test 21e "drop open reply while close and open are both in flight"
909 mkdir_on_mdt0 $DIR/$tdir-1
910 mkdir_on_mdt0 $DIR/$tdir-2
911 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
914 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
915 touch $DIR/$tdir-2/f &
917 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
919 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
922 wait $pid || return 1
923 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
925 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
926 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
929 run_test 21f "drop both reply while close and open are both in flight"
932 mkdir_on_mdt0 $DIR/$tdir-1
933 mkdir_on_mdt0 $DIR/$tdir-2
934 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
937 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
938 touch $DIR/$tdir-2/f &
940 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
942 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
945 wait $pid || return 1
946 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
948 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
949 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
952 run_test 21g "drop open reply and close request while close and open are both in flight"
955 mkdir_on_mdt0 $DIR/$tdir-1
956 mkdir_on_mdt0 $DIR/$tdir-2
957 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
960 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
961 touch $DIR/$tdir-2/f &
964 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
966 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
969 wait $pid || return 1
970 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
972 wait $touch_pid || return 2
974 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
975 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
978 run_test 21h "drop open request and close reply while close and open are both in flight"
980 # bug 3462 - multiple MDC requests
985 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
990 $MULTIOP $f1 msu || return 1
993 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
995 wait $close_pid || return 2
996 rm -rf $f2 || return 4
998 run_test 22 "drop close request and do mknod"
1001 multiop_bg_pause $DIR/$tfile O_c || return 1
1003 # give a chance for open
1007 drop_request "kill -USR1 $pid"
1010 wait $pid || return 1
1013 run_test 23 "client hang when close a file after mds crash"
1015 test_24a() { # bug 11710 details correct fsync() behavior
1016 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1019 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1020 cancel_lru_locks osc
1021 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1024 kill -USR1 $MULTI_PID
1027 lctl set_param fail_loc=0x0
1030 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1032 run_test 24a "fsync error (should return error)"
1035 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1037 dmesg -c > /dev/null
1039 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1040 error "$LFS setstripe failed"
1041 cancel_lru_locks osc
1042 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1043 error "mulitop Ow8192_yc failed"
1046 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1047 error "mulitop Ow8192_c failed"
1052 kill -USR1 $MULTI_PID1
1055 kill -USR1 $MULTI_PID2
1058 lctl set_param fail_loc=0x0
1060 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1061 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1064 dmesg | grep "dirty page discard:" ||
1065 error "no discarded dirty page found!"
1067 run_test 24b "test dirty page discard due to client eviction"
1069 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1070 # this test can only run from a client on a separate node.
1071 remote_ost || { skip "local OST" && return 0; }
1072 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1073 remote_mds || { skip "local MDS" && return 0; }
1075 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1076 skip "msg and ost1 are at the same node"
1080 check_timeout || return 1
1082 # make sure all imports are connected and not IDLE
1083 do_facet client lfs df > /dev/null
1084 # make sure client will not be discarded by server due to LU-14708
1085 $LFS setstripe -c -1 -S 64K $MOUNT/$tfile
1086 dd if=/dev/zero of=$MOUNT/$tfile bs=64K count=$OSTCOUNT oflag=sync ||
1090 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1091 do_facet client lctl set_param fail_loc=0x505
1092 local before=$(date +%s)
1095 # evictor takes PING_EVICT_TIMEOUT to evict.
1096 # But if there's a race to start the evictor from various obds,
1097 # the loser might have to wait for the next ping.
1098 sleep $((TIMEOUT * 2))
1099 do_facet client lctl set_param fail_loc=0x0
1100 do_facet client lfs df > /dev/null
1102 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1103 check_clients_evicted "$before ${oscs[@]}"
1104 check_clients_full 10 "${oscs[@]}"
1106 run_test 26a "evict dead exports"
1108 wait_client_evicted () {
1112 local varsvc=${facet}_svc
1114 wait_update_cond $(facet_active_host $facet) \
1115 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1116 "-le" $((exports - 1)) $timeout
1119 test_26b() { # bug 10140 - evict dead exports by pinger
1120 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1122 [[ $(facet_host mgs) != $(facet_host ost1) ]] ||
1123 skip "msg and ost1 are at the same node"
1125 check_timeout || return 1
1127 zconf_mount $HOSTNAME $MOUNT2 ||
1128 { error "Failed to mount $MOUNT2"; return 2; }
1129 # make sure all imports are connected and not IDLE
1130 do_facet client $LFS df > /dev/null
1131 $LFS setstripe -c -1 $MOUNT/$tfile
1133 local mds_nexp=$(do_facet mds1 \
1134 lctl get_param -n mdt.${mds1_svc}.num_exports)
1135 local ost_nexp=$(do_facet ost1 \
1136 lctl get_param -n obdfilter.${ost1_svc}.num_exports)
1137 # must be equal on all the nodes
1138 local INTERVAL=$(do_facet $SINGLEMDS lctl get_param -n ping_interval)
1139 local AT_MAX_SAVED=$(at_max_get mds1)
1141 at_max_set $TIMEOUT mds1
1142 at_max_set $TIMEOUT ost1
1143 stack_trap "at_max_set $AT_MAX_SAVED mds1" EXIT
1144 stack_trap "at_max_set $AT_MAX_SAVED ost1" EXIT
1146 echo "starting with '$ost_nexp' OST and '$mds_nexp' MDS exports"
1148 zconf_umount $HOSTNAME $MOUNT2 -f
1150 # see ptlrpc_export_timeout() for the pinger case; take a bit more the test sake
1151 local TOUT=$((INTERVAL * 2 + (TIMEOUT / 20 + 5 + TIMEOUT) * 3))
1152 TOUT=$((TOUT + (TOUT >> 3)))
1153 echo i $INTERVAL m $AT_MAX_SAVED t $TIMEOUT $TOUT
1154 wait_client_evicted ost1 $ost_nexp $TOUT ||
1155 error "Client was not evicted by OSS"
1156 wait_client_evicted mds1 $mds_nexp $TOUT ||
1157 error "Client was not evicted by MDS"
1159 run_test 26b "evict dead exports"
1162 mkdir_on_mdt0 $DIR/$tdir
1163 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1166 local save_FAILURE_MODE=$FAILURE_MODE
1168 facet_failover $SINGLEMDS
1169 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1170 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1171 # need to wait for reconnect
1172 echo waiting for fail_loc
1173 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1174 facet_failover $SINGLEMDS
1175 #no crashes allowed!
1176 kill -USR1 $CLIENT_PID
1179 FAILURE_MODE=$save_FAILURE_MODE
1181 run_test 27 "fail LOV while using OSC's"
1183 test_28() { # bug 6086 - error adding new clients
1184 do_facet client mcreate $DIR/$tfile || return 1
1185 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1186 echo "evicted as expected"
1187 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1188 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1189 # fail once (evicted), reconnect fail (fail_loc), ok
1190 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1192 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1194 run_test 28 "handle error adding new clients (bug 6086)"
1196 test_29a() { # bug 22273 - error adding new clients
1197 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1198 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1199 # fail abort so client will be new again
1200 fail_abort $SINGLEMDS
1201 client_up || error "reconnect failed"
1202 wait_osc_import_state $SINGLEMDS ost FULL
1205 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1207 test_29b() { # bug 22273 - error adding new clients
1208 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1209 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1210 # fail abort so client will be new again
1212 client_up || error "reconnect failed"
1215 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1219 # put a load of file creates/writes/deletes
1220 writemany -q $DIR/$tdir/$tfile 0 5 &
1222 echo writemany pid $CLIENT_PID
1226 # wait for client to reconnect to MDS
1231 # client process should see no problems even though MDS went down
1233 kill -USR1 $CLIENT_PID
1236 echo writemany returned $rc
1237 #these may fail because of eviction due to slow AST response.
1239 error_ignore bz13652 "writemany returned rc $rc" || true
1241 run_test 50 "failover MDS under load"
1244 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1245 do_facet ost1 lctl set_param fail_loc=0x00001310
1247 mkdir_on_mdt0 $DIR/$tdir
1248 # put a load of file creates/writes/deletes
1249 writemany -q $DIR/$tdir/$tfile 0 5 &
1253 facet_failover $SINGLEMDS
1254 # failover at various points during recovery
1255 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1256 echo will failover at $SEQ
1258 #echo failover in $i sec
1259 log "$TESTNAME: failover in $i sec"
1261 facet_failover $SINGLEMDS
1263 # client process should see no problems even though MDS went down
1264 # and recovery was interrupted
1266 kill -USR1 $CLIENT_PID
1269 echo writemany returned $rc
1271 error_ignore bz13652 "writemany returned rc $rc" || true
1273 run_test 51 "failover MDS during recovery"
1276 do_facet client "mkdir -p $DIR/$tdir"
1277 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1279 echo writemany pid $CLIENT_PID
1284 wait $CLIENT_PID || rc=$?
1285 # active client process should see an EIO for down OST
1286 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1287 # but timing or failover setup may allow success
1288 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1289 echo "writemany returned $rc"
1294 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1299 [ $rc -ne 0 ] && { return $rc; }
1300 # wait for client to reconnect to OST
1304 [ $rc -ne 0 ] && { return $rc; }
1311 run_test 52 "failover OST under load"
1313 # test of open reconstruct
1316 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1319 run_test 53a "touch: drop rep"
1324 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1327 run_test 53b "touch: drop rep"
1332 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1335 run_test 53c "touch: drop rep"
1338 zconf_mount $(hostname) $MOUNT2
1340 touch $DIR2/$tfile.1
1342 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1345 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1346 grep "went back in time")
1347 [ x"$ERROR" == x ] || error "back in time occured"
1349 run_test 54 "back in time"
1351 # bug 11330 - liblustre application death during I/O locks up OST
1353 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1357 # This test assumes relatively small max_dirty_mb setting
1358 # which we want to walk away from, so just for it we will
1359 # temporarily lower the value
1360 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1361 lctl set_param -n osc.*.max_dirty_mb=32
1362 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1364 # Minimum pass speed is 2MBps
1366 # LU-2887/LU-3089 - set min pass speed to 500KBps
1367 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1369 # first dd should be finished quickly
1370 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1371 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1374 echo "step1: testing ......"
1375 while kill -0 $DDPID 2> /dev/null; do
1377 if [ $count -gt $ddtimeout ]; then
1378 error "dd should be finished!"
1382 echo "(dd_pid=$DDPID, time=$count)successful"
1384 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1385 #define OBD_FAIL_OST_DROP_REQ 0x21d
1386 do_facet ost1 lctl set_param fail_loc=0x0000021d
1387 # second dd will be never finished
1388 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1391 echo "step2: testing ......"
1392 while [ $count -le $ddtimeout ]; do
1393 if ! kill -0 $DDPID 2> /dev/null; then
1395 error "dd shouldn't be finished! (time=$count)"
1400 echo "(dd_pid=$DDPID, time=$count)successful"
1402 #Recover fail_loc and dd will finish soon
1403 do_facet ost1 lctl set_param fail_loc=0
1405 echo "step3: testing ......"
1406 while kill -0 $DDPID 2> /dev/null; do
1408 if [ $count -gt $((ddtimeout + 440)) ]; then
1409 error "dd should be finished!"
1413 echo "(dd_pid=$DDPID, time=$count)successful"
1417 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1419 test_56() { # b=11277
1420 #define OBD_FAIL_MDS_RESEND 0x136
1422 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1423 stat $DIR/$tfile || error "stat failed"
1424 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1427 run_test 56 "do not fail on getattr resend"
1430 # no oscs means no client or mdt
1431 while lctl get_param osc.*.* > /dev/null 2>&1; do
1432 : # loop until proc file is removed
1436 test_57() { # bug 10866
1440 #define OBD_FAIL_LPROC_REMOVE 0xB00
1441 lctl set_param fail_loc=0x80000B00
1442 zconf_umount `hostname` $DIR
1443 lctl set_param fail_loc=0x80000B00
1444 fail_abort $SINGLEMDS
1446 lctl set_param fail_loc=0
1448 do_facet client "df $DIR"
1450 run_test 57 "read procfs entries causes kernel crash"
1452 test_58() { # bug 11546
1453 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1456 lctl set_param fail_loc=0x80000801
1457 cp $DIR/$tfile /dev/null &
1460 lctl set_param fail_loc=0
1461 drop_bl_callback_once rm -f $DIR/$tfile
1463 # the first 'df' could tigger the eviction caused by
1464 # 'drop_bl_callback_once', and it's normal case.
1465 # but the next 'df' should return successfully.
1466 do_facet client "df $DIR" || do_facet client "df $DIR"
1468 run_test 58 "Eviction in the middle of open RPC reply processing"
1470 test_59() { # bug 10589
1471 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1472 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1473 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1474 lctl set_param fail_loc=0x311
1475 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1476 [ $? = 0 ] || error "dd write failed"
1477 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1478 lctl set_param fail_loc=0
1480 zconf_umount `hostname` $MOUNT2 -f
1481 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1482 [ $? = 0 ] || error "dd read failed"
1483 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1484 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1486 run_test 59 "Read cancel race on client eviction"
1489 local num_files=${COUNT:-5000}
1490 test_mkdir $DIR/$tdir
1492 # Register (and start) changelog
1493 changelog_register || error "changelog_register failed"
1495 # Generate a large number of changelog entries
1496 createmany -o $DIR/$tdir/$tfile $num_files
1500 # Unlink files in the background
1501 unlinkmany $DIR/$tdir/$tfile $num_files &
1505 # Failover the MDS while unlinks are happening
1506 facet_failover $SINGLEMDS
1508 # Wait for unlinkmany to finish
1511 # Check if all the create/unlink events were recorded
1513 local cl_count=$(changelog_dump | grep -c UNLNK)
1514 echo "$cl_count unlinks in changelog"
1516 changelog_deregister || error "changelog_deregister failed"
1517 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1518 [ $cl_count -eq $num_files ] ||
1519 error "Recorded $cl_count of $num_files unlinks"
1520 # Also make sure we can clear large changelogs
1521 cl_count=$(changelog_dump | wc -l)
1522 [ $cl_count -le 2 ] ||
1523 error "Changelog not empty: $cl_count entries"
1524 else # If other users, there may be other unlinks in the log
1525 [ $cl_count -ge $num_files ] ||
1526 error "Recorded $cl_count of $num_files unlinks"
1527 changelog_users $SINGLEMDS
1528 echo "other changelog users; can't verify clear"
1531 run_test 60 "Add Changelog entries during MDS failover"
1535 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1536 mdtosc=${mdtosc/-MDT*/-MDT\*}
1537 local cflags="osc.$mdtosc.connect_flags"
1538 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1539 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1541 mkdir_on_mdt0 $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1542 # Set the default stripe of $DIR/$tdir to put the files to ost1
1543 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1545 replay_barrier $SINGLEMDS
1546 createmany -o $DIR/$tdir/$tfile-%d 10
1547 local oid=$(do_facet ost1 "lctl get_param -n \
1548 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1550 fail_abort $SINGLEMDS
1552 touch $DIR/$tdir/$tfile
1553 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1554 awk '$1 == 0 { print $2 }')
1555 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1560 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1562 # test_62 as seen it b2_1 please do not reuse test_62
1565 # zconf_umount `hostname` $DIR
1566 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1567 # lctl set_param fail_loc=0x516
1570 #run_test 62 "Verify connection flags race - bug LU-1716"
1575 #grant lock1, export2
1576 $LFS setstripe -i -0 $DIR2/$tfile || error "setstripe failed"
1577 $MULTIOP $DIR2/$tfile Ow || error "multiop failed"
1579 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1580 do_facet ost $LCTL set_param fail_loc=0x31e
1581 #get waiting lock2, export1
1582 $MULTIOP $DIR/$tfile Ow &
1584 # let enqueue to get asleep
1588 $MULTIOP $DIR2/$tfile Ow &
1596 do_facet ost $LCTL set_param fail_loc=0
1603 run_test 65 "lock enqueue for destroyed export"
1607 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1608 skip "Need MDS version at least 2.7.51"
1610 # modify dir so that next revalidate would not obtain UPDATE lock
1613 # drop 1 reply with UPDATE lock
1614 mcreate $DIR/$tfile || error "mcreate failed: $?"
1615 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1618 # make the re-sent lock to sleep
1619 #define OBD_FAIL_MDS_RESEND 0x136
1620 do_nodes $(osts_nodes) $LCTL set_param fail_loc=0x80000136
1622 #initiate the re-connect & re-send
1623 local mdtname="MDT0000"
1624 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1625 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1626 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1629 #initiate the client eviction while enqueue re-send is in progress
1635 run_test 66 "lock enqueue re-send vs client eviction"
1639 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1640 $LCTL set_param fail_loc=0x80000531
1642 local mdtname="MDT0000"
1643 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1644 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1645 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1654 run_test 67 "connect vs import invalidate race"
1656 check_cli_ir_state()
1658 local NODE=${1:-$HOSTNAME}
1660 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1661 awk '/imperative_recovery:/ { print \\\$2}'")
1662 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1663 error "Error state $st, must be ENABLED or DISABLED"
1667 check_target_ir_state()
1670 local name=${target}_svc
1671 local recovery_proc=obdfilter.${!name}.recovery_status
1675 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1676 awk '/status:/{ print \\\$2}'")
1677 [ x$st = xRECOVERING ] || break
1679 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1680 awk '/IR:/{ print \\\$2}'")
1681 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1682 error "Error state $st, must be ENABLED or DISABLED"
1688 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1693 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1694 awk '/state:/{ print \\\$2 }'")
1698 nidtbl_version_mgs()
1700 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1701 awk '/nidtbl_version:/{ print \\\$2 }'")
1705 # nidtbl_version_client <mds1|client> [node]
1706 nidtbl_version_client()
1709 local node=${2:-$HOSTNAME}
1711 if [ X$cli = Xclient ]; then
1714 local obdtype=${cli/%[0-9]*/}
1715 [ $obdtype != mds ] && error "wrong parameters $cli"
1717 node=$(facet_active_host $cli)
1722 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1723 awk "/$cli/{print \$6}" |sort -u)
1725 # in case there are multiple mounts on the client node
1727 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1731 nidtbl_versions_match()
1733 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1736 target_instance_match()
1742 obdtype=${srv/%[0-9]*/}
1753 error "invalid target type" $srv
1758 local target=${srv}_svc
1759 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1760 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1761 awk '/instance/{ print $2 }' | head -n1)
1763 return $([ $si -eq $ci ])
1768 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1769 { skip "MGS without IR support"; return 0; }
1771 # MDT was just restarted in the previous test, make sure everything
1774 while [ $cnt -gt 0 ]; do
1775 nidtbl_versions_match && break
1781 set_ir_status disabled
1783 local prev_ver=$(nidtbl_version_client client)
1785 local saved_FAILURE_MODE=$FAILURE_MODE
1786 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1790 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1791 error "version must not change due to IR disabled"
1792 target_instance_match ost1 || error "instance mismatch"
1796 FAILURE_MODE=$saved_FAILURE_MODE
1798 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1802 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1803 skip "MGS without IR support"
1807 local ost1_imp=$(get_osc_import_name client ost1)
1809 # disable pinger recovery
1810 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1811 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1815 target_instance_match ost1 || error "instance mismatch"
1816 nidtbl_versions_match || error "version must match"
1818 run_test 101a "IR: Make sure IR works w/o normal recovery"
1822 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1823 skip "MGS without IR support"
1827 local ost1_imp=$(get_osc_import_name client ost1)
1829 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1830 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1831 # disable pinger recovery
1832 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1833 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1835 #OST may return EAGAIN if it is not configured yet
1838 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1842 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1843 { skip "MGS without IR support"; return 0; }
1845 local clients=${CLIENTS:-$HOSTNAME}
1852 # let's have a new nidtbl version
1855 # sleep for a while so that clients can see the failure of ost
1856 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1857 # int mgc_request.c:
1858 # define MGC_TIMEOUT_MIN_SECONDS 5
1859 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1860 local count=30 # 20 seconds at most
1861 while [ $count -gt 0 ]; do
1862 nidtbl_versions_match && break
1867 nidtbl_versions_match || error "nidtbl mismatch"
1870 old_version=$(nidtbl_version_client client)
1872 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1875 combined_mgs_mds && mgsdev=mds1
1876 remount_facet $mgsdev
1879 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1882 new_version=$(nidtbl_version_client client)
1883 [ $new_version -lt $old_version ] &&
1884 error "nidtbl version wrong after mgs restarts"
1887 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1891 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1892 { skip "MGS without IR support"; return 0; }
1894 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1896 # workaround solution to generate config log on the mds
1902 # We need this test because mds is like a client in IR context.
1903 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1904 error "MDS should start w/o mgs"
1906 # start mgs and remount mds w/ ir
1907 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1910 # remount client so that fsdb will be created on the MGS
1911 umount_client $MOUNT || error "umount failed"
1912 mount_client $MOUNT || error "mount failed"
1914 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1916 while [ $count -gt 0 ]; do
1917 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1922 # after a while, mds should be able to reconnect to mgs and fetch
1923 # up-to-date nidtbl version
1924 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1929 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1933 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1934 { skip "MGS without IR support"; return 0; }
1939 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1940 error "OST1 cannot start"
1943 local ir_state=$(check_target_ir_state ost1)
1945 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1946 error "ir status on ost1 should be DISABLED"
1948 run_test 104 "IR: ost can disable IR voluntarily"
1952 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1953 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1954 { skip "MGS without IR support"; return 0; }
1958 # get one of the clients from client list
1959 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1961 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1962 zconf_umount $rcli $MOUNT || error "umount failed"
1963 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1965 # make sure lustre mount at $rcli disabling IR
1966 local ir_state=$(check_cli_ir_state $rcli)
1967 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1968 error "IR state must be DISABLED at $rcli"
1970 # Since the client just mounted, its last_rcvd entry is not on disk.
1971 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1972 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1973 $LFS setstripe -i 0 $DIR/$tfile
1974 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1976 # make sure MGS's state is Partial
1977 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1980 # make sure IR on ost1 is DISABLED
1981 local ir_state=$(check_target_ir_state ost1)
1982 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1983 error "IR status on ost1 should be DISABLED"
1985 # remount with the default MOUNT_OPTS
1986 zconf_umount $rcli $MOUNT || error "umount failed"
1987 zconf_mount $rcli $MOUNT || error "mount failed"
1989 # make sure MGS's state is full
1990 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1993 # make sure IR on ost1 is ENABLED
1994 local ir_state=$(check_target_ir_state ost1)
1995 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1996 error "IR status on ost1 should be ENABLED"
2000 run_test 105 "IR: NON IR clients support"
2008 test_106() { # LU-1789
2009 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
2010 skip "Need MDS version at least 2.3.50"
2012 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
2013 $LCTL set_param fail_loc=0x805
2016 trap cleanup_106 EXIT
2018 # enable lightweight flag on mdc connection
2021 local MDS_NEXP=$(do_facet $SINGLEMDS \
2022 lctl get_param -n mdt.${mds1_svc}.num_exports |
2024 $LCTL set_param fail_loc=0
2026 touch $DIR2/$tfile || error "failed to create empty file"
2027 replay_barrier $SINGLEMDS
2029 $LCTL set_param debug=ha
2031 facet_failover $SINGLEMDS
2033 # lightweight goes through LUSTRE_IMP_RECOVER during failover
2034 touch -c $DIR2/$tfile || true
2035 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2036 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
2037 $TMP/lustre-log-$TESTNAME.log)
2038 [ -z "$recovered" ] && error "lightweight client was not recovered"
2040 # and all operations performed by lightweight client should be
2041 # synchronous, so the file created before mds restart should be there
2042 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2047 run_test 106 "lightweight connection support"
2053 mkdir_on_mdt0 $DIR/$tdir
2054 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2055 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2056 multiop $DIR/$tdir D_c &
2058 mkdir $DIR/$tdir/dir_106 &
2060 do_facet $SINGLEMDS lctl set_param fail_loc=0
2063 wait $CLIENT_PID || rc=$?
2064 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2066 kill -USR1 $close_pid
2067 wait $close_pid || return 2
2071 run_test 107 "drop reint reply, then restart MDT"
2075 $LFS setstripe -c 1 -i 0 $DIR/$tdir
2077 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2085 client_up || error "reconnect failed"
2086 rm -f $DIR/$tdir/$tfile
2088 run_test 108 "client eviction don't crash"
2091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2092 local remote_dir=$DIR/$tdir/remote_dir
2096 #prepare for 110 test, which need set striped dir on remote MDT.
2097 for num in $(seq $MDSCOUNT); do
2099 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2103 mkdir_on_mdt0 $DIR/$tdir
2104 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2105 error "lfs mkdir failed"
2106 local diridx=$($LFS getstripe -m $remote_dir)
2107 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2109 rm -rf $DIR/$tdir || error "rmdir failed"
2111 run_test 110a "create remote directory: drop client req"
2114 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2115 local remote_dir=$DIR/$tdir/remote_dir
2118 mkdir_on_mdt0 $DIR/$tdir
2119 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2120 error "lfs mkdir failed"
2122 diridx=$($LFS getstripe -m $remote_dir)
2123 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2125 rm -rf $DIR/$tdir || error "rmdir failed"
2127 run_test 110b "create remote directory: drop Master rep"
2130 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2131 local remote_dir=$DIR/$tdir/remote_dir
2134 mkdir_on_mdt0 $DIR/$tdir
2135 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2136 error "lfs mkdir failed"
2138 diridx=$($LFS getstripe -m $remote_dir)
2139 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2141 rm -rf $DIR/$tdir || error "rmdir failed"
2143 run_test 110c "create remote directory: drop update rep on slave MDT"
2146 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2147 local remote_dir=$DIR/$tdir/remote_dir
2150 mkdir_on_mdt0 $DIR/$tdir
2151 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2153 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2155 rm -rf $DIR/$tdir || error "rmdir failed"
2159 run_test 110d "remove remote directory: drop client req"
2162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2163 local remote_dir=$DIR/$tdir/remote_dir
2166 mkdir_on_mdt0 $DIR/$tdir
2167 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2168 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2170 rm -rf $DIR/$tdir || error "rmdir failed"
2174 run_test 110e "remove remote directory: drop master rep"
2177 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2178 local remote_dir=$DIR/$tdir/remote_dir
2181 mkdir_on_mdt0 $DIR/$tdir
2182 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2183 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2184 error "rm remote dir failed"
2186 rm -rf $DIR/$tdir || error "rmdir failed"
2188 run_test 110f "remove remote directory: drop slave rep"
2191 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2192 skip "Need MDS version at least 2.11.0"
2194 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2196 mkdir_on_mdt0 $DIR/$tdir
2197 touch $DIR/$tdir/$tfile
2199 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2200 do_facet mds1 $LCTL set_param fail_loc=0x119
2201 $LFS migrate -m 1 $DIR/$tdir &
2204 do_facet mds1 $LCTL set_param fail_loc=0
2208 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2209 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2210 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2211 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2213 rm -rf $DIR/$tdir || error "rmdir failed"
2215 run_test 110g "drop reply during migration"
2218 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2219 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2220 skip "Need MDS version at least 2.7.56"
2222 local src_dir=$DIR/$tdir/source_dir
2223 local tgt_dir=$DIR/$tdir/target_dir
2227 $LFS mkdir -i $MDTIDX $tgt_dir
2229 dd if=/etc/hosts of=$src_dir/src_file
2230 touch $tgt_dir/tgt_file
2231 drop_update_reply $MDTIDX \
2232 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2233 error "mrename failed"
2235 $CHECKSTAT -t file $src_dir/src_file &&
2236 error "src_file present after rename"
2238 diff /etc/hosts $tgt_dir/tgt_file ||
2239 error "file changed after rename"
2242 run_test 110h "drop update reply during cross-MDT file rename"
2245 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2246 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2247 skip "Need MDS version at least 2.7.56"
2249 local src_dir=$DIR/$tdir/source_dir
2250 local tgt_dir=$DIR/$tdir/target_dir
2254 $LFS mkdir -i $MDTIDX $tgt_dir
2256 mkdir $src_dir/src_dir
2257 touch $src_dir/src_dir/a
2258 mkdir $tgt_dir/tgt_dir
2259 drop_update_reply $MDTIDX \
2260 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2261 error "mrename failed"
2263 $CHECKSTAT -t dir $src_dir/src_dir &&
2264 error "src_dir present after rename"
2266 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2267 error "tgt_dir not present after rename"
2269 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2270 error "a not present after rename"
2272 run_test 110i "drop update reply during cross-MDT dir rename"
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2276 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2277 skip "Need MDS version at least 2.7.56"
2279 local remote_dir=$DIR/$tdir/remote_dir
2280 local local_dir=$DIR/$tdir/local_dir
2283 mkdir_on_mdt0 $DIR/$tdir
2284 mkdir $DIR/$tdir/local_dir
2285 $LFS mkdir -i $MDTIDX $remote_dir
2287 touch $local_dir/local_file
2288 drop_update_reply $MDTIDX \
2289 "ln $local_dir/local_file $remote_dir/remote_file" ||
2292 $CHECKSTAT -t file $remote_dir/remote_file ||
2293 error "remote not present after ln"
2295 run_test 110j "drop update reply during cross-MDT ln"
2298 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2299 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2300 skip "Need MDS version at least 2.12.55"
2303 stop mds2 || error "stop mds2 failed"
2305 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2306 do_facet mds2 lctl set_param fail_loc=0x80001103
2307 local OPTS="$MDS_MOUNT_OPTS -o abort_recovery"
2308 start mds2 $(mdsdevname 2) $OPTS ||
2309 error "start MDS with abort_recovery should succeed"
2310 do_facet mds2 lctl set_param fail_loc=0
2313 stop mds2 || error "cleanup: stop mds2 failed"
2314 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS ||
2315 error "cleanup: start mds2 failed"
2316 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2317 client_up || error "post-failover df failed"
2320 run_test 110k "FID_QUERY failed during recovery"
2323 (( $(lustre_version_code $SINGLEMDS) >= $(version_code 2.14.52) )) ||
2324 skip "Need MDS version at least 2.14.52"
2325 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
2326 local remote_dir=$DIR/$tdir/remote_dir
2331 mkdir_on_mdt0 $DIR/$tdir
2333 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x0525
2334 do_facet mds1 $LCTL set_param fail_loc=0x80000525
2335 $LFS mkdir -i 1 -c2 $remote_dir &
2338 # initiate the re-connect & re-send
2339 mdccli=$(do_facet mds2 $LCTL dl |
2340 awk '/MDT0000-osp-MDT0001/ {print $4;}')
2341 uuid=$(do_facet mds2 $LCTL get_param -n osp.$mdccli.mdt_conn_uuid)
2342 echo "conn_uuid=$uuid"
2343 do_facet mds2 $LCTL set_param "osp.$mdccli.import=connection=$uuid"
2346 (( $? == 0 )) || error "mkdir failed"
2348 diridx=$($LFS getstripe -m $remote_dir)
2349 (( $diridx == 1 )) || error "$diridx != 1"
2350 rm -rf $DIR/$tdir || error "rmdir failed"
2352 run_test 110m "update resent vs original RPC race"
2354 # LU-2844 mdt prepare fail should not cause umount oops
2357 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2358 skip "Need MDS version at least 2.3.62"
2360 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2361 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2362 stop $SINGLEMDS || error "stop MDS failed"
2363 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS &&
2364 error "start MDS should fail"
2365 do_facet $SINGLEMDS lctl set_param fail_loc=0
2366 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2367 error "start MDS failed"
2369 run_test 111 "mdd setup fail should not cause umount oops"
2373 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2375 do_facet_random_file client $TMP/$tfile 100K ||
2376 error_noexit "Create random file $TMP/$tfile"
2378 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2379 error_noexit "Can't pause_bulk copy"
2382 # expect cmp to succeed, client resent bulk
2383 cmp $TMP/$tfile $DIR/$tfile ||
2384 error_noexit "Wrong data has been written"
2386 error_noexit "Can't remove file"
2389 run_test 112a "bulk resend while orignal request is in progress"
2396 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2397 cancel_lru_locks osc
2400 $LCTL set_param fail_loc=$fail1 fail_val=3
2401 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2405 set_nodes_failloc "$(osts_nodes)" $fail2
2407 wait $pid || error "dd failed"
2415 local fail_val2=${4:-0}
2421 $LCTL set_param fail_loc=$fail1 fail_val=4
2422 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2427 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2431 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2432 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2437 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2438 skip "need at least 2.8.50 on OST"
2440 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2441 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2442 test_115_read 0x8000051b 0x8000051a
2444 run_test 115a "read: late REQ MDunlink and no bulk"
2447 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2448 skip "need at least 2.8.50 on OST"
2450 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2451 #define OBD_FAIL_OST_ENOSPC 0x215
2453 # pass $OSTCOUNT for the fail_loc to be caught
2454 # appropriately by the IO thread
2455 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2457 run_test 115b "write: late REQ MDunlink and no bulk"
2460 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2461 skip "need at least 2.8.50 on OST"
2463 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2464 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2465 test_115_read 0x8000050f 0x8000051a
2467 run_test 115c "read: late Reply MDunlink and no bulk"
2470 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2471 skip "need at least 2.8.50 on OST"
2473 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2474 #define OBD_FAIL_OST_ENOSPC 0x215
2475 test_115_write 0x8000050f 0x80000215 0
2477 run_test 115d "write: late Reply MDunlink and no bulk"
2480 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2481 skip "need at least 2.8.50 on OST"
2483 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2484 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2485 test_115_read 0x80000510 0x80000211
2487 run_test 115e "read: late Bulk MDunlink and no reply"
2490 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2491 skip "need at least 2.8.50 on OST"
2493 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2494 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2495 test_115_read 0x8000051b 0x80000211
2497 run_test 115f "read: late REQ MDunlink and no reply"
2500 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2501 skip "need at least 2.8.50 on OST"
2503 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2504 test_115_read 0x8000051c 0
2506 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2508 # parameters: fail_loc CMD RC
2515 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2516 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2517 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2518 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2521 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2522 [ "$1" = "CLEANUP" ] &&
2523 fail=0x80000320 && echo ", $1 cp first"
2524 [ "$1" = "REPLY" ] &&
2525 fail=0x80000321 && echo ", $1 cp first"
2526 [ "$1" = "DEADLOCK CLEANUP" ] &&
2527 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2528 [ "$1" = "DEADLOCK REPLY" ] &&
2529 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2531 if [ x"$2" = x"get" ]; then
2532 #for TEST lock, take a conflict in advance
2533 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2534 echo "** Taking conflict **"
2535 flocks_test 5 set read sleep 10 $DIR/$tfile &
2541 $LCTL set_param fail_loc=$fail
2543 flocks_test 5 $2 write $DIR/$tfile &
2547 echo "** Evicting and re-connecting client **"
2552 if [ x"$2" = x"get" ]; then
2559 # check if the return value is allowed
2560 [ $rc -eq $3 ] && rc=0
2562 $LCTL set_param fail_loc=0
2566 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2567 # the ORIGINAL lock.
2572 flocks_test 5 set write sleep 4 $DIR/$tfile &
2576 # let unlock to sleep in CP CB
2577 $LCTL set_param fail_loc=$1
2580 # let cleanup to cleep in CP CB
2588 $LCTL set_param fail_loc=0
2593 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2596 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2597 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2598 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2600 test_120_reply "REPLY" set 5 || error "SET race failed"
2601 test_120_reply "REPLY" get 5 || error "GET race failed"
2602 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2605 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2606 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2608 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2610 run_test 120 "flock race: completion vs. evict"
2613 local BEFORE=$(date +%s)
2616 # modify dir so that next revalidate would not obtain UPDATE lock
2619 # drop 1 reply with UPDATE lock,
2620 # resend should not create 2nd lock on server
2621 mcreate $DIR/$tfile || error "mcreate failed: $?"
2622 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2624 # 2 BL AST will be sent to client, both must find the same lock,
2625 # race them to not get EINVAL for 2nd BL AST
2626 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2627 $LCTL set_param fail_loc=0x8000031f
2629 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2630 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2631 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2633 # let the client reconnect
2635 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2636 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2638 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2640 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2644 test_mkdir -p -c1 $DIR/$tdir
2645 local mdts=$(mdts_nodes)
2647 # Prevent interference from layout intent RPCs due to
2648 # asynchronous writeback. These will be tested in 130c below.
2649 do_nodes ${CLIENTS:-$HOSTNAME} sync
2651 # get only LOOKUP lock on $tdir
2652 cancel_lru_locks mdc
2653 ls $DIR/$tdir/$tfile 2>/dev/null
2655 # get getattr by fid on $tdir
2657 # we need to race with unlink, unlink must complete before we will
2658 # take a DLM lock, otherwise unlink will wait until getattr will
2659 # complete; but later than getattr starts so that getattr found
2661 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2662 set_nodes_failloc $mdts 0x80000160
2669 # drop the reply so that resend happens on an unlinked file.
2670 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2671 set_nodes_failloc $mdts 0x80000157
2675 remote_mds_nodsh && skip "remote MDS with nodsh"
2676 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2677 skip "Need server version newer than 2.7.1"
2681 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2684 run_test 130a "enqueue resend on not existing file"
2687 remote_mds_nodsh && skip "remote MDS with nodsh"
2688 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2689 skip "Need server version newer than 2.7.1"
2692 # let the reply to be dropped
2695 #define OBD_FAIL_SRV_ENOENT 0x217
2696 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2698 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2701 run_test 130b "enqueue resend on a stale inode"
2704 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2705 local mdts=$(mdts_nodes)
2707 do_nodes ${CLIENTS:-$HOSTNAME} sync
2708 echo XXX > $DIR/$tfile
2710 cancel_lru_locks mdc
2712 # Trigger writeback on $tfile.
2714 # we need to race with unlink, unlink must complete before we will
2715 # take a DLM lock, otherwise unlink will wait until intent will
2716 # complete; but later than intent starts so that intent found
2718 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2719 set_nodes_failloc $mdts 0x80000160
2726 # drop the reply so that resend happens on an unlinked file.
2727 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2728 set_nodes_failloc $mdts 0x80000157
2730 # let the reply to be dropped
2733 #define OBD_FAIL_SRV_ENOENT 0x217
2734 set_nodes_failloc $mdts 0x80000217
2740 run_test 130c "layout intent resend on a stale inode"
2743 local before=$(date +%s)
2746 mount_client $MOUNT2 || error "mount filed"
2749 # get a lock on client so that export would reach the stale list
2750 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2751 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2754 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2755 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2757 $TRUNCATE $DIR/$tfile 100 &
2760 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2764 umount_client $MOUNT2
2766 evict=$(do_facet client $LCTL get_param \
2767 osc.$FSNAME-OST0000-osc-*/state |
2768 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2770 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2771 (do_facet client $LCTL get_param \
2772 osc.$FSNAME-OST0000-osc-*/state;
2773 error "eviction happened: $evict before:$before")
2775 run_test 132 "long punch"
2778 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2781 # get a lock on client so that export would reach the stale list
2782 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2783 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2785 # another IO under the same lock
2786 #define OBD_FAIL_OSC_DELAY_IO 0x414
2787 $LCTL set_param fail_loc=0x80000414
2788 $LCTL set_param fail_val=4 fail_loc=0x80000414
2789 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2793 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2794 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2798 wait $pid && error "dd succeeded"
2801 run_test 131 "IO vs evict results to IO under staled lock"
2804 local t=$((TIMEOUT * 2))
2807 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2809 multiop_bg_pause $DIR/$tfile O_jc || return 1
2812 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2813 do_nodes $(mdts_nodes) $LCTL set_param fail_loc=0x80000157
2815 echo "waiting for multiop $PID"
2816 wait $PID || return 2
2822 run_test 133 "don't fail on flock resend"
2825 [ $CLIENTCOUNT -lt 2 ] &&
2826 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2828 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2829 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2830 error "touch failed"
2831 zconf_umount_clients $CLIENTS $MOUNT
2832 zconf_mount_clients $CLIENTS $MOUNT
2834 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2835 # assume commit interval is 5
2836 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2838 local -a clients=(${CLIENTS//,/ })
2839 local client1=${clients[0]}
2840 local client2=${clients[1]}
2842 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2844 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2847 wait $rmpid || error "rm failed"
2848 wait $mvpid || error "mv failed"
2851 run_test 134 "race between failover and search for reply data free slot"
2854 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2855 skip "Need MDS version at least 2.12.51"
2858 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2859 # to have parent dir write lock before open/resend
2860 touch $DIR/$tdir/$tfile
2861 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2862 do_nodes $(mdts_nodes) "$LCTL set_param fail_loc=0x80000157"
2863 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2864 error "Failed to open DOM file"
2866 run_test 135 "DOM: open/create resend to return size"
2869 remote_mds_nodsh && skip "remote MDS with nodsh"
2870 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2871 skip "Need MDS version at least 2.12.52"
2873 local mdts=$(comma_list $(mdts_nodes))
2874 local MDT0=$(facet_svc $SINGLEMDS)
2876 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2877 [ -n "$clog" ] || error "changelog_register failed"
2878 cl_mask=$(do_facet mds1 $LCTL get_param \
2879 mdd.$MDT0.changelog_mask -n)
2880 changelog_chmask "ALL"
2882 # generate some changelog records to accumulate
2883 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2884 createmany -m $DIR/$tdir/$tfile 10000 ||
2885 error "create $DIR/$tdir/$tfile failed"
2887 local size1=$(do_facet $SINGLEMDS \
2888 $LCTL get_param -n mdd.$MDT0.changelog_size)
2889 echo "Changelog size $size1"
2891 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2892 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2894 # launch changelog_deregister in background on MDS
2895 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2896 > foo.out 2> foo.err < /dev/null &"
2897 # give time to reach fail_loc
2900 # fail_loc will make MDS sleep in the middle of changelog_deregister
2901 # take this opportunity to abruptly kill MDS
2902 FAILURE_MODE_save=$FAILURE_MODE
2905 FAILURE_MODE=$FAILURE_MODE_save
2907 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2909 local size2=$(do_facet $SINGLEMDS \
2910 $LCTL get_param -n mdd.$MDT0.changelog_size)
2911 echo "Changelog size $size2"
2912 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2913 mdd.$MDT0.changelog_users | grep $clog")
2914 echo "After crash, changelog user $clog2"
2916 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2917 error "changelog record count unchanged"
2919 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2921 run_test 136 "changelog_deregister leaving pending records"
2925 mkdir_on_mdt0 $DIR/$tdir
2928 dd if=/dev/zero of=$DIR/$tdir/d1/$tfile bs=4096 count=1
2929 dd if=/dev/zero of=$DIR/$tdir/d2/$tfile bs=4096 count=1
2930 cancel_lru_locks osc
2932 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2933 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2935 # RPC1: any reply is to be delayed to disable last_xid logic
2936 ln $DIR/$tdir/d1/$tfile $DIR/$tdir/d1/f2 &
2939 # RPC2: setattr1 reply is delayed & resent
2940 # original reply comes to client; the resend get asleep
2941 chmod 666 $DIR/$tdir/d2/$tfile
2943 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2944 chmod 777 $DIR/$tdir/d2/$tfile
2946 # RPC2 resend wakes up
2948 [ $(stat -c "%a" $DIR/$tdir/d2/$tfile) == 777 ] ||
2949 error "resend got applied"
2951 run_test 137 "late resend must be skipped if already applied"
2954 remote_mds_nodsh && skip "remote MDS with nodsh"
2955 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2956 [[ "$MDS1_VERSION" -ge $(version_code 2.12.59) ]] ||
2957 skip "Need server version newer than 2.12.59"
2959 zconf_umount_clients $CLIENTS $MOUNT
2961 #define OBD_FAIL_TGT_RECOVERY_CONNECT 0x724
2962 #delay a first step of recovey when MDS waiting clients
2963 #and failing to get osp logs
2964 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x724 fail_val=5
2966 facet_failover $SINGLEMDS
2968 #waiting failover and recovery timer
2969 #the valuse is based on target_recovery_overseer() wait_event timeout
2971 stop $SINGLEMDS || error "stop MDS failed"
2972 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
2973 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2974 error "start MDS failed"
2975 zconf_mount_clients $CLIENTS $MOUNT
2977 run_test 138 "Umount MDT during recovery"
2980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2981 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
2982 skip "Need MDS version at least 2.13.50"
2984 stop $SINGLEMDS || error "stop $SINGLEMDS failed"
2986 #define OBD_FAIL_OSP_INVALID_LOGID 0x2106
2987 do_facet $SINGLEMDS $LCTL set_param fail_val=0x68 fail_loc=0x80002106
2988 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2989 error "Fail to start $SINGLEMDS"
2991 run_test 139 "corrupted catid won't cause crash"
2994 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
2995 skip "Need MDS version at least 2.13.50"
2997 slr=$(do_facet mds1 \
2998 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
2999 stack_trap "do_facet mds1 $LCTL set_param \
3000 mdt.*.local_recovery=$slr" EXIT
3002 # disable recovery for local clients
3003 # so local clients should be marked with no_recovery flag
3004 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
3008 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
3009 grep export_flags.*no_recovery | wc -l)
3010 echo "$cnt clients with recovery disabled"
3012 [ $cnt -eq 0 ] && error "no clients with recovery disabled"
3014 # enable recovery for local clients
3015 # so no local clients should be marked with no_recovery flag
3016 do_facet mds1 $LCTL set_param mdt.*.local_recovery=1
3019 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
3020 grep export_flags.*no_recovery | wc -l)
3021 echo "$cnt clients with recovery disabled"
3023 [ $cnt -eq 0 ] || error "$cnt clients with recovery disabled"
3025 run_test 140a "local mount is flagged properly"
3028 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
3029 skip "Need MDS version at least 2.13.50"
3031 slr=$(do_facet mds1 \
3032 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
3033 stack_trap "do_facet mds1 $LCTL set_param \
3034 mdt.*.local_recovery=$slr" EXIT
3036 # disable recovery for local clients
3037 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
3043 # Lustre: tfs-MDT0000: Recovery over after 0:03, of 2 clients 2 rec...
3044 local recovery=$(do_facet mds1 dmesg |
3045 awk '/Recovery over after/ { print $6 }' | tail -1 |
3046 awk -F: '{ print $1 * 60 + $2 }')
3047 (( recovery < TIMEOUT * 2 + 5 )) ||
3048 error "recovery took too long $recovery > $((TIMEOUT * 2 + 5))"
3050 run_test 140b "local mount is excluded from recovery"
3057 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3058 combined_mgs_mds || skip "needs combined MGS/MDT"
3059 ( local_mode || from_build_tree ) &&
3060 skip "cannot run in local mode or from build tree"
3062 # some get_param have a bug to handle dot in param name
3063 oldgen=$(do_facet ost1 $LCTL get_param -n mgc.*.import |
3064 awk '/generation:/{print $NF}')
3065 do_rpc_nodes $(facet_active_host ost1) cancel_lru_locks MGC
3066 local end=$((SECONDS + 30))
3069 while (( oldc == 0 || tmpc != oldc )) && (( SECONDS < end )); do
3072 oldc=$(do_facet ost1 \
3073 $LCTL "get_param -n 'ldlm.namespaces.MGC*.lock_count'")
3077 wait_mgc_import_state ost1 FULL
3078 wait_update_facet_cond ost1 "$LCTL get_param -n mgc.*.import |
3079 awk '/generation:/{print}' | cut -d':' -f2" "!=" " $oldgen"
3080 do_rpc_nodes $(facet_active_host ost1) cancel_lru_locks MGC
3081 wait_update_facet ost1 \
3082 "$LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count'" $oldc ||
3084 newc=$(do_facet ost1 \
3085 $LCTL get_param -n 'ldlm.namespaces.MGC*.lock_count')
3086 error "mgc lost locks ($oldc != $newc)"
3089 run_test 141 "do not lose locks on MGS restart"
3092 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
3093 skip "Need MDS version at least 2.11.56"
3095 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
3096 do_facet mds1 $LCTL set_param fail_loc=0x165
3097 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
3100 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
3102 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3103 error "MDD orphan cleanup thread not quit"
3105 run_test 142 "orphan name stub can be cleaned up in startup"
3108 (( $MDS1_VERSION >= $(version_code 2.13.0) )) ||
3109 skip "Need MDS version at least 2.13.0"
3110 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3112 local mntpt=$(facet_mntpt $SINGLEMDS)
3114 mount_fstype $SINGLEMDS || error "mount as fstype $SINGLEMDS failed"
3115 do_facet $SINGLEMDS touch $mntpt/PENDING/$tfile
3116 unmount_fstype $SINGLEMDS
3117 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3119 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
3120 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3121 error "MDD orphan cleanup thread not quit"
3123 run_test 143 "orphan cleanup thread shouldn't be blocked even delete failed"
3126 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3127 skip "server does not support overstriping"
3128 (( MDS1_VERSION >= $(version_code 2.15.50.49) )) ||
3129 skip "Need MDS version at least 2.15.50.49"
3137 local mdts=$(mdts_nodes)
3139 large_xattr_enabled || skip_env "ea_inode feature disabled"
3140 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3141 stack_trap "rm -rf $DIR/$tdir" EXIT
3143 mds_timeout=$(do_facet mds1 $LCTL get_param -n timeout)
3144 do_nodes $mdts "$LCTL set_param timeout=300"
3145 stack_trap "do_nodes $mdts $LCTL set_param timeout=$mds_timeout"
3147 $LFS setstripe -i 0 -C $setcount $DIR/$tdir || error "setstripe failed"
3149 for (( i = 0; i < 50; i++)); do
3150 touch $DIR/$tdir/$tfile_$i &
3157 for pid in $pids; do
3158 kill -9 $pid >/dev/null 2>&1
3164 # here we measure MDT stop + MDT start time. For error case MDT stop takes
3165 # about obd_timeout-60 (240) seconds. Without error - less than 30s.
3166 # MDT start takes different time depends on a configuration, let's check
3168 diff=$((after - before))
3169 (( $diff < 240 )) || error "MDT failover took $diff seconds"
3171 # failover mds1 back to the primary server
3174 run_test 144a "MDT failover should stop precreation threads"
3177 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3178 skip "server does not support overstriping"
3179 (( MDS1_VERSION >= $(version_code 2.15.51.50) )) ||
3180 skip "Need MDS version at least 2.15.51.50"
3186 local mdts=$(mdts_nodes)
3188 large_xattr_enabled || skip_env "ea_inode feature disabled"
3189 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3190 stack_trap "rm -rf $DIR/$tdir" EXIT
3192 mds_timeout=$(do_facet mds1 $LCTL get_param -n timeout)
3193 do_nodes $mdts "$LCTL set_param timeout=300"
3194 stack_trap "do_nodes $mdts $LCTL set_param timeout=$mds_timeout"
3196 $LFS setstripe -i 0 -C $setcount $DIR/$tdir || error "setstripe failed"
3198 for (( i = 0; i < 50; i++)); do
3199 touch $DIR/$tdir/$tfile_$i &
3205 # 60s is not enought with ZFS which is still significatnly
3206 # slower on some operations like record writing
3208 [[ "$mds1_FSTYPE" != "zfs" ]] || stime=120
3211 for pid in $pids; do
3212 ps -p $pid > /dev/null
3213 (( $? == 0 )) && rc=1
3214 kill -9 $pid >/dev/null 2>&1
3217 (( $rc == 0 )) || { fail mds1; error "Create thread still running"; }
3219 run_test 144b "orphan cleanup shouldn't be blocked for no objects+failover situation"
3222 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3223 remote_mds_nodsh && skip "remote MDS with nodsh"
3224 remote_ost_nodsh && skip "remote OST with nodsh"
3225 (( OST1_VERSION >= $(version_code 2.15.59.53) )) ||
3226 skip "need OSS >= v2_15_59.53 for reconnect fix"
3229 #increase a precreation window
3230 mkdir_on_mdt0 $DIR/$tdir
3231 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3232 createmany -o $DIR/$tdir/$tfile 9000
3235 #define OBD_FAIL_OST_DELORPHAN_DELAY 0x254
3236 #delay delorphan request to reconnection 5seconds
3237 do_facet ost1 $LCTL set_param fail_loc=0x0000254 fail_val=5
3239 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3241 wait_recovery_complete mds1 || error "MDS recovery not done"
3245 do_facet mds1 $LCTL --device $FSNAME-OST0000-osc-MDT0000 recover
3247 do_facet ost1 $LCTL set_param fail_loc=0 fail_val=0
3249 #first and second orphan request delayed for 5seconds
3252 local testid=${TESTNAME//_/ }
3254 do_facet ost1 "dmesg | tac | sed '/$testid/,$ d'" |
3255 grep "trust the OST"
3257 if (( rc == 0 )); then
3259 error "LAST_ID synchronization failed"
3264 run_test 144c "reconnection during orphan cleanup shouldn't lose LAST_ID synchronization"
3267 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
3268 [ $(facet_active_host mds2) = $(facet_active_host mds3) ] &&
3269 skip "needs mds2 and mds3 on separate nodes"
3275 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
3276 echo block mds_connect from mds2
3277 do_facet mds2 "$LCTL set_param fail_loc=0x507"
3279 #define OBD_FAIL_OUT_UPDATE_DROP 0x1707
3280 echo block recovery updates from mds3
3281 do_facet mds3 "$LCTL set_param fail_loc=0x1707"
3283 local hard_timeout=\
3284 $(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard)
3288 local get_soft_timeout_cmd=\
3289 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_soft 2>/dev/null"
3291 echo wait until mds1 recovery_time_soft is $hard_timeout
3292 wait_update $(facet_host mds1) "$get_soft_timeout_cmd" \
3293 "$hard_timeout" $hard_timeout
3295 echo unblock mds_connect from mds2
3296 do_facet mds2 "$LCTL set_param fail_loc=0"
3298 echo upblock recovery updates from mds3
3299 do_facet mds3 "$LCTL set_param fail_loc=0"
3302 [ -f $DIR/$tfile ] || error "$DIR/$tfile does not exist"
3304 run_test 145 "connect mdtlovs and process update logs after recovery expire"
3307 (( $MDS1_VERSION >= $(version_code 2.15.54.6) )) ||
3308 skip "Need MDS >= v2_15_54-6-g3c69d46e17 for eviction_count"
3310 local prev_count=$(do_facet $SINGLEMDS \
3311 $LCTL get_param -n "mdt.${mds1_svc}.eviction_count")
3317 local next_count=$(do_facet $SINGLEMDS \
3318 $LCTL get_param -n "mdt.${mds1_svc}.eviction_count")
3320 [ "$prev_count" -lt "$next_count" ] ||
3321 error "wrong eviction count ($prev_count >= $next_count)"
3323 run_test 146 "test eviction is counted properly"
3326 local obd_timeout=200
3327 local old=$($LCTL get_param -n timeout)
3329 local connection_count
3331 $LFS setstripe -i 0 -c 1 $f
3332 stripe_index=$($LFS getstripe -i $f)
3333 if [ $stripe_index -ne 0 ]; then
3335 error "$f: stripe_index $stripe_index != 0" && return
3338 $LCTL set_param timeout=$obd_timeout
3339 stack_trap "$LCTL set_param timeout=$old && client_reconnect" EXIT
3341 # OBD_FAIL_OST_CONNECT_NET2
3342 # lost reply to connect request
3343 do_facet ost1 lctl set_param fail_loc=0x00000225 timeout=$obd_timeout
3344 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0 timeout=$old" EXIT
3349 $LFS df $MOUNT > /dev/null 2>&1 &
3350 sleep $((obd_timeout * 3 / 4))
3352 $LCTL get_param osc.$FSNAME-OST0000-osc-*.state
3353 connection_count=$($LCTL get_param osc.$FSNAME-OST0000-osc-*.state |
3354 tac | sed "/FULL/,$ d" | grep CONNECTING | wc -l)
3356 echo $connection_count
3357 (($connection_count >= 6)) || error "Client reconnected too slow"
3359 run_test 147 "Check client reconnect"
3362 local wce_param="obdfilter.$FSNAME-OST0000.writethrough_cache_enable"
3363 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3364 local amc=$(at_max_get client)
3365 local amo=$(at_max_get ost1)
3370 timeout=$(request_timeout client)
3372 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3373 # save old r/o cache settings
3374 save_lustre_params ost1 $wce_param > $p
3377 do_facet ost1 "$LCTL set_param -n $wce_param=0"
3380 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3381 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
3382 cp $DIR/$tfile $TMP/$tfile
3383 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3384 do_facet ost1 $LCTL set_param fail_loc=0x80000227
3385 do_facet ost1 $LCTL set_param fail_val=$((timeout+2))
3386 dd if=/dev/urandom of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3387 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3389 cancel_lru_locks osc
3390 cmp -b $DIR/$tfile $TMP/$tfile || error "wrong data"
3392 rm -f $DIR/$tfile $TMP/$tfile
3394 at_max_set $amc client
3395 at_max_set $amo ost1
3397 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3398 # restore initial r/o cache settings
3399 restore_lustre_params < $p
3404 run_test 148 "data corruption through resend"
3407 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3409 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3411 # make an orphan striped dir
3412 $MULTIOP $DIR/$tdir D_c &
3415 rmdir $DIR/$tdir || error "can't rmdir"
3417 # stop a slave MDT where one ons stripe is located
3420 # stopping should not cause orphan as another MDT can
3424 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3425 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "mds1 start fail"
3433 run_test 149 "skip orphan removal at umount"
3436 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3440 lazystatfs=$($LCTL get_param -n llite.$FSNAME-*.lazystatfs | head -1)
3441 max=$($LCTL get_param -n llite.$FSNAME-*.statahead_max | head -1)
3443 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3444 $LCTL set_param llite.$FSNAME-*.statahead_max=0
3445 stack_trap "$LCTL set_param llite.$FSNAME-*.lazystatfs=$lazystatfs" EXIT
3446 stack_trap "$LCTL set_param llite.$FSNAME-*.statahead_max=$max" EXIT
3447 # stop a slave MDT where one ons stripe is located
3450 stack_trap "start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS && \
3451 wait_recovery_complete mds1 && clients_up && true" EXIT
3453 df $MOUNT || error "statfs failed"
3456 run_test 150 "statfs when MDT0 offline with lazystatfs option"
3459 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3460 skip "server does not support overstriping"
3471 large_xattr_enabled || skip_env "ea_inode feature disabled"
3472 version=$(do_facet mds1 \
3473 uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
3474 version=$(version_code ${version//\./ })
3475 if (( $version < $(version_code 4.6.0) )); then
3476 skip "MDS Linux kernel does not support killable semaphore"
3479 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3480 test_mkdir -i 0 -c 1 -p $DIR/$tdir/rr
3481 test_mkdir -i 0 -c 1 -p $DIR/$tdir/qos
3482 stack_trap "rm -rf $DIR/$tdir" EXIT
3484 $LFS setstripe -C $setcount $DIR/$tdir/rr/ || error "setstripe failed"
3487 #define OBD_FAIL_MDS_LOD_CREATE_PAUSE 0x173
3488 #Simulate OST failover and sleep RR allocation under lq_rw_sem
3489 do_facet mds1 $LCTL set_param fail_loc=0x80000173 fail_val=20
3491 for (( i = 0; i < 2; i++)); do
3492 touch $DIR/$tdir/rr/$tfile_$i &
3493 pids_rr="$pids_rr $!"
3497 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
3498 do_facet mds1 $LCTL set_param lov.*.qos_threshold_rr=0
3499 stack_trap "do_facet mds1 $LCTL set_param lov.*.qos_threshold_rr=$saved" EXIT
3501 #create files with QoS algo, killable semaphore sleeps for 2seconds
3502 for (( i = 0; i < 3; i++)); do
3503 touch $DIR/$tdir/qos/$tfile_$i &
3504 pids_qos="$pids_qos $!"
3507 for pid in $pids_qos; do
3512 diff=$((after - before))
3513 echo "QoS allocation took $diff seconds"
3514 for pid in $pids_rr; do
3519 error "QoS allocation slower than RR, killable semaphore doesn't work"
3521 run_test 152 "QoS object allocation could be awakened in case of OST failover"
3524 (( MDS1_VERSION >= $(version_code 2.15.54.113) )) ||
3525 skip "need MDS >= v2_15_54-113-g654d5f3fa4df for reconnect fix"
3527 #define OBD_FAIL_MDS_CONNECT_VS_EVICT 0x174
3528 do_facet mds1 "$LCTL set_param fail_loc=0x174"
3529 # first drop ping reply from MDS and then
3530 # evict on the subsequent reconnect
3531 # (see target_handle_connect)
3532 sleep $((TIMEOUT + 3))
3534 do_facet mds1 "$LCTL set_param fail_loc=0"
3535 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
3536 error "Fail to start $SINGLEMDS"
3537 wait_recovery_complete mds1 || error "MDS recovery not done"
3539 run_test 153 "evict vs reconnect race"
3542 (( MDS1_VERSION >= $(version_code 2.15.60.2) )) ||
3543 skip "need MDS >= v2_15_60-2-ge81805244476 for llog fix"
3544 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3548 local mnt=$(facet_mntpt mds2)
3551 local ula=($(do_facet mds2 od -t u8 $mnt/update_log | \
3552 awk '{ if($2 > 0) printf "0x%x:0x%x:0x0 ", $3, $2 }'))
3553 [ ${#ula[@]} -lt 2 ] && error "update_log file corruption"
3555 local catfile=$mnt/update_log_dir/\[${ula[0]}\]
3557 echo replace file $catfile
3558 do_facet mds2 dd if=/dev/urandom of=$catfile count=100 ||
3559 error "Write file $catfile error"
3562 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "mds2 start fail"
3565 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3567 echo waiting mds1 recovery....
3568 wait_recovery_complete mds1 20
3570 do_facet mds1 $LCTL get_param mdt.$FSNAME-MDT0000.recovery_status | \
3571 grep -w COMPLETE || error "Recovery was blocked"
3573 run_test 154a "corruption update llog can be skipped"
3576 (( MDS1_VERSION >= $(version_code 2.15.60.2) )) ||
3577 skip "need MDS >= v2_15_60-2-ge81805244476 for llog fix"
3578 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3582 stack_trap "do_facet mds1 $LCTL set_param fail_loc=0"
3583 #define OBD_FAIL_TGT_RECOVERY_CONNECT 0x724
3584 do_facet mds1 $LCTL set_param fail_loc=0x0724 fail_val=5
3585 local OPTS="$MDS_MOUNT_OPTS -o abort_recov"
3586 start mds1 $(mdsdevname 1) $OPTS ||
3587 error "start MDS with abort_recovery failed"
3589 echo waiting mds1 recovery....
3590 wait_recovery_complete mds1 30
3591 do_facet mds1 $LCTL get_param mdt.$FSNAME-MDT0000.recovery_status | \
3592 grep -w COMPLETE || error "Recovery was blocked"
3594 mount_client $MOUNT2
3595 umount_client $MOUNT2
3596 remount_client $MOUNT
3598 run_test 154b "restore update llog after failed recovery"
3601 (( MDS1_VERSION >= $(version_code 2.15.58.110) )) ||
3602 skip "need MDS >= v2_15_58-110-g71f8e5d6506f for ptlrpc fix"
3608 lsoutput1=$(ls -l $DIR)
3610 zconf_umount $HOSTNAME $MOUNT || error "umount failed"
3611 # make sure that last_rcvd update is committed
3613 zconf_mount $HOSTNAME $MOUNT || error "mount failed"
3615 replay_barrier_nosync mds1
3619 lsoutput2=$(ls -l $DIR) || error "ls failed"
3620 [[ $lsoutput1 == $lsoutput2 ]] || error "$lsoutput1 != $lsoutput2"
3622 run_test 155 "failover after client remount"
3626 (( OST1_VERSION >= $(version_code v2_15_60-90-g9df01eee75) )) ||
3627 skip "Need OST >= 2.15.60.90 for tot_granted miscount fix"
3629 # on failover recovery time hard will be 9 * 5
3630 local saved_timeout=$(do_facet ost1 $LCTL get_param -n timeout)
3632 do_facet mgs $LCTL set_param -P timeout=5 ||
3633 error "failed to set obd_timeout"
3634 stack_trap "do_facet mgs $LCTL set_param -P timeout=$saved_timeout" \
3637 $LFS setstripe -c 1 -i 0 $DIR/$tfile || error "setstripe failed"
3639 # this is to sync last_rcvd, so that the client will have to
3640 # send replay on recovery
3646 $MULTIOP $DIR/$tfile oO_RDWR:O_SYNC:w1048576c || error "multiop failed"
3648 # delay write replay for 45 sec (OBD_RECOVERY_TIME_HARD) to
3649 # get the client evicted as not sending replays
3651 #define OBD_FAIL_PTLRPC_REPLAY_PAUSE 0x536
3652 $LCTL set_param fail_loc=0x80000536 fail_val=45
3656 # check that ost1 evicted the client in recovery
3658 clients=($(do_facet ost1 \
3659 $LCTL get_param -n obdfilter.$FSNAME-OST0000.recovery_status |
3660 awk '/completed_clients/ { print $2 }' | tr '/' '\n'))
3661 [[ $((${clients[0]} + 1)) == ${clients[1]} ]] ||
3662 error "client not evicted by ost1"
3664 local testid=$(echo $TESTNAME | tr '_' ' ')
3665 do_facet ost1 dmesg | tac | sed "/$testid/,$ d" |
3666 grep "ofd_obd_disconnect: tot_granted" &&
3667 error "grant miscount" || true
3669 run_test 156 "tot_granted miscount after client eviction"
3673 (( MDS1_VERSION >= $(version_code 2.15.58.110) )) ||
3674 skip "need MDS >= v2_15_58-110-g71f8e5d6506f to avoid eviction"
3676 $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
3677 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
3678 cancel_lru_locks osc
3680 #define OBD_FAIL_LLITE_FAULT_PAUSE 0x1432
3681 $LCTL set_param fail_loc=0x80001432 fail_val=3
3682 $MULTIOP $DIR/$tfile soO_RDWR:MRUc &
3688 (( rc == 0 || rc == 135 )) ||
3689 error "multiop failed with $rc, not SIGBUS (135)"
3691 run_test 157 "eviction during mmaped i/o"
3694 do_facet mds2 $LCTL set_param fail_loc=0
3695 zconf_umount_clients $CLIENTS $MOUNT
3700 (( $MDS1_VERSION >= $(version_code 2.15.62) )) ||
3701 skip "Need MDS version at least 2.15.62 for -EACCES fix"
3702 (( MDSCOUNT > 1 )) || skip "needs >= 2 MDTS"
3704 remount_client $MOUNT
3705 # ensure there is no MOUNT2 on clients
3706 zconf_umount_clients $CLIENTS $MOUNT2 -f
3708 stack_trap cleanup_158 EXIT RETURN
3710 # client import is evicted after failover followed by -EACCES
3711 #define OBD_FAIL_MDS_CONNECT_ACCESS 0x2402
3712 do_facet mds2 $LCTL set_param fail_loc=0x2402
3716 do_facet mds2 $LCTL set_param fail_loc=0
3717 wait_recovery_complete mds2 || error "MDS recovery not done"
3720 local mdc2=$($LCTL dl | awk '/mdc.*MDT0001-mdc*/ { print $4}')
3721 local active=$($LCTL get_param -n mdc.$mdc2.active)
3722 (( active == 0 )) || error "import status is 'active'"
3723 $LCTL --device $mdc2 activate
3724 active=$($LCTL get_param -n mdc.$mdc2.active)
3725 (( active == 1 )) || error "import status is not 'active'"
3726 status=$($LFS check mdts | grep $mdc2 | grep -c active)
3727 (( status == 1 )) || {
3729 error "import is not operational"
3732 run_test 158a "connect without access right"
3735 (( $MDS1_VERSION >= $(version_code 2.15.62) )) ||
3736 skip "Need MDS version at least 2.15.62 for group lock destroy fix"
3739 local size=$((1024*100))
3743 test_mkdir -i 0 -c 1 $DIR/$tdir
3744 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3746 for ((i = 1; i <= threads; i++)); do
3747 local file=$DIR/$tdir/file_$i
3748 #open/group lock/write/unlink/pause/group unlock/close
3749 $MULTIOP $file OG1234w10240u_g1234c &
3754 #evict client from MDS, MDS starts to unlink files/destroy objects
3758 wait_update_facet_cond --verbose mds1 \
3759 "$LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.destroys_in_flight" \
3760 "-le" "2" $((timeout * 3))
3762 do_facet mds1 $LCTL get_param osp.$FSNAME-OST0000-osc-MDT0000.error_list
3763 for ((i = 1; i <= threads; i++)); do
3764 kill -USR1 ${pids[$i]} && wait ${pids[$i]}
3767 (( rc == 0 )) || error "destroying OST objects are blocked"
3769 #without group lock, wait and check if all objects are destroyed
3770 sleep $((timeout * 3))
3771 do_facet mds1 $LCTL get_param osp.$FSNAME-OST0000-osc-MDT0000.error_list
3772 local errs=$(do_facet mds1 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.error_list | wc -l)
3773 rc=$(do_facet mds1 $LCTL get_param -n osp.$FSNAME-OST0000-osc-MDT0000.destroys_in_flight)
3775 (( $errs == 0 )) || error "error_list not empty"
3776 (( $rc == 0 )) || error "$rc destroys in flight"
3778 run_test 160 "MDT destroys are blocked by grouplocks"
3781 [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
3782 local ping_interval=$($LCTL get_param -n ping_interval)
3783 local evict_multiplier=$($LCTL get_param -n evict_multiplier)
3784 local pause=$((ping_interval * (evict_multiplier + 2)))
3786 #define OBD_FAIL_OBD_PAUSE_EVICTOR 0x60f
3787 do_facet mds1 $LCTL set_param fail_loc=0x8000060f
3789 $LFS mkdir -i 1 $DIR/$tdir || error "mkdir $tdir"
3790 $LFS mkdir -i 0 $DIR/$tdir/remote || error "mkdir $tdir/remote"
3792 echo sleep $pause seconds
3794 rmdir $DIR/$tdir/remote || error "rmdir $tdir/remote"
3796 run_test 161 "evict osp by ping evictor"
3799 local mntpt=$(facet_mntpt $SINGLEMDS)
3801 test_mkdir -i 0 -c 1 $DIR/$tdir
3802 $LFS setstripe -c 1 -i 0 $DIR/$tdir
3804 local wfile=$DIR/$tdir/$tfile
3805 local rstr="aAdDiPST"
3807 stack_trap "chattr -$rstr $wfile; rm -rf $DIR/$tdir" EXIT
3810 for ((i = 0; i < ${#rstr[0]}; i++)); do
3813 chattr +$c $wfile || error "Flag [$c] should succeed"
3816 local attr1=($(lsattr $wfile))
3819 [[ -n ${attr1//-/} ]] || error "lsattr failed: $(lsattr $wfile)"
3822 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3824 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
3826 local attr2=($(lsattr $wfile))
3828 [[ "$attr1" == "$attr2" ]] ||
3829 error "'$attr1' different with '$attr2'"
3832 run_test 162 "File attributes should be persisted after MDS failover"
3835 remote_mds_nodsh && skip "remote MDS with nodsh"
3836 (( "$MDS1_VERSION" >= $(version_code 2.16.54) )) ||
3837 skip "Need MDS version at least 2.16.54 to skip llog holes"
3842 changelog_register || error "changelog_register failed"
3843 stack_trap changelog_deregister EXIT
3844 test_mkdir -c 0 $DIR/$tdir || error "mkdir $tdir failed"
3845 mdtidx=$(($($LFS getdirstripe -i $DIR/$tdir) + 1))
3846 mdtsvc=$(facet_svc mds$mdtidx)
3847 echo mds$mdtidx $mdtsvc
3849 cl_mask=$(do_facet mds$mdtidx $LCTL get_param mdd.$mdtsvc.changelog_mask -n)
3850 changelog_chmask "ALL"
3851 stack_trap "do_facet mds$mdtidx \
3852 $LCTL set_param mdd.$mdtsvc.changelog_mask=\'$cl_mask\' -n" EXIT
3854 #define OBD_FAIL_MDS_CHANGELOG_FAIL_WRITE 0x18f
3855 do_facet mds$mdtidx $LCTL set_param fail_loc=0x18f fail_val=30
3857 # generate some changelog records to create a gap every 31 index
3858 for (( i = 0; i < 10; i++)); do
3859 createmany -m $DIR/$tdir/$tfile_$i 40 &
3862 # Check changelog gap processing without a jump to a next chunk
3863 changelog_dump | awk -F'[ .]' '{if(prev != "" && $2 - prev > 2) \
3864 {print"Errot between "prev" and "$2; exit 1}prev=$2}' ||
3867 run_test 163 "changelog check for fail write and processing records"
3869 complete_test $SECONDS
3870 check_and_cleanup_lustre