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 "
15 # bug number for skipped test: LU-12896
16 ALWAYS_EXCEPT+=" 110k"
17 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 selinux_status=$(getenforce)
21 if [ "$selinux_status" != "Disabled" ]; then
22 # bug number for skipped test: LU-12928
23 $SHARED_KEY && ALWAYS_EXCEPT+=" 136"
26 require_dsh_mds || exit 0
28 # also long tests: 19, 21a, 21e, 21f, 23, 27
30 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
34 # Allow us to override the setup if we already have a mounted system by
35 # setting SETUP=" " and CLEANUP=" "
37 CLEANUP=${CLEANUP:-""}
39 check_and_setup_lustre
42 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
45 local f1="$DIR/$tfile"
46 local f2="$DIR/$tfile.2"
48 drop_request "mcreate $f1" ||
49 error_noexit "create '$f1': drop req"
51 drop_reint_reply "mcreate $f2" ||
52 error_noexit "create '$f2': drop rep"
54 drop_request "tchmod 111 $f2" ||
55 error_noexit "chmod '$f2': drop req"
57 drop_reint_reply "tchmod 666 $f2" ||
58 error_noexit "chmod '$f2': drop rep"
60 drop_request "statone $f2" ||
61 error_noexit "stat '$f2': drop req"
63 drop_reply "statone $f2" ||
64 error_noexit "stat '$f2': drop rep"
66 run_test 1 "create, chmod, stat: drop req, drop rep"
70 do_facet_create_file client $t 10K ||
71 error_noexit "Create file $t"
73 drop_request "cat $t > /dev/null" ||
74 error_noexit "Open request for $t file"
76 drop_reply "cat $t > /dev/null" ||
77 error_noexit "Open replay for $t file"
79 run_test 4 "open: drop req, drop rep"
84 local RR="$T-renamed-again"
85 do_facet_create_file client $T 10K ||
86 error_noexit "Create file $T"
88 drop_request "mv $T $R" ||
89 error_noexit "Rename $T"
91 drop_reint_reply "mv $R $RR" ||
92 error_noexit "Failed rename replay on $R"
94 do_facet client "checkstat -v $RR" ||
95 error_noexit "checkstat error on $RR"
97 do_facet client "rm $RR" ||
98 error_noexit "Can't remove file $RR"
100 run_test 5 "rename: drop req, drop rep"
104 local LINK1=$DIR/$tfile.link1
105 local LINK2=$DIR/$tfile.link2
107 do_facet_create_file client $T 10K ||
108 error_noexit "Create file $T"
110 drop_request "mlink $T $LINK1" ||
111 error_noexit "mlink request for $T"
113 drop_reint_reply "mlink $T $LINK2" ||
114 error_noexit "mlink reply for $T"
116 drop_request "munlink $LINK1" ||
117 error_noexit "munlink request for $T"
119 drop_reint_reply "munlink $LINK2" ||
120 error_noexit "munlink reply for $T"
122 do_facet client "rm $T" ||
123 error_noexit "Can't remove file $T"
125 run_test 6 "link, unlink: drop req, drop rep"
129 drop_reint_reply "touch $DIR/$tfile" || return 1
131 run_test 8 "touch: drop rep (bug 1423)"
135 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
139 do_facet_random_file client $TMP/$tfile 1K ||
140 error_noexit "Create random file $TMP/$tfile"
141 # make this big, else test 9 doesn't wait for bulk -- bz 5595
142 do_facet_create_file client $TMP/$t1 4M ||
143 error_noexit "Create file $TMP/$t1"
144 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
145 error_noexit "Can't copy to $DIR/$t1 file"
146 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
147 error_noexit "Can't pause_bulk copy"
148 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
149 error_noexit "Can't copy file"
150 do_facet client "sync"
151 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
152 error_noexit "Can't remove files"
153 do_facet client "rm $TMP/$t1 $TMP/$tfile"
155 run_test 9 "pause bulk on OST (bug 1420)"
159 local before=$(date +%s)
162 do_facet client "stat $DIR > /dev/null" ||
163 error "failed to stat $DIR: $?"
164 drop_bl_callback "chmod 0777 $DIR" ||
165 error "failed to chmod $DIR: $?"
167 # let the client reconnect
169 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
170 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
171 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
172 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
173 error "no eviction: $evict before:$before")
175 do_facet client checkstat -v -p 0777 $DIR ||
176 error "client checkstat failed: $?"
178 run_test 10a "finish request on server after client eviction (bug 1521)"
181 local before=$(date +%s)
184 [[ "$MDS1_VERSION" -lt $(version_code 2.6.53) ]] &&
185 skip "Need MDS version at least 2.6.53"
186 do_facet client "stat $DIR > /dev/null" ||
187 error "failed to stat $DIR: $?"
188 drop_bl_callback_once "chmod 0777 $DIR" ||
189 error "failed to chmod $DIR: $?"
191 # let the client reconnect
193 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
194 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
196 [ -z "$evict" ] || [[ $evict -le $before ]] ||
197 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
198 error "eviction happened: $evict before:$before")
200 do_facet client checkstat -v -p 0777 $DIR ||
201 error "client checkstat failed: $?"
203 run_test 10b "re-send BL AST"
206 local before=$(date +%s)
215 workdir="${DIR}/${tdir}"
216 mkdir -p ${workdir} || error "can't create workdir $?"
217 stat ${workdir} > /dev/null ||
218 error "failed to stat ${workdir}: $?"
219 mdtidx=$($LFS getdirstripe -i ${workdir})
220 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
221 awk '{sub("_UUID", "", $2); print $2;}')
223 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
224 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
225 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
227 drop_bl_callback_once "chmod 0777 ${workdir}" &
232 # force client reconnect
233 $LCTL set_param "${mdcpath}"
235 # wait client reconnect
239 evict=$($LCTL get_param mdc.${mdccli}.state |
240 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
242 [[ $evict -le $before ]] ||
243 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
244 error "eviction happened: $EVICT before:$BEFORE" )
246 [ $rc -eq 0 ] || error "chmod must finished OK"
247 checkstat -v -p 0777 "${workdir}" ||
248 error "client checkstat failed: $?"
250 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
253 local before=$(date +%s)
256 [[ "$MDS1_VERSION" -lt $(version_code 2.6.90) ]] &&
257 skip "Need MDS version at least 2.6.90"
259 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
262 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
264 remount_client $MOUNT
268 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
269 echo -n hello | dd of=$DIR1/$tfile bs=5
271 stat $DIR2/$tfile >& /dev/null
272 $LCTL set_param fail_err=71
273 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
278 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
279 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
281 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
283 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
285 [[ $evict -gt $before ]] ||
286 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
287 error "no eviction: $evict before:$before")
289 $LCTL set_param fail_err=0
291 umount_client $MOUNT2
293 run_test 10d "test failed blocking ast"
297 [[ "$OST1_VERSION" -le $(version_code 2.8.58) ]] &&
298 skip "Need OST version at least 2.8.59"
299 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients"
300 [ $(facet_host client) == $(facet_host ost1) ] &&
301 skip "need ost1 and client on different nodes"
302 local -a clients=(${CLIENTS//,/ })
303 local client1=${clients[0]}
304 local client2=${clients[1]}
306 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
307 $MULTIOP $DIR/$tfile-1 Ow1048576c
309 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
310 $LCTL set_param fail_loc=0x80000305
312 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
313 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
314 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
315 # 1. to return ENOTCONN from ldlm_handle_enqueue0
316 # 2. to pause reconnect handling between resend and setting
317 # import to LUSTRE_IMP_FULL state
318 do_facet ost1 "$LCTL set_param fail_val=3"
320 # client1 fails ro respond to bl ast
321 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
324 # ost1 returns error on enqueue, which causes client1 to reconnect
325 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
326 error "multiop failed"
329 do_facet ost1 "$LCTL set_param fail_loc=0"
330 do_facet ost1 "$LCTL set_param fail_val=0"
332 run_test 10e "re-send BL AST vs reconnect race 2"
335 # wake up a thread waiting for completion after eviction
337 do_facet client $MULTIOP $DIR/$tfile Ow ||
338 { error "multiop write failed: $?"; return 1; }
339 do_facet client $MULTIOP $DIR/$tfile or ||
340 { error "multiop read failed: $?"; return 2; }
344 do_facet client $MULTIOP $DIR/$tfile or ||
345 { error "multiop read failed: $?"; return 3; }
346 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
347 echo "evicted as expected"
349 do_facet client munlink $DIR/$tfile ||
350 { error "munlink failed: $?"; return 4; }
351 # allow recovery to complete
352 client_up || client_up || sleep $TIMEOUT
354 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
358 $LCTL mark $MULTIOP $DIR/$tfile OS_c
359 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
360 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
361 multiop_bg_pause $DIR/$tfile OS_c ||
362 { error "multiop failed: $?"; return 1; }
364 #define OBD_FAIL_MDS_CLOSE_NET 0x115
366 echo "waiting for multiop $PID"
367 wait $PID || { error "wait for multiop faile: $?"; return 2; }
368 do_facet client munlink $DIR/$tfile ||
369 { error "client munlink failed: $?"; return 3; }
370 # allow recovery to complete
371 client_up || client_up || sleep $TIMEOUT
373 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
375 # Bug 113, check that readdir lost recv timeout works.
377 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
378 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
379 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
380 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
381 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
382 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
383 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
385 run_test 13 "mdc_readpage restart test (bug 1138)"
387 # Bug 113, check that readdir lost send timeout works.
390 touch $DIR/$tdir/newentry
391 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
392 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
393 ls $DIR/$tdir || return 1
394 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
396 run_test 14 "mdc_readpage resend test (bug 1138)"
399 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
400 touch $DIR/$tfile && return 1
403 run_test 15 "failed open (-ENOMEM)"
405 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
407 lctl set_param -n llite.*.max_read_ahead_mb 0
411 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
415 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
417 do_facet_random_file client $TMP/$tfile 100K ||
418 { error_noexit "Create random file $TMP/$T" ; return 0; }
419 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
420 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
424 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
425 do_facet ost1 "lctl set_param fail_loc=0x80000504"
427 # OST bulk will time out here, client resends
428 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
429 do_facet ost1 lctl set_param fail_loc=0
430 # give recovery a chance to finish (shouldn't take long)
432 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
436 run_test 16 "timeout bulk put, don't evict client (2732)"
441 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
443 local SAMPLE_FILE=$TMP/$tfile
444 do_facet_random_file client $SAMPLE_FILE 20K ||
445 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
447 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
448 if at_is_enabled; then
449 at_max_saved=$(at_max_get ost1)
450 at_max_set $TIMEOUT ost1
453 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
454 # OST bulk will time out here, client retries
455 do_facet ost1 lctl set_param fail_loc=0x80000503
456 # need to ensure we send an RPC
457 do_facet client cp $SAMPLE_FILE $DIR/$tfile
460 # with AT, client will wait adaptive_max*factor+net_latency before
461 # expiring the req, hopefully timeout*2 is enough
462 sleep $(($TIMEOUT*2))
464 do_facet ost1 lctl set_param fail_loc=0
465 do_facet client "df $DIR"
466 # expect cmp to succeed, client resent bulk
467 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
468 do_facet client "rm $DIR/$tfile" || return 4
469 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
472 run_test 17a "timeout bulk get, don't evict client (2732)"
475 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
477 # get one of the clients from client list
478 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
479 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
480 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
481 [ -z "$ldlm_enqueue_min" ] &&
482 skip "missing /sys/.../ldlm_enqueue_min" && return 0
484 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
485 error "setstripe failed"
486 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
487 error "setstripe 2 failed"
489 save_lustre_params ost1 "at_history" > $p
490 save_lustre_params ost1 "bulk_timeout" >> $p
491 local dev="${FSNAME}-OST0000"
492 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
493 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
495 local new_at_history=15
497 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
498 do_facet ost1 "$LCTL set_param bulk_timeout=30"
499 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
501 # brw_size is required to be 4m so that bulk transfer timeout
502 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
503 local brw_size=$($LCTL get_param -n \
504 osc.$FSNAME-OST0000-osc-[^M]*.import |
505 awk '/max_brw_size/{print $2}')
506 if [ $brw_size -ne 4194304 ]
508 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
509 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
510 remount_client $MOUNT
513 # get service estimate expanded
514 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
515 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
516 echo "delay rpc servicing by 35 seconds"
517 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
520 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
521 awk '/portal 6/ {print $5}')
522 echo "service estimates increased to $estimate"
524 # let current worst service estimate to get closer to obliteration
525 sleep $((new_at_history / 3))
527 # start i/o and simulate bulk transfer loss
528 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
529 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
530 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
533 # start lock conflict handling
534 sleep $((new_at_history / 3))
535 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
538 # obliterate the worst service estimate
539 sleep $((new_at_history / 3 + 1))
540 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
542 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
543 awk '/portal 6/ {print $5}')
544 echo "service estimate dropped to $estimate"
547 [[ $? == 0 ]] || error "write failed"
549 [[ $? == 0 ]] || error "read failed"
551 restore_lustre_params <$p
552 if [ $brw_size -ne 4194304 ]
554 remount_client $MOUNT || error "remount_client failed"
556 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
558 run_test 17b "timeout bulk get, dont evict client (3582)"
561 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
563 do_facet_create_file client $TMP/$tfile 20K ||
564 { error_noexit "Create file $TMP/$tfile" ; return 0; }
566 do_facet client mkdir -p $DIR/$tdir
570 pgcache_empty || return 1
573 $LFS setstripe -i 1 -c 1 $f
574 stripe_index=$($LFS getstripe -i $f)
575 if [ $stripe_index -ne 1 ]; then
577 error "$f: stripe_index $stripe_index != 1" && return
580 do_facet client cp $TMP/$tfile $f
582 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
583 $LCTL --device $osc2dev deactivate || return 3
584 # my understanding is that there should be nothing in the page
585 # cache after the client reconnects?
587 pgcache_empty || rc=2
588 $LCTL --device $osc2dev activate
592 run_test 18a "manual ost invalidate clears page cache immediately"
595 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
597 do_facet_create_file client $TMP/$tfile 20K ||
598 { error_noexit "Create file $TMP/$tfile" ; return 0; }
600 do_facet client mkdir -p $DIR/$tdir
604 pgcache_empty || return 1
606 $LFS setstripe -i 0 -c 1 $f
607 stripe_index=$($LFS getstripe -i $f)
608 if [ $stripe_index -ne 0 ]; then
610 error "$f: stripe_index $stripe_index != 0" && return
613 do_facet client cp $TMP/$tfile $f
616 # allow recovery to complete
617 sleep $((TIMEOUT + 2))
618 # my understanding is that there should be nothing in the page
619 # cache after the client reconnects?
621 pgcache_empty || rc=2
625 run_test 18b "eviction and reconnect clears page cache (2766)"
628 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
630 do_facet_create_file client $TMP/$tfile 20K ||
631 { error_noexit "Create file $TMP/$tfile" ; return 0; }
633 do_facet client mkdir -p $DIR/$tdir
637 pgcache_empty || return 1
639 $LFS setstripe -i 0 -c 1 $f
640 stripe_index=$($LFS getstripe -i $f)
641 if [ $stripe_index -ne 0 ]; then
643 error "$f: stripe_index $stripe_index != 0" && return
646 do_facet client cp $TMP/$tfile $f
650 # OBD_FAIL_OST_CONNECT_NET2
651 # lost reply to connect request
652 do_facet ost1 lctl set_param fail_loc=0x80000225
655 $LFS df $MOUNT > /dev/null 2>&1
657 # my understanding is that there should be nothing in the page
658 # cache after the client reconnects?
660 pgcache_empty || rc=2
664 run_test 18c "Dropped connect reply after eviction handing (14755)"
667 local BEFORE=`date +%s`
670 mount_client $DIR2 || error "failed to mount $DIR2"
672 # cancel cached locks from OST to avoid eviction from it
675 do_facet client "stat $DIR > /dev/null" ||
676 error "failed to stat $DIR: $?"
677 drop_ldlm_cancel "chmod 0777 $DIR2" ||
678 error "failed to chmod $DIR2"
682 # let the client reconnect
684 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
685 awk -F"[ [,]" '/EVICTED ]$/ \
686 { if (mx<$5) {mx=$5;} } END { print mx }')
688 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
689 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
690 error "no eviction: $EVICT before:$BEFORE")
692 run_test 19a "test expired_lock_main on mds (2867)"
695 local BEFORE=`date +%s`
698 mount_client $DIR2 || error "failed to mount $DIR2: $?"
700 # cancel cached locks from MDT to avoid eviction from it
703 do_facet client $MULTIOP $DIR/$tfile Ow ||
704 error "failed to run multiop: $?"
705 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
706 error "failed to ldlm_cancel: $?"
708 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
709 do_facet client munlink $DIR/$tfile ||
710 error "failed to unlink $DIR/$tfile: $?"
712 # let the client reconnect
714 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
715 awk -F"[ [,]" '/EVICTED ]$/ \
716 { if (mx < $5) {mx = $5;} } END { print mx }')
718 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
719 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
720 error "no eviction: $EVICT before:$BEFORE")
722 run_test 19b "test expired_lock_main on ost (2867)"
725 local BEFORE=`date +%s`
728 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
730 mkdir -p $DIR1/$tfile
733 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
734 do_facet mds $LCTL set_param fail_loc=0x80000516
736 touch $DIR2/$tfile/file1 &
738 # let touch to get blocked on the server
742 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
745 # let the client reconnect
747 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
748 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
750 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
752 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
754 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
755 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
758 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
759 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
762 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
763 do_facet ost1 lctl set_param fail_loc=0x80000308
764 kill -USR1 $MULTI_PID
767 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
769 run_test 20a "ldlm_handle_enqueue error (should return error)"
771 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
772 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
775 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
777 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
778 do_facet ost1 lctl set_param fail_loc=0x80000308
779 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
780 error "didn't fail open enqueue" || true
782 run_test 20b "ldlm_handle_enqueue error (should return error)"
785 mkdir -p $DIR/$tdir-1
786 mkdir -p $DIR/$tdir-2
787 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
790 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
791 $MULTIOP $DIR/$tdir-2/f Oc &
794 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
796 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
797 kill -USR1 $close_pid
799 wait $close_pid || return 1
800 wait $open_pid || return 2
801 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
803 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
804 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
808 run_test 21a "drop close request while close and open are both in flight"
811 mkdir -p $DIR/$tdir-1
812 mkdir -p $DIR/$tdir-2
813 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
816 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
817 mcreate $DIR/$tdir-2/f &
820 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
822 kill -USR1 $close_pid
824 wait $close_pid || return 1
825 wait $open_pid || return 3
827 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
828 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
831 run_test 21b "drop open request while close and open are both in flight"
834 mkdir -p $DIR/$tdir-1
835 mkdir -p $DIR/$tdir-2
836 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
839 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
840 mcreate $DIR/$tdir-2/f &
843 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
845 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
846 kill -USR1 $close_pid
848 wait $close_pid || return 1
849 wait $open_pid || return 2
851 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
853 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
854 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
857 run_test 21c "drop both request while close and open are both in flight"
860 mkdir -p $DIR/$tdir-1
861 mkdir -p $DIR/$tdir-2
862 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
865 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
866 $MULTIOP $DIR/$tdir-2/f Oc &
868 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
870 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
873 wait $pid || return 1
874 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
876 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
877 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
881 run_test 21d "drop close reply while close and open are both in flight"
884 mkdir -p $DIR/$tdir-1
885 mkdir -p $DIR/$tdir-2
886 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
889 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
890 touch $DIR/$tdir-2/f &
892 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
896 wait $pid || return 1
899 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
900 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
903 run_test 21e "drop open reply while close and open are both in flight"
906 mkdir -p $DIR/$tdir-1
907 mkdir -p $DIR/$tdir-2
908 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
911 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
912 touch $DIR/$tdir-2/f &
914 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
916 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
919 wait $pid || return 1
920 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
922 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
923 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
926 run_test 21f "drop both reply while close and open are both in flight"
929 mkdir -p $DIR/$tdir-1
930 mkdir -p $DIR/$tdir-2
931 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
934 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
935 touch $DIR/$tdir-2/f &
937 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
939 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
942 wait $pid || return 1
943 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
945 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
946 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
949 run_test 21g "drop open reply and close request while close and open are both in flight"
952 mkdir -p $DIR/$tdir-1
953 mkdir -p $DIR/$tdir-2
954 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
957 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
958 touch $DIR/$tdir-2/f &
961 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
963 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
966 wait $pid || return 1
967 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
969 wait $touch_pid || return 2
971 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
972 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
975 run_test 21h "drop open request and close reply while close and open are both in flight"
977 # bug 3462 - multiple MDC requests
982 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
987 $MULTIOP $f1 msu || return 1
990 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
992 wait $close_pid || return 2
993 rm -rf $f2 || return 4
995 run_test 22 "drop close request and do mknod"
998 multiop_bg_pause $DIR/$tfile O_c || return 1
1000 # give a chance for open
1004 drop_request "kill -USR1 $pid"
1007 wait $pid || return 1
1010 run_test 23 "client hang when close a file after mds crash"
1012 test_24a() { # bug 11710 details correct fsync() behavior
1013 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1016 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1017 cancel_lru_locks osc
1018 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1021 kill -USR1 $MULTI_PID
1024 lctl set_param fail_loc=0x0
1027 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1029 run_test 24a "fsync error (should return error)"
1031 wait_client_evicted () {
1034 local varsvc=${facet}_svc
1036 wait_update $(facet_active_host $facet) \
1037 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1042 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1044 dmesg -c > /dev/null
1046 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1047 error "$LFS setstripe failed"
1048 cancel_lru_locks osc
1049 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1050 error "mulitop Ow8192_yc failed"
1053 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1054 error "mulitop Ow8192_c failed"
1059 kill -USR1 $MULTI_PID1
1062 kill -USR1 $MULTI_PID2
1065 lctl set_param fail_loc=0x0
1067 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1068 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1071 dmesg | grep "dirty page discard:" ||
1072 error "no discarded dirty page found!"
1074 run_test 24b "test dirty page discard due to client eviction"
1076 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1077 # this test can only run from a client on a separate node.
1078 remote_ost || { skip "local OST" && return 0; }
1079 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1080 remote_mds || { skip "local MDS" && return 0; }
1082 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1083 skip "msg and ost1 are at the same node"
1087 check_timeout || return 1
1089 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1090 do_facet client lctl set_param fail_loc=0x505
1091 local before=$(date +%s)
1094 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1095 # But if there's a race to start the evictor from various obds,
1096 # the loser might have to wait for the next ping.
1097 sleep $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1098 do_facet client lctl set_param fail_loc=0x0
1099 do_facet client df > /dev/null
1101 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1102 check_clients_evicted $before ${oscs[@]}
1103 check_clients_full 10 ${oscs[@]}
1105 run_test 26a "evict dead exports"
1107 test_26b() { # bug 10140 - evict dead exports by pinger
1108 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1110 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1111 skip "msg and ost1 are at the same node"
1115 check_timeout || return 1
1117 zconf_mount `hostname` $MOUNT2 ||
1118 { error "Failed to mount $MOUNT2"; return 2; }
1119 sleep 1 # wait connections being established
1121 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1122 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1124 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1126 zconf_umount `hostname` $MOUNT2 -f
1128 # PING_INTERVAL max(obd_timeout / 4, 1U)
1129 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1131 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1132 # But if there's a race to start the evictor from various obds,
1133 # the loser might have to wait for the next ping.
1134 # = 9 * PING_INTERVAL + PING_INTERVAL
1135 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1136 # let's wait $((TIMEOUT * 3)) # bug 19887
1138 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1139 error "Client was not evicted by ost" rc=1
1140 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1141 error "Client was not evicted by mds"
1143 run_test 26b "evict dead exports"
1147 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1150 local save_FAILURE_MODE=$FAILURE_MODE
1152 facet_failover $SINGLEMDS
1153 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1154 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1155 # need to wait for reconnect
1156 echo waiting for fail_loc
1157 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1158 facet_failover $SINGLEMDS
1159 #no crashes allowed!
1160 kill -USR1 $CLIENT_PID
1163 FAILURE_MODE=$save_FAILURE_MODE
1165 run_test 27 "fail LOV while using OSC's"
1167 test_28() { # bug 6086 - error adding new clients
1168 do_facet client mcreate $DIR/$tfile || return 1
1169 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1170 echo "evicted as expected"
1171 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1172 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1173 # fail once (evicted), reconnect fail (fail_loc), ok
1174 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1176 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1178 run_test 28 "handle error adding new clients (bug 6086)"
1180 test_29a() { # bug 22273 - error adding new clients
1181 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1182 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1183 # fail abort so client will be new again
1184 fail_abort $SINGLEMDS
1185 client_up || error "reconnect failed"
1186 wait_osc_import_state $SINGLEMDS ost FULL
1189 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1191 test_29b() { # bug 22273 - error adding new clients
1192 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1193 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1194 # fail abort so client will be new again
1196 client_up || error "reconnect failed"
1199 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1203 # put a load of file creates/writes/deletes
1204 writemany -q $DIR/$tdir/$tfile 0 5 &
1206 echo writemany pid $CLIENT_PID
1210 # wait for client to reconnect to MDS
1215 # client process should see no problems even though MDS went down
1217 kill -USR1 $CLIENT_PID
1220 echo writemany returned $rc
1221 #these may fail because of eviction due to slow AST response.
1223 error_ignore bz13652 "writemany returned rc $rc" || true
1225 run_test 50 "failover MDS under load"
1228 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1229 do_facet ost1 lctl set_param fail_loc=0x00001310
1232 # put a load of file creates/writes/deletes
1233 writemany -q $DIR/$tdir/$tfile 0 5 &
1237 facet_failover $SINGLEMDS
1238 # failover at various points during recovery
1239 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1240 echo will failover at $SEQ
1243 #echo failover in $i sec
1244 log "test_$testnum: failover in $i sec"
1246 facet_failover $SINGLEMDS
1248 # client process should see no problems even though MDS went down
1249 # and recovery was interrupted
1251 kill -USR1 $CLIENT_PID
1254 echo writemany returned $rc
1256 error_ignore bz13652 "writemany returned rc $rc" || true
1258 run_test 51 "failover MDS during recovery"
1261 do_facet client "mkdir -p $DIR/$tdir"
1262 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1264 echo writemany pid $CLIENT_PID
1269 wait $CLIENT_PID || rc=$?
1270 # active client process should see an EIO for down OST
1271 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1272 # but timing or failover setup may allow success
1273 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1274 echo "writemany returned $rc"
1279 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1284 [ $rc -ne 0 ] && { return $rc; }
1285 # wait for client to reconnect to OST
1289 [ $rc -ne 0 ] && { return $rc; }
1296 run_test 52 "failover OST under load"
1298 # test of open reconstruct
1301 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1304 run_test 53 "touch: drop rep"
1307 zconf_mount $(hostname) $MOUNT2
1309 touch $DIR2/$tfile.1
1311 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1314 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1315 grep "went back in time")
1316 [ x"$ERROR" == x ] || error "back in time occured"
1318 run_test 54 "back in time"
1320 # bug 11330 - liblustre application death during I/O locks up OST
1322 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1326 # This test assumes relatively small max_dirty_mb setting
1327 # which we want to walk away from, so just for it we will
1328 # temporarily lower the value
1329 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1330 lctl set_param -n osc.*.max_dirty_mb=32
1331 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1333 # Minimum pass speed is 2MBps
1335 # LU-2887/LU-3089 - set min pass speed to 500KBps
1336 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1338 # first dd should be finished quickly
1339 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1340 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1343 echo "step1: testing ......"
1344 while kill -0 $DDPID 2> /dev/null; do
1346 if [ $count -gt $ddtimeout ]; then
1347 error "dd should be finished!"
1351 echo "(dd_pid=$DDPID, time=$count)successful"
1353 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1354 #define OBD_FAIL_OST_DROP_REQ 0x21d
1355 do_facet ost1 lctl set_param fail_loc=0x0000021d
1356 # second dd will be never finished
1357 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1360 echo "step2: testing ......"
1361 while [ $count -le $ddtimeout ]; do
1362 if ! kill -0 $DDPID 2> /dev/null; then
1364 error "dd shouldn't be finished! (time=$count)"
1369 echo "(dd_pid=$DDPID, time=$count)successful"
1371 #Recover fail_loc and dd will finish soon
1372 do_facet ost1 lctl set_param fail_loc=0
1374 echo "step3: testing ......"
1375 while kill -0 $DDPID 2> /dev/null; do
1377 if [ $count -gt $((ddtimeout + 440)) ]; then
1378 error "dd should be finished!"
1382 echo "(dd_pid=$DDPID, time=$count)successful"
1386 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1388 test_56() { # b=11277
1389 #define OBD_FAIL_MDS_RESEND 0x136
1391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1392 stat $DIR/$tfile || error "stat failed"
1393 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1396 run_test 56 "do not fail on getattr resend"
1399 # no oscs means no client or mdt
1400 while lctl get_param osc.*.* > /dev/null 2>&1; do
1401 : # loop until proc file is removed
1405 test_57() { # bug 10866
1409 #define OBD_FAIL_LPROC_REMOVE 0xB00
1410 lctl set_param fail_loc=0x80000B00
1411 zconf_umount `hostname` $DIR
1412 lctl set_param fail_loc=0x80000B00
1413 fail_abort $SINGLEMDS
1415 lctl set_param fail_loc=0
1417 do_facet client "df $DIR"
1419 run_test 57 "read procfs entries causes kernel crash"
1421 test_58() { # bug 11546
1422 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1425 lctl set_param fail_loc=0x80000801
1426 cp $DIR/$tfile /dev/null &
1429 lctl set_param fail_loc=0
1430 drop_bl_callback_once rm -f $DIR/$tfile
1432 # the first 'df' could tigger the eviction caused by
1433 # 'drop_bl_callback_once', and it's normal case.
1434 # but the next 'df' should return successfully.
1435 do_facet client "df $DIR" || do_facet client "df $DIR"
1437 run_test 58 "Eviction in the middle of open RPC reply processing"
1439 test_59() { # bug 10589
1440 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1441 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1442 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1443 lctl set_param fail_loc=0x311
1444 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1445 [ $? = 0 ] || error "dd write failed"
1446 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1447 lctl set_param fail_loc=0
1449 zconf_umount `hostname` $MOUNT2 -f
1450 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1451 [ $? = 0 ] || error "dd read failed"
1452 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1453 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1455 run_test 59 "Read cancel race on client eviction"
1458 local num_files=${COUNT:-5000}
1459 test_mkdir $DIR/$tdir
1461 # Register (and start) changelog
1462 changelog_register || error "changelog_register failed"
1464 # Generate a large number of changelog entries
1465 createmany -o $DIR/$tdir/$tfile $num_files
1469 # Unlink files in the background
1470 unlinkmany $DIR/$tdir/$tfile $num_files &
1474 # Failover the MDS while unlinks are happening
1475 facet_failover $SINGLEMDS
1477 # Wait for unlinkmany to finish
1480 # Check if all the create/unlink events were recorded
1482 local cl_count=$(changelog_dump | grep -c UNLNK)
1483 echo "$cl_count unlinks in changelog"
1485 changelog_deregister || error "changelog_deregister failed"
1486 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1487 [ $cl_count -eq $num_files ] ||
1488 error "Recorded $cl_count of $num_files unlinks"
1489 # Also make sure we can clear large changelogs
1490 cl_count=$(changelog_dump | wc -l)
1491 [ $cl_count -le 2 ] ||
1492 error "Changelog not empty: $cl_count entries"
1493 else # If other users, there may be other unlinks in the log
1494 [ $cl_count -ge $num_files ] ||
1495 error "Recorded $cl_count of $num_files unlinks"
1496 changelog_users $SINGLEMDS
1497 echo "other changelog users; can't verify clear"
1500 run_test 60 "Add Changelog entries during MDS failover"
1504 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1505 mdtosc=${mdtosc/-MDT*/-MDT\*}
1506 local cflags="osc.$mdtosc.connect_flags"
1507 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1508 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1510 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1511 # Set the default stripe of $DIR/$tdir to put the files to ost1
1512 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1514 replay_barrier $SINGLEMDS
1515 createmany -o $DIR/$tdir/$tfile-%d 10
1516 local oid=$(do_facet ost1 "lctl get_param -n \
1517 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1519 fail_abort $SINGLEMDS
1521 touch $DIR/$tdir/$tfile
1522 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1523 awk '$1 == 0 { print $2 }')
1524 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1529 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1531 # test_62 as seen it b2_1 please do not reuse test_62
1534 # zconf_umount `hostname` $DIR
1535 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1536 # lctl set_param fail_loc=0x516
1539 #run_test 62 "Verify connection flags race - bug LU-1716"
1544 #grant lock1, export2
1545 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1546 $MULTIOP $DIR2/$tfile Ow || return 2
1548 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1549 do_facet ost $LCTL set_param fail_loc=0x31e
1550 #get waiting lock2, export1
1551 $MULTIOP $DIR/$tfile Ow &
1553 # let enqueue to get asleep
1557 $MULTIOP $DIR2/$tfile Ow &
1565 do_facet ost $LCTL set_param fail_loc=0
1572 run_test 65 "lock enqueue for destroyed export"
1576 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1577 skip "Need MDS version at least 2.7.51"
1579 local list=$(comma_list $(osts_nodes))
1581 # modify dir so that next revalidate would not obtain UPDATE lock
1584 # drop 1 reply with UPDATE lock
1585 mcreate $DIR/$tfile || error "mcreate failed: $?"
1586 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1589 # make the re-sent lock to sleep
1590 #define OBD_FAIL_MDS_RESEND 0x136
1591 do_nodes $list $LCTL set_param fail_loc=0x80000136
1593 #initiate the re-connect & re-send
1594 local mdtname="MDT0000"
1595 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1596 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1597 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1600 #initiate the client eviction while enqueue re-send is in progress
1606 run_test 66 "lock enqueue re-send vs client eviction"
1610 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1611 $LCTL set_param fail_loc=0x80000531
1613 local mdtname="MDT0000"
1614 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1615 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1616 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1625 run_test 67 "connect vs import invalidate race"
1627 check_cli_ir_state()
1629 local NODE=${1:-$HOSTNAME}
1631 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1632 awk '/imperative_recovery:/ { print \\\$2}'")
1633 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1634 error "Error state $st, must be ENABLED or DISABLED"
1638 check_target_ir_state()
1641 local name=${target}_svc
1642 local recovery_proc=obdfilter.${!name}.recovery_status
1646 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1647 awk '/status:/{ print \\\$2}'")
1648 [ x$st = xRECOVERING ] || break
1650 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1651 awk '/IR:/{ print \\\$2}'")
1652 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1653 error "Error state $st, must be ENABLED or DISABLED"
1659 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1664 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1665 awk '/state:/{ print \\\$2 }'")
1669 nidtbl_version_mgs()
1671 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1672 awk '/nidtbl_version:/{ print \\\$2 }'")
1676 # nidtbl_version_client <mds1|client> [node]
1677 nidtbl_version_client()
1680 local node=${2:-$HOSTNAME}
1682 if [ X$cli = Xclient ]; then
1685 local obdtype=${cli/%[0-9]*/}
1686 [ $obdtype != mds ] && error "wrong parameters $cli"
1688 node=$(facet_active_host $cli)
1693 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1694 awk "/$cli/{print \$6}" |sort -u)
1696 # in case there are multiple mounts on the client node
1698 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1702 nidtbl_versions_match()
1704 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1707 target_instance_match()
1713 obdtype=${srv/%[0-9]*/}
1724 error "invalid target type" $srv
1729 local target=${srv}_svc
1730 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1731 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1732 awk '/instance/{ print $2 }' | head -n1)
1734 return $([ $si -eq $ci ])
1739 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1740 { skip "MGS without IR support"; return 0; }
1742 # MDT was just restarted in the previous test, make sure everything
1745 while [ $cnt -gt 0 ]; do
1746 nidtbl_versions_match && break
1752 set_ir_status disabled
1754 local prev_ver=$(nidtbl_version_client client)
1756 local saved_FAILURE_MODE=$FAILURE_MODE
1757 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1761 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1762 error "version must not change due to IR disabled"
1763 target_instance_match ost1 || error "instance mismatch"
1767 FAILURE_MODE=$saved_FAILURE_MODE
1769 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1773 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1774 skip "MGS without IR support"
1778 local ost1_imp=$(get_osc_import_name client ost1)
1780 # disable pinger recovery
1781 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1782 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1786 target_instance_match ost1 || error "instance mismatch"
1787 nidtbl_versions_match || error "version must match"
1789 run_test 101a "IR: Make sure IR works w/o normal recovery"
1793 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1794 skip "MGS without IR support"
1798 local ost1_imp=$(get_osc_import_name client ost1)
1800 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1801 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1802 # disable pinger recovery
1803 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1804 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1806 #OST may return EAGAIN if it is not configured yet
1809 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1813 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1814 { skip "MGS without IR support"; return 0; }
1816 local clients=${CLIENTS:-$HOSTNAME}
1823 # let's have a new nidtbl version
1826 # sleep for a while so that clients can see the failure of ost
1827 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1828 # int mgc_request.c:
1829 # define MGC_TIMEOUT_MIN_SECONDS 5
1830 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1831 local count=30 # 20 seconds at most
1832 while [ $count -gt 0 ]; do
1833 nidtbl_versions_match && break
1838 nidtbl_versions_match || error "nidtbl mismatch"
1841 old_version=$(nidtbl_version_client client)
1843 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1846 combined_mgs_mds && mgsdev=mds1
1847 remount_facet $mgsdev
1850 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1853 new_version=$(nidtbl_version_client client)
1854 [ $new_version -lt $old_version ] &&
1855 error "nidtbl version wrong after mgs restarts"
1858 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1862 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1863 { skip "MGS without IR support"; return 0; }
1865 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1867 # workaround solution to generate config log on the mds
1873 # We need this test because mds is like a client in IR context.
1874 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1875 error "MDS should start w/o mgs"
1877 # start mgs and remount mds w/ ir
1878 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1881 # remount client so that fsdb will be created on the MGS
1882 umount_client $MOUNT || error "umount failed"
1883 mount_client $MOUNT || error "mount failed"
1885 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1887 while [ $count -gt 0 ]; do
1888 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1893 # after a while, mds should be able to reconnect to mgs and fetch
1894 # up-to-date nidtbl version
1895 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1900 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1904 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1905 { skip "MGS without IR support"; return 0; }
1910 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1911 error "OST1 cannot start"
1914 local ir_state=$(check_target_ir_state ost1)
1915 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1916 error "ir status on ost1 should be DISABLED"
1918 run_test 104 "IR: ost can disable IR voluntarily"
1922 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1923 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1924 { skip "MGS without IR support"; return 0; }
1928 # get one of the clients from client list
1929 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1931 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1932 zconf_umount $rcli $MOUNT || error "umount failed"
1933 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1935 # make sure lustre mount at $rcli disabling IR
1936 local ir_state=$(check_cli_ir_state $rcli)
1937 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1938 error "IR state must be DISABLED at $rcli"
1940 # Since the client just mounted, its last_rcvd entry is not on disk.
1941 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1942 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1943 $SETSTRIPE -i 0 $DIR/$tfile
1944 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1946 # make sure MGS's state is Partial
1947 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1950 # make sure IR on ost1 is DISABLED
1951 local ir_state=$(check_target_ir_state ost1)
1952 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1953 error "IR status on ost1 should be DISABLED"
1955 # remount with the default MOUNT_OPTS
1956 zconf_umount $rcli $MOUNT || error "umount failed"
1957 zconf_mount $rcli $MOUNT || error "mount failed"
1959 # make sure MGS's state is full
1960 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1963 # make sure IR on ost1 is ENABLED
1964 local ir_state=$(check_target_ir_state ost1)
1965 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1966 error "IR status on ost1 should be ENABLED"
1970 run_test 105 "IR: NON IR clients support"
1978 test_106() { # LU-1789
1979 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1980 skip "Need MDS version at least 2.3.50"
1982 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1983 $LCTL set_param fail_loc=0x805
1986 trap cleanup_106 EXIT
1988 # enable lightweight flag on mdc connection
1991 local MDS_NEXP=$(do_facet $SINGLEMDS \
1992 lctl get_param -n mdt.${mds1_svc}.num_exports |
1994 $LCTL set_param fail_loc=0
1996 touch $DIR2/$tfile || error "failed to create empty file"
1997 replay_barrier $SINGLEMDS
1999 $LCTL set_param debug=ha
2001 facet_failover $SINGLEMDS
2003 # lightweight goes through LUSTRE_IMP_RECOVER during failover
2004 touch -c $DIR2/$tfile || true
2005 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2006 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
2007 $TMP/lustre-log-$TESTNAME.log)
2008 [ -z "$recovered" ] && error "lightweight client was not recovered"
2010 # and all operations performed by lightweight client should be
2011 # synchronous, so the file created before mds restart should be there
2012 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2017 run_test 106 "lightweight connection support"
2024 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2025 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2026 multiop $DIR/$tdir D_c &
2028 mkdir $DIR/$tdir/dir_106 &
2030 do_facet $SINGLEMDS lctl set_param fail_loc=0
2033 wait $CLIENT_PID || rc=$?
2034 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2036 kill -USR1 $close_pid
2037 wait $close_pid || return 2
2041 run_test 107 "drop reint reply, then restart MDT"
2045 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
2047 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2055 client_up || error "reconnect failed"
2056 rm -f $DIR/$tdir/$tfile
2058 run_test 108 "client eviction don't crash"
2061 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2062 local remote_dir=$DIR/$tdir/remote_dir
2066 #prepare for 110 test, which need set striped dir on remote MDT.
2067 for num in $(seq $MDSCOUNT); do
2069 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2074 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2075 error "lfs mkdir failed"
2076 local diridx=$($LFS getstripe -m $remote_dir)
2077 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2079 rm -rf $DIR/$tdir || error "rmdir failed"
2081 run_test 110a "create remote directory: drop client req"
2084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2085 local remote_dir=$DIR/$tdir/remote_dir
2089 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2090 error "lfs mkdir failed"
2092 diridx=$($LFS getstripe -m $remote_dir)
2093 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2095 rm -rf $DIR/$tdir || error "rmdir failed"
2097 run_test 110b "create remote directory: drop Master rep"
2100 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2101 local remote_dir=$DIR/$tdir/remote_dir
2105 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2106 error "lfs mkdir failed"
2108 diridx=$($GETSTRIPE -m $remote_dir)
2109 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2111 rm -rf $DIR/$tdir || error "rmdir failed"
2113 run_test 110c "create remote directory: drop update rep on slave MDT"
2116 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2117 local remote_dir=$DIR/$tdir/remote_dir
2121 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2123 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2125 rm -rf $DIR/$tdir || error "rmdir failed"
2129 run_test 110d "remove remote directory: drop client req"
2132 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2133 local remote_dir=$DIR/$tdir/remote_dir
2137 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2138 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2140 rm -rf $DIR/$tdir || error "rmdir failed"
2144 run_test 110e "remove remote directory: drop master rep"
2147 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2148 local remote_dir=$DIR/$tdir/remote_dir
2152 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2153 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2154 error "rm remote dir failed"
2156 rm -rf $DIR/$tdir || error "rmdir failed"
2158 run_test 110f "remove remote directory: drop slave rep"
2161 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2162 skip "Need MDS version at least 2.11.0"
2164 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2167 touch $DIR/$tdir/$tfile
2169 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2170 do_facet mds1 $LCTL set_param fail_loc=0x119
2171 $LFS migrate -m 1 $DIR/$tdir &
2174 do_facet mds1 $LCTL set_param fail_loc=0
2178 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2179 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2180 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2181 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2183 rm -rf $DIR/$tdir || error "rmdir failed"
2185 run_test 110g "drop reply during migration"
2188 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2189 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2190 skip "Need MDS version at least 2.7.56"
2192 local src_dir=$DIR/$tdir/source_dir
2193 local tgt_dir=$DIR/$tdir/target_dir
2197 $LFS mkdir -i $MDTIDX $tgt_dir
2199 dd if=/etc/hosts of=$src_dir/src_file
2200 touch $tgt_dir/tgt_file
2201 drop_update_reply $MDTIDX \
2202 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2203 error "mrename failed"
2205 $CHECKSTAT -t file $src_dir/src_file &&
2206 error "src_file present after rename"
2208 diff /etc/hosts $tgt_dir/tgt_file ||
2209 error "file changed after rename"
2212 run_test 110h "drop update reply during cross-MDT file rename"
2215 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2216 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2217 skip "Need MDS version at least 2.7.56"
2219 local src_dir=$DIR/$tdir/source_dir
2220 local tgt_dir=$DIR/$tdir/target_dir
2224 $LFS mkdir -i $MDTIDX $tgt_dir
2226 mkdir $src_dir/src_dir
2227 touch $src_dir/src_dir/a
2228 mkdir $tgt_dir/tgt_dir
2229 drop_update_reply $MDTIDX \
2230 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2231 error "mrename failed"
2233 $CHECKSTAT -t dir $src_dir/src_dir &&
2234 error "src_dir present after rename"
2236 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2237 error "tgt_dir not present after rename"
2239 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2240 error "a not present after rename"
2242 run_test 110i "drop update reply during cross-MDT dir rename"
2245 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2246 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2247 skip "Need MDS version at least 2.7.56"
2249 local remote_dir=$DIR/$tdir/remote_dir
2250 local local_dir=$DIR/$tdir/local_dir
2254 mkdir $DIR/$tdir/local_dir
2255 $LFS mkdir -i $MDTIDX $remote_dir
2257 touch $local_dir/local_file
2258 drop_update_reply $MDTIDX \
2259 "ln $local_dir/local_file $remote_dir/remote_file" ||
2262 $CHECKSTAT -t file $remote_dir/remote_file ||
2263 error "remote not present after ln"
2265 run_test 110j "drop update reply during cross-MDT ln"
2268 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2269 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2270 skip "Need MDS version at least 2.12.55"
2272 stop mds2 || error "stop mds2 failed"
2275 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2276 do_facet mds2 lctl set_param fail_loc=0x1103
2277 start mds2 $(mdsdevname 2) -o abort_recovery ||
2278 error "start MDS with abort_recovery should succeed"
2279 do_facet mds2 lctl set_param fail_loc=0
2282 stop mds2 || error "cleanup: stop mds2 failed"
2283 start mds2 $(mdsdevname 2) || error "cleanup: start mds2 failed"
2284 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2285 client_up || error "post-failover df failed"
2287 run_test 110k "FID_QUERY failed during recovery"
2289 # LU-2844 mdt prepare fail should not cause umount oops
2292 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2293 skip "Need MDS version at least 2.3.62"
2295 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2296 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2297 stop $SINGLEMDS || error "stop MDS failed"
2298 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
2299 error "start MDS should fail"
2300 do_facet $SINGLEMDS lctl set_param fail_loc=0
2301 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) ||
2302 error "start MDS failed"
2304 run_test 111 "mdd setup fail should not cause umount oops"
2308 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2310 do_facet_random_file client $TMP/$tfile 100K ||
2311 error_noexit "Create random file $TMP/$tfile"
2313 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2314 error_noexit "Can't pause_bulk copy"
2317 # expect cmp to succeed, client resent bulk
2318 cmp $TMP/$tfile $DIR/$tfile ||
2319 error_noexit "Wrong data has been written"
2321 error_noexit "Can't remove file"
2324 run_test 112a "bulk resend while orignal request is in progress"
2331 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2332 cancel_lru_locks osc
2335 $LCTL set_param fail_loc=$fail1 fail_val=3
2336 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2340 set_nodes_failloc "$(osts_nodes)" $fail2
2342 wait $pid || error "dd failed"
2350 local fail_val2=${4:-0}
2356 $LCTL set_param fail_loc=$fail1 fail_val=4
2357 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2362 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2366 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2367 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2372 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2373 skip "need at least 2.8.50 on OST"
2375 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2376 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2377 test_115_read 0x8000051b 0x8000051a
2379 run_test 115a "read: late REQ MDunlink and no bulk"
2382 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2383 skip "need at least 2.8.50 on OST"
2385 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2386 #define OBD_FAIL_OST_ENOSPC 0x215
2388 # pass $OSTCOUNT for the fail_loc to be caught
2389 # appropriately by the IO thread
2390 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2392 run_test 115b "write: late REQ MDunlink and no bulk"
2395 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2396 skip "need at least 2.8.50 on OST"
2398 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2399 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2400 test_115_read 0x8000050f 0x8000051a
2402 run_test 115c "read: late Reply MDunlink and no bulk"
2405 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2406 skip "need at least 2.8.50 on OST"
2408 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2409 #define OBD_FAIL_OST_ENOSPC 0x215
2410 test_115_write 0x8000050f 0x80000215 0
2412 run_test 115d "write: late Reply MDunlink and no bulk"
2415 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2416 skip "need at least 2.8.50 on OST"
2418 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2419 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2420 test_115_read 0x80000510 0x80000211
2422 run_test 115e "read: late Bulk MDunlink and no reply"
2425 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2426 skip "need at least 2.8.50 on OST"
2428 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2429 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2430 test_115_read 0x8000051b 0x80000211
2432 run_test 115f "read: late REQ MDunlink and no reply"
2435 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2436 skip "need at least 2.8.50 on OST"
2438 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2439 test_115_read 0x8000051c 0
2441 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2443 # parameters: fail_loc CMD RC
2450 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2451 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2452 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2453 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2456 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2457 [ "$1" = "CLEANUP" ] &&
2458 fail=0x80000320 && echo ", $1 cp first"
2459 [ "$1" = "REPLY" ] &&
2460 fail=0x80000321 && echo ", $1 cp first"
2461 [ "$1" = "DEADLOCK CLEANUP" ] &&
2462 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2463 [ "$1" = "DEADLOCK REPLY" ] &&
2464 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2466 if [ x"$2" = x"get" ]; then
2467 #for TEST lock, take a conflict in advance
2468 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2469 echo "** Taking conflict **"
2470 flocks_test 5 set read sleep 10 $DIR/$tfile &
2476 $LCTL set_param fail_loc=$fail
2478 flocks_test 5 $2 write $DIR/$tfile &
2482 echo "** Evicting and re-connecting client **"
2487 if [ x"$2" = x"get" ]; then
2494 # check if the return value is allowed
2495 [ $rc -eq $3 ] && rc=0
2497 $LCTL set_param fail_loc=0
2501 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2502 # the ORIGINAL lock.
2507 flocks_test 5 set write sleep 4 $DIR/$tfile &
2511 # let unlock to sleep in CP CB
2512 $LCTL set_param fail_loc=$1
2515 # let cleanup to cleep in CP CB
2523 $LCTL set_param fail_loc=0
2528 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2531 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2532 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2533 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2535 test_120_reply "REPLY" set 5 || error "SET race failed"
2536 test_120_reply "REPLY" get 5 || error "GET race failed"
2537 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2540 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2541 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2543 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2545 run_test 120 "flock race: completion vs. evict"
2548 local BEFORE=$(date +%s)
2551 # modify dir so that next revalidate would not obtain UPDATE lock
2554 # drop 1 reply with UPDATE lock,
2555 # resend should not create 2nd lock on server
2556 mcreate $DIR/$tfile || error "mcreate failed: $?"
2557 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2559 # 2 BL AST will be sent to client, both must find the same lock,
2560 # race them to not get EINVAL for 2nd BL AST
2561 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2562 $LCTL set_param fail_loc=0x8000031f
2564 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2565 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2566 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2568 # let the client reconnect
2570 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2571 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2573 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2575 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2579 test_mkdir -p $DIR/$tdir
2581 # Prevent interference from layout intent RPCs due to
2582 # asynchronous writeback. These will be tested in 130c below.
2583 do_nodes ${CLIENTS:-$HOSTNAME} sync
2585 # get only LOOKUP lock on $tdir
2586 cancel_lru_locks mdc
2587 ls $DIR/$tdir/$tfile 2>/dev/null
2589 # get getattr by fid on $tdir
2591 # we need to race with unlink, unlink must complete before we will
2592 # take a DLM lock, otherwise unlink will wait until getattr will
2593 # complete; but later than getattr starts so that getattr found
2595 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2596 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2603 # drop the reply so that resend happens on an unlinked file.
2604 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2605 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2609 remote_mds_nodsh && skip "remote MDS with nodsh"
2610 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2611 skip "Need server version newer than 2.7.1"
2615 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2618 run_test 130a "enqueue resend on not existing file"
2621 remote_mds_nodsh && skip "remote MDS with nodsh"
2622 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2623 skip "Need server version newer than 2.7.1"
2626 # let the reply to be dropped
2629 #define OBD_FAIL_SRV_ENOENT 0x217
2630 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2632 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2635 run_test 130b "enqueue resend on a stale inode"
2638 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2640 do_nodes ${CLIENTS:-$HOSTNAME} sync
2641 echo XXX > $DIR/$tfile
2643 cancel_lru_locks mdc
2645 # Trigger writeback on $tfile.
2647 # we need to race with unlink, unlink must complete before we will
2648 # take a DLM lock, otherwise unlink will wait until intent will
2649 # complete; but later than intent starts so that intent found
2651 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2652 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2659 # drop the reply so that resend happens on an unlinked file.
2660 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2661 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2663 # let the reply to be dropped
2666 #define OBD_FAIL_SRV_ENOENT 0x217
2667 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2673 run_test 130c "layout intent resend on a stale inode"
2676 local before=$(date +%s)
2679 mount_client $MOUNT2 || error "mount filed"
2682 # get a lock on client so that export would reach the stale list
2683 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2684 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2687 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2688 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2690 $TRUNCATE $DIR/$tfile 100 &
2693 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2697 umount_client $MOUNT2
2699 evict=$(do_facet client $LCTL get_param \
2700 osc.$FSNAME-OST0000-osc-*/state |
2701 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2703 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2704 (do_facet client $LCTL get_param \
2705 osc.$FSNAME-OST0000-osc-*/state;
2706 error "eviction happened: $evict before:$before")
2708 run_test 132 "long punch"
2711 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2714 # get a lock on client so that export would reach the stale list
2715 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2716 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2718 # another IO under the same lock
2719 #define OBD_FAIL_OSC_DELAY_IO 0x414
2720 $LCTL set_param fail_loc=0x80000414
2721 $LCTL set_param fail_val=4 fail_loc=0x80000414
2722 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2726 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2727 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2731 wait $pid && error "dd succeeded"
2734 run_test 131 "IO vs evict results to IO under staled lock"
2737 local list=$(comma_list $(mdts_nodes))
2739 local t=$((TIMEOUT * 2))
2742 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2744 multiop_bg_pause $DIR/$tfile O_jc || return 1
2747 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2748 do_nodes $list $LCTL set_param fail_loc=0x80000157
2750 echo "waiting for multiop $PID"
2751 wait $PID || return 2
2757 run_test 133 "don't fail on flock resend"
2760 [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
2761 [ $CLIENTCOUNT -lt 2 ] &&
2762 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2764 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2765 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2766 error "touch failed"
2767 zconf_umount_clients $CLIENTS $MOUNT
2768 zconf_mount_clients $CLIENTS $MOUNT
2770 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2771 # assume commit interval is 5
2772 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2774 local -a clients=(${CLIENTS//,/ })
2775 local client1=${clients[0]}
2776 local client2=${clients[1]}
2778 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2780 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2783 wait $rmpid || error "rm failed"
2784 wait $mvpid || error "mv failed"
2787 run_test 134 "race between failover and search for reply data free slot"
2790 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2791 skip "Need MDS version at least 2.12.51"
2794 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2795 # to have parent dir write lock before open/resend
2796 touch $DIR/$tdir/$tfile
2797 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2798 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2799 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2800 error "Failed to open DOM file"
2802 run_test 135 "DOM: open/create resend to return size"
2805 remote_mds_nodsh && skip "remote MDS with nodsh"
2806 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2807 skip "Need MDS version at least 2.12.52"
2809 local mdts=$(comma_list $(mdts_nodes))
2810 local MDT0=$(facet_svc $SINGLEMDS)
2812 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2813 [ -n "$clog" ] || error "changelog_register failed"
2814 cl_mask=$(do_facet mds1 $LCTL get_param \
2815 mdd.$MDT0.changelog_mask -n)
2816 changelog_chmask "ALL"
2818 # generate some changelog records to accumulate
2819 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2820 createmany -m $DIR/$tdir/$tfile 10000 ||
2821 error "create $DIR/$tdir/$tfile failed"
2823 local size1=$(do_facet $SINGLEMDS \
2824 $LCTL get_param -n mdd.$MDT0.changelog_size)
2825 echo "Changelog size $size1"
2827 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2828 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2830 # launch changelog_deregister in background on MDS
2831 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2832 > foo.out 2> foo.err < /dev/null &"
2833 # give time to reach fail_loc
2836 # fail_loc will make MDS sleep in the middle of changelog_deregister
2837 # take this opportunity to abruptly kill MDS
2838 FAILURE_MODE_save=$FAILURE_MODE
2841 FAILURE_MODE=$FAILURE_MODE_save
2843 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2845 local size2=$(do_facet $SINGLEMDS \
2846 $LCTL get_param -n mdd.$MDT0.changelog_size)
2847 echo "Changelog size $size2"
2848 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2849 mdd.$MDT0.changelog_users | grep $clog")
2850 echo "After crash, changelog user $clog2"
2852 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2853 error "changelog record count unchanged"
2855 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2857 run_test 136 "changelog_deregister leaving pending records"
2863 dd if=/dev/zero of=$DIR/d1/$tfile bs=4096 count=1
2864 dd if=/dev/zero of=$DIR/d2/$tfile bs=4096 count=1
2865 cancel_lru_locks osc
2867 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2868 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2870 # RPC1: any reply is to be delayed to disable last_xid logic
2871 ln $DIR/d1/$tfile $DIR/d1/f2 &
2874 # RPC2: setattr1 reply is delayed & resent
2875 # original reply comes to client; the resend get asleep
2876 chmod 666 $DIR/d2/$tfile
2878 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2879 chmod 777 $DIR/d2/$tfile
2881 # RPC2 resend wakes up
2883 [ $(stat -c "%a" $DIR/d2/$tfile) == 777 ] || error "resend got applied"
2885 run_test 137 "late resend must be skipped if already applied"
2888 check_and_cleanup_lustre