5 export MULTIOP=${MULTIOP:-multiop}
6 PTLDEBUG=${PTLDEBUG:--1}
7 LUSTRE=${LUSTRE:-`dirname $0`/..}
8 . $LUSTRE/tests/test-framework.sh
10 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
13 ALWAYS_EXCEPT="$RECOVERY_SMALL_EXCEPT "
14 # bug number for skipped test:
16 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
18 require_dsh_mds || exit 0
20 # also long tests: 19, 21a, 21e, 21f, 23, 27
22 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
26 # Allow us to override the setup if we already have a mounted system by
27 # setting SETUP=" " and CLEANUP=" "
29 CLEANUP=${CLEANUP:-""}
31 check_and_setup_lustre
34 rm -rf $DIR/d[0-9]* $DIR/f.${TESTSUITE}*
37 local f1="$DIR/$tfile"
38 local f2="$DIR/$tfile.2"
40 drop_request "mcreate $f1" ||
41 error_noexit "create '$f1': drop req"
43 drop_reint_reply "mcreate $f2" ||
44 error_noexit "create '$f2': drop rep"
46 drop_request "tchmod 111 $f2" ||
47 error_noexit "chmod '$f2': drop req"
49 drop_reint_reply "tchmod 666 $f2" ||
50 error_noexit "chmod '$f2': drop rep"
52 drop_request "statone $f2" ||
53 error_noexit "stat '$f2': drop req"
55 drop_reply "statone $f2" ||
56 error_noexit "stat '$f2': drop rep"
58 run_test 1 "create, chmod, stat: drop req, drop rep"
62 do_facet_create_file client $t 10K ||
63 error_noexit "Create file $t"
65 drop_request "cat $t > /dev/null" ||
66 error_noexit "Open request for $t file"
68 drop_reply "cat $t > /dev/null" ||
69 error_noexit "Open replay for $t file"
71 run_test 4 "open: drop req, drop rep"
76 local RR="$T-renamed-again"
77 do_facet_create_file client $T 10K ||
78 error_noexit "Create file $T"
80 drop_request "mv $T $R" ||
81 error_noexit "Rename $T"
83 drop_reint_reply "mv $R $RR" ||
84 error_noexit "Failed rename replay on $R"
86 do_facet client "checkstat -v $RR" ||
87 error_noexit "checkstat error on $RR"
89 do_facet client "rm $RR" ||
90 error_noexit "Can't remove file $RR"
92 run_test 5 "rename: drop req, drop rep"
96 local LINK1=$DIR/$tfile.link1
97 local LINK2=$DIR/$tfile.link2
99 do_facet_create_file client $T 10K ||
100 error_noexit "Create file $T"
102 drop_request "mlink $T $LINK1" ||
103 error_noexit "mlink request for $T"
105 drop_reint_reply "mlink $T $LINK2" ||
106 error_noexit "mlink reply for $T"
108 drop_request "munlink $LINK1" ||
109 error_noexit "munlink request for $T"
111 drop_reint_reply "munlink $LINK2" ||
112 error_noexit "munlink reply for $T"
114 do_facet client "rm $T" ||
115 error_noexit "Can't remove file $T"
117 run_test 6 "link, unlink: drop req, drop rep"
121 drop_reint_reply "touch $DIR/$tfile" || return 1
123 run_test 8 "touch: drop rep (bug 1423)"
127 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
131 do_facet_random_file client $TMP/$tfile 1K ||
132 error_noexit "Create random file $TMP/$tfile"
133 # make this big, else test 9 doesn't wait for bulk -- bz 5595
134 do_facet_create_file client $TMP/$t1 4M ||
135 error_noexit "Create file $TMP/$t1"
136 do_facet client "cp $TMP/$t1 $DIR/$t1" ||
137 error_noexit "Can't copy to $DIR/$t1 file"
138 pause_bulk "cp $TMP/$tfile $DIR/$tfile" ||
139 error_noexit "Can't pause_bulk copy"
140 do_facet client "cp $TMP/$t1 $DIR/$t2" ||
141 error_noexit "Can't copy file"
142 do_facet client "sync"
143 do_facet client "rm $DIR/$tfile $DIR/$t2 $DIR/$t1" ||
144 error_noexit "Can't remove files"
145 do_facet client "rm $TMP/$t1 $TMP/$tfile"
147 run_test 9 "pause bulk on OST (bug 1420)"
151 local before=$(date +%s)
154 do_facet client "stat $DIR > /dev/null" ||
155 error "failed to stat $DIR: $?"
156 drop_bl_callback "chmod 0777 $DIR" ||
157 error "failed to chmod $DIR: $?"
159 # let the client reconnect
161 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
162 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
163 [ ! -z "$evict" ] && [[ $evict -gt $before ]] ||
164 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
165 error "no eviction: $evict before:$before")
167 do_facet client checkstat -v -p 0777 $DIR ||
168 error "client checkstat failed: $?"
170 run_test 10a "finish request on server after client eviction (bug 1521)"
173 local before=$(date +%s)
176 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.53) ]] &&
177 skip "Need MDS version at least 2.6.53" && return
178 do_facet client "stat $DIR > /dev/null" ||
179 error "failed to stat $DIR: $?"
180 drop_bl_callback_once "chmod 0777 $DIR" ||
181 error "failed to chmod $DIR: $?"
183 # let the client reconnect
185 evict=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
186 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
188 [ -z "$evict" ] || [[ $evict -le $before ]] ||
189 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
190 error "eviction happened: $evict before:$before")
192 do_facet client checkstat -v -p 0777 $DIR ||
193 error "client checkstat failed: $?"
195 run_test 10b "re-send BL AST"
198 local before=$(date +%s)
207 workdir="${DIR}/${tdir}"
208 mkdir -p ${workdir} || error "can't create workdir $?"
209 stat ${workdir} > /dev/null ||
210 error "failed to stat ${workdir}: $?"
211 mdtidx=$($LFS getdirstripe -i ${workdir})
212 mdtname=$($LFS mdts ${workdir} | grep -e "^$mdtidx:" |
213 awk '{sub("_UUID", "", $2); print $2;}')
215 mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
216 conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
217 mdcpath="mdc.${mdccli}.import=connection=${conn_uuid}"
219 drop_bl_callback_once "chmod 0777 ${workdir}" &
224 # force client reconnect
225 $LCTL set_param "${mdcpath}"
227 # wait client reconnect
231 evict=$($LCTL get_param mdc.${mdccli}.state |
232 awk -F"[ [,]" '/EVICTED]$/ { if (t<$4) {t=$4;} } END { print t }')
234 [[ $evict -le $before ]] ||
235 ( $LCTL get_param mdc.$FSNAME-MDT*.state;
236 error "eviction happened: $EVICT before:$BEFORE" )
238 [ $rc -eq 0 ] || error "chmod must finished OK"
239 checkstat -v -p 0777 "${workdir}" ||
240 error "client checkstat failed: $?"
242 run_test 10c "re-send BL AST vs reconnect race (LU-5569)"
245 local before=$(date +%s)
248 [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.90) ]] &&
249 skip "Need MDS version at least 2.6.90" && return
251 # sleep 1 is to make sure that BEFORE is not equal to EVICTED below
254 echo -n ", world" | dd of=$TMP/$tfile bs=1c seek=5
256 remount_client $MOUNT
260 $LFS setstripe -i 0 -c 1 $DIR1/$tfile
261 echo -n hello | dd of=$DIR1/$tfile bs=5
263 stat $DIR2/$tfile >& /dev/null
264 $LCTL set_param fail_err=71
265 drop_bl_callback "echo -n \\\", world\\\" >> $DIR2/$tfile"
270 cmp -l $DIR1/$tfile $DIR2/$tfile || error "file contents differ"
271 cmp -l $DIR1/$tfile $TMP/$tfile || error "wrong content found"
273 evict=$(do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state | \
275 awk -F"[ [,]" '/EVICTED$/ { if (mx<$1) {mx=$1;} } END { print mx }')
277 [[ $evict -gt $before ]] ||
278 (do_facet client $LCTL get_param osc.$FSNAME-OST0000*.state;
279 error "no eviction: $evict before:$before")
281 $LCTL set_param fail_err=0
283 umount_client $MOUNT2
285 run_test 10d "test failed blocking ast"
289 [[ $(lustre_version_code ost1) -le $(version_code 2.8.58) ]] &&
290 skip "Need OST version at least 2.8.59" && return 0
291 [ $CLIENTCOUNT -lt 2 ] && skip "need two clients" && return 0
292 [ $(facet_host client) == $(facet_host ost1) ] &&
293 skip "need ost1 and client on different nodes" && return 0
294 local -a clients=(${CLIENTS//,/ })
295 local client1=${clients[0]}
296 local client2=${clients[1]}
298 $LFS setstripe -c 1 -i 0 $DIR/$tfile-1 $DIR/$tfile-2
299 $MULTIOP $DIR/$tfile-1 Ow1048576c
301 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
302 $LCTL set_param fail_loc=0x80000305
304 #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
305 do_facet ost1 "$LCTL set_param fail_loc=0x1000030e"
306 # hit OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT twice:
307 # 1. to return ENOTCONN from ldlm_handle_enqueue0
308 # 2. to pause reconnect handling between resend and setting
309 # import to LUSTRE_IMP_FULL state
310 do_facet ost1 "$LCTL set_param fail_val=3"
312 # client1 fails ro respond to bl ast
313 do_node $client2 "$MULTIOP $DIR/$tfile-1 Ow1048576c" &
316 # ost1 returns error on enqueue, which causes client1 to reconnect
317 do_node $client1 "$MULTIOP $DIR/$tfile-2 Ow1048576c" ||
318 error "multiop failed"
321 do_facet ost1 "$LCTL set_param fail_loc=0"
322 do_facet ost1 "$LCTL set_param fail_val=0"
324 run_test 10e "re-send BL AST vs reconnect race 2"
327 # wake up a thread waiting for completion after eviction
329 do_facet client $MULTIOP $DIR/$tfile Ow ||
330 { error "multiop write failed: $?"; return 1; }
331 do_facet client $MULTIOP $DIR/$tfile or ||
332 { error "multiop read failed: $?"; return 2; }
336 do_facet client $MULTIOP $DIR/$tfile or ||
337 { error "multiop read failed: $?"; return 3; }
338 drop_bl_callback_once $MULTIOP $DIR/$tfile Ow ||
339 echo "evicted as expected"
341 do_facet client munlink $DIR/$tfile ||
342 { error "munlink failed: $?"; return 4; }
343 # allow recovery to complete
344 client_up || client_up || sleep $TIMEOUT
346 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
350 $LCTL mark $MULTIOP $DIR/$tfile OS_c
351 do_facet $SINGLEMDS "lctl set_param fail_loc=0x115"
352 clear_failloc $SINGLEMDS $((TIMEOUT * 2)) &
353 multiop_bg_pause $DIR/$tfile OS_c ||
354 { error "multiop failed: $?"; return 1; }
356 #define OBD_FAIL_MDS_CLOSE_NET 0x115
358 echo "waiting for multiop $PID"
359 wait $PID || { error "wait for multiop faile: $?"; return 2; }
360 do_facet client munlink $DIR/$tfile ||
361 { error "client munlink failed: $?"; return 3; }
362 # allow recovery to complete
363 client_up || client_up || sleep $TIMEOUT
365 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
367 # Bug 113, check that readdir lost recv timeout works.
369 mkdir -p $DIR/$tdir || { error "mkdir failed: $?"; return 1; }
370 touch $DIR/$tdir/newentry || { error "touch failed: $?"; return 2; }
371 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
372 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000104"
373 ls $DIR/$tdir || { error "ls failed: $?"; return 3; }
374 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
375 rm -rf $DIR/$tdir || { error "remove test dir failed: $?"; return 4; }
377 run_test 13 "mdc_readpage restart test (bug 1138)"
379 # Bug 113, check that readdir lost send timeout works.
382 touch $DIR/$tdir/newentry
383 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
384 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000106"
385 ls $DIR/$tdir || return 1
386 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
388 run_test 14 "mdc_readpage resend test (bug 1138)"
391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
392 touch $DIR/$tfile && return 1
395 run_test 15 "failed open (-ENOMEM)"
397 READ_AHEAD=`lctl get_param -n llite.*.max_read_ahead_mb | head -n 1`
399 lctl set_param -n llite.*.max_read_ahead_mb 0
403 lctl set_param -n llite.*.max_read_ahead_mb $READ_AHEAD
407 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
409 do_facet_random_file client $TMP/$tfile 100K ||
410 { error_noexit "Create random file $TMP/$T" ; return 0; }
411 do_facet client "cp $TMP/$tfile $DIR/$tfile" ||
412 { error_noexit "Copy to $DIR/$tfile file" ; return 0; }
416 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
417 do_facet ost1 "lctl set_param fail_loc=0x80000504"
419 # OST bulk will time out here, client resends
420 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 1
421 do_facet ost1 lctl set_param fail_loc=0
422 # give recovery a chance to finish (shouldn't take long)
424 do_facet client "cmp $TMP/$tfile $DIR/$tfile" || return 2
428 run_test 16 "timeout bulk put, don't evict client (2732)"
433 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
435 local SAMPLE_FILE=$TMP/$tfile
436 do_facet_random_file client $SAMPLE_FILE 20K ||
437 { error_noexit "Create random file $SAMPLE_FILE" ; return 0; }
439 # With adaptive timeouts, bulk_get won't expire until adaptive_timeout_max
440 if at_is_enabled; then
441 at_max_saved=$(at_max_get ost1)
442 at_max_set $TIMEOUT ost1
445 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
446 # OST bulk will time out here, client retries
447 do_facet ost1 lctl set_param fail_loc=0x80000503
448 # need to ensure we send an RPC
449 do_facet client cp $SAMPLE_FILE $DIR/$tfile
452 # with AT, client will wait adaptive_max*factor+net_latency before
453 # expiring the req, hopefully timeout*2 is enough
454 sleep $(($TIMEOUT*2))
456 do_facet ost1 lctl set_param fail_loc=0
457 do_facet client "df $DIR"
458 # expect cmp to succeed, client resent bulk
459 do_facet client "cmp $SAMPLE_FILE $DIR/$tfile" || return 3
460 do_facet client "rm $DIR/$tfile" || return 4
461 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
464 run_test 17a "timeout bulk get, don't evict client (2732)"
467 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
469 # get one of the clients from client list
470 local rcli=$(echo $RCLIENTS | cut -d ' ' -f 1)
471 local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
472 local ldlm_enqueue_min=$(do_facet ost1 find /sys -name ldlm_enqueue_min)
473 [ -z "$ldlm_enqueue_min" ] &&
474 skip "missing /sys/.../ldlm_enqueue_min" && return 0
476 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/$tfile ||
477 error "setstripe failed"
478 $LFS setstripe -i 0 -c 1 -S 1048576 $DIR/${tfile}2 ||
479 error "setstripe 2 failed"
481 save_lustre_params ost1 "at_history" > $p
482 save_lustre_params ost1 "bulk_timeout" >> $p
483 local dev="${FSNAME}-OST0000"
484 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
485 local ldlm_enqueue_min_save=$(do_facet ost1 cat $ldlm_enqueue_min)
487 local new_at_history=15
489 do_facet ost1 "$LCTL set_param at_history=$new_at_history"
490 do_facet ost1 "$LCTL set_param bulk_timeout=30"
491 do_facet ost1 "echo 30 > /sys/module/ptlrpc/parameters/ldlm_enqueue_min"
493 # brw_size is required to be 4m so that bulk transfer timeout
494 # could be simulated with OBD_FAIL_PTLRPC_CLIENT_BULK_CB3
495 local brw_size=$($LCTL get_param -n \
496 osc.$FSNAME-OST0000-osc-[^M]*.import |
497 awk '/max_brw_size/{print $2}')
498 if [ $brw_size -ne 4194304 ]
500 save_lustre_params ost1 "obdfilter.$dev.brw_size" >> $p
501 do_facet ost1 "$LCTL set_param obdfilter.$dev.brw_size=4"
502 remount_client $MOUNT
505 # get service estimate expanded
506 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
507 do_facet ost1 "$LCTL set_param fail_loc=0x80000224 fail_val=35"
508 echo "delay rpc servicing by 35 seconds"
509 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=fdatasync
512 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
513 awk '/portal 6/ {print $5}')
514 echo "service estimates increased to $estimate"
516 # let current worst service estimate to get closer to obliteration
517 sleep $((new_at_history / 3))
519 # start i/o and simulate bulk transfer loss
520 #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB3 0x520
521 do_facet ost1 "$LCTL set_param fail_loc=0xa0000520 fail_val=1"
522 dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 conv=fdatasync,notrunc &
525 # start lock conflict handling
526 sleep $((new_at_history / 3))
527 do_node $rcli "dd if=$DIR/$tfile of=/dev/null bs=1M count=1" &
530 # obliterate the worst service estimate
531 sleep $((new_at_history / 3 + 1))
532 dd if=/dev/zero of=$DIR/${tfile}2 bs=1M count=1
534 estimate=$($LCTL get_param -n osc.$dev-osc-*.timeouts |
535 awk '/portal 6/ {print $5}')
536 echo "service estimate dropped to $estimate"
539 [[ $? == 0 ]] || error "write failed"
541 [[ $? == 0 ]] || error "read failed"
543 restore_lustre_params <$p
544 if [ $brw_size -ne 4194304 ]
546 remount_client $MOUNT || error "remount_client failed"
548 do_facet ost1 "echo $ldlm_enqueue_min_save > $ldlm_enqueue_min"
550 run_test 17b "timeout bulk get, dont evict client (3582)"
553 [ -z ${ost2_svc} ] && skip_env "needs 2 osts" && return 0
555 do_facet_create_file client $TMP/$tfile 20K ||
556 { error_noexit "Create file $TMP/$tfile" ; return 0; }
558 do_facet client mkdir -p $DIR/$tdir
562 pgcache_empty || return 1
565 $LFS setstripe -i 1 -c 1 $f
566 stripe_index=$($LFS getstripe -i $f)
567 if [ $stripe_index -ne 1 ]; then
569 error "$f: stripe_index $stripe_index != 1" && return
572 do_facet client cp $TMP/$tfile $f
574 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | egrep -v 'MDT' | awk '{print $1}'`
575 $LCTL --device $osc2dev deactivate || return 3
576 # my understanding is that there should be nothing in the page
577 # cache after the client reconnects?
579 pgcache_empty || rc=2
580 $LCTL --device $osc2dev activate
584 run_test 18a "manual ost invalidate clears page cache immediately"
587 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
589 do_facet_create_file client $TMP/$tfile 20K ||
590 { error_noexit "Create file $TMP/$tfile" ; return 0; }
592 do_facet client mkdir -p $DIR/$tdir
596 pgcache_empty || return 1
598 $LFS setstripe -i 0 -c 1 $f
599 stripe_index=$($LFS getstripe -i $f)
600 if [ $stripe_index -ne 0 ]; then
602 error "$f: stripe_index $stripe_index != 0" && return
605 do_facet client cp $TMP/$tfile $f
608 # allow recovery to complete
609 sleep $((TIMEOUT + 2))
610 # my understanding is that there should be nothing in the page
611 # cache after the client reconnects?
613 pgcache_empty || rc=2
617 run_test 18b "eviction and reconnect clears page cache (2766)"
620 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
622 do_facet_create_file client $TMP/$tfile 20K ||
623 { error_noexit "Create file $TMP/$tfile" ; return 0; }
625 do_facet client mkdir -p $DIR/$tdir
629 pgcache_empty || return 1
631 $LFS setstripe -i 0 -c 1 $f
632 stripe_index=$($LFS getstripe -i $f)
633 if [ $stripe_index -ne 0 ]; then
635 error "$f: stripe_index $stripe_index != 0" && return
638 do_facet client cp $TMP/$tfile $f
642 # OBD_FAIL_OST_CONNECT_NET2
643 # lost reply to connect request
644 do_facet ost1 lctl set_param fail_loc=0x80000225
647 $LFS df $MOUNT > /dev/null 2>&1
649 # my understanding is that there should be nothing in the page
650 # cache after the client reconnects?
652 pgcache_empty || rc=2
656 run_test 18c "Dropped connect reply after eviction handing (14755)"
659 local BEFORE=`date +%s`
662 mount_client $DIR2 || error "failed to mount $DIR2"
664 # cancel cached locks from OST to avoid eviction from it
667 do_facet client "stat $DIR > /dev/null" ||
668 error "failed to stat $DIR: $?"
669 drop_ldlm_cancel "chmod 0777 $DIR2" ||
670 error "failed to chmod $DIR2"
674 # let the client reconnect
676 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
677 awk -F"[ [,]" '/EVICTED ]$/ \
678 { if (mx<$5) {mx=$5;} } END { print mx }')
680 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
681 (do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state;
682 error "no eviction: $EVICT before:$BEFORE")
684 run_test 19a "test expired_lock_main on mds (2867)"
687 local BEFORE=`date +%s`
690 mount_client $DIR2 || error "failed to mount $DIR2: $?"
692 # cancel cached locks from MDT to avoid eviction from it
695 do_facet client $MULTIOP $DIR/$tfile Ow ||
696 error "failed to run multiop: $?"
697 drop_ldlm_cancel $MULTIOP $DIR2/$tfile Ow ||
698 error "failed to ldlm_cancel: $?"
700 umount_client $DIR2 || error "failed to unmount $DIR2: $?"
701 do_facet client munlink $DIR/$tfile ||
702 error "failed to unlink $DIR/$tfile: $?"
704 # let the client reconnect
706 EVICT=$(do_facet client $LCTL get_param osc.$FSNAME-OST*.state |
707 awk -F"[ [,]" '/EVICTED ]$/ \
708 { if (mx < $5) {mx = $5;} } END { print mx }')
710 [ ! -z "$EVICT" ] && [[ $EVICT -gt $BEFORE ]] ||
711 (do_facet client $LCTL get_param osc.$FSNAME-OST*.state;
712 error "no eviction: $EVICT before:$BEFORE")
714 run_test 19b "test expired_lock_main on ost (2867)"
717 local BEFORE=`date +%s`
720 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=0
722 mkdir -p $DIR1/$tfile
725 #define OBD_FAIL_PTLRPC_CANCEL_RESEND 0x516
726 do_facet mds $LCTL set_param fail_loc=0x80000516
728 touch $DIR2/$tfile/file1 &
730 # let touch to get blocked on the server
734 $LCTL set_param ldlm.namespaces.*.early_lock_cancel=1
737 # let the client reconnect
739 EVICT=$(do_facet client $LCTL get_param mdc.$FSNAME-MDT*.state |
740 awk -F"[ [,]" '/EVICTED ]$/ { if (mx<$5) {mx=$5;} } END { print mx }')
742 [ -z "$EVICT" ] || [[ $EVICT -le $BEFORE ]] || error "eviction happened"
744 run_test 19c "check reconnect and lock resend do not trigger expired_lock_main"
746 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
747 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
750 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
751 multiop_bg_pause $DIR/$tdir/${tfile} O_wc || return 1
754 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
755 do_facet ost1 lctl set_param fail_loc=0x80000308
756 kill -USR1 $MULTI_PID
759 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
761 run_test 20a "ldlm_handle_enqueue error (should return error)"
763 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
764 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
767 $LFS setstripe -i 0 -c 1 $DIR/$tdir/${tfile}
769 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
770 do_facet ost1 lctl set_param fail_loc=0x80000308
771 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
772 error "didn't fail open enqueue" || true
774 run_test 20b "ldlm_handle_enqueue error (should return error)"
777 mkdir -p $DIR/$tdir-1
778 mkdir -p $DIR/$tdir-2
779 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
782 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
783 $MULTIOP $DIR/$tdir-2/f Oc &
786 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
788 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
789 kill -USR1 $close_pid
791 wait $close_pid || return 1
792 wait $open_pid || return 2
793 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
795 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
796 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
800 run_test 21a "drop close request while close and open are both in flight"
803 mkdir -p $DIR/$tdir-1
804 mkdir -p $DIR/$tdir-2
805 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
808 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
809 mcreate $DIR/$tdir-2/f &
812 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
814 kill -USR1 $close_pid
816 wait $close_pid || return 1
817 wait $open_pid || return 3
819 $CHECKSTAT -t file $DIR/$tdir-1/f || return 4
820 $CHECKSTAT -t file $DIR/$tdir-2/f || return 5
823 run_test 21b "drop open request while close and open are both in flight"
826 mkdir -p $DIR/$tdir-1
827 mkdir -p $DIR/$tdir-2
828 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
831 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
832 mcreate $DIR/$tdir-2/f &
835 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
837 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
838 kill -USR1 $close_pid
840 wait $close_pid || return 1
841 wait $open_pid || return 2
843 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
845 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
846 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
849 run_test 21c "drop both request while close and open are both in flight"
852 mkdir -p $DIR/$tdir-1
853 mkdir -p $DIR/$tdir-2
854 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
857 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000129"
858 $MULTIOP $DIR/$tdir-2/f Oc &
860 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
862 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
865 wait $pid || return 1
866 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
868 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
869 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
873 run_test 21d "drop close reply while close and open are both in flight"
876 mkdir -p $DIR/$tdir-1
877 mkdir -p $DIR/$tdir-2
878 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
881 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
882 touch $DIR/$tdir-2/f &
884 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
888 wait $pid || return 1
891 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
892 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
895 run_test 21e "drop open reply while close and open are both in flight"
898 mkdir -p $DIR/$tdir-1
899 mkdir -p $DIR/$tdir-2
900 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
903 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
904 touch $DIR/$tdir-2/f &
906 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
908 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
911 wait $pid || return 1
912 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
914 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
915 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
918 run_test 21f "drop both reply while close and open are both in flight"
921 mkdir -p $DIR/$tdir-1
922 mkdir -p $DIR/$tdir-2
923 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
926 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
927 touch $DIR/$tdir-2/f &
929 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
931 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
934 wait $pid || return 1
935 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
937 $CHECKSTAT -t file $DIR/$tdir-1/f || return 2
938 $CHECKSTAT -t file $DIR/$tdir-2/f || return 3
941 run_test 21g "drop open reply and close request while close and open are both in flight"
944 mkdir -p $DIR/$tdir-1
945 mkdir -p $DIR/$tdir-2
946 multiop_bg_pause $DIR/$tdir-1/f O_c || return 1
949 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
950 touch $DIR/$tdir-2/f &
953 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
955 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000122"
958 wait $pid || return 1
959 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
961 wait $touch_pid || return 2
963 $CHECKSTAT -t file $DIR/$tdir-1/f || return 3
964 $CHECKSTAT -t file $DIR/$tdir-2/f || return 4
967 run_test 21h "drop open request and close reply while close and open are both in flight"
969 # bug 3462 - multiple MDC requests
974 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
979 $MULTIOP $f1 msu || return 1
982 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
984 wait $close_pid || return 2
985 rm -rf $f2 || return 4
987 run_test 22 "drop close request and do mknod"
990 multiop_bg_pause $DIR/$tfile O_c || return 1
992 # give a chance for open
996 drop_request "kill -USR1 $pid"
999 wait $pid || return 1
1002 run_test 23 "client hang when close a file after mds crash"
1004 test_24a() { # bug 11710 details correct fsync() behavior
1005 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1008 $LFS setstripe -i 0 -c 1 $DIR/$tdir
1009 cancel_lru_locks osc
1010 multiop_bg_pause $DIR/$tdir/$tfile Owy_wyc || return 1
1013 kill -USR1 $MULTI_PID
1016 lctl set_param fail_loc=0x0
1019 error_ignore bz5494 "multiop didn't fail fsync: rc $rc" || true
1021 run_test 24a "fsync error (should return error)"
1023 wait_client_evicted () {
1026 local varsvc=${facet}_svc
1028 wait_update $(facet_active_host $facet) \
1029 "lctl get_param -n *.${!varsvc}.num_exports | cut -d' ' -f2" \
1034 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1036 dmesg -c > /dev/null
1038 lfs setstripe $DIR/$tdir -S 0 -i 0 -c 1 ||
1039 error "$LFS setstripe failed"
1040 cancel_lru_locks osc
1041 multiop_bg_pause $DIR/$tdir/$tfile-1 Ow8192_yc ||
1042 error "mulitop Ow8192_yc failed"
1045 multiop_bg_pause $DIR/$tdir/$tfile-2 Ow8192_c ||
1046 error "mulitop Ow8192_c failed"
1051 kill -USR1 $MULTI_PID1
1054 kill -USR1 $MULTI_PID2
1057 lctl set_param fail_loc=0x0
1059 [ $rc1 -eq 0 -o $rc2 -eq 0 ] &&
1060 error_ignore bz5494 "multiop didn't fail fsync: $rc1 or close: $rc2" ||
1063 dmesg | grep "dirty page discard:" ||
1064 error "no discarded dirty page found!"
1066 run_test 24b "test dirty page discard due to client eviction"
1068 test_26a() { # was test_26 bug 5921 - evict dead exports by pinger
1069 # this test can only run from a client on a separate node.
1070 remote_ost || { skip "local OST" && return 0; }
1071 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1072 remote_mds || { skip "local MDS" && return 0; }
1074 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1075 skip "msg and ost1 are at the same node"
1079 check_timeout || return 1
1081 # OBD_FAIL_PTLRPC_DROP_RPC 0x505
1082 do_facet client lctl set_param fail_loc=0x505
1083 local before=$(date +%s)
1086 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1087 # But if there's a race to start the evictor from various obds,
1088 # the loser might have to wait for the next ping.
1089 sleep $((TIMEOUT * 2 + TIMEOUT * 3 / 4))
1090 do_facet client lctl set_param fail_loc=0x0
1091 do_facet client df > /dev/null
1093 local oscs=$(lctl dl | awk '/-osc-/ {print $4}')
1094 check_clients_evicted $before ${oscs[@]}
1095 check_clients_full 10 ${oscs[@]}
1097 run_test 26a "evict dead exports"
1099 test_26b() { # bug 10140 - evict dead exports by pinger
1100 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1102 if [ $(facet_host mgs) = $(facet_host ost1) ]; then
1103 skip "msg and ost1 are at the same node"
1107 check_timeout || return 1
1109 zconf_mount `hostname` $MOUNT2 ||
1110 { error "Failed to mount $MOUNT2"; return 2; }
1111 sleep 1 # wait connections being established
1113 local MDS_NEXP=$(do_facet $SINGLEMDS lctl get_param -n mdt.${mds1_svc}.num_exports | cut -d' ' -f2)
1114 local OST_NEXP=$(do_facet ost1 lctl get_param -n obdfilter.${ost1_svc}.num_exports | cut -d' ' -f2)
1116 echo starting with $OST_NEXP OST and $MDS_NEXP MDS exports
1118 zconf_umount `hostname` $MOUNT2 -f
1120 # PING_INTERVAL max(obd_timeout / 4, 1U)
1121 # PING_EVICT_TIMEOUT (PING_INTERVAL * 6)
1123 # evictor takes PING_EVICT_TIMEOUT + 3 * PING_INTERVAL to evict.
1124 # But if there's a race to start the evictor from various obds,
1125 # the loser might have to wait for the next ping.
1126 # = 9 * PING_INTERVAL + PING_INTERVAL
1127 # = 10 PING_INTERVAL = 10 obd_timeout / 4 = 2.5 obd_timeout
1128 # let's wait $((TIMEOUT * 3)) # bug 19887
1130 wait_client_evicted ost1 $OST_NEXP $((TIMEOUT * 3)) || \
1131 error "Client was not evicted by ost" rc=1
1132 wait_client_evicted $SINGLEMDS $MDS_NEXP $((TIMEOUT * 3)) || \
1133 error "Client was not evicted by mds"
1135 run_test 26b "evict dead exports"
1139 writemany -q -a $DIR/$tdir/$tfile 0 5 &
1142 local save_FAILURE_MODE=$FAILURE_MODE
1144 facet_failover $SINGLEMDS
1145 #define OBD_FAIL_OSC_SHUTDOWN 0x407
1146 do_facet $SINGLEMDS lctl set_param fail_loc=0x80000407
1147 # need to wait for reconnect
1148 echo waiting for fail_loc
1149 wait_update_facet $SINGLEMDS "lctl get_param -n fail_loc" "-2147482617"
1150 facet_failover $SINGLEMDS
1151 #no crashes allowed!
1152 kill -USR1 $CLIENT_PID
1155 FAILURE_MODE=$save_FAILURE_MODE
1157 run_test 27 "fail LOV while using OSC's"
1159 test_28() { # bug 6086 - error adding new clients
1160 do_facet client mcreate $DIR/$tfile || return 1
1161 drop_bl_callback_once "chmod 0777 $DIR/$tfile" ||
1162 echo "evicted as expected"
1163 #define OBD_FAIL_MDS_CLIENT_ADD 0x12f
1164 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012f"
1165 # fail once (evicted), reconnect fail (fail_loc), ok
1166 client_up || (sleep 10; client_up) || (sleep 10; client_up) || error "reconnect failed"
1168 fail $SINGLEMDS # verify MDS last_rcvd can be loaded
1170 run_test 28 "handle error adding new clients (bug 6086)"
1172 test_29a() { # bug 22273 - error adding new clients
1173 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000711"
1175 # fail abort so client will be new again
1176 fail_abort $SINGLEMDS
1177 client_up || error "reconnect failed"
1178 wait_osc_import_state $SINGLEMDS ost FULL
1181 run_test 29a "error adding new clients doesn't cause LBUG (bug 22273)"
1183 test_29b() { # bug 22273 - error adding new clients
1184 #define OBD_FAIL_TGT_CLIENT_ADD 0x711
1185 do_facet ost1 "lctl set_param fail_loc=0x80000711"
1186 # fail abort so client will be new again
1188 client_up || error "reconnect failed"
1191 run_test 29b "error adding new clients doesn't cause LBUG (bug 22273)"
1195 # put a load of file creates/writes/deletes
1196 writemany -q $DIR/$tdir/$tfile 0 5 &
1198 echo writemany pid $CLIENT_PID
1202 # wait for client to reconnect to MDS
1207 # client process should see no problems even though MDS went down
1209 kill -USR1 $CLIENT_PID
1212 echo writemany returned $rc
1213 #these may fail because of eviction due to slow AST response.
1215 error_ignore bz13652 "writemany returned rc $rc" || true
1217 run_test 50 "failover MDS under load"
1220 #define OBD_FAIL_MDS_SYNC_CAPA_SL 0x1310
1221 do_facet ost1 lctl set_param fail_loc=0x00001310
1224 # put a load of file creates/writes/deletes
1225 writemany -q $DIR/$tdir/$tfile 0 5 &
1229 facet_failover $SINGLEMDS
1230 # failover at various points during recovery
1231 SEQ="1 5 10 $(seq $TIMEOUT 5 $(($TIMEOUT+10)))"
1232 echo will failover at $SEQ
1235 #echo failover in $i sec
1236 log "test_$testnum: failover in $i sec"
1238 facet_failover $SINGLEMDS
1240 # client process should see no problems even though MDS went down
1241 # and recovery was interrupted
1243 kill -USR1 $CLIENT_PID
1246 echo writemany returned $rc
1248 error_ignore bz13652 "writemany returned rc $rc" || true
1250 run_test 51 "failover MDS during recovery"
1253 do_facet client "mkdir -p $DIR/$tdir"
1254 do_facet client "writemany -q -a $DIR/$tdir/$tfile 300 5" &
1256 echo writemany pid $CLIENT_PID
1261 wait $CLIENT_PID || rc=$?
1262 # active client process should see an EIO for down OST
1263 [ $rc -eq 5 ] && { echo "writemany correctly failed $rc" && return 0; }
1264 # but timing or failover setup may allow success
1265 [ $rc -eq 0 ] && { echo "writemany succeeded" && return 0; }
1266 echo "writemany returned $rc"
1271 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1276 [ $rc -ne 0 ] && { return $rc; }
1277 # wait for client to reconnect to OST
1281 [ $rc -ne 0 ] && { return $rc; }
1288 run_test 52 "failover OST under load"
1290 # test of open reconstruct
1293 drop_mdt_ldlm_reply "openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tfile" ||\
1296 run_test 53 "touch: drop rep"
1299 zconf_mount $(hostname) $MOUNT2
1301 touch $DIR2/$tfile.1
1303 cat $DIR2/$tfile.missing # save transno = 0, rc != 0 into last_rcvd
1306 ERROR=$(dmesg | egrep "(test 54|went back in time)" | tail -n1 |
1307 grep "went back in time")
1308 [ x"$ERROR" == x ] || error "back in time occured"
1310 run_test 54 "back in time"
1312 # bug 11330 - liblustre application death during I/O locks up OST
1314 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1318 # This test assumes relatively small max_dirty_mb setting
1319 # which we want to walk away from, so just for it we will
1320 # temporarily lower the value
1321 local max_dirty_mb=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
1322 lctl set_param -n osc.*.max_dirty_mb=32
1323 stack_trap "lctl set_param osc.*.max_dirty_mb=$max_dirty_mb" EXIT
1325 # Minimum pass speed is 2MBps
1327 # LU-2887/LU-3089 - set min pass speed to 500KBps
1328 [ "$(facet_fstype ost1)" = "zfs" ] && ddtimeout=256
1330 # first dd should be finished quickly
1331 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-1
1332 dd if=/dev/zero of=$DIR/$tdir/$tfile-1 bs=32M count=4 &
1335 echo "step1: testing ......"
1336 while kill -0 $DDPID 2> /dev/null; do
1338 if [ $count -gt $ddtimeout ]; then
1339 error "dd should be finished!"
1343 echo "(dd_pid=$DDPID, time=$count)successful"
1345 $LFS setstripe -c 1 -i 0 $DIR/$tdir/$tfile-2
1346 #define OBD_FAIL_OST_DROP_REQ 0x21d
1347 do_facet ost1 lctl set_param fail_loc=0x0000021d
1348 # second dd will be never finished
1349 dd if=/dev/zero of=$DIR/$tdir/$tfile-2 bs=32M count=4 &
1352 echo "step2: testing ......"
1353 while [ $count -le $ddtimeout ]; do
1354 if ! kill -0 $DDPID 2> /dev/null; then
1356 error "dd shouldn't be finished! (time=$count)"
1361 echo "(dd_pid=$DDPID, time=$count)successful"
1363 #Recover fail_loc and dd will finish soon
1364 do_facet ost1 lctl set_param fail_loc=0
1366 echo "step3: testing ......"
1367 while kill -0 $DDPID 2> /dev/null; do
1369 if [ $count -gt $((ddtimeout + 440)) ]; then
1370 error "dd should be finished!"
1374 echo "(dd_pid=$DDPID, time=$count)successful"
1378 run_test 55 "ost_brw_read/write drops timed-out read/write request"
1380 test_56() { # b=11277
1381 #define OBD_FAIL_MDS_RESEND 0x136
1383 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000136"
1384 stat $DIR/$tfile || error "stat failed"
1385 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1388 run_test 56 "do not fail on getattr resend"
1391 # no oscs means no client or mdt
1392 while lctl get_param osc.*.* > /dev/null 2>&1; do
1393 : # loop until proc file is removed
1397 test_57() { # bug 10866
1401 #define OBD_FAIL_LPROC_REMOVE 0xB00
1402 lctl set_param fail_loc=0x80000B00
1403 zconf_umount `hostname` $DIR
1404 lctl set_param fail_loc=0x80000B00
1405 fail_abort $SINGLEMDS
1407 lctl set_param fail_loc=0
1409 do_facet client "df $DIR"
1411 run_test 57 "read procfs entries causes kernel crash"
1413 test_58() { # bug 11546
1414 #define OBD_FAIL_MDC_ENQUEUE_PAUSE 0x801
1417 lctl set_param fail_loc=0x80000801
1418 cp $DIR/$tfile /dev/null &
1421 lctl set_param fail_loc=0
1422 drop_bl_callback_once rm -f $DIR/$tfile
1424 # the first 'df' could tigger the eviction caused by
1425 # 'drop_bl_callback_once', and it's normal case.
1426 # but the next 'df' should return successfully.
1427 do_facet client "df $DIR" || do_facet client "df $DIR"
1429 run_test 58 "Eviction in the middle of open RPC reply processing"
1431 test_59() { # bug 10589
1432 zconf_mount `hostname` $MOUNT2 || error "Failed to mount $MOUNT2"
1433 echo $DIR2 | grep -q $MOUNT2 || error "DIR2 is not set properly: $DIR2"
1434 #define OBD_FAIL_LDLM_CANCEL_EVICT_RACE 0x311
1435 lctl set_param fail_loc=0x311
1436 writes=$(LANG=C dd if=/dev/zero of=$DIR2/$tfile count=1 2>&1)
1437 [ $? = 0 ] || error "dd write failed"
1438 writes=$(echo $writes | awk -F '+' '/out/ {print $1}')
1439 lctl set_param fail_loc=0
1441 zconf_umount `hostname` $MOUNT2 -f
1442 reads=$(LANG=C dd if=$DIR/$tfile of=/dev/null 2>&1)
1443 [ $? = 0 ] || error "dd read failed"
1444 reads=$(echo $reads | awk -F '+' '/in/ {print $1}')
1445 [ "$reads" -eq "$writes" ] || error "read" $reads "blocks, must be" $writes
1447 run_test 59 "Read cancel race on client eviction"
1450 local num_files=${COUNT:-5000}
1451 test_mkdir $DIR/$tdir
1453 # Register (and start) changelog
1454 changelog_register || error "changelog_register failed"
1456 # Generate a large number of changelog entries
1457 createmany -o $DIR/$tdir/$tfile $num_files
1461 # Unlink files in the background
1462 unlinkmany $DIR/$tdir/$tfile $num_files &
1466 # Failover the MDS while unlinks are happening
1467 facet_failover $SINGLEMDS
1469 # Wait for unlinkmany to finish
1472 # Check if all the create/unlink events were recorded
1474 local cl_count=$(changelog_dump | grep -c UNLNK)
1475 echo "$cl_count unlinks in changelog"
1477 changelog_deregister || error "changelog_deregister failed"
1478 if ! changelog_users $SINGLEMDS | grep -q "^cl"; then
1479 [ $cl_count -eq $num_files ] ||
1480 error "Recorded $cl_count of $num_files unlinks"
1481 # Also make sure we can clear large changelogs
1482 cl_count=$(changelog_dump | wc -l)
1483 [ $cl_count -le 2 ] ||
1484 error "Changelog not empty: $cl_count entries"
1485 else # If other users, there may be other unlinks in the log
1486 [ $cl_count -ge $num_files ] ||
1487 error "Recorded $cl_count of $num_files unlinks"
1488 changelog_users $SINGLEMDS
1489 echo "other changelog users; can't verify clear"
1492 run_test 60 "Add Changelog entries during MDS failover"
1496 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
1497 mdtosc=${mdtosc/-MDT*/-MDT\*}
1498 local cflags="osc.$mdtosc.connect_flags"
1499 do_facet $SINGLEMDS "lctl get_param -n $cflags" |grep -q skip_orphan
1500 [ $? -ne 0 ] && skip "don't have skip orphan feature" && return
1502 mkdir -p $DIR/$tdir || error "mkdir dir $DIR/$tdir failed"
1503 # Set the default stripe of $DIR/$tdir to put the files to ost1
1504 $LFS setstripe -c 1 -i 0 $DIR/$tdir
1506 replay_barrier $SINGLEMDS
1507 createmany -o $DIR/$tdir/$tfile-%d 10
1508 local oid=$(do_facet ost1 "lctl get_param -n \
1509 obdfilter.${ost1_svc}.last_id" | sed -e 's/.*://')
1511 fail_abort $SINGLEMDS
1513 touch $DIR/$tdir/$tfile
1514 local id=$($LFS getstripe $DIR/$tdir/$tfile |
1515 awk '$1 == 0 { print $2 }')
1516 [ $id -le $oid ] && error "the orphan objid was reused, failed"
1521 run_test 61 "Verify to not reuse orphan objects - bug 17025"
1523 # test_62 as seen it b2_1 please do not reuse test_62
1526 # zconf_umount `hostname` $DIR
1527 # #define OBD_FAIL_PTLRPC_DELAY_IMP_FULL 0x516
1528 # lctl set_param fail_loc=0x516
1531 #run_test 62 "Verify connection flags race - bug LU-1716"
1536 #grant lock1, export2
1537 $SETSTRIPE -i -0 $DIR2/$tfile || return 1
1538 $MULTIOP $DIR2/$tfile Ow || return 2
1540 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
1541 do_facet ost $LCTL set_param fail_loc=0x31e
1542 #get waiting lock2, export1
1543 $MULTIOP $DIR/$tfile Ow &
1545 # let enqueue to get asleep
1549 $MULTIOP $DIR2/$tfile Ow &
1557 do_facet ost $LCTL set_param fail_loc=0
1564 run_test 65 "lock enqueue for destroyed export"
1568 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.51) ]] ||
1569 { skip "Need MDS version at least 2.7.51"; return 0; }
1571 local list=$(comma_list $(osts_nodes))
1573 # modify dir so that next revalidate would not obtain UPDATE lock
1576 # drop 1 reply with UPDATE lock
1577 mcreate $DIR/$tfile || error "mcreate failed: $?"
1578 drop_mdt_ldlm_reply_once "stat $DIR/$tfile" &
1581 # make the re-sent lock to sleep
1582 #define OBD_FAIL_MDS_RESEND 0x136
1583 do_nodes $list $LCTL set_param fail_loc=0x80000136
1585 #initiate the re-connect & re-send
1586 local mdccli=$($LCTL dl | awk '/-MDT0000-mdc-/ {print $4;}')
1587 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.conn_uuid)
1588 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}"
1591 #initiate the client eviction while enqueue re-send is in progress
1597 run_test 66 "lock enqueue re-send vs client eviction"
1601 #define OBD_FAIL_PTLRPC_CONNECT_RACE 0x531
1602 $LCTL set_param fail_loc=0x80000531
1604 local mdtname="MDT0000"
1605 local mdccli=$($LCTL dl | grep "${mdtname}-mdc" | awk '{print $4;}')
1606 local conn_uuid=$($LCTL get_param -n mdc.${mdccli}.mds_conn_uuid)
1607 $LCTL set_param "mdc.${mdccli}.import=connection=${conn_uuid}" &
1616 run_test 67 "connect vs import invalidate race"
1618 check_cli_ir_state()
1620 local NODE=${1:-$HOSTNAME}
1622 st=$(do_node $NODE "lctl get_param mgc.*.ir_state |
1623 awk '/imperative_recovery:/ { print \\\$2}'")
1624 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1625 error "Error state $st, must be ENABLED or DISABLED"
1629 check_target_ir_state()
1632 local name=${target}_svc
1633 local recovery_proc=obdfilter.${!name}.recovery_status
1637 st=$(do_facet $target "$LCTL get_param -n $recovery_proc |
1638 awk '/status:/{ print \\\$2}'")
1639 [ x$st = xRECOVERING ] || break
1641 st=$(do_facet $target "lctl get_param -n $recovery_proc |
1642 awk '/IR:/{ print \\\$2}'")
1643 [ $st != ON -o $st != OFF -o $st != ENABLED -o $st != DISABLED ] ||
1644 error "Error state $st, must be ENABLED or DISABLED"
1650 do_facet mgs lctl set_param -n mgs.MGS.live.$FSNAME="state=$1"
1655 local state=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1656 awk '/state:/{ print \\\$2 }'")
1660 nidtbl_version_mgs()
1662 local ver=$(do_facet mgs "lctl get_param -n mgs.MGS.live.$FSNAME |
1663 awk '/nidtbl_version:/{ print \\\$2 }'")
1667 # nidtbl_version_client <mds1|client> [node]
1668 nidtbl_version_client()
1671 local node=${2:-$HOSTNAME}
1673 if [ X$cli = Xclient ]; then
1676 local obdtype=${cli/%[0-9]*/}
1677 [ $obdtype != mds ] && error "wrong parameters $cli"
1679 node=$(facet_active_host $cli)
1684 local vers=$(do_node $node "lctl get_param -n mgc.*.ir_state" |
1685 awk "/$cli/{print \$6}" |sort -u)
1687 # in case there are multiple mounts on the client node
1689 [ ${#arr[@]} -ne 1 ] && error "versions on client node mismatch"
1693 nidtbl_versions_match()
1695 [ $(nidtbl_version_mgs) -eq $(nidtbl_version_client ${1:-client}) ]
1698 target_instance_match()
1704 obdtype=${srv/%[0-9]*/}
1715 error "invalid target type" $srv
1720 local target=${srv}_svc
1721 local si=$(do_facet $srv lctl get_param -n $obdname.${!target}.instance)
1722 local ci=$(lctl get_param -n $cliname.${!target}-${cliname}-*.import |
1723 awk '/instance/{ print $2 }' | head -n1)
1725 return $([ $si -eq $ci ])
1730 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1731 { skip "MGS without IR support"; return 0; }
1733 # MDT was just restarted in the previous test, make sure everything
1736 while [ $cnt -gt 0 ]; do
1737 nidtbl_versions_match && break
1743 set_ir_status disabled
1745 local prev_ver=$(nidtbl_version_client client)
1747 local saved_FAILURE_MODE=$FAILURE_MODE
1748 [ $(facet_host mgs) = $(facet_host ost1) ] && FAILURE_MODE="SOFT"
1752 [ $(nidtbl_version_client client) -eq $prev_ver ] ||
1753 error "version must not change due to IR disabled"
1754 target_instance_match ost1 || error "instance mismatch"
1758 FAILURE_MODE=$saved_FAILURE_MODE
1760 run_test 100 "IR: Make sure normal recovery still works w/o IR"
1764 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1765 skip "MGS without IR support"
1769 local ost1_imp=$(get_osc_import_name client ost1)
1771 # disable pinger recovery
1772 lctl set_param -n osc.$ost1_imp.pinger_recov=0
1773 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1777 target_instance_match ost1 || error "instance mismatch"
1778 nidtbl_versions_match || error "version must match"
1780 run_test 101a "IR: Make sure IR works w/o normal recovery"
1784 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1785 skip "MGS without IR support"
1789 local ost1_imp=$(get_osc_import_name client ost1)
1791 #define OBD_FAIL_OST_PREPARE_DELAY 0x247
1792 do_facet ost1 "$LCTL set_param fail_loc=0x247"
1793 # disable pinger recovery
1794 $LCTL set_param -n osc.$ost1_imp.pinger_recov=0
1795 stack_trap "$LCTL set_param -n osc.$ost1_imp.pinger_recov=1" EXIT
1797 #OST may return EAGAIN if it is not configured yet
1800 run_test 101b "IR: Make sure IR works w/o normal recovery and proceed EAGAIN"
1804 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1805 { skip "MGS without IR support"; return 0; }
1807 local clients=${CLIENTS:-$HOSTNAME}
1814 # let's have a new nidtbl version
1817 # sleep for a while so that clients can see the failure of ost
1818 # it must be MGC_TIMEOUT_MIN_SECONDS + MGC_TIMEOUT_RAND_CENTISEC.
1819 # int mgc_request.c:
1820 # define MGC_TIMEOUT_MIN_SECONDS 5
1821 # define MGC_TIMEOUT_RAND_CENTISEC 0x1ff /* ~500 *
1822 local count=30 # 20 seconds at most
1823 while [ $count -gt 0 ]; do
1824 nidtbl_versions_match && break
1829 nidtbl_versions_match || error "nidtbl mismatch"
1832 old_version=$(nidtbl_version_client client)
1834 zconf_umount_clients $clients $MOUNT || error "Cannot umount client"
1837 combined_mgs_mds && mgsdev=mds1
1838 remount_facet $mgsdev
1841 zconf_mount_clients $clients $MOUNT || error "Cannot mount client"
1844 new_version=$(nidtbl_version_client client)
1845 [ $new_version -lt $old_version ] &&
1846 error "nidtbl version wrong after mgs restarts"
1849 run_test 102 "IR: New client gets updated nidtbl after MGS restart"
1853 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1854 { skip "MGS without IR support"; return 0; }
1856 combined_mgs_mds && skip "needs separate mgs and mds" && return 0
1858 # workaround solution to generate config log on the mds
1864 # We need this test because mds is like a client in IR context.
1865 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS ||
1866 error "MDS should start w/o mgs"
1868 # start mgs and remount mds w/ ir
1869 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
1872 # remount client so that fsdb will be created on the MGS
1873 umount_client $MOUNT || error "umount failed"
1874 mount_client $MOUNT || error "mount failed"
1876 # sleep 30 seconds so the MDS has a chance to detect MGS restarting
1878 while [ $count -gt 0 ]; do
1879 [ $(nidtbl_version_client mds1) -ne 0 ] && break
1884 # after a while, mds should be able to reconnect to mgs and fetch
1885 # up-to-date nidtbl version
1886 nidtbl_versions_match mds1 || error "mds nidtbl mismatch"
1891 run_test 103 "IR: MDS can start w/o MGS and get updated nidtbl later"
1895 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1896 { skip "MGS without IR support"; return 0; }
1901 start ost1 $(ostdevname 1) "$OST_MOUNT_OPTS -onoir" ||
1902 error "OST1 cannot start"
1905 local ir_state=$(check_target_ir_state ost1)
1906 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1907 error "ir status on ost1 should be DISABLED"
1909 run_test 104 "IR: ost can disable IR voluntarily"
1913 [ -z "$RCLIENTS" ] && skip "Needs multiple clients" && return 0
1914 do_facet mgs $LCTL list_param mgs.*.ir_timeout ||
1915 { skip "MGS without IR support"; return 0; }
1919 # get one of the clients from client list
1920 local rcli=$(echo $RCLIENTS |cut -d' ' -f 1)
1922 local mount_opts=${MOUNT_OPTS:+$MOUNT_OPTS,}noir
1923 zconf_umount $rcli $MOUNT || error "umount failed"
1924 zconf_mount $rcli $MOUNT $mount_opts || error "mount failed"
1926 # make sure lustre mount at $rcli disabling IR
1927 local ir_state=$(check_cli_ir_state $rcli)
1928 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1929 error "IR state must be DISABLED at $rcli"
1931 # Since the client just mounted, its last_rcvd entry is not on disk.
1932 # Send an RPC so exp_need_sync forces last_rcvd to commit this export
1933 # so the client can reconnect during OST recovery (LU-924, LU-1582)
1934 $SETSTRIPE -i 0 $DIR/$tfile
1935 dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 conv=sync
1937 # make sure MGS's state is Partial
1938 [ $(get_ir_status) = "partial" ] || error "MGS IR state must be partial"
1941 # make sure IR on ost1 is DISABLED
1942 local ir_state=$(check_target_ir_state ost1)
1943 [ $ir_state = "DISABLED" -o $ir_state = "OFF" ] ||
1944 error "IR status on ost1 should be DISABLED"
1946 # remount with the default MOUNT_OPTS
1947 zconf_umount $rcli $MOUNT || error "umount failed"
1948 zconf_mount $rcli $MOUNT || error "mount failed"
1950 # make sure MGS's state is full
1951 [ $(get_ir_status) = "full" ] || error "MGS IR status must be full"
1954 # make sure IR on ost1 is ENABLED
1955 local ir_state=$(check_target_ir_state ost1)
1956 [ $ir_state = "ENABLED" -o $ir_state = "ON" ] ||
1957 error "IR status on ost1 should be ENABLED"
1961 run_test 105 "IR: NON IR clients support"
1969 test_106() { # LU-1789
1970 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.50) ]] ||
1971 { skip "Need MDS version at least 2.3.50"; return 0; }
1973 #define OBD_FAIL_MDC_LIGHTWEIGHT 0x805
1974 $LCTL set_param fail_loc=0x805
1977 trap cleanup_106 EXIT
1979 # enable lightweight flag on mdc connection
1982 local MDS_NEXP=$(do_facet $SINGLEMDS \
1983 lctl get_param -n mdt.${mds1_svc}.num_exports |
1985 $LCTL set_param fail_loc=0
1987 touch $DIR2/$tfile || error "failed to create empty file"
1988 replay_barrier $SINGLEMDS
1990 $LCTL set_param debug=ha
1992 facet_failover $SINGLEMDS
1994 # lightweight goes through LUSTRE_IMP_RECOVER during failover
1995 touch -c $DIR2/$tfile || true
1996 $LCTL dk $TMP/lustre-log-$TESTNAME.log
1997 recovered=$(awk '/MDT0000-mdc-[0-9a-f]*. lwp recover/ { print }' \
1998 $TMP/lustre-log-$TESTNAME.log)
1999 [ -z "$recovered" ] && error "lightweight client was not recovered"
2001 # and all operations performed by lightweight client should be
2002 # synchronous, so the file created before mds restart should be there
2003 $CHECKSTAT -t file $DIR/$tfile || error "file not present"
2008 run_test 106 "lightweight connection support"
2015 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2016 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2017 multiop $DIR/$tdir D_c &
2019 mkdir $DIR/$tdir/dir_106 &
2021 do_facet $SINGLEMDS lctl set_param fail_loc=0
2024 wait $CLIENT_PID || rc=$?
2025 checkstat -t dir $DIR/$tdir/dir_106 || return 1
2027 kill -USR1 $close_pid
2028 wait $close_pid || return 2
2032 run_test 107 "drop reint reply, then restart MDT"
2036 $SETSTRIPE -c 1 -i 0 $DIR/$tdir
2038 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=256 &
2046 client_up || error "reconnect failed"
2047 rm -f $DIR/$tdir/$tfile
2049 run_test 108 "client eviction don't crash"
2052 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2053 local remote_dir=$DIR/$tdir/remote_dir
2057 #prepare for 110 test, which need set striped dir on remote MDT.
2058 for num in $(seq $MDSCOUNT); do
2060 lctl set_param -n mdt.$FSNAME*.enable_remote_dir=1 \
2065 drop_request "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2066 error "lfs mkdir failed"
2067 local diridx=$($LFS getstripe -m $remote_dir)
2068 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2070 rm -rf $DIR/$tdir || error "rmdir failed"
2072 run_test 110a "create remote directory: drop client req"
2075 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2076 local remote_dir=$DIR/$tdir/remote_dir
2080 drop_reint_reply "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2081 error "lfs mkdir failed"
2083 diridx=$($LFS getstripe -m $remote_dir)
2084 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2086 rm -rf $DIR/$tdir || error "rmdir failed"
2088 run_test 110b "create remote directory: drop Master rep"
2091 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2092 local remote_dir=$DIR/$tdir/remote_dir
2096 drop_update_reply $mdtidx "$LFS mkdir -i $mdtidx -c2 $remote_dir" ||
2097 error "lfs mkdir failed"
2099 diridx=$($GETSTRIPE -m $remote_dir)
2100 [ $diridx -eq $mdtidx ] || error "$diridx != $mdtidx"
2102 rm -rf $DIR/$tdir || error "rmdir failed"
2104 run_test 110c "create remote directory: drop update rep on slave MDT"
2107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2108 local remote_dir=$DIR/$tdir/remote_dir
2112 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2114 drop_request "rm -rf $remote_dir" || error "rm remote dir failed"
2116 rm -rf $DIR/$tdir || error "rmdir failed"
2120 run_test 110d "remove remote directory: drop client req"
2123 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2124 local remote_dir=$DIR/$tdir/remote_dir
2128 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2129 drop_reint_reply "rm -rf $remote_dir" || error "rm remote dir failed"
2131 rm -rf $DIR/$tdir || error "rmdir failed"
2135 run_test 110e "remove remote directory: drop master rep"
2138 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2139 local remote_dir=$DIR/$tdir/remote_dir
2143 $LFS mkdir -i $MDTIDX -c2 $remote_dir || error "lfs mkdir failed"
2144 drop_update_reply $MDTIDX "rm -rf $remote_dir" ||
2145 error "rm remote dir failed"
2147 rm -rf $DIR/$tdir || error "rmdir failed"
2149 run_test 110f "remove remote directory: drop slave rep"
2152 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.11.0) ]] ||
2153 { skip "Need MDS version at least 2.11.0"; return 0; }
2155 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2158 touch $DIR/$tdir/$tfile
2160 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2161 do_facet mds1 $LCTL set_param fail_loc=0x119
2162 $LFS migrate -m 1 $DIR/$tdir &
2165 do_facet mds1 $LCTL set_param fail_loc=0
2169 mdt_index=$($LFS getstripe -m $DIR/$tdir)
2170 [ $mdt_index == 1 ] || error "$tdir is not on MDT1"
2171 mdt_index=$($LFS getstripe -m $DIR/$tdir/$tfile)
2172 [ $mdt_index == 1 ] || error "$tfile is not on MDT1"
2174 rm -rf $DIR/$tdir || error "rmdir failed"
2176 run_test 110g "drop reply during migration"
2179 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2180 local server_version=$(lustre_version_code mds1)
2181 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2182 { skip "Need MDS version at least 2.7.56"; return 0; }
2184 local src_dir=$DIR/$tdir/source_dir
2185 local tgt_dir=$DIR/$tdir/target_dir
2189 $LFS mkdir -i $MDTIDX $tgt_dir
2191 dd if=/etc/hosts of=$src_dir/src_file
2192 touch $tgt_dir/tgt_file
2193 drop_update_reply $MDTIDX \
2194 "mrename $src_dir/src_file $tgt_dir/tgt_file" ||
2195 error "mrename failed"
2197 $CHECKSTAT -t file $src_dir/src_file &&
2198 error "src_file present after rename"
2200 diff /etc/hosts $tgt_dir/tgt_file ||
2201 error "file changed after rename"
2204 run_test 110h "drop update reply during cross-MDT file rename"
2207 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2208 local server_version=$(lustre_version_code mds1)
2209 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2210 { skip "Need MDS version at least 2.7.56"; return 0; }
2212 local src_dir=$DIR/$tdir/source_dir
2213 local tgt_dir=$DIR/$tdir/target_dir
2217 $LFS mkdir -i $MDTIDX $tgt_dir
2219 mkdir $src_dir/src_dir
2220 touch $src_dir/src_dir/a
2221 mkdir $tgt_dir/tgt_dir
2222 drop_update_reply $MDTIDX \
2223 "mrename $src_dir/src_dir $tgt_dir/tgt_dir" ||
2224 error "mrename failed"
2226 $CHECKSTAT -t dir $src_dir/src_dir &&
2227 error "src_dir present after rename"
2229 $CHECKSTAT -t dir $tgt_dir/tgt_dir ||
2230 error "tgt_dir not present after rename"
2232 $CHECKSTAT -t file $tgt_dir/tgt_dir/a ||
2233 error "a not present after rename"
2235 run_test 110i "drop update reply during cross-MDT dir rename"
2238 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2239 local server_version=$(lustre_version_code mds1)
2240 [[ $server_version -ge $(version_code 2.7.56) ]] ||
2241 { skip "Need MDS version at least 2.7.56"; return 0; }
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 [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.62) ]] ||
2287 { skip "Need MDS version at least 2.3.62"; return 0; }
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2367 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2377 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2390 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2400 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2410 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2420 skip "need at least 2.8.50 on OST" && return 0
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 [ $(lustre_version_code ost1) -lt $(version_code 2.8.50) ] &&
2430 skip "need at least 2.8.50 on OST" && return 0
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" && return
2604 local server_version=$(lustre_version_code $SINGLEMDS)
2605 [[ $server_version -ge $(version_code 2.7.2) ]] ||
2606 { skip "Need server version newer than 2.7.1"; return 0; }
2610 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2613 run_test 130a "enqueue resend on not existing file"
2616 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2617 local server_version=$(lustre_version_code $SINGLEMDS)
2618 [[ $server_version -ge $(version_code 2.7.2) ]] ||
2619 { skip "Need server version newer than 2.7.1"; return 0; }
2622 # let the reply to be dropped
2625 #define OBD_FAIL_SRV_ENOENT 0x217
2626 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2628 wait $T130_PID || [ $? -eq 0 ] && error "stat should fail"
2631 run_test 130b "enqueue resend on a stale inode"
2634 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2636 do_nodes ${CLIENTS:-$HOSTNAME} sync
2637 echo XXX > $DIR/$tfile
2639 cancel_lru_locks mdc
2641 # Trigger writeback on $tfile.
2643 # we need to race with unlink, unlink must complete before we will
2644 # take a DLM lock, otherwise unlink will wait until intent will
2645 # complete; but later than intent starts so that intent found
2647 #define OBD_FAIL_MDS_INTENT_DELAY 0x160
2648 set_nodes_failloc "$(mdts_nodes)" 0x80000160
2655 # drop the reply so that resend happens on an unlinked file.
2656 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2657 set_nodes_failloc "$(mdts_nodes)" 0x80000157
2659 # let the reply to be dropped
2662 #define OBD_FAIL_SRV_ENOENT 0x217
2663 set_nodes_failloc "$(mdts_nodes)" 0x80000217
2669 run_test 130c "layout intent resend on a stale inode"
2672 local before=$(date +%s)
2675 mount_client $MOUNT2 || error "mount filed"
2678 # get a lock on client so that export would reach the stale list
2679 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2680 dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync ||
2683 #define OBD_FAIL_OST_PAUSE_PUNCH 0x236
2684 do_facet ost1 $LCTL set_param fail_val=120 fail_loc=0x80000236
2686 $TRUNCATE $DIR/$tfile 100 &
2689 dd if=/dev/zero of=$DIR2/$tfile bs=4096 count=1 conv=notrunc ||
2693 umount_client $MOUNT2
2695 evict=$(do_facet client $LCTL get_param \
2696 osc.$FSNAME-OST0000-osc-*/state |
2697 awk -F"[ [,]" '/EVICTED ]$/ { if (t<$5) {t=$5;} } END { print t }')
2699 [ -z "$evict" ] || [[ $evict -le $before ]] ||
2700 (do_facet client $LCTL get_param \
2701 osc.$FSNAME-OST0000-osc-*/state;
2702 error "eviction happened: $evict before:$before")
2704 run_test 132 "long punch"
2707 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
2710 # get a lock on client so that export would reach the stale list
2711 $SETSTRIPE -i 0 $DIR/$tfile || error "setstripe failed"
2712 dd if=/dev/zero of=$DIR/$tfile count=1 || error "dd failed"
2714 # another IO under the same lock
2715 #define OBD_FAIL_OSC_DELAY_IO 0x414
2716 $LCTL set_param fail_loc=0x80000414
2717 $LCTL set_param fail_val=4 fail_loc=0x80000414
2718 dd if=/dev/zero of=$DIR/$tfile count=1 conv=notrunc oflag=dsync &
2722 #define OBD_FAIL_LDLM_BL_EVICT 0x31e
2723 set_nodes_failloc "$(osts_nodes)" 0x8000031e
2727 wait $pid && error "dd succeeded"
2730 run_test 131 "IO vs evict results to IO under staled lock"
2733 local list=$(comma_list $(mdts_nodes))
2735 local t=$((TIMEOUT * 2))
2738 flock $DIR/$tfile -c "echo bl lock;sleep $t;echo bl flock unlocked" &
2740 multiop_bg_pause $DIR/$tfile O_jc || return 1
2743 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2744 do_nodes $list $LCTL set_param fail_loc=0x80000157
2746 echo "waiting for multiop $PID"
2747 wait $PID || return 2
2753 run_test 133 "don't fail on flock resend"
2756 [ -z "$CLIENTS" ] && skip "Need two or more clients" && return
2757 [ $CLIENTCOUNT -lt 2 ] &&
2758 { skip "Need 2+ clients, have $CLIENTCOUNT" && return; }
2760 mkdir -p $MOUNT/$tdir/1 $MOUNT/$tdir/2 || error "mkdir failed"
2761 touch $MOUNT/$tdir/1/$tfile $MOUNT/$tdir/2/$tfile ||
2762 error "touch failed"
2763 zconf_umount_clients $CLIENTS $MOUNT
2764 zconf_mount_clients $CLIENTS $MOUNT
2766 #define OBD_FAIL_TGT_REPLY_DATA_RACE 0x722
2767 # assume commit interval is 5
2768 do_facet mds1 "$LCTL set_param fail_loc=0x722 fail_val=5"
2770 local -a clients=(${CLIENTS//,/ })
2771 local client1=${clients[0]}
2772 local client2=${clients[1]}
2774 do_node $client1 rm $MOUNT/$tdir/1/$tfile &
2776 do_node $client2 mv $MOUNT/$tdir/2/$tfile $MOUNT/$tdir/2/${tfile}_2 &
2779 wait $rmpid || error "rm failed"
2780 wait $mvpid || error "mv failed"
2783 run_test 134 "race between failover and search for reply data free slot"
2786 [ $MDS1_VERSION -lt $(version_code 2.12.51) ] &&
2787 skip "Need MDS version at least 2.12.51"
2790 $LFS setstripe -E 1M -L mdt $DIR/$tdir
2791 # to have parent dir write lock before open/resend
2792 touch $DIR/$tdir/$tfile
2793 #define OBD_FAIL_MDS_LDLM_REPLY_NET 0x157
2794 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param fail_loc=0x80000157
2795 openfile -f O_RDWR:O_CREAT -m 0755 $DIR/$tdir/$tfile ||
2796 error "Failed to open DOM file"
2798 run_test 135 "DOM: open/create resend to return size"
2801 remote_mds_nodsh && skip "remote MDS with nodsh" && return
2802 [[ $MDS1_VERSION -ge $(version_code 2.12.52) ]] ||
2803 skip "Need MDS version at least 2.12.52"
2805 local mdts=$(comma_list $(mdts_nodes))
2806 local MDT0=$(facet_svc $SINGLEMDS)
2808 local clog=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
2809 [ -n "$clog" ] || error "changelog_register failed"
2810 cl_mask=$(do_facet mds1 $LCTL get_param \
2811 mdd.$MDT0.changelog_mask -n)
2812 changelog_chmask "ALL"
2814 # generate some changelog records to accumulate
2815 test_mkdir -i 0 -c 0 $DIR/$tdir || error "mkdir $tdir failed"
2816 createmany -m $DIR/$tdir/$tfile 10000 ||
2817 error "create $DIR/$tdir/$tfile failed"
2819 local size1=$(do_facet $SINGLEMDS \
2820 $LCTL get_param -n mdd.$MDT0.changelog_size)
2821 echo "Changelog size $size1"
2823 #define OBD_FAIL_LLOG_PURGE_DELAY 0x1318
2824 do_nodes $mdts $LCTL set_param fail_loc=0x1318 fail_val=30
2826 # launch changelog_deregister in background on MDS
2827 do_facet mds1 "nohup $LCTL --device $MDT0 changelog_deregister $clog \
2828 > foo.out 2> foo.err < /dev/null &"
2829 # give time to reach fail_loc
2832 # fail_loc will make MDS sleep in the middle of changelog_deregister
2833 # take this opportunity to abruptly kill MDS
2834 FAILURE_MODE_save=$FAILURE_MODE
2837 FAILURE_MODE=$FAILURE_MODE_save
2839 do_nodes $mdts $LCTL set_param fail_loc=0x0 fail_val=0
2841 local size2=$(do_facet $SINGLEMDS \
2842 $LCTL get_param -n mdd.$MDT0.changelog_size)
2843 echo "Changelog size $size2"
2844 local clog2=$(do_facet $SINGLEMDS "$LCTL get_param -n \
2845 mdd.$MDT0.changelog_users | grep $clog")
2846 echo "After crash, changelog user $clog2"
2848 [ -n "$clog2" -o $size2 -lt $size1 ] ||
2849 error "changelog record count unchanged"
2851 do_facet mds1 $LCTL set_param mdd.$MDT0.changelog_mask=\'$cl_mask\' -n
2853 run_test 136 "changelog_deregister leaving pending records"
2856 check_and_cleanup_lustre