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 do_facet client cp /etc/termcap $MOUNT
228 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
229 sysctl -w lustre.fail_loc=0x80000504
231 # will get evicted here
232 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
233 sysctl -w lustre.fail_loc=0
234 # give recovery a chance to finish (shouldn't take long)
236 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
238 run_test 16 "timeout bulk put, evict client (2732)"
241 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
242 # client will get evicted here
243 sysctl -w lustre.fail_loc=0x80000503
244 do_facet client cp /etc/termcap $DIR/$tfile
245 sysctl -w lustre.fail_loc=0
249 do_facet client "cmp /etc/termcap $DIR/$tfile" && return 1
250 do_facet client "rm $DIR/$tfile" || return 2
253 run_test 17 "timeout bulk get, evict client (2732)"
256 do_facet client mkdir -p $MOUNT/$tdir
257 f=$MOUNT/$tdir/$tfile
260 pgcache_empty || return 1
263 lfs setstripe $f $((128 * 1024)) 1 1
265 do_facet client cp /etc/termcap $f
267 local osc2_dev=`$LCTL device_list | \
268 awk '(/ost2.*client_facet/){print $4}' `
269 $LCTL --device %$osc2_dev deactivate
270 # my understanding is that there should be nothing in the page
271 # cache after the client reconnects?
273 pgcache_empty || rc=2
274 $LCTL --device %$osc2_dev activate
278 run_test 18a "manual ost invalidate clears page cache immediately"
281 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
282 do_facet client mkdir -p $MOUNT/$tdir
283 f=$MOUNT/$tdir/$tfile
284 f2=$MOUNT/$tdir/${tfile}-2
287 pgcache_empty || return 1
289 # shouldn't have to set stripe size of count==1
290 lfs setstripe $f $((128 * 1024)) 0 1
291 lfs setstripe $f2 $((128 * 1024)) 0 1
293 do_facet client cp /etc/termcap $f
295 # just use this write to trigger the client's eviction from the ost
296 sysctl -w lustre.fail_loc=0x80000503
297 do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
299 sysctl -w lustre.fail_loc=0
300 # allow recovery to complete
301 sleep $((TIMEOUT + 2))
302 # my understanding is that there should be nothing in the page
303 # cache after the client reconnects?
305 pgcache_empty || rc=2
309 run_test 18b "eviction and reconnect clears page cache (2766)"
313 do_facet client mcreate $f || return 1
314 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
316 do_facet client checkstat -v -p 0777 $f || echo evicted
317 do_facet client "munlink $f"
319 run_test 19a "test expired_lock_main on mds (2867)"
323 do_facet client multiop $f Ow || return 1
324 do_facet client multiop $f or || return 2
328 do_facet client multiop $f or || return 3
329 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
331 do_facet client munlink $f || return 4
333 run_test 19b "test expired_lock_main on ost (2867)"
335 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
337 multiop $DIR/$tdir/${tfile} O_wc &
341 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
342 do_facet ost sysctl -w lustre.fail_loc=0x80000308
343 kill -USR1 $MULTI_PID
346 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
348 run_test 20a "ldlm_handle_enqueue error (should return error)"
350 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
352 touch $DIR/$tdir/${tfile}
354 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
355 do_facet ost sysctl -w lustre.fail_loc=0x80000308
356 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
357 error "didn't fail open enqueue" || true
359 run_test 20b "ldlm_handle_enqueue error (should return error)"