5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
11 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT "
15 require_dsh_mds || exit 0
17 # Allow us to override the setup if we already have a mounted system by
18 # setting SETUP=" " and CLEANUP=" "
20 CLEANUP=${CLEANUP:-""}
22 check_and_setup_lustre
25 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
30 local f1="$DIR/$tfile"
31 local f2="$DIR/$tfile.2"
33 drop_request "mcreate $f1" ||
34 error_noexit "create '$f1': drop req"
36 drop_reint_reply "mcreate $f2" ||
37 error_noexit "create '$f2': drop rep"
39 drop_request "tchmod 111 $f2" ||
40 error_noexit "chmod '$f2': drop req"
42 drop_reint_reply "tchmod 666 $f2" ||
43 error_noexit "chmod '$f2': drop rep"
45 drop_request "statone $f2" ||
46 error_noexit "stat '$f2': drop req"
48 drop_reply "statone $f2" ||
49 error_noexit "stat '$f2': drop rep"
51 run_test 1 "create, chmod, stat: drop req, drop rep"
55 do_facet_create_file client $t 10K ||
56 error_noexit "Create file $t"
58 drop_request "cat $t > /dev/null" ||
59 error_noexit "Open request for $t file"
61 drop_reply "cat $t > /dev/null" ||
62 error_noexit "Open replay for $t file"
64 run_test 4 "open: drop req, drop rep"
69 local RR="$T-renamed-again"
70 do_facet_create_file client $T 10K ||
71 error_noexit "Create file $T"
73 drop_request "mv $T $R" ||
74 error_noexit "Rename $T"
76 drop_reint_reply "mv $R $RR" ||
77 error_noexit "Failed rename replay on $R"
79 do_facet client "checkstat -v $RR" ||
80 error_noexit "checkstat error on $RR"
82 do_facet client "rm $RR" ||
83 error_noexit "Can't remove file $RR"
85 run_test 5 "rename: drop req, drop rep"
89 local LINK1=$DIR/$tfile.link1
90 local LINK2=$DIR/$tfile.link2
92 do_facet_create_file client $T 10K ||
93 error_noexit "Create file $T"
95 drop_request "mlink $T $LINK1" ||
96 error_noexit "mlink request for $T"
98 drop_reint_reply "mlink $T $LINK2" ||
99 error_noexit "mlink reply for $T"
101 drop_request "munlink $LINK1" ||
102 error_noexit "munlink request for $T"
104 drop_reint_reply "munlink $LINK2" ||
105 error_noexit "munlink reply for $T"
107 do_facet client "rm $T" ||
108 error_noexit "Can't remove file $T"
110 run_test 6 "link, unlink: drop req, drop rep"
114 drop_reint_reply "touch $DIR/$tfile" || return 1
116 run_test 8 "touch: drop rep (bug 1423)"
120 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
124 do_facet_random_file client $TMP/$tfile 1K ||
125 error_noexit "Create random file $TMP/$tfile"
126 # make this big, else test 9 doesn't wait for bulk -- bz 5595
127 do_facet_create_file client $TMP/$t1 4M ||
128 error_noexit "Create file $TMP/$t1"
129 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
130 error_noexit "Can't copy to $DIR/$t1 file"
131 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
132 error_noexit "Can't pause_bulk copy"
133 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
134 error_noexit "Can't copy file"
135 do_facet client "sync"
136 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
137 error_noexit "Can't remove files"
138 do_facet client "rm $TMP/$t1 $TMP/$tfile"
140 run_test 9 "pause bulk on OST (bug 1420)"
144 local before=$(date +%s)
147 do_facet client "stat $DIR > /dev/null" ||
148 error "failed to stat $DIR: $?"
149 drop_bl_callback "chmod 0777 $DIR" ||
150 error "failed to chmod $DIR: $?"
152 # let the client reconnect
154 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
155 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
156 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
157 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
158 error "no eviction: $evict before:$before")
160 do_facet client checkstat -v -p 0777 $DIR ||
161 error "client checkstat failed: $?"
163 run_test 10a "finish request on server after client eviction (bug 1521)"
166 local before=$(date +%s)
169 [[ "$MDS1_VERSION" -lt $(version_code 2.6.53) ]] &&
170 skip "Need MDS version at least 2.6.53"
171 do_facet client "stat $DIR > /dev/null" ||
172 error "failed to stat $DIR: $?"
173 drop_bl_callback_once "chmod 0777 $DIR" ||
174 error "failed to chmod $DIR: $?"
176 # let the client reconnect
178 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
179 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
181 [ -z "$evict" ] || [[ $evict -le $before ]] ||
182 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
183 error "eviction happened: $evict before:$before")
185 do_facet client checkstat -v -p 0777 $DIR ||
186 error "client checkstat failed: $?"
188 run_test 10b "re-send BL AST"
191 local before=$(date +%s)
200 workdir="${DIR}/${tdir}"
201 mkdir -p ${workdir} || error "can't create workdir $?"
202 stat ${workdir} > /dev/null ||
203 error "failed to stat ${workdir}: $?"
204 mdtidx=$($LFS getdirstripe -i ${workdir})
205 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
206 awk '{sub("_UUID", "", $2); print $2;}')
208 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
209 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
210 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
212 drop_bl_callback_once "chmod 0777 ${workdir}" &
217 # force client reconnect
218 $LCTL set_param "${mdcpath}"
220 # wait client reconnect
224 evict=$($LCTL get_param mdc.${mdccli}.state |
225 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
227 [[ $evict -le $before ]] ||
228 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
229 error "eviction happened: $EVICT before:$BEFORE" )
231 [ $rc -eq 0 ] || error "chmod must finished OK"
232 checkstat -v -p 0777 "${workdir}" ||
233 error "client checkstat failed: $?"
235 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
238 local before=$(date +%s)
241 [[ "$MDS1_VERSION" -lt $(version_code 2.6.90) ]] &&
242 skip "Need MDS version at least 2.6.90"
244 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
247 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
249 remount_client $MOUNT
253 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
254 echo -n hello | dd of=$DIR1/$tfile bs=5
256 stat $DIR2/$tfile >& /dev/null
257 $LCTL set_param fail_err=71
258 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
263 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
264 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
266 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
268 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
270 [[ $evict -gt $before ]] ||
271 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
272 error "no eviction: $evict before:$before")
274 $LCTL set_param fail_err=0
276 umount_client $MOUNT2
278 run_test 10d "test failed blocking ast"
282 [[ "$OST1_VERSION" -le $(version_code 2.8.58) ]] &&
283 skip "Need OST version at least 2.8.59"
284 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients"
285 [ $(facet_host client) == $(facet_host ost1) ] &&
286 skip "need ost1 and client on different nodes"
287 local -a clients=(${CLIENTS//,/ })
288 local client1=${clients[0]}
289 local client2=${clients[1]}
291 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
292 $MULTIOP $DIR/$tfile-1 Ow1048576c
294 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
295 $LCTL set_param fail_loc=0x80000305
297 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
298 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
299 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
300 # 1. to return ENOTCONN from ldlm_handle_enqueue0
301 # 2. to pause reconnect handling between resend and setting
302 # import to LUSTRE_IMP_FULL state
303 do_facet ost1 "$LCTL set_param fail_val=3"
305 # client1 fails ro respond to bl ast
306 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
309 # ost1 returns error on enqueue, which causes client1 to reconnect
310 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
311 error "multiop failed"
314 do_facet ost1 "$LCTL set_param fail_loc=0"
315 do_facet ost1 "$LCTL set_param fail_val=0"
317 run_test 10e "re-send BL AST vs reconnect race 2"
320 # wake up a thread waiting for completion after eviction
322 do_facet client $MULTIOP $DIR/$tfile Ow ||
323 { error "multiop write failed: $?"; return 1; }
324 do_facet client $MULTIOP $DIR/$tfile or ||
325 { error "multiop read failed: $?"; return 2; }
329 do_facet client $MULTIOP $DIR/$tfile or ||
330 { error "multiop read failed: $?"; return 3; }
331 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
332 echo "evicted as expected"
334 do_facet client munlink $DIR/$tfile ||
335 { error "munlink failed: $?"; return 4; }
336 # allow recovery to complete
337 client_up || client_up || sleep $TIMEOUT
339 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
343 $LCTL mark $MULTIOP $DIR/$tfile OS_c
344 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
345 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
346 multiop_bg_pause $DIR/$tfile OS_c ||
347 { error "multiop failed: $?"; return 1; }
349 #define OBD_FAIL_MDS_CLOSE_NET 0x115
351 echo "waiting for multiop $PID"
352 wait $PID || { error "wait for multiop faile: $?"; return 2; }
353 do_facet client munlink $DIR/$tfile ||
354 { error "client munlink failed: $?"; return 3; }
355 # allow recovery to complete
356 client_up || client_up || sleep $TIMEOUT
358 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
360 # Bug 113, check that readdir lost recv timeout works.
362 mkdir_on_mdt0 $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
363 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
364 # OBD_FAIL_MDS_READPAGE_NET|CFS_FAIL_ONCE
365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
366 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
367 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
368 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
370 run_test 13 "mdc_readpage restart test (bug 1138)"
372 # Bug 113, check that readdir lost send timeout works.
374 mkdir_on_mdt0 $DIR/$tdir
375 touch $DIR/$tdir/newentry
376 # OBD_FAIL_MDS_SENDPAGE|CFS_FAIL_ONCE
377 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
378 ls $DIR/$tdir || return 1
379 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
381 run_test 14 "mdc_readpage resend test (bug 1138)"
384 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
385 touch $DIR/$tfile && return 1
388 run_test 15 "failed open (-ENOMEM)"
390 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
392 lctl set_param -n llite.*.max_read_ahead_mb 0
396 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
400 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
402 do_facet_random_file client $TMP/$tfile 100K ||
403 { error_noexit "Create random file $TMP/$T" ; return 0; }
404 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
405 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
409 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | CFS_FAIL_ONCE
410 do_facet ost1 "lctl set_param fail_loc=0x80000504"
412 # OST bulk will time out here, client resends
413 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
414 do_facet ost1 lctl set_param fail_loc=0
415 # give recovery a chance to finish (shouldn't take long)
417 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
421 run_test 16 "timeout bulk put, don't evict client (2732)"
426 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
428 local SAMPLE_FILE=$TMP/$tfile
429 do_facet_random_file client $SAMPLE_FILE 20K ||
430 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
432 # With adaptive timeouts, bulk_get won't expire until
433 # adaptive_timeout_max
434 if at_is_enabled; then
435 at_max_saved=$(at_max_get ost1)
436 at_max_set $TIMEOUT ost1
439 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | CFS_FAIL_ONCE
440 # OST bulk will time out here, client retries
441 do_facet ost1 lctl set_param fail_loc=0x80000503
442 # need to ensure we send an RPC
443 do_facet client cp $SAMPLE_FILE $DIR/$tfile
446 # with AT, client will wait adaptive_max*factor+net_latency before
447 # expiring the req, hopefully timeout*2 is enough
448 sleep $(($TIMEOUT*2))
450 do_facet ost1 lctl set_param fail_loc=0
451 do_facet client "df $DIR"
452 # expect cmp to succeed, client resent bulk
453 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
454 do_facet client "rm $DIR/$tfile" || return 4
455 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
458 run_test 17a "timeout bulk get, don't evict client (2732)"
461 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
463 # get one of the clients from client list
464 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
465 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
466 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
467 [ -z "$ldlm_enqueue_min" ] &&
468 skip "missing /sys/.../ldlm_enqueue_min" && return 0
470 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
471 error "setstripe failed"
472 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
473 error "setstripe 2 failed"
475 save_lustre_params ost1 "at_history" > $p
476 save_lustre_params ost1 "bulk_timeout" >> $p
477 local dev="${FSNAME}-OST0000"
478 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
479 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
481 local new_at_history=15
483 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
484 do_facet ost1 "$LCTL set_param bulk_timeout=30"
485 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
487 # brw_size is required to be 4m so that bulk transfer timeout
488 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
489 local brw_size=$($LCTL get_param -n \
490 osc.$FSNAME-OST0000-osc-[^M]*.import |
491 awk '/max_brw_size/{print $2}')
492 if [ $brw_size -ne 4194304 ]
494 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
495 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
496 remount_client $MOUNT
499 # get service estimate expanded
500 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
501 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
502 echo "delay rpc servicing by 35 seconds"
503 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
506 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
507 awk '/portal 6/ {print $5}')
508 echo "service estimates increased to $estimate"
510 # let current worst service estimate to get closer to obliteration
511 sleep $((new_at_history / 3))
513 # start i/o and simulate bulk transfer loss
514 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
515 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
516 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
519 # start lock conflict handling
520 sleep $((new_at_history / 3))
521 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
524 # obliterate the worst service estimate
525 sleep $((new_at_history / 3 + 1))
526 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
528 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
529 awk '/portal 6/ {print $5}')
530 echo "service estimate dropped to $estimate"
533 [[ $? == 0 ]] || error "write failed"
535 [[ $? == 0 ]] || error "read failed"
537 restore_lustre_params <$p
538 if [ $brw_size -ne 4194304 ]
540 remount_client $MOUNT || error "remount_client failed"
542 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
544 run_test 17b "timeout bulk get, dont evict client (3582)"
547 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
549 do_facet_create_file client $TMP/$tfile 20K ||
550 { error_noexit "Create file $TMP/$tfile" ; return 0; }
552 do_facet client mkdir -p $DIR/$tdir
556 pgcache_empty || return 1
559 $LFS setstripe -i 1 -c 1 $f
560 stripe_index=$($LFS getstripe -i $f)
561 if [ $stripe_index -ne 1 ]; then
563 error "$f: stripe_index $stripe_index != 1" && return
566 do_facet client cp $TMP/$tfile $f
568 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
569 $LCTL --device $osc2dev deactivate || return 3
570 # my understanding is that there should be nothing in the page
571 # cache after the client reconnects?
573 pgcache_empty || rc=2
574 $LCTL --device $osc2dev activate
578 run_test 18a "manual ost invalidate clears page cache immediately"
581 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
583 do_facet_create_file client $TMP/$tfile 20K ||
584 { error_noexit "Create file $TMP/$tfile" ; return 0; }
586 do_facet client mkdir -p $DIR/$tdir
590 pgcache_empty || return 1
592 $LFS setstripe -i 0 -c 1 $f
593 stripe_index=$($LFS getstripe -i $f)
594 if [ $stripe_index -ne 0 ]; then
596 error "$f: stripe_index $stripe_index != 0" && return
599 do_facet client cp $TMP/$tfile $f
602 # allow recovery to complete
603 sleep $((TIMEOUT + 2))
604 # my understanding is that there should be nothing in the page
605 # cache after the client reconnects?
607 pgcache_empty || rc=2
611 run_test 18b "eviction and reconnect clears page cache (2766)"
614 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
616 do_facet_create_file client $TMP/$tfile 20K ||
617 { error_noexit "Create file $TMP/$tfile" ; return 0; }
619 do_facet client mkdir -p $DIR/$tdir
623 pgcache_empty || return 1
625 $LFS setstripe -i 0 -c 1 $f
626 stripe_index=$($LFS getstripe -i $f)
627 if [ $stripe_index -ne 0 ]; then
629 error "$f: stripe_index $stripe_index != 0" && return
632 do_facet client cp $TMP/$tfile $f
636 # OBD_FAIL_OST_CONNECT_NET2
637 # lost reply to connect request
638 do_facet ost1 lctl set_param fail_loc=0x80000225
641 $LFS df $MOUNT > /dev/null 2>&1
643 # my understanding is that there should be nothing in the page
644 # cache after the client reconnects?
646 pgcache_empty || rc=2
650 run_test 18c "Dropped connect reply after eviction handing (14755)"
653 local BEFORE=`date +%s`
656 mount_client $DIR2 || error "failed to mount $DIR2"
658 # cancel cached locks from OST to avoid eviction from it
661 do_facet client "stat $DIR > /dev/null" ||
662 error "failed to stat $DIR: $?"
663 drop_ldlm_cancel "chmod 0777 $DIR2" ||
664 error "failed to chmod $DIR2"
668 # let the client reconnect
670 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
671 awk -F"[ [,]" '/EVICTED ]$/ \
672 { if (mx<$5) {mx=$5;} } END { print mx }')
674 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
675 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
676 error "no eviction: $EVICT before:$BEFORE")
678 run_test 19a "test expired_lock_main on mds (2867)"
681 local BEFORE=`date +%s`
684 mount_client $DIR2 || error "failed to mount $DIR2: $?"
686 # cancel cached locks from MDT to avoid eviction from it
689 do_facet client $MULTIOP $DIR/$tfile Ow ||
690 error "failed to run multiop: $?"
691 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
692 error "failed to ldlm_cancel: $?"
694 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
695 do_facet client munlink $DIR/$tfile ||
696 error "failed to unlink $DIR/$tfile: $?"
698 # let the client reconnect
700 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
701 awk -F"[ [,]" '/EVICTED ]$/ \
702 { if (mx < $5) {mx = $5;} } END { print mx }')
704 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
705 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
706 error "no eviction: $EVICT before:$BEFORE")
708 run_test 19b "test expired_lock_main on ost (2867)"
711 local BEFORE=`date +%s`
714 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
716 mkdir -p $DIR1/$tfile
719 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
720 do_facet mds $LCTL set_param fail_loc=0x80000516
722 touch $DIR2/$tfile/file1 &
724 # let touch to get blocked on the server
728 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
731 # let the client reconnect
733 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
734 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
736 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
738 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
740 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
741 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
744 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
745 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
748 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
749 do_facet ost1 lctl set_param fail_loc=0x80000308
750 kill -USR1 $MULTI_PID
753 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
755 run_test 20a "ldlm_handle_enqueue error (should return error)"
757 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
758 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
761 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
763 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
764 do_facet ost1 lctl set_param fail_loc=0x80000308
765 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
766 error "didn't fail open enqueue" || true
768 run_test 20b "ldlm_handle_enqueue error (should return error)"
771 mkdir_on_mdt0 $DIR/$tdir-1
772 mkdir_on_mdt0 $DIR/$tdir-2
773 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
776 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
777 $MULTIOP $DIR/$tdir-2/f Oc &
780 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
782 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
783 kill -USR1 $close_pid
785 wait $close_pid || return 1
786 wait $open_pid || return 2
787 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
789 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
790 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
794 run_test 21a "drop close request while close and open are both in flight"
797 mkdir_on_mdt0 $DIR/$tdir-1
798 mkdir_on_mdt0 $DIR/$tdir-2
799 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
802 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
803 mcreate $DIR/$tdir-2/f &
806 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
808 kill -USR1 $close_pid
810 wait $close_pid || return 1
811 wait $open_pid || return 3
813 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
814 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
817 run_test 21b "drop open request while close and open are both in flight"
820 mkdir_on_mdt0 $DIR/$tdir-1
821 mkdir_on_mdt0 $DIR/$tdir-2
822 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
825 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
826 mcreate $DIR/$tdir-2/f &
829 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
831 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
832 kill -USR1 $close_pid
834 wait $close_pid || return 1
835 wait $open_pid || return 2
837 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
839 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
840 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
843 run_test 21c "drop both request while close and open are both in flight"
846 mkdir_on_mdt0 $DIR/$tdir-1
847 mkdir_on_mdt0 $DIR/$tdir-2
848 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
851 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
852 $MULTIOP $DIR/$tdir-2/f Oc &
854 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
856 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
859 wait $pid || return 1
860 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
862 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
863 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
867 run_test 21d "drop close reply while close and open are both in flight"
870 mkdir_on_mdt0 $DIR/$tdir-1
871 mkdir_on_mdt0 $DIR/$tdir-2
872 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
875 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
876 touch $DIR/$tdir-2/f &
878 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
882 wait $pid || return 1
885 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
886 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
889 run_test 21e "drop open reply while close and open are both in flight"
892 mkdir_on_mdt0 $DIR/$tdir-1
893 mkdir_on_mdt0 $DIR/$tdir-2
894 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
897 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
898 touch $DIR/$tdir-2/f &
900 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
902 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
905 wait $pid || return 1
906 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
908 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
909 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
912 run_test 21f "drop both reply while close and open are both in flight"
915 mkdir_on_mdt0 $DIR/$tdir-1
916 mkdir_on_mdt0 $DIR/$tdir-2
917 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
920 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
921 touch $DIR/$tdir-2/f &
923 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
925 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
928 wait $pid || return 1
929 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
931 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
932 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
935 run_test 21g "drop open reply and close request while close and open are both in flight"
938 mkdir_on_mdt0 $DIR/$tdir-1
939 mkdir_on_mdt0 $DIR/$tdir-2
940 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
943 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
944 touch $DIR/$tdir-2/f &
947 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
949 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
952 wait $pid || return 1
953 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
955 wait $touch_pid || return 2
957 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
958 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
961 run_test 21h "drop open request and close reply while close and open are both in flight"
963 # bug 3462 - multiple MDC requests
968 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
973 $MULTIOP $f1 msu || return 1
976 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
978 wait $close_pid || return 2
979 rm -rf $f2 || return 4
981 run_test 22 "drop close request and do mknod"
984 multiop_bg_pause $DIR/$tfile O_c || return 1
986 # give a chance for open
990 drop_request "kill -USR1 $pid"
993 wait $pid || return 1
996 run_test 23 "client hang when close a file after mds crash"
998 test_24a() { # bug 11710 details correct fsync() behavior
999 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1002 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1003 cancel_lru_locks osc
1004 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1007 kill -USR1 $MULTI_PID
1010 lctl set_param fail_loc=0x0
1013 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1015 run_test 24a "fsync error (should return error)"
1017 wait_client_evicted () {
1020 local varsvc=${facet}_svc
1022 wait_update $(facet_active_host $facet) \
1023 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1028 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1030 dmesg -c > /dev/null
1032 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1033 error "$LFS setstripe failed"
1034 cancel_lru_locks osc
1035 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1036 error "mulitop Ow8192_yc failed"
1039 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1040 error "mulitop Ow8192_c failed"
1045 kill -USR1 $MULTI_PID1
1048 kill -USR1 $MULTI_PID2
1051 lctl set_param fail_loc=0x0
1053 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1054 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1057 dmesg | grep "dirty page discard:" ||
1058 error "no discarded dirty page found!"
1060 run_test 24b "test dirty page discard due to client eviction"
1062 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1063 # this test can only run from a client on a separate node.
1064 remote_ost || { skip "local OST" && return 0; }
1065 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1066 remote_mds || { skip "local MDS" && return 0; }
1068 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1069 skip "msg and ost1 are at the same node"
1073 check_timeout || return 1
1075 # make sure all imports are connected and not IDLE
1076 do_facet client lfs df > /dev/null
1077 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1078 do_facet client lctl set_param fail_loc=0x505
1079 local before=$(date +%s)
1082 # evictor takes PING_EVICT_TIMEOUT to evict.
1083 # But if there's a race to start the evictor from various obds,
1084 # the loser might have to wait for the next ping.
1085 sleep $((TIMEOUT * 2))
1086 do_facet client lctl set_param fail_loc=0x0
1087 do_facet client lfs df > /dev/null
1089 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1090 check_clients_evicted "$before ${oscs[@]}"
1091 check_clients_full 10 "${oscs[@]}"
1093 run_test 26a "evict dead exports"
1095 test_26b() { # bug 10140 - evict dead exports by pinger
1096 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1098 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1099 skip "msg and ost1 are at the same node"
1103 check_timeout || return 1
1105 zconf_mount `hostname` $MOUNT2 ||
1106 { error "Failed to mount $MOUNT2"; return 2; }
1107 sleep 1 # wait connections being established
1109 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1110 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1112 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1114 zconf_umount `hostname` $MOUNT2 -f
1116 # PING_INTERVAL max(obd_timeout / 4, 1U)
1117 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1119 # evictor takes PING_EVICT_TIMEOUT to evict.
1120 # But if there's a race to start the evictor from various obds,
1121 # the loser might have to wait for the next ping.
1122 # = 6 * PING_INTERVAL + PING_INTERVAL
1123 # = 7 PING_INTERVAL = 7 obd_timeout / 4 = (1+3/4)obd_timeout
1124 # let's wait $((TIMEOUT * 2)) # bug 19887
1125 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 2)) ||
1126 error "Client was not evicted by ost"
1127 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 2)) ||
1128 error "Client was not evicted by mds"
1130 run_test 26b "evict dead exports"
1133 mkdir_on_mdt0 $DIR/$tdir
1134 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1137 local save_FAILURE_MODE=$FAILURE_MODE
1139 facet_failover $SINGLEMDS
1140 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1141 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1142 # need to wait for reconnect
1143 echo waiting for fail_loc
1144 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1145 facet_failover $SINGLEMDS
1146 #no crashes allowed!
1147 kill -USR1 $CLIENT_PID
1150 FAILURE_MODE=$save_FAILURE_MODE
1152 run_test 27 "fail LOV while using OSC's"
1154 test_28() { # bug 6086 - error adding new clients
1155 do_facet client mcreate $DIR/$tfile || return 1
1156 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1157 echo "evicted as expected"
1158 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1159 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1160 # fail once (evicted), reconnect fail (fail_loc), ok
1161 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1163 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1165 run_test 28 "handle error adding new clients (bug 6086)"
1167 test_29a() { # bug 22273 - error adding new clients
1168 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1169 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1170 # fail abort so client will be new again
1171 fail_abort $SINGLEMDS
1172 client_up || error "reconnect failed"
1173 wait_osc_import_state $SINGLEMDS ost FULL
1176 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1178 test_29b() { # bug 22273 - error adding new clients
1179 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1180 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1181 # fail abort so client will be new again
1183 client_up || error "reconnect failed"
1186 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1190 # put a load of file creates/writes/deletes
1191 writemany -q $DIR/$tdir/$tfile 0 5 &
1193 echo writemany pid $CLIENT_PID
1197 # wait for client to reconnect to MDS
1202 # client process should see no problems even though MDS went down
1204 kill -USR1 $CLIENT_PID
1207 echo writemany returned $rc
1208 #these may fail because of eviction due to slow AST response.
1210 error_ignore bz13652 "writemany returned rc $rc" || true
1212 run_test 50 "failover MDS under load"
1215 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1216 do_facet ost1 lctl set_param fail_loc=0x00001310
1218 mkdir_on_mdt0 $DIR/$tdir
1219 # put a load of file creates/writes/deletes
1220 writemany -q $DIR/$tdir/$tfile 0 5 &
1224 facet_failover $SINGLEMDS
1225 # failover at various points during recovery
1226 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1227 echo will failover at $SEQ
1229 #echo failover in $i sec
1230 log "$TESTNAME: failover in $i sec"
1232 facet_failover $SINGLEMDS
1234 # client process should see no problems even though MDS went down
1235 # and recovery was interrupted
1237 kill -USR1 $CLIENT_PID
1240 echo writemany returned $rc
1242 error_ignore bz13652 "writemany returned rc $rc" || true
1244 run_test 51 "failover MDS during recovery"
1247 do_facet client "mkdir -p $DIR/$tdir"
1248 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1250 echo writemany pid $CLIENT_PID
1255 wait $CLIENT_PID || rc=$?
1256 # active client process should see an EIO for down OST
1257 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1258 # but timing or failover setup may allow success
1259 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1260 echo "writemany returned $rc"
1265 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1270 [ $rc -ne 0 ] && { return $rc; }
1271 # wait for client to reconnect to OST
1275 [ $rc -ne 0 ] && { return $rc; }
1282 run_test 52 "failover OST under load"
1284 # test of open reconstruct
1287 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1290 run_test 53a "touch: drop rep"
1295 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1298 run_test 53b "touch: drop rep"
1303 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||
1306 run_test 53c "touch: drop rep"
1309 zconf_mount $(hostname) $MOUNT2
1311 touch $DIR2/$tfile.1
1313 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1316 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1317 grep "went back in time")
1318 [ x"$ERROR" == x ] || error "back in time occured"
1320 run_test 54 "back in time"
1322 # bug 11330 - liblustre application death during I/O locks up OST
1324 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1328 # This test assumes relatively small max_dirty_mb setting
1329 # which we want to walk away from, so just for it we will
1330 # temporarily lower the value
1331 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1332 lctl set_param -n osc.*.max_dirty_mb=32
1333 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1335 # Minimum pass speed is 2MBps
1337 # LU-2887/LU-3089 - set min pass speed to 500KBps
1338 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1340 # first dd should be finished quickly
1341 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1342 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1345 echo "step1: testing ......"
1346 while kill -0 $DDPID 2> /dev/null; do
1348 if [ $count -gt $ddtimeout ]; then
1349 error "dd should be finished!"
1353 echo "(dd_pid=$DDPID, time=$count)successful"
1355 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1356 #define OBD_FAIL_OST_DROP_REQ 0x21d
1357 do_facet ost1 lctl set_param fail_loc=0x0000021d
1358 # second dd will be never finished
1359 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1362 echo "step2: testing ......"
1363 while [ $count -le $ddtimeout ]; do
1364 if ! kill -0 $DDPID 2> /dev/null; then
1366 error "dd shouldn't be finished! (time=$count)"
1371 echo "(dd_pid=$DDPID, time=$count)successful"
1373 #Recover fail_loc and dd will finish soon
1374 do_facet ost1 lctl set_param fail_loc=0
1376 echo "step3: testing ......"
1377 while kill -0 $DDPID 2> /dev/null; do
1379 if [ $count -gt $((ddtimeout + 440)) ]; then
1380 error "dd should be finished!"
1384 echo "(dd_pid=$DDPID, time=$count)successful"
1388 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1390 test_56() { # b=11277
1391 #define OBD_FAIL_MDS_RESEND 0x136
1393 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1394 stat $DIR/$tfile || error "stat failed"
1395 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1398 run_test 56 "do not fail on getattr resend"
1401 # no oscs means no client or mdt
1402 while lctl get_param osc.*.* > /dev/null 2>&1; do
1403 : # loop until proc file is removed
1407 test_57() { # bug 10866
1411 #define OBD_FAIL_LPROC_REMOVE 0xB00
1412 lctl set_param fail_loc=0x80000B00
1413 zconf_umount `hostname` $DIR
1414 lctl set_param fail_loc=0x80000B00
1415 fail_abort $SINGLEMDS
1417 lctl set_param fail_loc=0
1419 do_facet client "df $DIR"
1421 run_test 57 "read procfs entries causes kernel crash"
1423 test_58() { # bug 11546
1424 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1427 lctl set_param fail_loc=0x80000801
1428 cp $DIR/$tfile /dev/null &
1431 lctl set_param fail_loc=0
1432 drop_bl_callback_once rm -f $DIR/$tfile
1434 # the first 'df' could tigger the eviction caused by
1435 # 'drop_bl_callback_once', and it's normal case.
1436 # but the next 'df' should return successfully.
1437 do_facet client "df $DIR" || do_facet client "df $DIR"
1439 run_test 58 "Eviction in the middle of open RPC reply processing"
1441 test_59() { # bug 10589
1442 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1443 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1444 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1445 lctl set_param fail_loc=0x311
1446 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1447 [ $? = 0 ] || error "dd write failed"
1448 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1449 lctl set_param fail_loc=0
1451 zconf_umount `hostname` $MOUNT2 -f
1452 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1453 [ $? = 0 ] || error "dd read failed"
1454 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1455 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1457 run_test 59 "Read cancel race on client eviction"
1460 local num_files=${COUNT:-5000}
1461 test_mkdir $DIR/$tdir
1463 # Register (and start) changelog
1464 changelog_register || error "changelog_register failed"
1466 # Generate a large number of changelog entries
1467 createmany -o $DIR/$tdir/$tfile $num_files
1471 # Unlink files in the background
1472 unlinkmany $DIR/$tdir/$tfile $num_files &
1476 # Failover the MDS while unlinks are happening
1477 facet_failover $SINGLEMDS
1479 # Wait for unlinkmany to finish
1482 # Check if all the create/unlink events were recorded
1484 local cl_count=$(changelog_dump | grep -c UNLNK)
1485 echo "$cl_count unlinks in changelog"
1487 changelog_deregister || error "changelog_deregister failed"
1488 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1489 [ $cl_count -eq $num_files ] ||
1490 error "Recorded $cl_count of $num_files unlinks"
1491 # Also make sure we can clear large changelogs
1492 cl_count=$(changelog_dump | wc -l)
1493 [ $cl_count -le 2 ] ||
1494 error "Changelog not empty: $cl_count entries"
1495 else # If other users, there may be other unlinks in the log
1496 [ $cl_count -ge $num_files ] ||
1497 error "Recorded $cl_count of $num_files unlinks"
1498 changelog_users $SINGLEMDS
1499 echo "other changelog users; can't verify clear"
1502 run_test 60 "Add Changelog entries during MDS failover"
1506 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1507 mdtosc=${mdtosc/-MDT*/-MDT\*}
1508 local cflags="osc.$mdtosc.connect_flags"
1509 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1510 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1512 mkdir_on_mdt0 $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1513 # Set the default stripe of $DIR/$tdir to put the files to ost1
1514 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1516 replay_barrier $SINGLEMDS
1517 createmany -o $DIR/$tdir/$tfile-%d 10
1518 local oid=$(do_facet ost1 "lctl get_param -n \
1519 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1521 fail_abort $SINGLEMDS
1523 touch $DIR/$tdir/$tfile
1524 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1525 awk '$1 == 0 { print $2 }')
1526 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1531 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1533 # test_62 as seen it b2_1 please do not reuse test_62
1536 # zconf_umount `hostname` $DIR
1537 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1538 # lctl set_param fail_loc=0x516
1541 #run_test 62 "Verify connection flags race - bug LU-1716"
1546 #grant lock1, export2
1547 $LFS setstripe -i -0 $DIR2/$tfile || error "setstripe failed"
1548 $MULTIOP $DIR2/$tfile Ow || error "multiop failed"
1550 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1551 do_facet ost $LCTL set_param fail_loc=0x31e
1552 #get waiting lock2, export1
1553 $MULTIOP $DIR/$tfile Ow &
1555 # let enqueue to get asleep
1559 $MULTIOP $DIR2/$tfile Ow &
1567 do_facet ost $LCTL set_param fail_loc=0
1574 run_test 65 "lock enqueue for destroyed export"
1578 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1579 skip "Need MDS version at least 2.7.51"
1581 local list=$(comma_list $(osts_nodes))
1583 # modify dir so that next revalidate would not obtain UPDATE lock
1586 # drop 1 reply with UPDATE lock
1587 mcreate $DIR/$tfile || error "mcreate failed: $?"
1588 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1591 # make the re-sent lock to sleep
1592 #define OBD_FAIL_MDS_RESEND 0x136
1593 do_nodes $list $LCTL set_param fail_loc=0x80000136
1595 #initiate the re-connect & re-send
1596 local mdtname="MDT0000"
1597 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1598 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1599 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1602 #initiate the client eviction while enqueue re-send is in progress
1608 run_test 66 "lock enqueue re-send vs client eviction"
1612 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1613 $LCTL set_param fail_loc=0x80000531
1615 local mdtname="MDT0000"
1616 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1617 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1618 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1627 run_test 67 "connect vs import invalidate race"
1629 check_cli_ir_state()
1631 local NODE=${1:-$HOSTNAME}
1633 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1634 awk '/imperative_recovery:/ { print \\\$2}'")
1635 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1636 error "Error state $st, must be ENABLED or DISABLED"
1640 check_target_ir_state()
1643 local name=${target}_svc
1644 local recovery_proc=obdfilter.${!name}.recovery_status
1648 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1649 awk '/status:/{ print \\\$2}'")
1650 [ x$st = xRECOVERING ] || break
1652 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1653 awk '/IR:/{ print \\\$2}'")
1654 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1655 error "Error state $st, must be ENABLED or DISABLED"
1661 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1666 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1667 awk '/state:/{ print \\\$2 }'")
1671 nidtbl_version_mgs()
1673 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1674 awk '/nidtbl_version:/{ print \\\$2 }'")
1678 # nidtbl_version_client <mds1|client> [node]
1679 nidtbl_version_client()
1682 local node=${2:-$HOSTNAME}
1684 if [ X$cli = Xclient ]; then
1687 local obdtype=${cli/%[0-9]*/}
1688 [ $obdtype != mds ] && error "wrong parameters $cli"
1690 node=$(facet_active_host $cli)
1695 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1696 awk "/$cli/{print \$6}" |sort -u)
1698 # in case there are multiple mounts on the client node
1700 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1704 nidtbl_versions_match()
1706 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1709 target_instance_match()
1715 obdtype=${srv/%[0-9]*/}
1726 error "invalid target type" $srv
1731 local target=${srv}_svc
1732 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1733 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1734 awk '/instance/{ print $2 }' | head -n1)
1736 return $([ $si -eq $ci ])
1741 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1742 { skip "MGS without IR support"; return 0; }
1744 # MDT was just restarted in the previous test, make sure everything
1747 while [ $cnt -gt 0 ]; do
1748 nidtbl_versions_match && break
1754 set_ir_status disabled
1756 local prev_ver=$(nidtbl_version_client client)
1758 local saved_FAILURE_MODE=$FAILURE_MODE
1759 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1763 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1764 error "version must not change due to IR disabled"
1765 target_instance_match ost1 || error "instance mismatch"
1769 FAILURE_MODE=$saved_FAILURE_MODE
1771 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1775 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1776 skip "MGS without IR support"
1780 local ost1_imp=$(get_osc_import_name client ost1)
1782 # disable pinger recovery
1783 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1784 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1788 target_instance_match ost1 || error "instance mismatch"
1789 nidtbl_versions_match || error "version must match"
1791 run_test 101a "IR: Make sure IR works w/o normal recovery"
1795 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1796 skip "MGS without IR support"
1800 local ost1_imp=$(get_osc_import_name client ost1)
1802 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1803 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1804 # disable pinger recovery
1805 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1806 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1808 #OST may return EAGAIN if it is not configured yet
1811 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1815 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1816 { skip "MGS without IR support"; return 0; }
1818 local clients=${CLIENTS:-$HOSTNAME}
1825 # let's have a new nidtbl version
1828 # sleep for a while so that clients can see the failure of ost
1829 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1830 # int mgc_request.c:
1831 # define MGC_TIMEOUT_MIN_SECONDS 5
1832 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1833 local count=30 # 20 seconds at most
1834 while [ $count -gt 0 ]; do
1835 nidtbl_versions_match && break
1840 nidtbl_versions_match || error "nidtbl mismatch"
1843 old_version=$(nidtbl_version_client client)
1845 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1848 combined_mgs_mds && mgsdev=mds1
1849 remount_facet $mgsdev
1852 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1855 new_version=$(nidtbl_version_client client)
1856 [ $new_version -lt $old_version ] &&
1857 error "nidtbl version wrong after mgs restarts"
1860 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1864 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1865 { skip "MGS without IR support"; return 0; }
1867 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1869 # workaround solution to generate config log on the mds
1875 # We need this test because mds is like a client in IR context.
1876 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1877 error "MDS should start w/o mgs"
1879 # start mgs and remount mds w/ ir
1880 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1883 # remount client so that fsdb will be created on the MGS
1884 umount_client $MOUNT || error "umount failed"
1885 mount_client $MOUNT || error "mount failed"
1887 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1889 while [ $count -gt 0 ]; do
1890 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1895 # after a while, mds should be able to reconnect to mgs and fetch
1896 # up-to-date nidtbl version
1897 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1902 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1906 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1907 { skip "MGS without IR support"; return 0; }
1912 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1913 error "OST1 cannot start"
1916 local ir_state=$(check_target_ir_state ost1)
1918 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1919 error "ir status on ost1 should be DISABLED"
1921 run_test 104 "IR: ost can disable IR voluntarily"
1925 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1926 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1927 { skip "MGS without IR support"; return 0; }
1931 # get one of the clients from client list
1932 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1934 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1935 zconf_umount $rcli $MOUNT || error "umount failed"
1936 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1938 # make sure lustre mount at $rcli disabling IR
1939 local ir_state=$(check_cli_ir_state $rcli)
1940 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1941 error "IR state must be DISABLED at $rcli"
1943 # Since the client just mounted, its last_rcvd entry is not on disk.
1944 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1945 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1946 $LFS setstripe -i 0 $DIR/$tfile
1947 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1949 # make sure MGS's state is Partial
1950 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1953 # make sure IR on ost1 is DISABLED
1954 local ir_state=$(check_target_ir_state ost1)
1955 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1956 error "IR status on ost1 should be DISABLED"
1958 # remount with the default MOUNT_OPTS
1959 zconf_umount $rcli $MOUNT || error "umount failed"
1960 zconf_mount $rcli $MOUNT || error "mount failed"
1962 # make sure MGS's state is full
1963 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1966 # make sure IR on ost1 is ENABLED
1967 local ir_state=$(check_target_ir_state ost1)
1968 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1969 error "IR status on ost1 should be ENABLED"
1973 run_test 105 "IR: NON IR clients support"
1981 test_106() { # LU-1789
1982 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1983 skip "Need MDS version at least 2.3.50"
1985 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1986 $LCTL set_param fail_loc=0x805
1989 trap cleanup_106 EXIT
1991 # enable lightweight flag on mdc connection
1994 local MDS_NEXP=$(do_facet $SINGLEMDS \
1995 lctl get_param -n mdt.${mds1_svc}.num_exports |
1997 $LCTL set_param fail_loc=0
1999 touch $DIR2/$tfile || error "failed to create empty file"
2000 replay_barrier $SINGLEMDS
2002 $LCTL set_param debug=ha
2004 facet_failover $SINGLEMDS
2006 # lightweight goes through LUSTRE_IMP_RECOVER during failover
2007 touch -c $DIR2/$tfile || true
2008 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2009 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
2010 $TMP/lustre-log-$TESTNAME.log)
2011 [ -z "$recovered" ] && error "lightweight client was not recovered"
2013 # and all operations performed by lightweight client should be
2014 # synchronous, so the file created before mds restart should be there
2015 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2020 run_test 106 "lightweight connection support"
2026 mkdir_on_mdt0 $DIR/$tdir
2027 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2028 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2029 multiop $DIR/$tdir D_c &
2031 mkdir $DIR/$tdir/dir_106 &
2033 do_facet $SINGLEMDS lctl set_param fail_loc=0
2036 wait $CLIENT_PID || rc=$?
2037 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2039 kill -USR1 $close_pid
2040 wait $close_pid || return 2
2044 run_test 107 "drop reint reply, then restart MDT"
2048 $LFS setstripe -c 1 -i 0 $DIR/$tdir
2050 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2058 client_up || error "reconnect failed"
2059 rm -f $DIR/$tdir/$tfile
2061 run_test 108 "client eviction don't crash"
2064 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2065 local remote_dir=$DIR/$tdir/remote_dir
2069 #prepare for 110 test, which need set striped dir on remote MDT.
2070 for num in $(seq $MDSCOUNT); do
2072 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2076 mkdir_on_mdt0 $DIR/$tdir
2077 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2078 error "lfs mkdir failed"
2079 local diridx=$($LFS getstripe -m $remote_dir)
2080 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2082 rm -rf $DIR/$tdir || error "rmdir failed"
2084 run_test 110a "create remote directory: drop client req"
2087 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2088 local remote_dir=$DIR/$tdir/remote_dir
2091 mkdir_on_mdt0 $DIR/$tdir
2092 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2093 error "lfs mkdir failed"
2095 diridx=$($LFS getstripe -m $remote_dir)
2096 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2098 rm -rf $DIR/$tdir || error "rmdir failed"
2100 run_test 110b "create remote directory: drop Master rep"
2103 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2104 local remote_dir=$DIR/$tdir/remote_dir
2107 mkdir_on_mdt0 $DIR/$tdir
2108 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2109 error "lfs mkdir failed"
2111 diridx=$($LFS getstripe -m $remote_dir)
2112 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2114 rm -rf $DIR/$tdir || error "rmdir failed"
2116 run_test 110c "create remote directory: drop update rep on slave MDT"
2119 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2120 local remote_dir=$DIR/$tdir/remote_dir
2123 mkdir_on_mdt0 $DIR/$tdir
2124 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2126 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2128 rm -rf $DIR/$tdir || error "rmdir failed"
2132 run_test 110d "remove remote directory: drop client req"
2135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2136 local remote_dir=$DIR/$tdir/remote_dir
2139 mkdir_on_mdt0 $DIR/$tdir
2140 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2141 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2143 rm -rf $DIR/$tdir || error "rmdir failed"
2147 run_test 110e "remove remote directory: drop master rep"
2150 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2151 local remote_dir=$DIR/$tdir/remote_dir
2154 mkdir_on_mdt0 $DIR/$tdir
2155 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2156 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2157 error "rm remote dir failed"
2159 rm -rf $DIR/$tdir || error "rmdir failed"
2161 run_test 110f "remove remote directory: drop slave rep"
2164 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2165 skip "Need MDS version at least 2.11.0"
2167 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2169 mkdir_on_mdt0 $DIR/$tdir
2170 touch $DIR/$tdir/$tfile
2172 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2173 do_facet mds1 $LCTL set_param fail_loc=0x119
2174 $LFS migrate -m 1 $DIR/$tdir &
2177 do_facet mds1 $LCTL set_param fail_loc=0
2181 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2182 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2183 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2184 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2186 rm -rf $DIR/$tdir || error "rmdir failed"
2188 run_test 110g "drop reply during migration"
2191 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2192 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2193 skip "Need MDS version at least 2.7.56"
2195 local src_dir=$DIR/$tdir/source_dir
2196 local tgt_dir=$DIR/$tdir/target_dir
2200 $LFS mkdir -i $MDTIDX $tgt_dir
2202 dd if=/etc/hosts of=$src_dir/src_file
2203 touch $tgt_dir/tgt_file
2204 drop_update_reply $MDTIDX \
2205 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2206 error "mrename failed"
2208 $CHECKSTAT -t file $src_dir/src_file &&
2209 error "src_file present after rename"
2211 diff /etc/hosts $tgt_dir/tgt_file ||
2212 error "file changed after rename"
2215 run_test 110h "drop update reply during cross-MDT file rename"
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 mkdir $src_dir/src_dir
2230 touch $src_dir/src_dir/a
2231 mkdir $tgt_dir/tgt_dir
2232 drop_update_reply $MDTIDX \
2233 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2234 error "mrename failed"
2236 $CHECKSTAT -t dir $src_dir/src_dir &&
2237 error "src_dir present after rename"
2239 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2240 error "tgt_dir not present after rename"
2242 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2243 error "a not present after rename"
2245 run_test 110i "drop update reply during cross-MDT dir rename"
2248 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2249 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2250 skip "Need MDS version at least 2.7.56"
2252 local remote_dir=$DIR/$tdir/remote_dir
2253 local local_dir=$DIR/$tdir/local_dir
2256 mkdir_on_mdt0 $DIR/$tdir
2257 mkdir $DIR/$tdir/local_dir
2258 $LFS mkdir -i $MDTIDX $remote_dir
2260 touch $local_dir/local_file
2261 drop_update_reply $MDTIDX \
2262 "ln $local_dir/local_file $remote_dir/remote_file" ||
2265 $CHECKSTAT -t file $remote_dir/remote_file ||
2266 error "remote not present after ln"
2268 run_test 110j "drop update reply during cross-MDT ln"
2271 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2272 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2273 skip "Need MDS version at least 2.12.55"
2276 stop mds2 || error "stop mds2 failed"
2278 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2279 do_facet mds2 lctl set_param fail_loc=0x80001103
2280 local OPTS="$MDS_MOUNT_OPTS -o abort_recovery"
2281 start mds2 $(mdsdevname 2) $OPTS ||
2282 error "start MDS with abort_recovery should succeed"
2283 do_facet mds2 lctl set_param fail_loc=0
2286 stop mds2 || error "cleanup: stop mds2 failed"
2287 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS ||
2288 error "cleanup: start mds2 failed"
2289 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2290 client_up || error "post-failover df failed"
2293 run_test 110k "FID_QUERY failed during recovery"
2296 (( $(lustre_version_code $SINGLEMDS) >= $(version_code 2.14.52) )) ||
2297 skip "Need MDS version at least 2.14.52"
2298 (( $MDSCOUNT >= 2 )) || skip "needs at least 2 MDTs"
2299 local remote_dir=$DIR/$tdir/remote_dir
2304 mkdir_on_mdt0 $DIR/$tdir
2306 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x0525
2307 do_facet mds1 $LCTL set_param fail_loc=0x80000525
2308 $LFS mkdir -i 1 -c2 $remote_dir &
2311 # initiate the re-connect & re-send
2312 mdccli=$(do_facet mds2 $LCTL dl |
2313 awk '/MDT0000-osp-MDT0001/ {print $4;}')
2314 uuid=$(do_facet mds2 $LCTL get_param -n osp.$mdccli.mdt_conn_uuid)
2315 echo "conn_uuid=$uuid"
2316 do_facet mds2 $LCTL set_param "osp.$mdccli.import=connection=$uuid"
2319 (( $? == 0 )) || error "mkdir failed"
2321 diridx=$($LFS getstripe -m $remote_dir)
2322 (( $diridx == 1 )) || error "$diridx != 1"
2323 rm -rf $DIR/$tdir || error "rmdir failed"
2325 run_test 110m "update resent vs original RPC race"
2327 # LU-2844 mdt prepare fail should not cause umount oops
2330 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2331 skip "Need MDS version at least 2.3.62"
2333 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2334 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2335 stop $SINGLEMDS || error "stop MDS failed"
2336 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS &&
2337 error "start MDS should fail"
2338 do_facet $SINGLEMDS lctl set_param fail_loc=0
2339 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2340 error "start MDS failed"
2342 run_test 111 "mdd setup fail should not cause umount oops"
2346 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2348 do_facet_random_file client $TMP/$tfile 100K ||
2349 error_noexit "Create random file $TMP/$tfile"
2351 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2352 error_noexit "Can't pause_bulk copy"
2355 # expect cmp to succeed, client resent bulk
2356 cmp $TMP/$tfile $DIR/$tfile ||
2357 error_noexit "Wrong data has been written"
2359 error_noexit "Can't remove file"
2362 run_test 112a "bulk resend while orignal request is in progress"
2369 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2370 cancel_lru_locks osc
2373 $LCTL set_param fail_loc=$fail1 fail_val=3
2374 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2378 set_nodes_failloc "$(osts_nodes)" $fail2
2380 wait $pid || error "dd failed"
2388 local fail_val2=${4:-0}
2394 $LCTL set_param fail_loc=$fail1 fail_val=4
2395 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2400 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2404 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2405 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2410 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2411 skip "need at least 2.8.50 on OST"
2413 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2414 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2415 test_115_read 0x8000051b 0x8000051a
2417 run_test 115a "read: late REQ MDunlink and no bulk"
2420 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2421 skip "need at least 2.8.50 on OST"
2423 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2424 #define OBD_FAIL_OST_ENOSPC 0x215
2426 # pass $OSTCOUNT for the fail_loc to be caught
2427 # appropriately by the IO thread
2428 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2430 run_test 115b "write: late REQ MDunlink and no bulk"
2433 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2434 skip "need at least 2.8.50 on OST"
2436 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2437 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2438 test_115_read 0x8000050f 0x8000051a
2440 run_test 115c "read: late Reply MDunlink and no bulk"
2443 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2444 skip "need at least 2.8.50 on OST"
2446 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2447 #define OBD_FAIL_OST_ENOSPC 0x215
2448 test_115_write 0x8000050f 0x80000215 0
2450 run_test 115d "write: late Reply MDunlink and no bulk"
2453 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2454 skip "need at least 2.8.50 on OST"
2456 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2457 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2458 test_115_read 0x80000510 0x80000211
2460 run_test 115e "read: late Bulk MDunlink and no reply"
2463 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2464 skip "need at least 2.8.50 on OST"
2466 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2467 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2468 test_115_read 0x8000051b 0x80000211
2470 run_test 115f "read: late REQ MDunlink and no reply"
2473 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2474 skip "need at least 2.8.50 on OST"
2476 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2477 test_115_read 0x8000051c 0
2479 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2481 # parameters: fail_loc CMD RC
2488 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2489 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2490 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2491 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2494 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2495 [ "$1" = "CLEANUP" ] &&
2496 fail=0x80000320 && echo ", $1 cp first"
2497 [ "$1" = "REPLY" ] &&
2498 fail=0x80000321 && echo ", $1 cp first"
2499 [ "$1" = "DEADLOCK CLEANUP" ] &&
2500 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2501 [ "$1" = "DEADLOCK REPLY" ] &&
2502 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2504 if [ x"$2" = x"get" ]; then
2505 #for TEST lock, take a conflict in advance
2506 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2507 echo "** Taking conflict **"
2508 flocks_test 5 set read sleep 10 $DIR/$tfile &
2514 $LCTL set_param fail_loc=$fail
2516 flocks_test 5 $2 write $DIR/$tfile &
2520 echo "** Evicting and re-connecting client **"
2525 if [ x"$2" = x"get" ]; then
2532 # check if the return value is allowed
2533 [ $rc -eq $3 ] && rc=0
2535 $LCTL set_param fail_loc=0
2539 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2540 # the ORIGINAL lock.
2545 flocks_test 5 set write sleep 4 $DIR/$tfile &
2549 # let unlock to sleep in CP CB
2550 $LCTL set_param fail_loc=$1
2553 # let cleanup to cleep in CP CB
2561 $LCTL set_param fail_loc=0
2566 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2569 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2570 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2571 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2573 test_120_reply "REPLY" set 5 || error "SET race failed"
2574 test_120_reply "REPLY" get 5 || error "GET race failed"
2575 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2578 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2579 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2581 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2583 run_test 120 "flock race: completion vs. evict"
2586 local BEFORE=$(date +%s)
2589 # modify dir so that next revalidate would not obtain UPDATE lock
2592 # drop 1 reply with UPDATE lock,
2593 # resend should not create 2nd lock on server
2594 mcreate $DIR/$tfile || error "mcreate failed: $?"
2595 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2597 # 2 BL AST will be sent to client, both must find the same lock,
2598 # race them to not get EINVAL for 2nd BL AST
2599 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2600 $LCTL set_param fail_loc=0x8000031f
2602 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2603 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2604 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2606 # let the client reconnect
2608 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2609 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2611 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2613 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2617 test_mkdir -p $DIR/$tdir
2619 # Prevent interference from layout intent RPCs due to
2620 # asynchronous writeback. These will be tested in 130c below.
2621 do_nodes ${CLIENTS:-$HOSTNAME} sync
2623 # get only LOOKUP lock on $tdir
2624 cancel_lru_locks mdc
2625 ls $DIR/$tdir/$tfile 2>/dev/null
2627 # get getattr by fid on $tdir
2629 # we need to race with unlink, unlink must complete before we will
2630 # take a DLM lock, otherwise unlink will wait until getattr will
2631 # complete; but later than getattr starts so that getattr found
2633 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2634 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2641 # drop the reply so that resend happens on an unlinked file.
2642 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2643 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2647 remote_mds_nodsh && skip "remote MDS with nodsh"
2648 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2649 skip "Need server version newer than 2.7.1"
2653 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2656 run_test 130a "enqueue resend on not existing file"
2659 remote_mds_nodsh && skip "remote MDS with nodsh"
2660 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2661 skip "Need server version newer than 2.7.1"
2664 # let the reply to be dropped
2667 #define OBD_FAIL_SRV_ENOENT 0x217
2668 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2670 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2673 run_test 130b "enqueue resend on a stale inode"
2676 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2678 do_nodes ${CLIENTS:-$HOSTNAME} sync
2679 echo XXX > $DIR/$tfile
2681 cancel_lru_locks mdc
2683 # Trigger writeback on $tfile.
2685 # we need to race with unlink, unlink must complete before we will
2686 # take a DLM lock, otherwise unlink will wait until intent will
2687 # complete; but later than intent starts so that intent found
2689 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2690 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2697 # drop the reply so that resend happens on an unlinked file.
2698 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2699 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2701 # let the reply to be dropped
2704 #define OBD_FAIL_SRV_ENOENT 0x217
2705 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2711 run_test 130c "layout intent resend on a stale inode"
2714 local before=$(date +%s)
2717 mount_client $MOUNT2 || error "mount filed"
2720 # get a lock on client so that export would reach the stale list
2721 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2722 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2725 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2726 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2728 $TRUNCATE $DIR/$tfile 100 &
2731 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2735 umount_client $MOUNT2
2737 evict=$(do_facet client $LCTL get_param \
2738 osc.$FSNAME-OST0000-osc-*/state |
2739 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2741 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2742 (do_facet client $LCTL get_param \
2743 osc.$FSNAME-OST0000-osc-*/state;
2744 error "eviction happened: $evict before:$before")
2746 run_test 132 "long punch"
2749 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2752 # get a lock on client so that export would reach the stale list
2753 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2754 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2756 # another IO under the same lock
2757 #define OBD_FAIL_OSC_DELAY_IO 0x414
2758 $LCTL set_param fail_loc=0x80000414
2759 $LCTL set_param fail_val=4 fail_loc=0x80000414
2760 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2764 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2765 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2769 wait $pid && error "dd succeeded"
2772 run_test 131 "IO vs evict results to IO under staled lock"
2775 local list=$(comma_list $(mdts_nodes))
2777 local t=$((TIMEOUT * 2))
2780 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2782 multiop_bg_pause $DIR/$tfile O_jc || return 1
2785 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2786 do_nodes $list $LCTL set_param fail_loc=0x80000157
2788 echo "waiting for multiop $PID"
2789 wait $PID || return 2
2795 run_test 133 "don't fail on flock resend"
2798 [ $CLIENTCOUNT -lt 2 ] &&
2799 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2801 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2802 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2803 error "touch failed"
2804 zconf_umount_clients $CLIENTS $MOUNT
2805 zconf_mount_clients $CLIENTS $MOUNT
2807 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2808 # assume commit interval is 5
2809 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2811 local -a clients=(${CLIENTS//,/ })
2812 local client1=${clients[0]}
2813 local client2=${clients[1]}
2815 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2817 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2820 wait $rmpid || error "rm failed"
2821 wait $mvpid || error "mv failed"
2824 run_test 134 "race between failover and search for reply data free slot"
2827 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2828 skip "Need MDS version at least 2.12.51"
2831 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2832 # to have parent dir write lock before open/resend
2833 touch $DIR/$tdir/$tfile
2834 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2835 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2836 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2837 error "Failed to open DOM file"
2839 run_test 135 "DOM: open/create resend to return size"
2842 remote_mds_nodsh && skip "remote MDS with nodsh"
2843 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2844 skip "Need MDS version at least 2.12.52"
2846 local mdts=$(comma_list $(mdts_nodes))
2847 local MDT0=$(facet_svc $SINGLEMDS)
2849 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2850 [ -n "$clog" ] || error "changelog_register failed"
2851 cl_mask=$(do_facet mds1 $LCTL get_param \
2852 mdd.$MDT0.changelog_mask -n)
2853 changelog_chmask "ALL"
2855 # generate some changelog records to accumulate
2856 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2857 createmany -m $DIR/$tdir/$tfile 10000 ||
2858 error "create $DIR/$tdir/$tfile failed"
2860 local size1=$(do_facet $SINGLEMDS \
2861 $LCTL get_param -n mdd.$MDT0.changelog_size)
2862 echo "Changelog size $size1"
2864 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2865 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2867 # launch changelog_deregister in background on MDS
2868 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2869 > foo.out 2> foo.err < /dev/null &"
2870 # give time to reach fail_loc
2873 # fail_loc will make MDS sleep in the middle of changelog_deregister
2874 # take this opportunity to abruptly kill MDS
2875 FAILURE_MODE_save=$FAILURE_MODE
2878 FAILURE_MODE=$FAILURE_MODE_save
2880 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2882 local size2=$(do_facet $SINGLEMDS \
2883 $LCTL get_param -n mdd.$MDT0.changelog_size)
2884 echo "Changelog size $size2"
2885 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2886 mdd.$MDT0.changelog_users | grep $clog")
2887 echo "After crash, changelog user $clog2"
2889 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2890 error "changelog record count unchanged"
2892 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2894 run_test 136 "changelog_deregister leaving pending records"
2898 mkdir_on_mdt0 $DIR/$tdir
2901 dd if=/dev/zero of=$DIR/$tdir/d1/$tfile bs=4096 count=1
2902 dd if=/dev/zero of=$DIR/$tdir/d2/$tfile bs=4096 count=1
2903 cancel_lru_locks osc
2905 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2906 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2908 # RPC1: any reply is to be delayed to disable last_xid logic
2909 ln $DIR/$tdir/d1/$tfile $DIR/$tdir/d1/f2 &
2912 # RPC2: setattr1 reply is delayed & resent
2913 # original reply comes to client; the resend get asleep
2914 chmod 666 $DIR/$tdir/d2/$tfile
2916 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2917 chmod 777 $DIR/$tdir/d2/$tfile
2919 # RPC2 resend wakes up
2921 [ $(stat -c "%a" $DIR/$tdir/d2/$tfile) == 777 ] ||
2922 error "resend got applied"
2924 run_test 137 "late resend must be skipped if already applied"
2927 remote_mds_nodsh && skip "remote MDS with nodsh"
2928 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2929 [[ "$MDS1_VERSION" -ge $(version_code 2.12.59) ]] ||
2930 skip "Need server version newer than 2.12.59"
2932 zconf_umount_clients $CLIENTS $MOUNT
2934 #define OBD_FAIL_TGT_RECOVERY_CONNECT 0x724
2935 #delay a first step of recovey when MDS waiting clients
2936 #and failing to get osp logs
2937 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x724 fail_val=5
2939 facet_failover $SINGLEMDS
2941 #waiting failover and recovery timer
2942 #the valuse is based on target_recovery_overseer() wait_event timeout
2944 stop $SINGLEMDS || error "stop MDS failed"
2945 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
2946 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2947 error "start MDS failed"
2948 zconf_mount_clients $CLIENTS $MOUNT
2950 run_test 138 "Umount MDT during recovery"
2953 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2954 [ $MDS1_VERSION -lt $(version_code 2.13.50) ] &&
2955 skip "Need MDS version at least 2.13.50"
2957 stop $SINGLEMDS || error "stop $SINGLEMDS failed"
2959 #define OBD_FAIL_OSP_INVALID_LOGID 0x2106
2960 do_facet $SINGLEMDS $LCTL set_param fail_val=0x68 fail_loc=0x80002106
2961 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
2962 error "Fail to start $SINGLEMDS"
2964 run_test 139 "corrupted catid won't cause crash"
2967 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
2968 skip "Need MDS version at least 2.13.50"
2970 slr=$(do_facet mds1 \
2971 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
2972 stack_trap "do_facet mds1 $LCTL set_param \
2973 mdt.*.local_recovery=$slr" EXIT
2975 # disable recovery for local clients
2976 # so local clients should be marked with no_recovery flag
2977 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
2981 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
2982 grep export_flags.*no_recovery | wc -l)
2983 echo "$cnt clients with recovery disabled"
2985 [ $cnt -eq 0 ] && error "no clients with recovery disabled"
2987 # enable recovery for local clients
2988 # so no local clients should be marked with no_recovery flag
2989 do_facet mds1 $LCTL set_param mdt.*.local_recovery=1
2992 cnt=$(do_facet mds1 $LCTL get_param "mdt.*MDT0000.exports.*.export" |
2993 grep export_flags.*no_recovery | wc -l)
2994 echo "$cnt clients with recovery disabled"
2996 [ $cnt -eq 0 ] || error "$cnt clients with recovery disabled"
2998 run_test 140a "local mount is flagged properly"
3001 [ $MDS1_VERSION -lt $(version_code 2.12.58) ] &&
3002 skip "Need MDS version at least 2.13.50"
3004 slr=$(do_facet mds1 \
3005 $LCTL get_param -n mdt.$FSNAME-MDT0000.local_recovery)
3006 stack_trap "do_facet mds1 $LCTL set_param \
3007 mdt.*.local_recovery=$slr" EXIT
3009 # disable recovery for local clients
3010 do_facet mds1 $LCTL set_param mdt.*.local_recovery=0
3016 # Lustre: tfs-MDT0000: Recovery over after 0:03, of 2 clients 2 rec...
3017 local recovery=$(do_facet mds1 dmesg |
3018 awk '/Recovery over after/ { print $6 }' | tail -1 |
3019 awk -F: '{ print $1 * 60 + $2 }')
3020 (( recovery < TIMEOUT * 2 + 5 )) ||
3021 error "recovery took too long $recovery > $((TIMEOUT * 2 + 5))"
3023 run_test 140b "local mount is excluded from recovery"
3029 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3030 combined_mgs_mds || skip "needs combined MGS/MDT"
3031 ( local_mode || from_build_tree ) &&
3032 skip "cannot run in local mode or from build tree"
3034 # some get_param have a bug to handle dot in param name
3035 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
3036 oldc=$(do_facet $SINGLEMDS $LCTL get_param -n \
3037 'ldlm.namespaces.MGC*.lock_count')
3039 do_rpc_nodes $(facet_active_host $SINGLEMDS) cancel_lru_locks MGC
3040 newc=$(do_facet $SINGLEMDS $LCTL get_param -n \
3041 'ldlm.namespaces.MGC*.lock_count')
3043 [ $oldc -eq $newc ] || error "mgc lost locks ($oldc != $newc)"
3046 run_test 141 "do not lose locks on MGS restart"
3049 [ $MDS1_VERSION -lt $(version_code 2.11.56) ] &&
3050 skip "Need MDS version at least 2.11.56"
3052 #define OBD_FAIL_MDS_ORPHAN_DELETE 0x165
3053 do_facet mds1 $LCTL set_param fail_loc=0x165
3054 $MULTIOP $DIR/$tfile Ouc || error "multiop failed"
3057 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
3059 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3060 error "MDD orphan cleanup thread not quit"
3062 run_test 142 "orphan name stub can be cleaned up in startup"
3065 (( $MDS1_VERSION >= $(version_code 2.13.0) )) ||
3066 skip "Need MDS version at least 2.13.0"
3067 [ "$PARALLEL" == "yes" ] && skip "skip parallel run"
3069 local mntpt=$(facet_mntpt $SINGLEMDS)
3071 mount_fstype $SINGLEMDS || error "mount as fstype $SINGLEMDS failed"
3072 do_facet $SINGLEMDS touch $mntpt/PENDING/$tfile
3073 unmount_fstype $SINGLEMDS
3074 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3076 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
3077 wait_update_facet mds1 "pgrep orph_.*-MDD | wc -l" "0" ||
3078 error "MDD orphan cleanup thread not quit"
3080 run_test 143 "orphan cleanup thread shouldn't be blocked even delete failed"
3083 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3084 skip "server does not support overstriping"
3085 (( MDS1_VERSION >= $(version_code 2.15.50.49) )) ||
3086 skip "Need MDS version at least 2.15.50.49"
3095 large_xattr_enabled || skip_env "ea_inode feature disabled"
3096 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3097 stack_trap "rm -rf $DIR/$tdir" EXIT
3099 mds_timeout=$(do_facet mds1 $LCTL get_param -n timeout)
3100 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=300
3101 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=$mds_timeout" EXIT
3103 $LFS setstripe -i 0 -C $setcount $DIR/$tdir || error "setstripe failed"
3105 for (( i = 0; i < 50; i++)); do
3106 touch $DIR/$tdir/$tfile_$i &
3113 for pid in $pids; do
3114 kill -9 $pid >/dev/null 2>&1
3120 # here we measure MDT stop + MDT start time. For error case MDT stop takes
3121 # about obd_timeout-60 (240) seconds. Without error - less than 30s.
3122 # MDT start takes different time depends on a configuration, let's check
3124 diff=$((after - before))
3125 (( $diff < 240 )) || error "MDT failover took $diff seconds"
3127 # failover mds1 back to the primary server
3130 run_test 144a "MDT failover should stop precreation threads"
3133 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3134 skip "server does not support overstriping"
3135 (( MDS1_VERSION >= $(version_code 2.15.51.50) )) ||
3136 skip "Need MDS version at least 2.15.51.50"
3143 large_xattr_enabled || skip_env "ea_inode feature disabled"
3144 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3145 stack_trap "rm -rf $DIR/$tdir" EXIT
3147 mds_timeout=$(do_facet mds1 $LCTL get_param -n timeout)
3148 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=300
3149 stack_trap "do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param timeout=$mds_timeout" EXIT
3151 $LFS setstripe -i 0 -C $setcount $DIR/$tdir || error "setstripe failed"
3153 for (( i = 0; i < 50; i++)); do
3154 touch $DIR/$tdir/$tfile_$i &
3160 # 60s is not enought with ZFS which is still significatnly
3161 # slower on some operations like record writing
3163 [[ "$mds1_FSTYPE" != "zfs" ]] || stime=120
3166 for pid in $pids; do
3167 ps -p $pid > /dev/null
3168 (( $? == 0 )) && rc=1
3169 kill -9 $pid >/dev/null 2>&1
3172 (( $rc == 0 )) || { fail mds1; error "Create thread still running"; }
3174 run_test 144b "orphan cleanup shouldn't be blocked for no objects+failover situation"
3177 [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
3178 [ $(facet_active_host mds2) = $(facet_active_host mds3) ] &&
3179 skip "needs mds2 and mds3 on separate nodes"
3185 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
3186 echo block mds_connect from mds2
3187 do_facet mds2 "$LCTL set_param fail_loc=0x507"
3189 #define OBD_FAIL_OUT_UPDATE_DROP 0x1707
3190 echo block recovery updates from mds3
3191 do_facet mds3 "$LCTL set_param fail_loc=0x1707"
3193 local hard_timeout=\
3194 $(do_facet mds1 $LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_hard)
3198 local get_soft_timeout_cmd=\
3199 "$LCTL get_param -n mdt.$FSNAME-MDT0000.recovery_time_soft 2>/dev/null"
3201 echo wait until mds1 recovery_time_soft is $hard_timeout
3202 wait_update $(facet_host mds1) "$get_soft_timeout_cmd" \
3203 "$hard_timeout" $hard_timeout
3205 echo unblock mds_connect from mds2
3206 do_facet mds2 "$LCTL set_param fail_loc=0"
3208 echo upblock recovery updates from mds3
3209 do_facet mds3 "$LCTL set_param fail_loc=0"
3212 [ -f $DIR/$tfile ] || error "$DIR/$tfile does not exist"
3214 run_test 145 "connect mdtlovs and process update logs after recovery expire"
3217 local prev_count=$(do_facet $SINGLEMDS \
3218 $LCTL get_param -n "mdt.${mds1_svc}.eviction_count")
3224 local next_count=$(do_facet $SINGLEMDS \
3225 $LCTL get_param -n "mdt.${mds1_svc}.eviction_count")
3227 [ "$prev_count" -lt "$next_count" ] ||
3228 error "wrong eviction count ($prev_count >= $next_count)"
3230 run_test 146 "test eviction is counted properly"
3233 local obd_timeout=200
3234 local old=$($LCTL get_param -n timeout)
3236 local connection_count
3238 $LFS setstripe -i 0 -c 1 $f
3239 stripe_index=$($LFS getstripe -i $f)
3240 if [ $stripe_index -ne 0 ]; then
3242 error "$f: stripe_index $stripe_index != 0" && return
3245 $LCTL set_param timeout=$obd_timeout
3246 stack_trap "$LCTL set_param timeout=$old && client_reconnect" EXIT
3248 # OBD_FAIL_OST_CONNECT_NET2
3249 # lost reply to connect request
3250 do_facet ost1 lctl set_param fail_loc=0x00000225 timeout=$obd_timeout
3251 stack_trap "do_facet ost1 $LCTL set_param fail_loc=0 timeout=$old" EXIT
3256 $LFS df $MOUNT > /dev/null 2>&1 &
3257 sleep $((obd_timeout * 3 / 4))
3259 $LCTL get_param osc.$FSNAME-OST0000-osc-*.state
3260 connection_count=$($LCTL get_param osc.$FSNAME-OST0000-osc-*.state |
3261 tac | sed "/FULL/,$ d" | grep CONNECTING | wc -l)
3263 echo $connection_count
3264 (($connection_count >= 6)) || error "Client reconnected too slow"
3266 run_test 147 "Check client reconnect"
3269 local wce_param="obdfilter.$FSNAME-OST0000.writethrough_cache_enable"
3270 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
3271 local amc=$(at_max_get client)
3272 local amo=$(at_max_get ost1)
3277 timeout=$(request_timeout client)
3279 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3280 # save old r/o cache settings
3281 save_lustre_params ost1 $wce_param > $p
3284 do_facet ost1 "$LCTL set_param -n $wce_param=0"
3287 $LFS setstripe -i 0 -c 1 $DIR/$tfile
3288 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=direct
3289 cp $DIR/$tfile $TMP/$tfile
3290 #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
3291 do_facet ost1 $LCTL set_param fail_loc=0x80000227
3292 do_facet ost1 $LCTL set_param fail_val=$((timeout+2))
3293 dd if=/dev/urandom of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3294 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=notrunc,fdatasync
3296 cancel_lru_locks osc
3297 cmp -b $DIR/$tfile $TMP/$tfile || error "wrong data"
3299 rm -f $DIR/$tfile $TMP/$tfile
3301 at_max_set $amc client
3302 at_max_set $amo ost1
3304 [ "$(facet_fstype ost1)" = "ldiskfs" ] && {
3305 # restore initial r/o cache settings
3306 restore_lustre_params < $p
3311 run_test 148 "data corruption through resend"
3314 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3316 test_mkdir -i 0 -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
3318 # make an orphan striped dir
3319 $MULTIOP $DIR/$tdir D_c &
3322 rmdir $DIR/$tdir || error "can't rmdir"
3324 # stop a slave MDT where one ons stripe is located
3327 # stopping should not cause orphan as another MDT can
3331 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3332 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "mds1 start fail"
3340 run_test 149 "skip orphan removal at umount"
3343 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3347 lazystatfs=$($LCTL get_param -n llite.$FSNAME-*.lazystatfs | head -1)
3348 max=$($LCTL get_param -n llite.$FSNAME-*.statahead_max | head -1)
3350 $LCTL set_param llite.$FSNAME-*.lazystatfs=1
3351 $LCTL set_param llite.$FSNAME-*.statahead_max=0
3352 stack_trap "$LCTL set_param llite.$FSNAME-*.lazystatfs=$lazystatfs" EXIT
3353 stack_trap "$LCTL set_param llite.$FSNAME-*.statahead_max=$max" EXIT
3354 # stop a slave MDT where one ons stripe is located
3357 stack_trap "start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS && \
3358 wait_recovery_complete mds1 && clients_up && true" EXIT
3360 df $MOUNT || error "statfs failed"
3363 run_test 150 "statfs when MDT0 offline with lazystatfs option"
3366 [[ $($LCTL get_param mdc.*.import) =~ connect_flags.*overstriping ]] ||
3367 skip "server does not support overstriping"
3378 large_xattr_enabled || skip_env "ea_inode feature disabled"
3379 version=$(do_facet mds1 \
3380 uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
3381 version=$(version_code ${version//\./ })
3382 if (( $version < $(version_code 4.6.0) )); then
3383 skip "MDS Linux kernel does not support killable semaphore"
3386 test_mkdir -i 0 -c 1 -p $DIR/$tdir
3387 test_mkdir -i 0 -c 1 -p $DIR/$tdir/rr
3388 test_mkdir -i 0 -c 1 -p $DIR/$tdir/qos
3389 stack_trap "rm -rf $DIR/$tdir" EXIT
3391 $LFS setstripe -C $setcount $DIR/$tdir/rr/ || error "setstripe failed"
3394 #define OBD_FAIL_MDS_LOD_CREATE_PAUSE 0x173
3395 #Simulate OST failover and sleep RR allocation under lq_rw_sem
3396 do_facet mds1 $LCTL set_param fail_loc=0x80000173 fail_val=20
3398 for (( i = 0; i < 2; i++)); do
3399 touch $DIR/$tdir/rr/$tfile_$i &
3400 pids_rr="$pids_rr $!"
3404 saved=$(do_facet mds1 $LCTL get_param -n lov.*0000*.qos_threshold_rr)
3405 do_facet mds1 $LCTL set_param lov.*.qos_threshold_rr=0
3406 stack_trap "do_facet mds1 $LCTL set_param lov.*.qos_threshold_rr=$saved" EXIT
3408 #create files with QoS algo, killable semaphore sleeps for 2seconds
3409 for (( i = 0; i < 3; i++)); do
3410 touch $DIR/$tdir/qos/$tfile_$i &
3411 pids_qos="$pids_qos $!"
3414 for pid in $pids_qos; do
3419 diff=$((after - before))
3420 echo "QoS allocation took $diff seconds"
3421 for pid in $pids_rr; do
3426 error "QoS allocation slower than RR, killable semaphore doesn't work"
3428 run_test 152 "QoS object allocation could be awakened in case of OST failover"
3431 #define OBD_FAIL_MDS_CONNECT_VS_EVICT 0x174
3432 do_facet mds1 "$LCTL set_param fail_loc=0x174"
3433 # first drop ping reply from MDS and then
3434 # evict on the subsequent reconnect
3435 # (see target_handle_connect)
3436 sleep $((TIMEOUT + 3))
3438 do_facet mds1 "$LCTL set_param fail_loc=0"
3439 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
3440 error "Fail to start $SINGLEMDS"
3441 wait_recovery_complete mds1 || error "MDS recovery not done"
3443 run_test 153 "evict vs reconnect race"
3446 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
3450 local mnt=$(facet_mntpt mds2)
3453 local ula=($(do_facet mds2 od -t u8 $mnt/update_log | \
3454 awk '{ if($2 > 0) printf "0x%x:0x%x:0x0 ", $3, $2 }'))
3455 [ ${#ula[@]} -lt 2 ] && error "update_log file corruption"
3457 local catfile=$mnt/update_log_dir/\[${ula[0]}\]
3459 echo replace file $catfile
3460 do_facet mds2 dd if=/dev/urandom of=$catfile count=100 ||
3461 error "Write file $catfile error"
3464 start mds2 $(mdsdevname 2) $MDS_MOUNT_OPTS || error "mds2 start fail"
3467 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS || error "mds1 start fail"
3469 echo waiting mds1 recovery....
3470 wait_recovery_complete mds1 20
3472 do_facet mds1 $LCTL get_param mdt.$FSNAME-MDT0000.recovery_status | \
3473 grep -w COMPLETE || error "Recovery was blocked"
3475 run_test 154 "corruption update llog can be skipped"
3477 complete_test $SECONDS
3478 check_and_cleanup_lustre