9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
11 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/lmv.sh}
20 # Allow us to override the setup if we already have a mounted system by
21 # setting SETUP=" " and CLEANUP=" "
22 SETUP=${SETUP:-"setup"}
23 CLEANUP=${CLEANUP:-"cleanup"}
28 if [ "$MDSCOUNT" -gt 1 ]; then
30 for num in `seq $MDSCOUNT`; do
31 MDSDEV=$TMP/mds${num}-`hostname`
32 add_mds mds$num --dev $MDSDEV --size $MDSSIZE --master --lmv lmv1
34 add_lov_to_lmv lov1 lmv1 --stripe_sz $STRIPE_BYTES \
35 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
36 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
37 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
38 add_client client --lmv lmv1 --lov lov1 --path $MOUNT
40 add_mds mds1 --dev $MDSDEV --size $MDSSIZE
41 add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
42 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
43 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
44 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
45 add_client client --mds mds1_svc --lov lov1 --path $MOUNT
51 start ost --reformat $OSTLCONFARGS
52 start ost2 --reformat $OSTLCONFARGS
53 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
54 start mds $MDSLCONFARGS --reformat
55 grep " $MOUNT " /proc/mounts || zconf_mount `hostname` $MOUNT
59 zconf_umount `hostname` $MOUNT
60 if [ "$MDSCOUNT" -gt 1 ]; then
61 for num in `seq $MDSCOUNT`; do
62 stop mds$num ${FORCE} $MDSLCONFARGS
65 stop mds ${FORCE} $MDSLCONFARGS
67 stop ost2 ${FORCE} --dump cleanup.log
68 stop ost ${FORCE} --dump cleanup.log
71 if [ ! -z "$EVAL" ]; then
76 if [ "$ONLY" == "setup" ]; then
81 if [ "$ONLY" == "cleanup" ]; then
82 sysctl -w portals.debug=0 || true
87 REFORMAT=--reformat $SETUP
91 drop_request "mcreate $MOUNT/1" || return 1
92 drop_reint_reply "mcreate $MOUNT/2" || return 2
94 run_test 1 "mcreate: drop req, drop rep"
97 drop_request "tchmod 111 $MOUNT/2" || return 1
98 drop_reint_reply "tchmod 666 $MOUNT/2" || return 2
100 run_test 2 "chmod: drop req, drop rep"
103 drop_request "statone $MOUNT/2" || return 1
104 drop_reply "statone $MOUNT/2" || return 2
106 run_test 3 "stat: drop req, drop rep"
109 do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
110 drop_request "cat $MOUNT/resolv.conf > /dev/null" || return 2
111 drop_reply "cat $MOUNT/resolv.conf > /dev/null" || return 3
113 run_test 4 "open: drop req, drop rep"
116 drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
117 drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
118 do_facet client "checkstat -v $MOUNT/renamed-again" || return 3
120 run_test 5 "rename: drop req, drop rep"
123 drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
124 drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2" || return 2
126 run_test 6 "link: drop req, drop rep"
129 drop_request "munlink $MOUNT/link1" || return 1
130 drop_reint_reply "munlink $MOUNT/link2" || return 2
132 run_test 7 "unlink: drop req, drop rep"
136 drop_reint_reply "touch $MOUNT/renamed" || return 1
138 run_test 8 "touch: drop rep (bug 1423)"
142 pause_bulk "cp /etc/profile $MOUNT" || return 1
143 do_facet client "cp /etc/termcap $MOUNT" || return 2
144 do_facet client "sync"
145 do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
147 run_test 9 "pause bulk on OST (bug 1420)"
151 do_facet client mcreate $MOUNT/f10 || return 1
152 drop_bl_callback "chmod 0777 $MOUNT/f10" || return 2
153 # wait for the mds to evict the client
154 #echo "sleep $(($TIMEOUT*2))"
155 #sleep $(($TIMEOUT*2))
156 do_facet client touch $MOUNT/f10 || echo "touch failed, evicted"
157 do_facet client checkstat -v -p 0777 $MOUNT/f10 || return 3
158 do_facet client "munlink $MOUNT/f10"
160 run_test 10 "finish request on server after client eviction (bug 1521)"
163 # wake up a thead waiting for completion after eviction
165 do_facet client multiop $MOUNT/$tfile Ow || return 1
166 do_facet client multiop $MOUNT/$tfile or || return 2
170 do_facet client multiop $MOUNT/$tfile or || return 3
171 drop_bl_callback multiop $MOUNT/$tfile Ow ||
172 echo "client evicted, as expected"
174 do_facet client munlink $MOUNT/$tfile || return 4
176 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
180 $LCTL mark multiop $MOUNT/$tfile OS_c
181 do_facet mds "sysctl -w lustre.fail_loc=0x115"
182 clear_failloc mds $((TIMEOUT * 2)) &
183 multiop $MOUNT/$tfile OS_c &
185 #define OBD_FAIL_MDS_CLOSE_NET 0x115
188 echo "waiting for multiop $PID"
189 wait $PID || return 2
190 do_facet client munlink $MOUNT/$tfile || return 3
192 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
194 # Bug 113, check that readdir lost recv timeout works.
196 mkdir /mnt/lustre/readdir
197 touch /mnt/lustre/readdir/newentry
198 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
199 do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
200 ls /mnt/lustre/readdir || return 1
201 do_facet mds "sysctl -w lustre.fail_loc=0"
202 rm -rf /mnt/lustre/readdir
204 run_test 13 "mdc_readpage restart test (bug 1138)"
206 # Bug 113, check that readdir lost send timeout works.
208 mkdir /mnt/lustre/readdir
209 touch /mnt/lustre/readdir/newentry
210 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
211 do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
212 ls /mnt/lustre/readdir || return 1
213 do_facet mds "sysctl -w lustre.fail_loc=0"
215 run_test 14 "mdc_readpage resend test (bug 1138)"
218 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
219 touch $DIR/$tfile && return 1
222 run_test 15 "failed open (-ENOMEM)"
225 for f in /proc/fs/lustre/llite/*/read_ahead; do
231 for f in /proc/fs/lustre/llite/*/read_ahead; do
237 do_facet client cp /etc/termcap $MOUNT
241 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
242 sysctl -w lustre.fail_loc=0x80000504
244 # will get evicted here
245 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
246 sysctl -w lustre.fail_loc=0
247 # give recovery a chance to finish (shouldn't take long)
249 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
252 run_test 16 "timeout bulk put, evict client (2732)"
255 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
256 # client will get evicted here
257 sysctl -w lustre.fail_loc=0x80000503
258 do_facet client cp /etc/termcap $DIR/$tfile
259 sysctl -w lustre.fail_loc=0
263 do_facet client "cmp /etc/termcap $DIR/$tfile" && return 1
264 do_facet client "rm $DIR/$tfile" || return 2
267 run_test 17 "timeout bulk get, evict client (2732)"
270 do_facet client mkdir -p $MOUNT/$tdir
271 f=$MOUNT/$tdir/$tfile
274 pgcache_empty || return 1
277 lfs setstripe $f $((128 * 1024)) 1 1
279 do_facet client cp /etc/termcap $f
281 local osc2_dev=`$LCTL device_list | \
282 awk '(/ost2.*client_facet/){print $4}' `
283 $LCTL --device %$osc2_dev deactivate
284 # my understanding is that there should be nothing in the page
285 # cache after the client reconnects?
287 pgcache_empty || rc=2
288 $LCTL --device %$osc2_dev activate
292 run_test 18a "manual ost invalidate clears page cache immediately"
295 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
296 do_facet client mkdir -p $MOUNT/$tdir
297 f=$MOUNT/$tdir/$tfile
298 f2=$MOUNT/$tdir/${tfile}-2
301 pgcache_empty || return 1
303 # shouldn't have to set stripe size of count==1
304 lfs setstripe $f $((128 * 1024)) 0 1
305 lfs setstripe $f2 $((128 * 1024)) 0 1
307 do_facet client cp /etc/termcap $f
309 # just use this write to trigger the client's eviction from the ost
310 sysctl -w lustre.fail_loc=0x80000503
311 do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
313 sysctl -w lustre.fail_loc=0
314 # allow recovery to complete
315 sleep $((TIMEOUT + 2))
316 # my understanding is that there should be nothing in the page
317 # cache after the client reconnects?
319 pgcache_empty || rc=2
323 run_test 18b "eviction and reconnect clears page cache (2766)"
327 do_facet client mcreate $f || return 1
328 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
330 do_facet client checkstat -v -p 0777 $f || echo evicted
331 do_facet client "munlink $f"
333 run_test 19a "test expired_lock_main on mds (2867)"
337 do_facet client multiop $f Ow || return 1
338 do_facet client multiop $f or || return 2
342 do_facet client multiop $f or || return 3
343 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
345 do_facet client munlink $f || return 4
347 run_test 19b "test expired_lock_main on ost (2867)"
349 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
351 multiop $DIR/$tdir/${tfile} O_wc &
355 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
356 do_facet ost sysctl -w lustre.fail_loc=0x80000308
357 kill -USR1 $MULTI_PID
360 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
362 run_test 20a "ldlm_handle_enqueue error (should return error)"
364 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
366 touch $DIR/$tdir/${tfile}
368 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
369 do_facet ost sysctl -w lustre.fail_loc=0x80000308
370 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
371 error "didn't fail open enqueue" || true
373 run_test 20b "ldlm_handle_enqueue error (should return error)"