9 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/lmv.sh}
21 # Allow us to override the setup if we already have a mounted system by
22 # setting SETUP=" " and CLEANUP=" "
23 SETUP=${SETUP:-"setup"}
24 CLEANUP=${CLEANUP:-"cleanup"}
29 if [ "$MDSCOUNT" -gt 1 ]; then
31 for mds in `mds_list`; do
32 MDSDEV=$TMP/${mds}-`hostname`
33 add_mds $mds --dev $MDSDEV --size $MDSSIZE --lmv lmv1_svc
35 add_lov_to_lmv lov1 lmv1_svc --stripe_sz $STRIPE_BYTES \
36 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
39 add_mds mds1 --dev $MDSDEV --size $MDSSIZE
40 add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
41 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
46 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
47 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
48 add_client client ${MDS} --lov lov1 --path $MOUNT
53 start ost --reformat $OSTLCONFARGS
54 start ost2 --reformat $OSTLCONFARGS
55 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
56 for mds in `mds_list`; do
57 start $mds --reformat $MDSLCONFARGS
60 grep " $MOUNT " /proc/mounts || zconf_mount `hostname` $MOUNT
64 zconf_umount `hostname` $MOUNT
65 for mds in `mds_list`; do
66 stop $mds ${FORCE} $MDSLCONFARGS
68 stop ost2 ${FORCE} --dump cleanup.log
69 stop ost ${FORCE} --dump cleanup.log
72 if [ ! -z "$EVAL" ]; then
77 if [ "$ONLY" == "setup" ]; then
82 if [ "$ONLY" == "cleanup" ]; then
83 sysctl -w portals.debug=0 || true
88 REFORMAT=--reformat $SETUP
92 drop_request "mcreate $MOUNT/1" || return 1
93 drop_reint_reply "mcreate $MOUNT/2" || return 2
95 run_test 1 "mcreate: drop req, drop rep"
98 drop_request "tchmod 111 $MOUNT/2" || return 1
99 drop_reint_reply "tchmod 666 $MOUNT/2" || return 2
101 run_test 2 "chmod: drop req, drop rep"
104 drop_request "statone $MOUNT/2" || return 1
105 drop_reply "statone $MOUNT/2" || return 2
107 run_test 3 "stat: drop req, drop rep"
110 do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
111 drop_request "cat $MOUNT/resolv.conf > /dev/null" || return 2
112 drop_reply "cat $MOUNT/resolv.conf > /dev/null" || return 3
114 run_test 4 "open: drop req, drop rep"
117 drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
118 drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
119 do_facet client "checkstat -v $MOUNT/renamed-again" || return 3
121 run_test 5 "rename: drop req, drop rep"
124 drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
125 drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2" || return 2
127 run_test 6 "link: drop req, drop rep"
130 drop_request "munlink $MOUNT/link1" || return 1
131 drop_reint_reply "munlink $MOUNT/link2" || return 2
133 run_test 7 "unlink: drop req, drop rep"
137 drop_reint_reply "touch $MOUNT/renamed" || return 1
139 run_test 8 "touch: drop rep (bug 1423)"
143 pause_bulk "cp /etc/profile $MOUNT" || return 1
144 do_facet client "cp /etc/termcap $MOUNT" || return 2
145 do_facet client "sync"
146 do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
148 run_test 9 "pause bulk on OST (bug 1420)"
152 do_facet client mcreate $MOUNT/f10 || return 1
153 drop_bl_callback "chmod 0777 $MOUNT/f10" || return 2
154 # wait for the mds to evict the client
155 #echo "sleep $(($TIMEOUT*2))"
156 #sleep $(($TIMEOUT*2))
157 do_facet client touch $MOUNT/f10 || echo "touch failed, evicted"
158 do_facet client checkstat -v -p 0777 $MOUNT/f10 || return 3
159 do_facet client "munlink $MOUNT/f10"
161 run_test 10 "finish request on server after client eviction (bug 1521)"
164 # wake up a thead waiting for completion after eviction
166 do_facet client multiop $MOUNT/$tfile Ow || return 1
167 do_facet client multiop $MOUNT/$tfile or || return 2
171 do_facet client multiop $MOUNT/$tfile or || return 3
172 drop_bl_callback multiop $MOUNT/$tfile Ow ||
173 echo "client evicted, as expected"
175 do_facet client munlink $MOUNT/$tfile || return 4
177 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
181 $LCTL mark multiop $MOUNT/$tfile OS_c
182 do_facet mds "sysctl -w lustre.fail_loc=0x115"
183 clear_failloc mds $((TIMEOUT * 2)) &
184 multiop $MOUNT/$tfile OS_c &
186 #define OBD_FAIL_MDS_CLOSE_NET 0x115
189 echo "waiting for multiop $PID"
190 wait $PID || return 2
191 do_facet client munlink $MOUNT/$tfile || return 3
193 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
195 # Bug 113, check that readdir lost recv timeout works.
197 mkdir /mnt/lustre/readdir
198 touch /mnt/lustre/readdir/newentry
199 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
200 do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
201 ls /mnt/lustre/readdir || return 1
202 do_facet mds "sysctl -w lustre.fail_loc=0"
203 rm -rf /mnt/lustre/readdir
205 run_test 13 "mdc_readpage restart test (bug 1138)"
207 # Bug 113, check that readdir lost send timeout works.
209 mkdir /mnt/lustre/readdir
210 touch /mnt/lustre/readdir/newentry
211 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
212 do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
213 ls /mnt/lustre/readdir || return 1
214 do_facet mds "sysctl -w lustre.fail_loc=0"
216 run_test 14 "mdc_readpage resend test (bug 1138)"
219 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
220 touch $DIR/$tfile && return 1
223 run_test 15 "failed open (-ENOMEM)"
226 for f in /proc/fs/lustre/llite/*/read_ahead; do
232 for f in /proc/fs/lustre/llite/*/read_ahead; do
238 do_facet client cp /etc/termcap $MOUNT
242 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
243 sysctl -w lustre.fail_loc=0x80000504
245 # will get evicted here
246 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
247 sysctl -w lustre.fail_loc=0
248 # give recovery a chance to finish (shouldn't take long)
250 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
253 run_test 16 "timeout bulk put, evict client (2732)"
256 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
257 # client will get evicted here
258 sysctl -w lustre.fail_loc=0x80000503
259 do_facet client cp /etc/termcap $DIR/$tfile
262 sysctl -w lustre.fail_loc=0
263 do_facet client "df $DIR"
265 do_facet client "cmp /etc/termcap $DIR/$tfile" && return 1
266 do_facet client "rm $DIR/$tfile" || return 2
269 run_test 17 "timeout bulk get, evict client (2732)"
272 do_facet client mkdir -p $MOUNT/$tdir
273 f=$MOUNT/$tdir/$tfile
276 pgcache_empty || return 1
279 lfs setstripe $f $((128 * 1024)) 1 1
281 do_facet client cp /etc/termcap $f
283 local osc2_dev=`$LCTL device_list | \
284 awk '(/ost2.*client_facet/){print $4}' `
285 $LCTL --device %$osc2_dev deactivate
286 # my understanding is that there should be nothing in the page
287 # cache after the client reconnects?
289 pgcache_empty || rc=2
290 $LCTL --device %$osc2_dev activate
294 run_test 18a "manual ost invalidate clears page cache immediately"
297 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
298 do_facet client mkdir -p $MOUNT/$tdir
299 f=$MOUNT/$tdir/$tfile
300 f2=$MOUNT/$tdir/${tfile}-2
303 pgcache_empty || return 1
305 # shouldn't have to set stripe size of count==1
306 lfs setstripe $f $((128 * 1024)) 0 1
307 lfs setstripe $f2 $((128 * 1024)) 0 1
309 do_facet client cp /etc/termcap $f
311 # just use this write to trigger the client's eviction from the ost
312 sysctl -w lustre.fail_loc=0x80000503
313 do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
315 sysctl -w lustre.fail_loc=0
316 # allow recovery to complete
317 sleep $((TIMEOUT + 2))
318 # my understanding is that there should be nothing in the page
319 # cache after the client reconnects?
321 pgcache_empty || rc=2
325 run_test 18b "eviction and reconnect clears page cache (2766)"
329 do_facet client mcreate $f || return 1
330 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
332 do_facet client checkstat -v -p 0777 $f || echo evicted
333 # let the client reconnect
335 do_facet client "munlink $f"
337 run_test 19a "test expired_lock_main on mds (2867)"
341 do_facet client multiop $f Ow || return 1
342 do_facet client multiop $f or || return 2
346 do_facet client multiop $f or || return 3
347 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
349 do_facet client munlink $f || return 4
351 run_test 19b "test expired_lock_main on ost (2867)"
353 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
355 multiop $DIR/$tdir/${tfile} O_wc &
359 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
360 do_facet ost sysctl -w lustre.fail_loc=0x80000308
361 kill -USR1 $MULTI_PID
364 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
366 run_test 20a "ldlm_handle_enqueue error (should return error)"
368 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
370 touch $DIR/$tdir/${tfile}
372 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
373 do_facet ost sysctl -w lustre.fail_loc=0x80000308
374 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
375 error "didn't fail open enqueue" || true
377 run_test 20b "ldlm_handle_enqueue error (should return error)"