5 PTLDEBUG=${PTLDEBUG:--1}
6 LUSTRE=${LUSTRE:-$(dirname $0)/..}
7 . $LUSTRE/tests/test-framework.sh
11 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT "
13 # bug number for skipped test: LU-12896
14 ALWAYS_EXCEPT+=" 110k"
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 selinux_status=$(getenforce)
19 if [ "$selinux_status" != "Disabled" ]; then
20 # bug number for skipped test: LU-12928
21 $SHARED_KEY && ALWAYS_EXCEPT+=" 136"
26 require_dsh_mds || exit 0
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 [[ "$MDS1_VERSION" -lt $(version_code 2.6.53) ]] &&
179 skip "Need MDS version at least 2.6.53"
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 [[ "$MDS1_VERSION" -lt $(version_code 2.6.90) ]] &&
251 skip "Need MDS version at least 2.6.90"
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 [[ "$OST1_VERSION" -le $(version_code 2.8.58) ]] &&
292 skip "Need OST version at least 2.8.59"
293 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients"
294 [ $(facet_host client) == $(facet_host ost1) ] &&
295 skip "need ost1 and client on different nodes"
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 |
1309 grep "went back in time")
1310 [ x"$ERROR" == x ] || error "back in time occured"
1312 run_test 54 "back in time"
1314 # bug 11330 - liblustre application death during I/O locks up OST
1316 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1320 # This test assumes relatively small max_dirty_mb setting
1321 # which we want to walk away from, so just for it we will
1322 # temporarily lower the value
1323 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1324 lctl set_param -n osc.*.max_dirty_mb=32
1325 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1327 # Minimum pass speed is 2MBps
1329 # LU-2887/LU-3089 - set min pass speed to 500KBps
1330 [ "$ost1_FSTYPE" = zfs ] && ddtimeout=256
1332 # first dd should be finished quickly
1333 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1334 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1337 echo "step1: testing ......"
1338 while kill -0 $DDPID 2> /dev/null; do
1340 if [ $count -gt $ddtimeout ]; then
1341 error "dd should be finished!"
1345 echo "(dd_pid=$DDPID, time=$count)successful"
1347 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1348 #define OBD_FAIL_OST_DROP_REQ 0x21d
1349 do_facet ost1 lctl set_param fail_loc=0x0000021d
1350 # second dd will be never finished
1351 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1354 echo "step2: testing ......"
1355 while [ $count -le $ddtimeout ]; do
1356 if ! kill -0 $DDPID 2> /dev/null; then
1358 error "dd shouldn't be finished! (time=$count)"
1363 echo "(dd_pid=$DDPID, time=$count)successful"
1365 #Recover fail_loc and dd will finish soon
1366 do_facet ost1 lctl set_param fail_loc=0
1368 echo "step3: testing ......"
1369 while kill -0 $DDPID 2> /dev/null; do
1371 if [ $count -gt $((ddtimeout + 440)) ]; then
1372 error "dd should be finished!"
1376 echo "(dd_pid=$DDPID, time=$count)successful"
1380 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1382 test_56() { # b=11277
1383 #define OBD_FAIL_MDS_RESEND 0x136
1385 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1386 stat $DIR/$tfile || error "stat failed"
1387 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1390 run_test 56 "do not fail on getattr resend"
1393 # no oscs means no client or mdt
1394 while lctl get_param osc.*.* > /dev/null 2>&1; do
1395 : # loop until proc file is removed
1399 test_57() { # bug 10866
1403 #define OBD_FAIL_LPROC_REMOVE 0xB00
1404 lctl set_param fail_loc=0x80000B00
1405 zconf_umount `hostname` $DIR
1406 lctl set_param fail_loc=0x80000B00
1407 fail_abort $SINGLEMDS
1409 lctl set_param fail_loc=0
1411 do_facet client "df $DIR"
1413 run_test 57 "read procfs entries causes kernel crash"
1415 test_58() { # bug 11546
1416 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1419 lctl set_param fail_loc=0x80000801
1420 cp $DIR/$tfile /dev/null &
1423 lctl set_param fail_loc=0
1424 drop_bl_callback_once rm -f $DIR/$tfile
1426 # the first 'df' could tigger the eviction caused by
1427 # 'drop_bl_callback_once', and it's normal case.
1428 # but the next 'df' should return successfully.
1429 do_facet client "df $DIR" || do_facet client "df $DIR"
1431 run_test 58 "Eviction in the middle of open RPC reply processing"
1433 test_59() { # bug 10589
1434 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1435 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1436 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1437 lctl set_param fail_loc=0x311
1438 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1439 [ $? = 0 ] || error "dd write failed"
1440 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1441 lctl set_param fail_loc=0
1443 zconf_umount `hostname` $MOUNT2 -f
1444 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1445 [ $? = 0 ] || error "dd read failed"
1446 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1447 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1449 run_test 59 "Read cancel race on client eviction"
1452 local num_files=${COUNT:-5000}
1453 test_mkdir $DIR/$tdir
1455 # Register (and start) changelog
1456 changelog_register || error "changelog_register failed"
1458 # Generate a large number of changelog entries
1459 createmany -o $DIR/$tdir/$tfile $num_files
1463 # Unlink files in the background
1464 unlinkmany $DIR/$tdir/$tfile $num_files &
1468 # Failover the MDS while unlinks are happening
1469 facet_failover $SINGLEMDS
1471 # Wait for unlinkmany to finish
1474 # Check if all the create/unlink events were recorded
1476 local cl_count=$(changelog_dump | grep -c UNLNK)
1477 echo "$cl_count unlinks in changelog"
1479 changelog_deregister || error "changelog_deregister failed"
1480 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1481 [ $cl_count -eq $num_files ] ||
1482 error "Recorded $cl_count of $num_files unlinks"
1483 # Also make sure we can clear large changelogs
1484 cl_count=$(changelog_dump | wc -l)
1485 [ $cl_count -le 2 ] ||
1486 error "Changelog not empty: $cl_count entries"
1487 else # If other users, there may be other unlinks in the log
1488 [ $cl_count -ge $num_files ] ||
1489 error "Recorded $cl_count of $num_files unlinks"
1490 changelog_users $SINGLEMDS
1491 echo "other changelog users; can't verify clear"
1494 run_test 60 "Add Changelog entries during MDS failover"
1498 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1499 mdtosc=${mdtosc/-MDT*/-MDT\*}
1500 local cflags="osc.$mdtosc.connect_flags"
1501 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1502 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1504 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1505 # Set the default stripe of $DIR/$tdir to put the files to ost1
1506 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1508 replay_barrier $SINGLEMDS
1509 createmany -o $DIR/$tdir/$tfile-%d 10
1510 local oid=$(do_facet ost1 "lctl get_param -n \
1511 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1513 fail_abort $SINGLEMDS
1515 touch $DIR/$tdir/$tfile
1516 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1517 awk '$1 == 0 { print $2 }')
1518 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1523 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1525 # test_62 as seen it b2_1 please do not reuse test_62
1528 # zconf_umount `hostname` $DIR
1529 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1530 # lctl set_param fail_loc=0x516
1533 #run_test 62 "Verify connection flags race - bug LU-1716"
1538 #grant lock1, export2
1539 $LFS setstripe -i -0 $DIR2/$tfile || error "setstripe failed"
1540 $MULTIOP $DIR2/$tfile Ow || error "multiop failed"
1542 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1543 do_facet ost $LCTL set_param fail_loc=0x31e
1544 #get waiting lock2, export1
1545 $MULTIOP $DIR/$tfile Ow &
1547 # let enqueue to get asleep
1551 $MULTIOP $DIR2/$tfile Ow &
1559 do_facet ost $LCTL set_param fail_loc=0
1566 run_test 65 "lock enqueue for destroyed export"
1570 [[ "$MDS1_VERSION" -ge $(version_code 2.7.51) ]] ||
1571 skip "Need MDS version at least 2.7.51"
1573 local list=$(comma_list $(osts_nodes))
1575 # modify dir so that next revalidate would not obtain UPDATE lock
1578 # drop 1 reply with UPDATE lock
1579 mcreate $DIR/$tfile || error "mcreate failed: $?"
1580 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1583 # make the re-sent lock to sleep
1584 #define OBD_FAIL_MDS_RESEND 0x136
1585 do_nodes $list $LCTL set_param fail_loc=0x80000136
1587 #initiate the re-connect & re-send
1588 local mdtname="MDT0000"
1589 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1590 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1591 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1594 #initiate the client eviction while enqueue re-send is in progress
1600 run_test 66 "lock enqueue re-send vs client eviction"
1604 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1605 $LCTL set_param fail_loc=0x80000531
1607 local mdtname="MDT0000"
1608 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1609 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1610 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1619 run_test 67 "connect vs import invalidate race"
1621 check_cli_ir_state()
1623 local NODE=${1:-$HOSTNAME}
1625 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1626 awk '/imperative_recovery:/ { print \\\$2}'")
1627 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1628 error "Error state $st, must be ENABLED or DISABLED"
1632 check_target_ir_state()
1635 local name=${target}_svc
1636 local recovery_proc=obdfilter.${!name}.recovery_status
1640 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1641 awk '/status:/{ print \\\$2}'")
1642 [ x$st = xRECOVERING ] || break
1644 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1645 awk '/IR:/{ print \\\$2}'")
1646 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1647 error "Error state $st, must be ENABLED or DISABLED"
1653 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1658 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1659 awk '/state:/{ print \\\$2 }'")
1663 nidtbl_version_mgs()
1665 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1666 awk '/nidtbl_version:/{ print \\\$2 }'")
1670 # nidtbl_version_client <mds1|client> [node]
1671 nidtbl_version_client()
1674 local node=${2:-$HOSTNAME}
1676 if [ X$cli = Xclient ]; then
1679 local obdtype=${cli/%[0-9]*/}
1680 [ $obdtype != mds ] && error "wrong parameters $cli"
1682 node=$(facet_active_host $cli)
1687 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1688 awk "/$cli/{print \$6}" |sort -u)
1690 # in case there are multiple mounts on the client node
1692 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1696 nidtbl_versions_match()
1698 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1701 target_instance_match()
1707 obdtype=${srv/%[0-9]*/}
1718 error "invalid target type" $srv
1723 local target=${srv}_svc
1724 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1725 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1726 awk '/instance/{ print $2 }' | head -n1)
1728 return $([ $si -eq $ci ])
1733 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1734 { skip "MGS without IR support"; return 0; }
1736 # MDT was just restarted in the previous test, make sure everything
1739 while [ $cnt -gt 0 ]; do
1740 nidtbl_versions_match && break
1746 set_ir_status disabled
1748 local prev_ver=$(nidtbl_version_client client)
1750 local saved_FAILURE_MODE=$FAILURE_MODE
1751 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1755 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1756 error "version must not change due to IR disabled"
1757 target_instance_match ost1 || error "instance mismatch"
1761 FAILURE_MODE=$saved_FAILURE_MODE
1763 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1767 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1768 skip "MGS without IR support"
1772 local ost1_imp=$(get_osc_import_name client ost1)
1774 # disable pinger recovery
1775 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1776 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1780 target_instance_match ost1 || error "instance mismatch"
1781 nidtbl_versions_match || error "version must match"
1783 run_test 101a "IR: Make sure IR works w/o normal recovery"
1787 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1788 skip "MGS without IR support"
1792 local ost1_imp=$(get_osc_import_name client ost1)
1794 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1795 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1796 # disable pinger recovery
1797 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1798 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1800 #OST may return EAGAIN if it is not configured yet
1803 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1807 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1808 { skip "MGS without IR support"; return 0; }
1810 local clients=${CLIENTS:-$HOSTNAME}
1817 # let's have a new nidtbl version
1820 # sleep for a while so that clients can see the failure of ost
1821 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1822 # int mgc_request.c:
1823 # define MGC_TIMEOUT_MIN_SECONDS 5
1824 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1825 local count=30 # 20 seconds at most
1826 while [ $count -gt 0 ]; do
1827 nidtbl_versions_match && break
1832 nidtbl_versions_match || error "nidtbl mismatch"
1835 old_version=$(nidtbl_version_client client)
1837 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1840 combined_mgs_mds && mgsdev=mds1
1841 remount_facet $mgsdev
1844 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1847 new_version=$(nidtbl_version_client client)
1848 [ $new_version -lt $old_version ] &&
1849 error "nidtbl version wrong after mgs restarts"
1852 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1856 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1857 { skip "MGS without IR support"; return 0; }
1859 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1861 # workaround solution to generate config log on the mds
1867 # We need this test because mds is like a client in IR context.
1868 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1869 error "MDS should start w/o mgs"
1871 # start mgs and remount mds w/ ir
1872 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1875 # remount client so that fsdb will be created on the MGS
1876 umount_client $MOUNT || error "umount failed"
1877 mount_client $MOUNT || error "mount failed"
1879 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1881 while [ $count -gt 0 ]; do
1882 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1887 # after a while, mds should be able to reconnect to mgs and fetch
1888 # up-to-date nidtbl version
1889 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1894 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1898 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1899 { skip "MGS without IR support"; return 0; }
1904 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1905 error "OST1 cannot start"
1908 local ir_state=$(check_target_ir_state ost1)
1909 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1910 error "ir status on ost1 should be DISABLED"
1912 run_test 104 "IR: ost can disable IR voluntarily"
1916 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1917 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1918 { skip "MGS without IR support"; return 0; }
1922 # get one of the clients from client list
1923 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1925 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1926 zconf_umount $rcli $MOUNT || error "umount failed"
1927 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1929 # make sure lustre mount at $rcli disabling IR
1930 local ir_state=$(check_cli_ir_state $rcli)
1931 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1932 error "IR state must be DISABLED at $rcli"
1934 # Since the client just mounted, its last_rcvd entry is not on disk.
1935 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1936 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1937 $LFS setstripe -i 0 $DIR/$tfile
1938 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1940 # make sure MGS's state is Partial
1941 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1944 # make sure IR on ost1 is DISABLED
1945 local ir_state=$(check_target_ir_state ost1)
1946 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1947 error "IR status on ost1 should be DISABLED"
1949 # remount with the default MOUNT_OPTS
1950 zconf_umount $rcli $MOUNT || error "umount failed"
1951 zconf_mount $rcli $MOUNT || error "mount failed"
1953 # make sure MGS's state is full
1954 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1957 # make sure IR on ost1 is ENABLED
1958 local ir_state=$(check_target_ir_state ost1)
1959 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1960 error "IR status on ost1 should be ENABLED"
1964 run_test 105 "IR: NON IR clients support"
1972 test_106() { # LU-1789
1973 [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
1974 skip "Need MDS version at least 2.3.50"
1976 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1977 $LCTL set_param fail_loc=0x805
1980 trap cleanup_106 EXIT
1982 # enable lightweight flag on mdc connection
1985 local MDS_NEXP=$(do_facet $SINGLEMDS \
1986 lctl get_param -n mdt.${mds1_svc}.num_exports |
1988 $LCTL set_param fail_loc=0
1990 touch $DIR2/$tfile || error "failed to create empty file"
1991 replay_barrier $SINGLEMDS
1993 $LCTL set_param debug=ha
1995 facet_failover $SINGLEMDS
1997 # lightweight goes through LUSTRE_IMP_RECOVER during failover
1998 touch -c $DIR2/$tfile || true
1999 $LCTL dk $TMP/lustre-log-$TESTNAME.log
2000 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
2001 $TMP/lustre-log-$TESTNAME.log)
2002 [ -z "$recovered" ] && error "lightweight client was not recovered"
2004 # and all operations performed by lightweight client should be
2005 # synchronous, so the file created before mds restart should be there
2006 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2011 run_test 106 "lightweight connection support"
2018 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2019 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2020 multiop $DIR/$tdir D_c &
2022 mkdir $DIR/$tdir/dir_106 &
2024 do_facet $SINGLEMDS lctl set_param fail_loc=0
2027 wait $CLIENT_PID || rc=$?
2028 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2030 kill -USR1 $close_pid
2031 wait $close_pid || return 2
2035 run_test 107 "drop reint reply, then restart MDT"
2039 $LFS setstripe -c 1 -i 0 $DIR/$tdir
2041 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2049 client_up || error "reconnect failed"
2050 rm -f $DIR/$tdir/$tfile
2052 run_test 108 "client eviction don't crash"
2055 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2056 local remote_dir=$DIR/$tdir/remote_dir
2060 #prepare for 110 test, which need set striped dir on remote MDT.
2061 for num in $(seq $MDSCOUNT); do
2063 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2068 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2069 error "lfs mkdir failed"
2070 local diridx=$($LFS getstripe -m $remote_dir)
2071 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2073 rm -rf $DIR/$tdir || error "rmdir failed"
2075 run_test 110a "create remote directory: drop client req"
2078 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2079 local remote_dir=$DIR/$tdir/remote_dir
2083 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2084 error "lfs mkdir failed"
2086 diridx=$($LFS getstripe -m $remote_dir)
2087 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2089 rm -rf $DIR/$tdir || error "rmdir failed"
2091 run_test 110b "create remote directory: drop Master rep"
2094 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2095 local remote_dir=$DIR/$tdir/remote_dir
2099 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2100 error "lfs mkdir failed"
2102 diridx=$($LFS getstripe -m $remote_dir)
2103 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2105 rm -rf $DIR/$tdir || error "rmdir failed"
2107 run_test 110c "create remote directory: drop update rep on slave MDT"
2110 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2111 local remote_dir=$DIR/$tdir/remote_dir
2115 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2117 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2119 rm -rf $DIR/$tdir || error "rmdir failed"
2123 run_test 110d "remove remote directory: drop client req"
2126 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2127 local remote_dir=$DIR/$tdir/remote_dir
2131 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2132 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2134 rm -rf $DIR/$tdir || error "rmdir failed"
2138 run_test 110e "remove remote directory: drop master rep"
2141 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2142 local remote_dir=$DIR/$tdir/remote_dir
2146 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2147 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2148 error "rm remote dir failed"
2150 rm -rf $DIR/$tdir || error "rmdir failed"
2152 run_test 110f "remove remote directory: drop slave rep"
2155 [[ "$MDS1_VERSION" -ge $(version_code 2.11.0) ]] ||
2156 skip "Need MDS version at least 2.11.0"
2158 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2161 touch $DIR/$tdir/$tfile
2163 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2164 do_facet mds1 $LCTL set_param fail_loc=0x119
2165 $LFS migrate -m 1 $DIR/$tdir &
2168 do_facet mds1 $LCTL set_param fail_loc=0
2172 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2173 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2174 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2175 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2177 rm -rf $DIR/$tdir || error "rmdir failed"
2179 run_test 110g "drop reply during migration"
2182 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2183 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2184 skip "Need MDS version at least 2.7.56"
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"
2210 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2211 skip "Need MDS version at least 2.7.56"
2213 local src_dir=$DIR/$tdir/source_dir
2214 local tgt_dir=$DIR/$tdir/target_dir
2218 $LFS mkdir -i $MDTIDX $tgt_dir
2220 mkdir $src_dir/src_dir
2221 touch $src_dir/src_dir/a
2222 mkdir $tgt_dir/tgt_dir
2223 drop_update_reply $MDTIDX \
2224 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2225 error "mrename failed"
2227 $CHECKSTAT -t dir $src_dir/src_dir &&
2228 error "src_dir present after rename"
2230 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2231 error "tgt_dir not present after rename"
2233 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2234 error "a not present after rename"
2236 run_test 110i "drop update reply during cross-MDT dir rename"
2239 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
2240 [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
2241 skip "Need MDS version at least 2.7.56"
2243 local remote_dir=$DIR/$tdir/remote_dir
2244 local local_dir=$DIR/$tdir/local_dir
2248 mkdir $DIR/$tdir/local_dir
2249 $LFS mkdir -i $MDTIDX $remote_dir
2251 touch $local_dir/local_file
2252 drop_update_reply $MDTIDX \
2253 "ln $local_dir/local_file $remote_dir/remote_file" ||
2256 $CHECKSTAT -t file $remote_dir/remote_file ||
2257 error "remote not present after ln"
2259 run_test 110j "drop update reply during cross-MDT ln"
2262 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTS"
2263 [[ "$MDS1_VERSION" -ge $(version_code 2.12.55) ]] ||
2264 skip "Need MDS version at least 2.12.55"
2266 stop mds2 || error "stop mds2 failed"
2269 #define OBD_FAIL_FLD_QUERY_REQ 0x1103
2270 do_facet mds2 lctl set_param fail_loc=0x1103
2271 start mds2 $(mdsdevname 2) -o abort_recovery ||
2272 error "start MDS with abort_recovery should succeed"
2273 do_facet mds2 lctl set_param fail_loc=0
2276 stop mds2 || error "cleanup: stop mds2 failed"
2277 start mds2 $(mdsdevname 2) || error "cleanup: start mds2 failed"
2278 zconf_mount $(hostname) $MOUNT || error "cleanup: mount failed"
2279 client_up || error "post-failover df failed"
2281 run_test 110k "FID_QUERY failed during recovery"
2283 # LU-2844 mdt prepare fail should not cause umount oops
2286 [[ "$MDS1_VERSION" -ge $(version_code 2.3.62) ]] ||
2287 skip "Need MDS version at least 2.3.62"
2289 #define OBD_FAIL_MDS_CHANGELOG_INIT 0x151
2290 do_facet $SINGLEMDS lctl set_param fail_loc=0x151
2291 stop $SINGLEMDS || error "stop MDS failed"
2292 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
2293 error "start MDS should fail"
2294 do_facet $SINGLEMDS lctl set_param fail_loc=0
2295 start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) ||
2296 error "start MDS failed"
2298 run_test 111 "mdd setup fail should not cause umount oops"
2302 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2304 do_facet_random_file client $TMP/$tfile 100K ||
2305 error_noexit "Create random file $TMP/$tfile"
2307 pause_bulk "cp $TMP/$tfile $DIR/$tfile" $TIMEOUT ||
2308 error_noexit "Can't pause_bulk copy"
2311 # expect cmp to succeed, client resent bulk
2312 cmp $TMP/$tfile $DIR/$tfile ||
2313 error_noexit "Wrong data has been written"
2315 error_noexit "Can't remove file"
2318 run_test 112a "bulk resend while orignal request is in progress"
2325 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
2326 cancel_lru_locks osc
2329 $LCTL set_param fail_loc=$fail1 fail_val=3
2330 dd of=/dev/null if=$DIR/$tfile bs=4096 count=1 &
2334 set_nodes_failloc "$(osts_nodes)" $fail2
2336 wait $pid || error "dd failed"
2344 local fail_val2=${4:-0}
2350 $LCTL set_param fail_loc=$fail1 fail_val=4
2351 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 oflag=dsync &
2356 set_nodes_failloc "$(osts_nodes)" $fail2 $fail_val2
2360 [ $error -eq 0 ] && [ $rc -ne 0 ] && error "dd error ($rc)"
2361 [ $error -ne 0 ] && [ $rc -eq 0 ] && error "dd success"
2366 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2367 skip "need at least 2.8.50 on OST"
2369 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2370 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2371 test_115_read 0x8000051b 0x8000051a
2373 run_test 115a "read: late REQ MDunlink and no bulk"
2376 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2377 skip "need at least 2.8.50 on OST"
2379 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2380 #define OBD_FAIL_OST_ENOSPC 0x215
2382 # pass $OSTCOUNT for the fail_loc to be caught
2383 # appropriately by the IO thread
2384 test_115_write 0x8000051b 0x80000215 1 $OSTCOUNT
2386 run_test 115b "write: late REQ MDunlink and no bulk"
2389 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2390 skip "need at least 2.8.50 on OST"
2392 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2393 #define OBD_FAIL_PTLRPC_DROP_BULK 0x51a
2394 test_115_read 0x8000050f 0x8000051a
2396 run_test 115c "read: late Reply MDunlink and no bulk"
2399 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2400 skip "need at least 2.8.50 on OST"
2402 #define OBD_FAIL_PTLRPC_LONG_REPL_UNLINK 0x50f
2403 #define OBD_FAIL_OST_ENOSPC 0x215
2404 test_115_write 0x8000050f 0x80000215 0
2406 run_test 115d "write: late Reply MDunlink and no bulk"
2409 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2410 skip "need at least 2.8.50 on OST"
2412 #define OBD_FAIL_PTLRPC_LONG_BULK_UNLINK 0x510
2413 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2414 test_115_read 0x80000510 0x80000211
2416 run_test 115e "read: late Bulk MDunlink and no reply"
2419 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2420 skip "need at least 2.8.50 on OST"
2422 #define OBD_FAIL_PTLRPC_LONG_REQ_UNLINK 0x51b
2423 #define OBD_FAIL_OST_ALL_REPLY_NET 0x211
2424 test_115_read 0x8000051b 0x80000211
2426 run_test 115f "read: late REQ MDunlink and no reply"
2429 [ "$OST1_VERSION" -lt $(version_code 2.8.50) ] &&
2430 skip "need at least 2.8.50 on OST"
2432 #define OBD_FAIL_PTLRPC_LONG_BOTH_UNLINK 0x51c
2433 test_115_read 0x8000051c 0
2435 run_test 115g "read: late REQ MDunlink and Reply MDunlink"
2437 # parameters: fail_loc CMD RC
2444 #define OBD_FAIL_LDLM_CP_CB_WAIT2 0x320
2445 #define OBD_FAIL_LDLM_CP_CB_WAIT3 0x321
2446 #define OBD_FAIL_LDLM_CP_CB_WAIT4 0x322
2447 #define OBD_FAIL_LDLM_CP_CB_WAIT5 0x323
2450 echo -n "** FLOCK REPLY vs. EVICTION race, lock $2"
2451 [ "$1" = "CLEANUP" ] &&
2452 fail=0x80000320 && echo ", $1 cp first"
2453 [ "$1" = "REPLY" ] &&
2454 fail=0x80000321 && echo ", $1 cp first"
2455 [ "$1" = "DEADLOCK CLEANUP" ] &&
2456 fail=0x80000322 && echo " DEADLOCK, CLEANUP cp first"
2457 [ "$1" = "DEADLOCK REPLY" ] &&
2458 fail=0x80000323 && echo " DEADLOCK, REPLY cp first"
2460 if [ x"$2" = x"get" ]; then
2461 #for TEST lock, take a conflict in advance
2462 # sleep longer than evictor to not confuse fail_loc: 2+2+4
2463 echo "** Taking conflict **"
2464 flocks_test 5 set read sleep 10 $DIR/$tfile &
2470 $LCTL set_param fail_loc=$fail
2472 flocks_test 5 $2 write $DIR/$tfile &
2476 echo "** Evicting and re-connecting client **"
2481 if [ x"$2" = x"get" ]; then
2488 # check if the return value is allowed
2489 [ $rc -eq $3 ] && rc=0
2491 $LCTL set_param fail_loc=0
2495 # a lock is taken, unlock vs. cleanup_resource() race for destroying
2496 # the ORIGINAL lock.
2501 flocks_test 5 set write sleep 4 $DIR/$tfile &
2505 # let unlock to sleep in CP CB
2506 $LCTL set_param fail_loc=$1
2509 # let cleanup to cleep in CP CB
2517 $LCTL set_param fail_loc=0
2522 flock_is_enabled || { skip "mount w/o flock enabled" && return; }
2525 test_120_reply "CLEANUP" set 5 || error "SET race failed"
2526 test_120_reply "CLEANUP" get 5 || error "GET race failed"
2527 test_120_reply "CLEANUP" unlock 5 || error "UNLOCK race failed"
2529 test_120_reply "REPLY" set 5 || error "SET race failed"
2530 test_120_reply "REPLY" get 5 || error "GET race failed"
2531 test_120_reply "REPLY" unlock 5 || error "UNLOCK race failed"
2534 test_120_reply "DEADLOCK CLEANUP" set 5 || error "DEADLOCK race failed"
2535 test_120_reply "DEADLOCK REPLY" set 35 || error "DEADLOCK race failed"
2537 test_120_destroy 0x320 || error "unlock-cleanup race failed"
2539 run_test 120 "flock race: completion vs. evict"
2542 local BEFORE=$(date +%s)
2545 # modify dir so that next revalidate would not obtain UPDATE lock
2548 # drop 1 reply with UPDATE lock,
2549 # resend should not create 2nd lock on server
2550 mcreate $DIR/$tfile || error "mcreate failed: $?"
2551 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" || error "stat failed: $?"
2553 # 2 BL AST will be sent to client, both must find the same lock,
2554 # race them to not get EINVAL for 2nd BL AST
2555 #define OBD_FAIL_LDLM_PAUSE_CANCEL2 0x31f
2556 $LCTL set_param fail_loc=0x8000031f
2558 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0 > /dev/null
2559 chmod 0777 $DIR/$tfile || error "chmod failed: $?"
2560 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1 > /dev/null
2562 # let the client reconnect
2564 EVICT=$($LCTL get_param mdc.$FSNAME-MDT*.state |
2565 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
2567 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
2569 run_test 113 "ldlm enqueue dropped reply should not cause deadlocks"
2573 test_mkdir -p $DIR/$tdir
2575 # Prevent interference from layout intent RPCs due to
2576 # asynchronous writeback. These will be tested in 130c below.
2577 do_nodes ${CLIENTS:-$HOSTNAME} sync
2579 # get only LOOKUP lock on $tdir
2580 cancel_lru_locks mdc
2581 ls $DIR/$tdir/$tfile 2>/dev/null
2583 # get getattr by fid on $tdir
2585 # we need to race with unlink, unlink must complete before we will
2586 # take a DLM lock, otherwise unlink will wait until getattr will
2587 # complete; but later than getattr starts so that getattr found
2589 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2590 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2597 # drop the reply so that resend happens on an unlinked file.
2598 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2599 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2603 remote_mds_nodsh && skip "remote MDS with nodsh"
2604 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2605 skip "Need server version newer than 2.7.1"
2609 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2612 run_test 130a "enqueue resend on not existing file"
2615 remote_mds_nodsh && skip "remote MDS with nodsh"
2616 [[ "$MDS1_VERSION" -ge $(version_code 2.7.2) ]] ||
2617 skip "Need server version newer than 2.7.1"
2620 # let the reply to be dropped
2623 #define OBD_FAIL_SRV_ENOENT 0x217
2624 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2626 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2629 run_test 130b "enqueue resend on a stale inode"
2632 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2634 do_nodes ${CLIENTS:-$HOSTNAME} sync
2635 echo XXX > $DIR/$tfile
2637 cancel_lru_locks mdc
2639 # Trigger writeback on $tfile.
2641 # we need to race with unlink, unlink must complete before we will
2642 # take a DLM lock, otherwise unlink will wait until intent will
2643 # complete; but later than intent starts so that intent found
2645 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2646 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2653 # drop the reply so that resend happens on an unlinked file.
2654 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2655 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2657 # let the reply to be dropped
2660 #define OBD_FAIL_SRV_ENOENT 0x217
2661 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2667 run_test 130c "layout intent resend on a stale inode"
2670 local before=$(date +%s)
2673 mount_client $MOUNT2 || error "mount filed"
2676 # get a lock on client so that export would reach the stale list
2677 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2678 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2681 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2682 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2684 $TRUNCATE $DIR/$tfile 100 &
2687 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2691 umount_client $MOUNT2
2693 evict=$(do_facet client $LCTL get_param \
2694 osc.$FSNAME-OST0000-osc-*/state |
2695 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2697 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2698 (do_facet client $LCTL get_param \
2699 osc.$FSNAME-OST0000-osc-*/state;
2700 error "eviction happened: $evict before:$before")
2702 run_test 132 "long punch"
2705 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2708 # get a lock on client so that export would reach the stale list
2709 $LFS setstripe -i 0 $DIR/$tfile || error "setstripe failed"
2710 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2712 # another IO under the same lock
2713 #define OBD_FAIL_OSC_DELAY_IO 0x414
2714 $LCTL set_param fail_loc=0x80000414
2715 $LCTL set_param fail_val=4 fail_loc=0x80000414
2716 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2720 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2721 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2725 wait $pid && error "dd succeeded"
2728 run_test 131 "IO vs evict results to IO under staled lock"
2731 local list=$(comma_list $(mdts_nodes))
2733 local t=$((TIMEOUT * 2))
2736 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2738 multiop_bg_pause $DIR/$tfile O_jc || return 1
2741 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2742 do_nodes $list $LCTL set_param fail_loc=0x80000157
2744 echo "waiting for multiop $PID"
2745 wait $PID || return 2
2751 run_test 133 "don't fail on flock resend"
2754 [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
2755 [ $CLIENTCOUNT -lt 2 ] &&
2756 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2758 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2759 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2760 error "touch failed"
2761 zconf_umount_clients $CLIENTS $MOUNT
2762 zconf_mount_clients $CLIENTS $MOUNT
2764 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2765 # assume commit interval is 5
2766 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2768 local -a clients=(${CLIENTS//,/ })
2769 local client1=${clients[0]}
2770 local client2=${clients[1]}
2772 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2774 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2777 wait $rmpid || error "rm failed"
2778 wait $mvpid || error "mv failed"
2781 run_test 134 "race between failover and search for reply data free slot"
2784 [ "$MDS1_VERSION" -lt $(version_code 2.12.51) ] &&
2785 skip "Need MDS version at least 2.12.51"
2788 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2789 # to have parent dir write lock before open/resend
2790 touch $DIR/$tdir/$tfile
2791 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2792 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2793 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2794 error "Failed to open DOM file"
2796 run_test 135 "DOM: open/create resend to return size"
2799 remote_mds_nodsh && skip "remote MDS with nodsh"
2800 [[ "$MDS1_VERSION" -ge $(version_code 2.12.52) ]] ||
2801 skip "Need MDS version at least 2.12.52"
2803 local mdts=$(comma_list $(mdts_nodes))
2804 local MDT0=$(facet_svc $SINGLEMDS)
2806 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2807 [ -n "$clog" ] || error "changelog_register failed"
2808 cl_mask=$(do_facet mds1 $LCTL get_param \
2809 mdd.$MDT0.changelog_mask -n)
2810 changelog_chmask "ALL"
2812 # generate some changelog records to accumulate
2813 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2814 createmany -m $DIR/$tdir/$tfile 10000 ||
2815 error "create $DIR/$tdir/$tfile failed"
2817 local size1=$(do_facet $SINGLEMDS \
2818 $LCTL get_param -n mdd.$MDT0.changelog_size)
2819 echo "Changelog size $size1"
2821 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2822 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2824 # launch changelog_deregister in background on MDS
2825 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2826 > foo.out 2> foo.err < /dev/null &"
2827 # give time to reach fail_loc
2830 # fail_loc will make MDS sleep in the middle of changelog_deregister
2831 # take this opportunity to abruptly kill MDS
2832 FAILURE_MODE_save=$FAILURE_MODE
2835 FAILURE_MODE=$FAILURE_MODE_save
2837 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2839 local size2=$(do_facet $SINGLEMDS \
2840 $LCTL get_param -n mdd.$MDT0.changelog_size)
2841 echo "Changelog size $size2"
2842 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2843 mdd.$MDT0.changelog_users | grep $clog")
2844 echo "After crash, changelog user $clog2"
2846 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2847 error "changelog record count unchanged"
2849 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2851 run_test 136 "changelog_deregister leaving pending records"
2857 dd if=/dev/zero of=$DIR/d1/$tfile bs=4096 count=1
2858 dd if=/dev/zero of=$DIR/d2/$tfile bs=4096 count=1
2859 cancel_lru_locks osc
2861 #define OBD_FAIL_PTLRPC_RESEND_RACE 0x525
2862 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000525"
2864 # RPC1: any reply is to be delayed to disable last_xid logic
2865 ln $DIR/d1/$tfile $DIR/d1/f2 &
2868 # RPC2: setattr1 reply is delayed & resent
2869 # original reply comes to client; the resend get asleep
2870 chmod 666 $DIR/d2/$tfile
2872 # RPC3: setattr2 on the same file; run ahead of RPC2 resend
2873 chmod 777 $DIR/d2/$tfile
2875 # RPC2 resend wakes up
2877 [ $(stat -c "%a" $DIR/d2/$tfile) == 777 ] || error "resend got applied"
2879 run_test 137 "late resend must be skipped if already applied"
2882 check_and_cleanup_lustre