5 export MULTIOP=${MULTIOP:-multiop}
6 PTLDEBUG=${PTLDEBUG:--1}
7 LUSTRE=${LUSTRE:-`dirname $0`/..}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT"
14 if [ "$MDSCOUNT" -gt "1" ]; then
15 # bug number for skipped test: LU-10931
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 require_dsh_mds || exit 0
22 # also long tests: 19, 21a, 21e, 21f, 23, 27
24 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
28 # Allow us to override the setup if we already have a mounted system by
29 # setting SETUP=" " and CLEANUP=" "
31 CLEANUP=${CLEANUP:-""}
33 check_and_setup_lustre
36 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
39 local f1="$DIR/$tfile"
40 local f2="$DIR/$tfile.2"
42 drop_request "mcreate $f1" ||
43 error_noexit "create '$f1': drop req"
45 drop_reint_reply "mcreate $f2" ||
46 error_noexit "create '$f2': drop rep"
48 drop_request "tchmod 111 $f2" ||
49 error_noexit "chmod '$f2': drop req"
51 drop_reint_reply "tchmod 666 $f2" ||
52 error_noexit "chmod '$f2': drop rep"
54 drop_request "statone $f2" ||
55 error_noexit "stat '$f2': drop req"
57 drop_reply "statone $f2" ||
58 error_noexit "stat '$f2': drop rep"
60 run_test 1 "create, chmod, stat: drop req, drop rep"
64 do_facet_create_file client $t 10K ||
65 error_noexit "Create file $t"
67 drop_request "cat $t > /dev/null" ||
68 error_noexit "Open request for $t file"
70 drop_reply "cat $t > /dev/null" ||
71 error_noexit "Open replay for $t file"
73 run_test 4 "open: drop req, drop rep"
78 local RR="$T-renamed-again"
79 do_facet_create_file client $T 10K ||
80 error_noexit "Create file $T"
82 drop_request "mv $T $R" ||
83 error_noexit "Rename $T"
85 drop_reint_reply "mv $R $RR" ||
86 error_noexit "Failed rename replay on $R"
88 do_facet client "checkstat -v $RR" ||
89 error_noexit "checkstat error on $RR"
91 do_facet client "rm $RR" ||
92 error_noexit "Can't remove file $RR"
94 run_test 5 "rename: drop req, drop rep"
98 local LINK1=$DIR/$tfile.link1
99 local LINK2=$DIR/$tfile.link2
101 do_facet_create_file client $T 10K ||
102 error_noexit "Create file $T"
104 drop_request "mlink $T $LINK1" ||
105 error_noexit "mlink request for $T"
107 drop_reint_reply "mlink $T $LINK2" ||
108 error_noexit "mlink reply for $T"
110 drop_request "munlink $LINK1" ||
111 error_noexit "munlink request for $T"
113 drop_reint_reply "munlink $LINK2" ||
114 error_noexit "munlink reply for $T"
116 do_facet client "rm $T" ||
117 error_noexit "Can't remove file $T"
119 run_test 6 "link, unlink: drop req, drop rep"
123 drop_reint_reply "touch $DIR/$tfile" || return 1
125 run_test 8 "touch: drop rep (bug 1423)"
129 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
133 do_facet_random_file client $TMP/$tfile 1K ||
134 error_noexit "Create random file $TMP/$tfile"
135 # make this big, else test 9 doesn't wait for bulk -- bz 5595
136 do_facet_create_file client $TMP/$t1 4M ||
137 error_noexit "Create file $TMP/$t1"
138 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
139 error_noexit "Can't copy to $DIR/$t1 file"
140 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
141 error_noexit "Can't pause_bulk copy"
142 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
143 error_noexit "Can't copy file"
144 do_facet client "sync"
145 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
146 error_noexit "Can't remove files"
147 do_facet client "rm $TMP/$t1 $TMP/$tfile"
149 run_test 9 "pause bulk on OST (bug 1420)"
153 local before=$(date +%s)
156 do_facet client "stat $DIR > /dev/null" ||
157 error "failed to stat $DIR: $?"
158 drop_bl_callback "chmod 0777 $DIR" ||
159 error "failed to chmod $DIR: $?"
161 # let the client reconnect
163 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
164 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
165 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
166 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
167 error "no eviction: $evict before:$before")
169 do_facet client checkstat -v -p 0777 $DIR ||
170 error "client checkstat failed: $?"
172 run_test 10a "finish request on server after client eviction (bug 1521)"
175 local before=$(date +%s)
178 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
179 skip "Need MDS version at least 2.6.53" && return
180 do_facet client "stat $DIR > /dev/null" ||
181 error "failed to stat $DIR: $?"
182 drop_bl_callback_once "chmod 0777 $DIR" ||
183 error "failed to chmod $DIR: $?"
185 # let the client reconnect
187 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
188 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
190 [ -z "$evict" ] || [[ $evict -le $before ]] ||
191 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
192 error "eviction happened: $evict before:$before")
194 do_facet client checkstat -v -p 0777 $DIR ||
195 error "client checkstat failed: $?"
197 run_test 10b "re-send BL AST"
200 local before=$(date +%s)
209 workdir="${DIR}/${tdir}"
210 mkdir -p ${workdir} || error "can't create workdir $?"
211 stat ${workdir} > /dev/null ||
212 error "failed to stat ${workdir}: $?"
213 mdtidx=$($LFS getdirstripe -i ${workdir})
214 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
215 awk '{sub("_UUID", "", $2); print $2;}')
217 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
218 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
219 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
221 drop_bl_callback_once "chmod 0777 ${workdir}" &
226 # force client reconnect
227 $LCTL set_param "${mdcpath}"
229 # wait client reconnect
233 evict=$($LCTL get_param mdc.${mdccli}.state |
234 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
236 [[ $evict -le $before ]] ||
237 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
238 error "eviction happened: $EVICT before:$BEFORE" )
240 [ $rc -eq 0 ] || error "chmod must finished OK"
241 checkstat -v -p 0777 "${workdir}" ||
242 error "client checkstat failed: $?"
244 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
247 local before=$(date +%s)
250 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
251 skip "Need MDS version at least 2.6.90" && return
253 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
256 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
258 remount_client $MOUNT
262 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
263 echo -n hello | dd of=$DIR1/$tfile bs=5
265 stat $DIR2/$tfile >& /dev/null
266 $LCTL set_param fail_err=71
267 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
272 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
273 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
275 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
277 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
279 [[ $evict -gt $before ]] ||
280 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
281 error "no eviction: $evict before:$before")
283 $LCTL set_param fail_err=0
285 umount_client $MOUNT2
287 run_test 10d "test failed blocking ast"
291 [[ $(lustre_version_code ost1) -le $(version_code 2.8.58) ]] &&
292 skip "Need OST version at least 2.8.59" && return 0
293 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients" && return 0
294 [ $(facet_host client) == $(facet_host ost1) ] &&
295 skip "need ost1 and client on different nodes" && return 0
296 local -a clients=(${CLIENTS//,/ })
297 local client1=${clients[0]}
298 local client2=${clients[1]}
300 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
301 $MULTIOP $DIR/$tfile-1 Ow1048576c
303 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
304 $LCTL set_param fail_loc=0x80000305
306 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
307 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
308 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
309 # 1. to return ENOTCONN from ldlm_handle_enqueue0
310 # 2. to pause reconnect handling between resend and setting
311 # import to LUSTRE_IMP_FULL state
312 do_facet ost1 "$LCTL set_param fail_val=3"
314 # client1 fails ro respond to bl ast
315 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
318 # ost1 returns error on enqueue, which causes client1 to reconnect
319 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
320 error "multiop failed"
323 do_facet ost1 "$LCTL set_param fail_loc=0"
324 do_facet ost1 "$LCTL set_param fail_val=0"
326 run_test 10e "re-send BL AST vs reconnect race 2"
329 # wake up a thread waiting for completion after eviction
331 do_facet client $MULTIOP $DIR/$tfile Ow ||
332 { error "multiop write failed: $?"; return 1; }
333 do_facet client $MULTIOP $DIR/$tfile or ||
334 { error "multiop read failed: $?"; return 2; }
338 do_facet client $MULTIOP $DIR/$tfile or ||
339 { error "multiop read failed: $?"; return 3; }
340 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
341 echo "evicted as expected"
343 do_facet client munlink $DIR/$tfile ||
344 { error "munlink failed: $?"; return 4; }
345 # allow recovery to complete
346 client_up || client_up || sleep $TIMEOUT
348 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
352 $LCTL mark $MULTIOP $DIR/$tfile OS_c
353 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
354 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
355 multiop_bg_pause $DIR/$tfile OS_c ||
356 { error "multiop failed: $?"; return 1; }
358 #define OBD_FAIL_MDS_CLOSE_NET 0x115
360 echo "waiting for multiop $PID"
361 wait $PID || { error "wait for multiop faile: $?"; return 2; }
362 do_facet client munlink $DIR/$tfile ||
363 { error "client munlink failed: $?"; return 3; }
364 # allow recovery to complete
365 client_up || client_up || sleep $TIMEOUT
367 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
369 # Bug 113, check that readdir lost recv timeout works.
371 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
372 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
373 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
374 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
375 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
376 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
377 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
379 run_test 13 "mdc_readpage restart test (bug 1138)"
381 # Bug 113, check that readdir lost send timeout works.
384 touch $DIR/$tdir/newentry
385 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
386 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
387 ls $DIR/$tdir || return 1
388 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
390 run_test 14 "mdc_readpage resend test (bug 1138)"
393 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
394 touch $DIR/$tfile && return 1
397 run_test 15 "failed open (-ENOMEM)"
399 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
401 lctl set_param -n llite.*.max_read_ahead_mb 0
405 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
409 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
411 do_facet_random_file client $TMP/$tfile 100K ||
412 { error_noexit "Create random file $TMP/$T" ; return 0; }
413 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
414 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
418 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
419 do_facet ost1 "lctl set_param fail_loc=0x80000504"
421 # OST bulk will time out here, client resends
422 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
423 do_facet ost1 lctl set_param fail_loc=0
424 # give recovery a chance to finish (shouldn't take long)
426 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
430 run_test 16 "timeout bulk put, don't evict client (2732)"
435 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
437 local SAMPLE_FILE=$TMP/$tfile
438 do_facet_random_file client $SAMPLE_FILE 20K ||
439 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
441 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
442 if at_is_enabled; then
443 at_max_saved=$(at_max_get ost1)
444 at_max_set $TIMEOUT ost1
447 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
448 # OST bulk will time out here, client retries
449 do_facet ost1 lctl set_param fail_loc=0x80000503
450 # need to ensure we send an RPC
451 do_facet client cp $SAMPLE_FILE $DIR/$tfile
454 # with AT, client will wait adaptive_max*factor+net_latency before
455 # expiring the req, hopefully timeout*2 is enough
456 sleep $(($TIMEOUT*2))
458 do_facet ost1 lctl set_param fail_loc=0
459 do_facet client "df $DIR"
460 # expect cmp to succeed, client resent bulk
461 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
462 do_facet client "rm $DIR/$tfile" || return 4
463 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
466 run_test 17a "timeout bulk get, don't evict client (2732)"
469 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
471 # get one of the clients from client list
472 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
473 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
474 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
475 [ -z "$ldlm_enqueue_min" ] &&
476 skip "missing /sys/.../ldlm_enqueue_min" && return 0
478 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
479 error "setstripe failed"
480 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
481 error "setstripe 2 failed"
483 save_lustre_params ost1 "at_history" > $p
484 save_lustre_params ost1 "bulk_timeout" >> $p
485 local dev="${FSNAME}-OST0000"
486 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
487 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
489 local new_at_history=15
491 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
492 do_facet ost1 "$LCTL set_param bulk_timeout=30"
493 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
495 # brw_size is required to be 4m so that bulk transfer timeout
496 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
497 local brw_size=$($LCTL get_param -n \
498 osc.$FSNAME-OST0000-osc-[^M]*.import |
499 awk '/max_brw_size/{print $2}')
500 if [ $brw_size -ne 4194304 ]
502 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
503 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
504 remount_client $MOUNT
507 # get service estimate expanded
508 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
509 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
510 echo "delay rpc servicing by 35 seconds"
511 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
514 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
515 awk '/portal 6/ {print $5}')
516 echo "service estimates increased to $estimate"
518 # let current worst service estimate to get closer to obliteration
519 sleep $((new_at_history / 3))
521 # start i/o and simulate bulk transfer loss
522 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
523 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
524 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
527 # start lock conflict handling
528 sleep $((new_at_history / 3))
529 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
532 # obliterate the worst service estimate
533 sleep $((new_at_history / 3 + 1))
534 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
536 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
537 awk '/portal 6/ {print $5}')
538 echo "service estimate dropped to $estimate"
541 [[ $? == 0 ]] || error "write failed"
543 [[ $? == 0 ]] || error "read failed"
545 restore_lustre_params <$p
546 if [ $brw_size -ne 4194304 ]
548 remount_client $MOUNT || error "remount_client failed"
550 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
552 run_test 17b "timeout bulk get, dont evict client (3582)"
555 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
557 do_facet_create_file client $TMP/$tfile 20K ||
558 { error_noexit "Create file $TMP/$tfile" ; return 0; }
560 do_facet client mkdir -p $DIR/$tdir
564 pgcache_empty || return 1
567 $LFS setstripe -i 1 -c 1 $f
568 stripe_index=$($LFS getstripe -i $f)
569 if [ $stripe_index -ne 1 ]; then
571 error "$f: stripe_index $stripe_index != 1" && return
574 do_facet client cp $TMP/$tfile $f
576 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
577 $LCTL --device $osc2dev deactivate || return 3
578 # my understanding is that there should be nothing in the page
579 # cache after the client reconnects?
581 pgcache_empty || rc=2
582 $LCTL --device $osc2dev activate
586 run_test 18a "manual ost invalidate clears page cache immediately"
589 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
591 do_facet_create_file client $TMP/$tfile 20K ||
592 { error_noexit "Create file $TMP/$tfile" ; return 0; }
594 do_facet client mkdir -p $DIR/$tdir
598 pgcache_empty || return 1
600 $LFS setstripe -i 0 -c 1 $f
601 stripe_index=$($LFS getstripe -i $f)
602 if [ $stripe_index -ne 0 ]; then
604 error "$f: stripe_index $stripe_index != 0" && return
607 do_facet client cp $TMP/$tfile $f
610 # allow recovery to complete
611 sleep $((TIMEOUT + 2))
612 # my understanding is that there should be nothing in the page
613 # cache after the client reconnects?
615 pgcache_empty || rc=2
619 run_test 18b "eviction and reconnect clears page cache (2766)"
622 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
624 do_facet_create_file client $TMP/$tfile 20K ||
625 { error_noexit "Create file $TMP/$tfile" ; return 0; }
627 do_facet client mkdir -p $DIR/$tdir
631 pgcache_empty || return 1
633 $LFS setstripe -i 0 -c 1 $f
634 stripe_index=$($LFS getstripe -i $f)
635 if [ $stripe_index -ne 0 ]; then
637 error "$f: stripe_index $stripe_index != 0" && return
640 do_facet client cp $TMP/$tfile $f
644 # OBD_FAIL_OST_CONNECT_NET2
645 # lost reply to connect request
646 do_facet ost1 lctl set_param fail_loc=0x80000225
649 $LFS df $MOUNT > /dev/null 2>&1
651 # my understanding is that there should be nothing in the page
652 # cache after the client reconnects?
654 pgcache_empty || rc=2
658 run_test 18c "Dropped connect reply after eviction handing (14755)"
661 local BEFORE=`date +%s`
664 mount_client $DIR2 || error "failed to mount $DIR2"
666 # cancel cached locks from OST to avoid eviction from it
669 do_facet client "stat $DIR > /dev/null" ||
670 error "failed to stat $DIR: $?"
671 drop_ldlm_cancel "chmod 0777 $DIR2" ||
672 error "failed to chmod $DIR2"
676 # let the client reconnect
678 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
679 awk -F"[ [,]" '/EVICTED ]$/ \
680 { if (mx<$5) {mx=$5;} } END { print mx }')
682 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
683 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
684 error "no eviction: $EVICT before:$BEFORE")
686 run_test 19a "test expired_lock_main on mds (2867)"
689 local BEFORE=`date +%s`
692 mount_client $DIR2 || error "failed to mount $DIR2: $?"
694 # cancel cached locks from MDT to avoid eviction from it
697 do_facet client $MULTIOP $DIR/$tfile Ow ||
698 error "failed to run multiop: $?"
699 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
700 error "failed to ldlm_cancel: $?"
702 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
703 do_facet client munlink $DIR/$tfile ||
704 error "failed to unlink $DIR/$tfile: $?"
706 # let the client reconnect
708 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
709 awk -F"[ [,]" '/EVICTED ]$/ \
710 { if (mx < $5) {mx = $5;} } END { print mx }')
712 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
713 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
714 error "no eviction: $EVICT before:$BEFORE")
716 run_test 19b "test expired_lock_main on ost (2867)"
719 local BEFORE=`date +%s`
722 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
724 mkdir -p $DIR1/$tfile
727 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
728 do_facet mds $LCTL set_param fail_loc=0x80000516
730 touch $DIR2/$tfile/file1 &
732 # let touch to get blocked on the server
736 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
739 # let the client reconnect
741 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
742 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
744 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
746 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
748 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
749 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
752 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
753 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
756 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
757 do_facet ost1 lctl set_param fail_loc=0x80000308
758 kill -USR1 $MULTI_PID
761 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
763 run_test 20a "ldlm_handle_enqueue error (should return error)"
765 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
766 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
769 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
771 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
772 do_facet ost1 lctl set_param fail_loc=0x80000308
773 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
774 error "didn't fail open enqueue" || true
776 run_test 20b "ldlm_handle_enqueue error (should return error)"
779 mkdir -p $DIR/$tdir-1
780 mkdir -p $DIR/$tdir-2
781 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
784 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
785 $MULTIOP $DIR/$tdir-2/f Oc &
788 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
790 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
791 kill -USR1 $close_pid
793 wait $close_pid || return 1
794 wait $open_pid || return 2
795 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
797 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
798 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
802 run_test 21a "drop close request while close and open are both in flight"
805 mkdir -p $DIR/$tdir-1
806 mkdir -p $DIR/$tdir-2
807 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
810 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
811 mcreate $DIR/$tdir-2/f &
814 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
816 kill -USR1 $close_pid
818 wait $close_pid || return 1
819 wait $open_pid || return 3
821 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
822 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
825 run_test 21b "drop open request while close and open are both in flight"
828 mkdir -p $DIR/$tdir-1
829 mkdir -p $DIR/$tdir-2
830 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
833 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
834 mcreate $DIR/$tdir-2/f &
837 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
839 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
840 kill -USR1 $close_pid
842 wait $close_pid || return 1
843 wait $open_pid || return 2
845 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
847 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
848 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
851 run_test 21c "drop both request while close and open are both in flight"
854 mkdir -p $DIR/$tdir-1
855 mkdir -p $DIR/$tdir-2
856 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
859 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
860 $MULTIOP $DIR/$tdir-2/f Oc &
862 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
864 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
867 wait $pid || return 1
868 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
870 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
871 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
875 run_test 21d "drop close reply while close and open are both in flight"
878 mkdir -p $DIR/$tdir-1
879 mkdir -p $DIR/$tdir-2
880 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
883 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
884 touch $DIR/$tdir-2/f &
886 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
890 wait $pid || return 1
893 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
894 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
897 run_test 21e "drop open reply while close and open are both in flight"
900 mkdir -p $DIR/$tdir-1
901 mkdir -p $DIR/$tdir-2
902 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
905 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
906 touch $DIR/$tdir-2/f &
908 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
910 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
913 wait $pid || return 1
914 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
916 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
917 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
920 run_test 21f "drop both reply while close and open are both in flight"
923 mkdir -p $DIR/$tdir-1
924 mkdir -p $DIR/$tdir-2
925 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
928 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
929 touch $DIR/$tdir-2/f &
931 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
933 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
936 wait $pid || return 1
937 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
939 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
940 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
943 run_test 21g "drop open reply and close request while close and open are both in flight"
946 mkdir -p $DIR/$tdir-1
947 mkdir -p $DIR/$tdir-2
948 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
952 touch $DIR/$tdir-2/f &
955 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
957 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
960 wait $pid || return 1
961 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
963 wait $touch_pid || return 2
965 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
966 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
969 run_test 21h "drop open request and close reply while close and open are both in flight"
971 # bug 3462 - multiple MDC requests
976 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
981 $MULTIOP $f1 msu || return 1
984 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
986 wait $close_pid || return 2
987 rm -rf $f2 || return 4
989 run_test 22 "drop close request and do mknod"
992 multiop_bg_pause $DIR/$tfile O_c || return 1
994 # give a chance for open
998 drop_request "kill -USR1 $pid"
1001 wait $pid || return 1
1004 run_test 23 "client hang when close a file after mds crash"
1006 test_24a() { # bug 11710 details correct fsync() behavior
1007 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1010 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1011 cancel_lru_locks osc
1012 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1015 kill -USR1 $MULTI_PID
1018 lctl set_param fail_loc=0x0
1021 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1023 run_test 24a "fsync error (should return error)"
1025 wait_client_evicted () {
1028 local varsvc=${facet}_svc
1030 wait_update $(facet_active_host $facet) \
1031 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1036 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1038 dmesg -c > /dev/null
1040 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1041 error "$LFS setstripe failed"
1042 cancel_lru_locks osc
1043 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1044 error "mulitop Ow8192_yc failed"
1047 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1048 error "mulitop Ow8192_c failed"
1053 kill -USR1 $MULTI_PID1
1056 kill -USR1 $MULTI_PID2
1059 lctl set_param fail_loc=0x0
1061 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1062 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1065 dmesg | grep "dirty page discard:" ||
1066 error "no discarded dirty page found!"
1068 run_test 24b "test dirty page discard due to client eviction"
1070 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1071 # this test can only run from a client on a separate node.
1072 remote_ost || { skip "local OST" && return 0; }
1073 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1074 remote_mds || { skip "local MDS" && return 0; }
1076 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1077 skip "msg and ost1 are at the same node"
1081 check_timeout || return 1
1083 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1084 do_facet client lctl set_param fail_loc=0x505
1085 local before=$(date +%s)
1088 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1089 # But if there's a race to start the evictor from various obds,
1090 # the loser might have to wait for the next ping.
1091 sleep $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1092 do_facet client lctl set_param fail_loc=0x0
1093 do_facet client df > /dev/null
1095 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1096 check_clients_evicted $before ${oscs[@]}
1097 check_clients_full 10 ${oscs[@]}
1099 run_test 26a "evict dead exports"
1101 test_26b() { # bug 10140 - evict dead exports by pinger
1102 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1104 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1105 skip "msg and ost1 are at the same node"
1109 check_timeout || return 1
1111 zconf_mount `hostname` $MOUNT2 ||
1112 { error "Failed to mount $MOUNT2"; return 2; }
1113 sleep 1 # wait connections being established
1115 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1116 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1118 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1120 zconf_umount `hostname` $MOUNT2 -f
1122 # PING_INTERVAL max(obd_timeout / 4, 1U)
1123 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1125 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1126 # But if there's a race to start the evictor from various obds,
1127 # the loser might have to wait for the next ping.
1128 # = 9 * PING_INTERVAL + PING_INTERVAL
1129 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1130 # let's wait $((TIMEOUT * 3)) # bug 19887
1132 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1133 error "Client was not evicted by ost" rc=1
1134 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1135 error "Client was not evicted by mds"
1137 run_test 26b "evict dead exports"
1141 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1144 local save_FAILURE_MODE=$FAILURE_MODE
1146 facet_failover $SINGLEMDS
1147 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1148 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1149 # need to wait for reconnect
1150 echo waiting for fail_loc
1151 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1152 facet_failover $SINGLEMDS
1153 #no crashes allowed!
1154 kill -USR1 $CLIENT_PID
1157 FAILURE_MODE=$save_FAILURE_MODE
1159 run_test 27 "fail LOV while using OSC's"
1161 test_28() { # bug 6086 - error adding new clients
1162 do_facet client mcreate $DIR/$tfile || return 1
1163 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1164 echo "evicted as expected"
1165 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1166 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1167 # fail once (evicted), reconnect fail (fail_loc), ok
1168 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1170 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1172 run_test 28 "handle error adding new clients (bug 6086)"
1174 test_29a() { # bug 22273 - error adding new clients
1175 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1176 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1177 # fail abort so client will be new again
1178 fail_abort $SINGLEMDS
1179 client_up || error "reconnect failed"
1180 wait_osc_import_state $SINGLEMDS ost FULL
1183 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1185 test_29b() { # bug 22273 - error adding new clients
1186 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1187 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1188 # fail abort so client will be new again
1190 client_up || error "reconnect failed"
1193 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1197 # put a load of file creates/writes/deletes
1198 writemany -q $DIR/$tdir/$tfile 0 5 &
1200 echo writemany pid $CLIENT_PID
1204 # wait for client to reconnect to MDS
1209 # client process should see no problems even though MDS went down
1211 kill -USR1 $CLIENT_PID
1214 echo writemany returned $rc
1215 #these may fail because of eviction due to slow AST response.
1217 error_ignore bz13652 "writemany returned rc $rc" || true
1219 run_test 50 "failover MDS under load"
1222 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1223 do_facet ost1 lctl set_param fail_loc=0x00001310
1226 # put a load of file creates/writes/deletes
1227 writemany -q $DIR/$tdir/$tfile 0 5 &
1231 facet_failover $SINGLEMDS
1232 # failover at various points during recovery
1233 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1234 echo will failover at $SEQ
1237 #echo failover in $i sec
1238 log "test_$testnum: failover in $i sec"
1240 facet_failover $SINGLEMDS
1242 # client process should see no problems even though MDS went down
1243 # and recovery was interrupted
1245 kill -USR1 $CLIENT_PID
1248 echo writemany returned $rc
1250 error_ignore bz13652 "writemany returned rc $rc" || true
1252 run_test 51 "failover MDS during recovery"
1255 do_facet client "mkdir -p $DIR/$tdir"
1256 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1258 echo writemany pid $CLIENT_PID
1263 wait $CLIENT_PID || rc=$?
1264 # active client process should see an EIO for down OST
1265 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1266 # but timing or failover setup may allow success
1267 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1268 echo "writemany returned $rc"
1273 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1278 [ $rc -ne 0 ] && { return $rc; }
1279 # wait for client to reconnect to OST
1283 [ $rc -ne 0 ] && { return $rc; }
1290 run_test 52 "failover OST under load"
1292 # test of open reconstruct
1295 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1298 run_test 53 "touch: drop rep"
1301 zconf_mount `hostname` $MOUNT2
1303 touch $DIR2/$tfile.1
1305 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1308 ERROR=`dmesg | egrep "(test 54|went back in time)" | tail -n1 | grep "went back in time"`
1309 [ x"$ERROR" == x ] || error "back in time occured"
1311 run_test 54 "back in time"
1313 # bug 11330 - liblustre application death during I/O locks up OST
1315 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1319 # This test assumes relatively small max_dirty_mb setting
1320 # which we want to walk away from, so just for it we will
1321 # temporarily lower the value
1322 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1323 lctl set_param -n osc.*.max_dirty_mb=32
1324 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1326 # Minimum pass speed is 2MBps
1328 # LU-2887/LU-3089 - set min pass speed to 500KBps
1329 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1331 # first dd should be finished quickly
1332 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1333 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1336 echo "step1: testing ......"
1337 while kill -0 $DDPID 2> /dev/null; do
1339 if [ $count -gt $ddtimeout ]; then
1340 error "dd should be finished!"
1344 echo "(dd_pid=$DDPID, time=$count)successful"
1346 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1347 #define OBD_FAIL_OST_DROP_REQ 0x21d
1348 do_facet ost1 lctl set_param fail_loc=0x0000021d
1349 # second dd will be never finished
1350 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1353 echo "step2: testing ......"
1354 while [ $count -le $ddtimeout ]; do
1355 if ! kill -0 $DDPID 2> /dev/null; then
1357 error "dd shouldn't be finished! (time=$count)"
1362 echo "(dd_pid=$DDPID, time=$count)successful"
1364 #Recover fail_loc and dd will finish soon
1365 do_facet ost1 lctl set_param fail_loc=0
1367 echo "step3: testing ......"
1368 while kill -0 $DDPID 2> /dev/null; do
1370 if [ $count -gt $((ddtimeout + 440)) ]; then
1371 error "dd should be finished!"
1375 echo "(dd_pid=$DDPID, time=$count)successful"
1379 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1381 test_56() { # b=11277
1382 #define OBD_FAIL_MDS_RESEND 0x136
1384 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1385 stat $DIR/$tfile || error "stat failed"
1386 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1389 run_test 56 "do not fail on getattr resend"
1392 # no oscs means no client or mdt
1393 while lctl get_param osc.*.* > /dev/null 2>&1; do
1394 : # loop until proc file is removed
1398 test_57() { # bug 10866
1402 #define OBD_FAIL_LPROC_REMOVE 0xB00
1403 lctl set_param fail_loc=0x80000B00
1404 zconf_umount `hostname` $DIR
1405 lctl set_param fail_loc=0x80000B00
1406 fail_abort $SINGLEMDS
1408 lctl set_param fail_loc=0
1410 do_facet client "df $DIR"
1412 run_test 57 "read procfs entries causes kernel crash"
1414 test_58() { # bug 11546
1415 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1418 lctl set_param fail_loc=0x80000801
1419 cp $DIR/$tfile /dev/null &
1422 lctl set_param fail_loc=0
1423 drop_bl_callback_once rm -f $DIR/$tfile
1425 # the first 'df' could tigger the eviction caused by
1426 # 'drop_bl_callback_once', and it's normal case.
1427 # but the next 'df' should return successfully.
1428 do_facet client "df $DIR" || do_facet client "df $DIR"
1430 run_test 58 "Eviction in the middle of open RPC reply processing"
1432 test_59() { # bug 10589
1433 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1434 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1435 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1436 lctl set_param fail_loc=0x311
1437 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1438 [ $? = 0 ] || error "dd write failed"
1439 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1440 lctl set_param fail_loc=0
1442 zconf_umount `hostname` $MOUNT2 -f
1443 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1444 [ $? = 0 ] || error "dd read failed"
1445 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1446 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1448 run_test 59 "Read cancel race on client eviction"
1451 local num_files=${COUNT:-5000}
1452 test_mkdir $DIR/$tdir
1454 # Register (and start) changelog
1455 changelog_register || error "changelog_register failed"
1457 # Generate a large number of changelog entries
1458 createmany -o $DIR/$tdir/$tfile $num_files
1462 # Unlink files in the background
1463 unlinkmany $DIR/$tdir/$tfile $num_files &
1467 # Failover the MDS while unlinks are happening
1468 facet_failover $SINGLEMDS
1470 # Wait for unlinkmany to finish
1473 # Check if all the create/unlink events were recorded
1475 local cl_count=$(changelog_dump | grep -c UNLNK)
1476 echo "$cl_count unlinks in changelog"
1478 changelog_deregister || error "changelog_deregister failed"
1479 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1480 [ $cl_count -eq $num_files ] ||
1481 error "Recorded $cl_count of $num_files unlinks"
1482 # Also make sure we can clear large changelogs
1483 cl_count=$(changelog_dump | wc -l)
1484 [ $cl_count -le 2 ] ||
1485 error "Changelog not empty: $cl_count entries"
1486 else # If other users, there may be other unlinks in the log
1487 [ $cl_count -ge $num_files ] ||
1488 error "Recorded $cl_count of $num_files unlinks"
1489 changelog_users $SINGLEMDS
1490 echo "other changelog users; can't verify clear"
1493 run_test 60 "Add Changelog entries during MDS failover"
1497 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1498 mdtosc=${mdtosc/-MDT*/-MDT\*}
1499 local cflags="osc.$mdtosc.connect_flags"
1500 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1501 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1503 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1504 # Set the default stripe of $DIR/$tdir to put the files to ost1
1505 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1507 replay_barrier $SINGLEMDS
1508 createmany -o $DIR/$tdir/$tfile-%d 10
1509 local oid=$(do_facet ost1 "lctl get_param -n \
1510 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1512 fail_abort $SINGLEMDS
1514 touch $DIR/$tdir/$tfile
1515 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1516 awk '$1 == 0 { print $2 }')
1517 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1522 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1524 # test_62 as seen it b2_1 please do not reuse test_62
1527 # zconf_umount `hostname` $DIR
1528 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1529 # lctl set_param fail_loc=0x516
1532 #run_test 62 "Verify connection flags race - bug LU-1716"
1537 #grant lock1, export2
1538 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1539 $MULTIOP $DIR2/$tfile Ow || return 2
1541 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1542 do_facet ost $LCTL set_param fail_loc=0x31e
1543 #get waiting lock2, export1
1544 $MULTIOP $DIR/$tfile Ow &
1546 # let enqueue to get asleep
1550 $MULTIOP $DIR2/$tfile Ow &
1558 do_facet ost $LCTL set_param fail_loc=0
1565 run_test 65 "lock enqueue for destroyed export"
1569 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1570 { skip "Need MDS version at least 2.7.51"; return 0; }
1572 local list=$(comma_list $(osts_nodes))
1574 # modify dir so that next revalidate would not obtain UPDATE lock
1577 # drop 1 reply with UPDATE lock
1578 mcreate $DIR/$tfile || error "mcreate failed: $?"
1579 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1582 # make the re-sent lock to sleep
1583 #define OBD_FAIL_MDS_RESEND 0x136
1584 do_nodes $list $LCTL set_param fail_loc=0x80000136
1586 #initiate the re-connect & re-send
1587 local mdccli=$($LCTL dl | awk '/-MDT0000-mdc-/ {print $4;}')
1588 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1589 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1592 #initiate the client eviction while enqueue re-send is in progress
1598 run_test 66 "lock enqueue re-send vs client eviction"
1602 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1603 $LCTL set_param fail_loc=0x80000531
1605 local mdtname="MDT0000"
1606 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1607 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1608 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1617 run_test 67 "connect vs import invalidate race"
1619 check_cli_ir_state()
1621 local NODE=${1:-$HOSTNAME}
1623 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1624 awk '/imperative_recovery:/ { print \\\$2}'")
1625 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1626 error "Error state $st, must be ENABLED or DISABLED"
1630 check_target_ir_state()
1633 local name=${target}_svc
1634 local recovery_proc=obdfilter.${!name}.recovery_status
1638 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1639 awk '/status:/{ print \\\$2}'")
1640 [ x$st = xRECOVERING ] || break
1642 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1643 awk '/IR:/{ print \\\$2}'")
1644 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1645 error "Error state $st, must be ENABLED or DISABLED"
1651 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1656 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1657 awk '/state:/{ print \\\$2 }'")
1661 nidtbl_version_mgs()
1663 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1664 awk '/nidtbl_version:/{ print \\\$2 }'")
1668 # nidtbl_version_client <mds1|client> [node]
1669 nidtbl_version_client()
1672 local node=${2:-$HOSTNAME}
1674 if [ X$cli = Xclient ]; then
1677 local obdtype=${cli/%[0-9]*/}
1678 [ $obdtype != mds ] && error "wrong parameters $cli"
1680 node=$(facet_active_host $cli)
1685 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1686 awk "/$cli/{print \$6}" |sort -u)
1688 # in case there are multiple mounts on the client node
1690 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1694 nidtbl_versions_match()
1696 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1699 target_instance_match()
1705 obdtype=${srv/%[0-9]*/}
1716 error "invalid target type" $srv
1721 local target=${srv}_svc
1722 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1723 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1724 awk '/instance/{ print $2 }' | head -n1)
1726 return $([ $si -eq $ci ])
1731 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1732 { skip "MGS without IR support"; return 0; }
1734 # MDT was just restarted in the previous test, make sure everything
1737 while [ $cnt -gt 0 ]; do
1738 nidtbl_versions_match && break
1744 set_ir_status disabled
1746 local prev_ver=$(nidtbl_version_client client)
1748 local saved_FAILURE_MODE=$FAILURE_MODE
1749 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1753 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1754 error "version must not change due to IR disabled"
1755 target_instance_match ost1 || error "instance mismatch"
1759 FAILURE_MODE=$saved_FAILURE_MODE
1761 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1765 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1766 skip "MGS without IR support"
1770 local ost1_imp=$(get_osc_import_name client ost1)
1772 # disable pinger recovery
1773 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1774 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1778 target_instance_match ost1 || error "instance mismatch"
1779 nidtbl_versions_match || error "version must match"
1781 run_test 101a "IR: Make sure IR works w/o normal recovery"
1785 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1786 skip "MGS without IR support"
1790 local ost1_imp=$(get_osc_import_name client ost1)
1792 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1793 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1794 # disable pinger recovery
1795 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1796 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1798 #OST may return EAGAIN if it is not configured yet
1801 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1805 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1806 { skip "MGS without IR support"; return 0; }
1808 local clients=${CLIENTS:-$HOSTNAME}
1815 # let's have a new nidtbl version
1818 # sleep for a while so that clients can see the failure of ost
1819 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1820 # int mgc_request.c:
1821 # define MGC_TIMEOUT_MIN_SECONDS 5
1822 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1823 local count=30 # 20 seconds at most
1824 while [ $count -gt 0 ]; do
1825 nidtbl_versions_match && break
1830 nidtbl_versions_match || error "nidtbl mismatch"
1833 old_version=$(nidtbl_version_client client)
1835 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1838 combined_mgs_mds && mgsdev=mds1
1839 remount_facet $mgsdev
1842 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1845 new_version=$(nidtbl_version_client client)
1846 [ $new_version -lt $old_version ] &&
1847 error "nidtbl version wrong after mgs restarts"
1850 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1854 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1855 { skip "MGS without IR support"; return 0; }
1857 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1859 # workaround solution to generate config log on the mds
1865 # We need this test because mds is like a client in IR context.
1866 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1867 error "MDS should start w/o mgs"
1869 # start mgs and remount mds w/ ir
1870 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1873 # remount client so that fsdb will be created on the MGS
1874 umount_client $MOUNT || error "umount failed"
1875 mount_client $MOUNT || error "mount failed"
1877 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1879 while [ $count -gt 0 ]; do
1880 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1885 # after a while, mds should be able to reconnect to mgs and fetch
1886 # up-to-date nidtbl version
1887 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1892 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1896 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1897 { skip "MGS without IR support"; return 0; }
1902 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1903 error "OST1 cannot start"
1906 local ir_state=$(check_target_ir_state ost1)
1907 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1908 error "ir status on ost1 should be DISABLED"
1910 run_test 104 "IR: ost can disable IR voluntarily"
1914 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1915 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1916 { skip "MGS without IR support"; return 0; }
1920 # get one of the clients from client list
1921 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1923 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1924 zconf_umount $rcli $MOUNT || error "umount failed"
1925 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1927 # make sure lustre mount at $rcli disabling IR
1928 local ir_state=$(check_cli_ir_state $rcli)
1929 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1930 error "IR state must be DISABLED at $rcli"
1932 # Since the client just mounted, its last_rcvd entry is not on disk.
1933 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1934 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1935 $SETSTRIPE -i 0 $DIR/$tfile
1936 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1938 # make sure MGS's state is Partial
1939 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1942 # make sure IR on ost1 is DISABLED
1943 local ir_state=$(check_target_ir_state ost1)
1944 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1945 error "IR status on ost1 should be DISABLED"
1947 # remount with the default MOUNT_OPTS
1948 zconf_umount $rcli $MOUNT || error "umount failed"
1949 zconf_mount $rcli $MOUNT || error "mount failed"
1951 # make sure MGS's state is full
1952 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1955 # make sure IR on ost1 is ENABLED
1956 local ir_state=$(check_target_ir_state ost1)
1957 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1958 error "IR status on ost1 should be ENABLED"
1962 run_test 105 "IR: NON IR clients support"
1970 test_106() { # LU-1789
1971 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1972 { skip "Need MDS version at least 2.3.50"; return 0; }
1974 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1975 $LCTL set_param fail_loc=0x805
1978 trap cleanup_106 EXIT
1980 # enable lightweight flag on mdc connection
1983 local MDS_NEXP=$(do_facet $SINGLEMDS \
1984 lctl get_param -n mdt.${mds1_svc}.num_exports |
1986 $LCTL set_param fail_loc=0
1988 touch $DIR2/$tfile || error "failed to create empty file"
1989 replay_barrier $SINGLEMDS
1991 $LCTL set_param debug=ha
1993 facet_failover $SINGLEMDS
1995 # lightweight goes through LUSTRE_IMP_RECOVER during failover
1996 touch -c $DIR2/$tfile || true
1997 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1998 recovered=`awk '/MDT0000-mdc-[0-9a-f]*: lwp recover/ {
2000 }' $TMP/lustre-log-$TESTNAME.log`
2001 [ -z "$recovered" ] && error "lightweight client was not recovered"
2003 # and all operations performed by lightweight client should be
2004 # synchronous, so the file created before mds restart should be there
2005 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2010 run_test 106 "lightweight connection support"
2017 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2018 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2019 multiop $DIR/$tdir D_c &
2021 mkdir $DIR/$tdir/dir_106 &
2023 do_facet $SINGLEMDS lctl set_param fail_loc=0
2026 wait $CLIENT_PID || rc=$?
2027 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2029 kill -USR1 $close_pid
2030 wait $close_pid || return 2
2034 run_test 107 "drop reint reply, then restart MDT"
2038 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
2040 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2048 client_up || error "reconnect failed"
2049 rm -f $DIR/$tdir/$tfile
2051 run_test 108 "client eviction don't crash"
2054 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2055 local remote_dir=$DIR/$tdir/remote_dir
2059 #prepare for 110 test, which need set striped dir on remote MDT.
2060 for num in $(seq $MDSCOUNT); do
2062 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2067 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2068 error "lfs mkdir failed"
2069 local diridx=$($LFS getstripe -m $remote_dir)
2070 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2072 rm -rf $DIR/$tdir || error "rmdir failed"
2074 run_test 110a "create remote directory: drop client req"
2077 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2078 local remote_dir=$DIR/$tdir/remote_dir
2082 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2083 error "lfs mkdir failed"
2085 diridx=$($LFS getstripe -m $remote_dir)
2086 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2088 rm -rf $DIR/$tdir || error "rmdir failed"
2090 run_test 110b "create remote directory: drop Master rep"
2093 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2094 local remote_dir=$DIR/$tdir/remote_dir
2098 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2099 error "lfs mkdir failed"
2101 diridx=$($GETSTRIPE -m $remote_dir)
2102 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2104 rm -rf $DIR/$tdir || error "rmdir failed"
2106 run_test 110c "create remote directory: drop update rep on slave MDT"
2109 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2110 local remote_dir=$DIR/$tdir/remote_dir
2114 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2116 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2118 rm -rf $DIR/$tdir || error "rmdir failed"
2122 run_test 110d "remove remote directory: drop client req"
2125 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2126 local remote_dir=$DIR/$tdir/remote_dir
2130 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2131 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2133 rm -rf $DIR/$tdir || error "rmdir failed"
2137 run_test 110e "remove remote directory: drop master rep"
2140 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2141 local remote_dir=$DIR/$tdir/remote_dir
2145 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2146 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2147 error "rm remote dir failed"
2149 rm -rf $DIR/$tdir || error "rmdir failed"
2151 run_test 110f "remove remote directory: drop slave rep"
2154 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.11.0) ]] ||
2155 { skip "Need MDS version at least 2.11.0"; return 0; }
2157 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2160 touch $DIR/$tdir/$tfile
2162 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2163 do_facet mds1 $LCTL set_param fail_loc=0x119
2164 $LFS migrate -m 1 $DIR/$tdir &
2167 do_facet mds1 $LCTL set_param fail_loc=0
2171 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2172 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2173 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2174 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2176 rm -rf $DIR/$tdir || error "rmdir failed"
2178 run_test 110g "drop reply during migration"
2181 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2182 local server_version=$(lustre_version_code mds1)
2183 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2184 { skip "Need MDS version at least 2.7.56"; return 0; }
2186 local src_dir=$DIR/$tdir/source_dir
2187 local tgt_dir=$DIR/$tdir/target_dir
2191 $LFS mkdir -i $MDTIDX $tgt_dir
2193 dd if=/etc/hosts of=$src_dir/src_file
2194 touch $tgt_dir/tgt_file
2195 drop_update_reply $MDTIDX \
2196 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2197 error "mrename failed"
2199 $CHECKSTAT -t file $src_dir/src_file &&
2200 error "src_file present after rename"
2202 diff /etc/hosts $tgt_dir/tgt_file ||
2203 error "file changed after rename"
2206 run_test 110h "drop update reply during cross-MDT file rename"
2209 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2210 local server_version=$(lustre_version_code mds1)
2211 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2212 { skip "Need MDS version at least 2.7.56"; return 0; }
2214 local src_dir=$DIR/$tdir/source_dir
2215 local tgt_dir=$DIR/$tdir/target_dir
2219 $LFS mkdir -i $MDTIDX $tgt_dir
2221 mkdir $src_dir/src_dir
2222 touch $src_dir/src_dir/a
2223 mkdir $tgt_dir/tgt_dir
2224 drop_update_reply $MDTIDX \
2225 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2226 error "mrename failed"
2228 $CHECKSTAT -t dir $src_dir/src_dir &&
2229 error "src_dir present after rename"
2231 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2232 error "tgt_dir not present after rename"
2234 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2235 error "a not present after rename"
2237 run_test 110i "drop update reply during cross-MDT dir rename"
2240 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2241 local server_version=$(lustre_version_code mds1)
2242 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2243 { skip "Need MDS version at least 2.7.56"; return 0; }
2245 local remote_dir=$DIR/$tdir/remote_dir
2246 local local_dir=$DIR/$tdir/local_dir
2250 mkdir $DIR/$tdir/local_dir
2251 $LFS mkdir -i $MDTIDX $remote_dir
2253 touch $local_dir/local_file
2254 drop_update_reply $MDTIDX \
2255 "ln $local_dir/local_file $remote_dir/remote_file" ||
2258 $CHECKSTAT -t file $remote_dir/remote_file ||
2259 error "remote not present after ln"
2261 run_test 110j "drop update reply during cross-MDT ln"
2264 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2265 [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
2266 { skip "Need MDS version at least 2.12.55"; }
2268 stop mds2 || error "stop mds2 failed"
2271 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2272 do_facet mds2 lctl set_param fail_loc=0x1103
2273 start mds2 $(mdsdevname 2) -o abort_recovery ||
2274 error "start MDS with abort_recovery should succeed"
2275 do_facet mds2 lctl set_param fail_loc=0
2278 stop mds2 || error "cleanup: stop mds2 failed"
2279 start mds2 $(mdsdevname 2) || error "cleanup: start mds2 failed"
2280 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2281 client_up || error "post-failover df failed"
2283 run_test 110k "FID_QUERY failed during recovery"
2285 # LU-2844 mdt prepare fail should not cause umount oops
2288 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2289 { skip "Need MDS version at least 2.3.62"; return 0; }
2291 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2292 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2293 stop $SINGLEMDS || error "stop MDS failed"
2294 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
2295 error "start MDS should fail"
2296 do_facet $SINGLEMDS lctl set_param fail_loc=0
2297 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) ||
2298 error "start MDS failed"
2300 run_test 111 "mdd setup fail should not cause umount oops"
2304 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2306 do_facet_random_file client $TMP/$tfile 100K ||
2307 error_noexit "Create random file $TMP/$tfile"
2309 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2310 error_noexit "Can't pause_bulk copy"
2313 # expect cmp to succeed, client resent bulk
2314 cmp $TMP/$tfile $DIR/$tfile ||
2315 error_noexit "Wrong data has been written"
2317 error_noexit "Can't remove file"
2320 run_test 112a "bulk resend while orignal request is in progress"
2327 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2328 cancel_lru_locks osc
2331 $LCTL set_param fail_loc=$fail1 fail_val=3
2332 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2336 set_nodes_failloc "$(osts_nodes)" $fail2
2338 wait $pid || error "dd failed"
2346 local fail_val2=${4:-0}
2352 $LCTL set_param fail_loc=$fail1 fail_val=4
2353 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2358 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2362 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2363 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2368 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2369 skip "need at least 2.8.50 on OST" && return 0
2371 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2372 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2373 test_115_read 0x8000051b 0x8000051a
2375 run_test 115a "read: late REQ MDunlink and no bulk"
2378 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2379 skip "need at least 2.8.50 on OST" && return 0
2381 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2382 #define OBD_FAIL_OST_ENOSPC 0x215
2384 # pass $OSTCOUNT for the fail_loc to be caught
2385 # appropriately by the IO thread
2386 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2388 run_test 115b "write: late REQ MDunlink and no bulk"
2391 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2392 skip "need at least 2.8.50 on OST" && return 0
2394 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2395 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2396 test_115_read 0x8000050f 0x8000051a
2398 run_test 115c "read: late Reply MDunlink and no bulk"
2401 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2402 skip "need at least 2.8.50 on OST" && return 0
2404 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2405 #define OBD_FAIL_OST_ENOSPC 0x215
2406 test_115_write 0x8000050f 0x80000215 0
2408 run_test 115d "write: late Reply MDunlink and no bulk"
2411 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2412 skip "need at least 2.8.50 on OST" && return 0
2414 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2415 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2416 test_115_read 0x80000510 0x80000211
2418 run_test 115e "read: late Bulk MDunlink and no reply"
2421 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2422 skip "need at least 2.8.50 on OST" && return 0
2424 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2425 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2426 test_115_read 0x8000051b 0x80000211
2428 run_test 115f "read: late REQ MDunlink and no reply"
2431 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2432 skip "need at least 2.8.50 on OST" && return 0
2434 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2435 test_115_read 0x8000051c 0
2437 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2439 # parameters: fail_loc CMD RC
2446 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2447 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2448 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2449 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2452 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2453 [ "$1" = "CLEANUP" ] &&
2454 fail=0x80000320 && echo ", $1 cp first"
2455 [ "$1" = "REPLY" ] &&
2456 fail=0x80000321 && echo ", $1 cp first"
2457 [ "$1" = "DEADLOCK CLEANUP" ] &&
2458 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2459 [ "$1" = "DEADLOCK REPLY" ] &&
2460 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2462 if [ x"$2" = x"get" ]; then
2463 #for TEST lock, take a conflict in advance
2464 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2465 echo "** Taking conflict **"
2466 flocks_test 5 set read sleep 10 $DIR/$tfile &
2472 $LCTL set_param fail_loc=$fail
2474 flocks_test 5 $2 write $DIR/$tfile &
2478 echo "** Evicting and re-connecting client **"
2483 if [ x"$2" = x"get" ]; then
2490 # check if the return value is allowed
2491 [ $rc -eq $3 ] && rc=0
2493 $LCTL set_param fail_loc=0
2497 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2498 # the ORIGINAL lock.
2503 flocks_test 5 set write sleep 4 $DIR/$tfile &
2507 # let unlock to sleep in CP CB
2508 $LCTL set_param fail_loc=$1
2511 # let cleanup to cleep in CP CB
2519 $LCTL set_param fail_loc=0
2524 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2527 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2528 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2529 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2531 test_120_reply "REPLY" set 5 || error "SET race failed"
2532 test_120_reply "REPLY" get 5 || error "GET race failed"
2533 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2536 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2537 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2539 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2541 run_test 120 "flock race: completion vs. evict"
2544 local BEFORE=$(date +%s)
2547 # modify dir so that next revalidate would not obtain UPDATE lock
2550 # drop 1 reply with UPDATE lock,
2551 # resend should not create 2nd lock on server
2552 mcreate $DIR/$tfile || error "mcreate failed: $?"
2553 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2555 # 2 BL AST will be sent to client, both must find the same lock,
2556 # race them to not get EINVAL for 2nd BL AST
2557 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2558 $LCTL set_param fail_loc=0x8000031f
2560 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2561 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2562 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2564 # let the client reconnect
2566 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2567 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2569 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2571 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2575 test_mkdir -p $DIR/$tdir
2577 # Prevent interference from layout intent RPCs due to
2578 # asynchronous writeback. These will be tested in 130c below.
2579 do_nodes ${CLIENTS:-$HOSTNAME} sync
2581 # get only LOOKUP lock on $tdir
2582 cancel_lru_locks mdc
2583 ls $DIR/$tdir/$tfile 2>/dev/null
2585 # get getattr by fid on $tdir
2587 # we need to race with unlink, unlink must complete before we will
2588 # take a DLM lock, otherwise unlink will wait until getattr will
2589 # complete; but later than getattr starts so that getattr found
2591 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2592 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2599 # drop the reply so that resend happens on an unlinked file.
2600 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2601 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2605 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2606 local server_version=$(lustre_version_code $SINGLEMDS)
2607 [[ $server_version -ge $(version_code 2.7.2) ]] ||
2608 { skip "Need server version newer than 2.7.1"; return 0; }
2612 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2615 run_test 130a "enqueue resend on not existing file"
2618 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2619 local server_version=$(lustre_version_code $SINGLEMDS)
2620 [[ $server_version -ge $(version_code 2.7.2) ]] ||
2621 { skip "Need server version newer than 2.7.1"; return 0; }
2624 # let the reply to be dropped
2627 #define OBD_FAIL_SRV_ENOENT 0x217
2628 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2630 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2633 run_test 130b "enqueue resend on a stale inode"
2636 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2638 do_nodes ${CLIENTS:-$HOSTNAME} sync
2639 echo XXX > $DIR/$tfile
2641 cancel_lru_locks mdc
2643 # Trigger writeback on $tfile.
2645 # we need to race with unlink, unlink must complete before we will
2646 # take a DLM lock, otherwise unlink will wait until intent will
2647 # complete; but later than intent starts so that intent found
2649 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2650 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2657 # drop the reply so that resend happens on an unlinked file.
2658 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2659 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2661 # let the reply to be dropped
2664 #define OBD_FAIL_SRV_ENOENT 0x217
2665 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2671 run_test 130c "layout intent resend on a stale inode"
2674 local before=$(date +%s)
2677 mount_client $MOUNT2 || error "mount filed"
2680 # get a lock on client so that export would reach the stale list
2681 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2682 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2685 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2686 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2688 $TRUNCATE $DIR/$tfile 100 &
2691 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2695 umount_client $MOUNT2
2697 evict=$(do_facet client $LCTL get_param \
2698 osc.$FSNAME-OST0000-osc-*/state |
2699 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2701 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2702 (do_facet client $LCTL get_param \
2703 osc.$FSNAME-OST0000-osc-*/state;
2704 error "eviction happened: $evict before:$before")
2706 run_test 132 "long punch"
2709 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2712 # get a lock on client so that export would reach the stale list
2713 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2714 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2716 # another IO under the same lock
2717 #define OBD_FAIL_OSC_DELAY_IO 0x414
2718 $LCTL set_param fail_loc=0x80000414
2719 $LCTL set_param fail_val=4 fail_loc=0x80000414
2720 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2724 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2725 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2729 wait $pid && error "dd succeeded"
2732 run_test 131 "IO vs evict results to IO under staled lock"
2735 local list=$(comma_list $(mdts_nodes))
2737 local t=$((TIMEOUT * 2))
2740 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2742 multiop_bg_pause $DIR/$tfile O_jc || return 1
2745 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2746 do_nodes $list $LCTL set_param fail_loc=0x80000157
2748 echo "waiting for multiop $PID"
2749 wait $PID || return 2
2755 run_test 133 "don't fail on flock resend"
2758 [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
2759 [ $CLIENTCOUNT -lt 2 ] &&
2760 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2762 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2763 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2764 error "touch failed"
2765 zconf_umount_clients $CLIENTS $MOUNT
2766 zconf_mount_clients $CLIENTS $MOUNT
2768 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2769 # assume commit interval is 5
2770 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2772 local -a clients=(${CLIENTS//,/ })
2773 local client1=${clients[0]}
2774 local client2=${clients[1]}
2776 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2778 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2781 wait $rmpid || error "rm failed"
2782 wait $mvpid || error "mv failed"
2785 run_test 134 "race between failover and search for reply data free slot"
2788 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
2789 skip "Need MDS version at least 2.12.51"
2792 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2793 # to have parent dir write lock before open/resend
2794 touch $DIR/$tdir/$tfile
2795 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2796 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2797 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2798 error "Failed to open DOM file"
2800 run_test 135 "DOM: open/create resend to return size"
2803 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2804 [[ $MDS1_VERSION -ge $(version_code 2.12.52) ]] ||
2805 skip "Need MDS version at least 2.12.52"
2807 local mdts=$(comma_list $(mdts_nodes))
2808 local MDT0=$(facet_svc $SINGLEMDS)
2810 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2811 [ -n "$clog" ] || error "changelog_register failed"
2812 cl_mask=$(do_facet mds1 $LCTL get_param \
2813 mdd.$MDT0.changelog_mask -n)
2814 changelog_chmask "ALL"
2816 # generate some changelog records to accumulate
2817 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2818 createmany -m $DIR/$tdir/$tfile 10000 ||
2819 error "create $DIR/$tdir/$tfile failed"
2821 local size1=$(do_facet $SINGLEMDS \
2822 $LCTL get_param -n mdd.$MDT0.changelog_size)
2823 echo "Changelog size $size1"
2825 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2826 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2828 # launch changelog_deregister in background on MDS
2829 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2830 > foo.out 2> foo.err < /dev/null &"
2831 # give time to reach fail_loc
2834 # fail_loc will make MDS sleep in the middle of changelog_deregister
2835 # take this opportunity to abruptly kill MDS
2836 FAILURE_MODE_save=$FAILURE_MODE
2839 FAILURE_MODE=$FAILURE_MODE_save
2841 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2843 local size2=$(do_facet $SINGLEMDS \
2844 $LCTL get_param -n mdd.$MDT0.changelog_size)
2845 echo "Changelog size $size2"
2846 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2847 mdd.$MDT0.changelog_users | grep $clog")
2848 echo "After crash, changelog user $clog2"
2850 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2851 error "changelog record count unchanged"
2853 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2855 run_test 136 "changelog_deregister leaving pending records"
2858 check_and_cleanup_lustre