9 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/local.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 add_mds mds --dev $MDSDEV --size $MDSSIZE
29 add_lov lov1 mds --stripe_sz $STRIPE_BYTES \
30 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
31 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
32 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
33 add_client client mds --lov lov1 --path $MOUNT
38 start ost --reformat $OSTLCONFARGS
39 start ost2 --reformat $OSTLCONFARGS
40 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
41 start mds $MDSLCONFARGS --reformat
42 grep " $MOUNT " /proc/mounts || zconf_mount `hostname` $MOUNT
46 zconf_umount `hostname` $MOUNT
47 stop mds ${FORCE} $MDSLCONFARGS
49 stop ost ${FORCE} --dump $TMP/recovery-small-`hostname`.log
54 do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
59 do_client "df -h $MOUNT" # trigger failover, if we haven't already
62 if [ ! -z "$EVAL" ]; then
67 if [ "$ONLY" == "cleanup" ]; then
68 sysctl -w portals.debug=0 || true
73 REFORMAT=--reformat $SETUP
76 [ "$ONLY" == "setup" ] && exit
79 drop_request "mcreate $MOUNT/1" || return 1
80 drop_reint_reply "mcreate $MOUNT/2" || return 2
82 run_test 1 "mcreate: drop req, drop rep"
85 drop_request "tchmod 111 $MOUNT/2" || return 1
86 drop_reint_reply "tchmod 666 $MOUNT/2" || return 2
88 run_test 2 "chmod: drop req, drop rep"
91 drop_request "statone $MOUNT/2" || return 1
92 drop_reply "statone $MOUNT/2" || return 2
94 run_test 3 "stat: drop req, drop rep"
97 do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
98 drop_request "cat $MOUNT/resolv.conf > /dev/null" || return 2
99 drop_reply "cat $MOUNT/resolv.conf > /dev/null" || return 3
101 run_test 4 "open: drop req, drop rep"
104 drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
105 drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
106 do_facet client "checkstat -v $MOUNT/renamed-again" || return 3
108 run_test 5 "rename: drop req, drop rep"
111 drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
112 drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2" || return 2
114 run_test 6 "link: drop req, drop rep"
117 drop_request "munlink $MOUNT/link1" || return 1
118 drop_reint_reply "munlink $MOUNT/link2" || return 2
120 run_test 7 "unlink: drop req, drop rep"
124 drop_reint_reply "touch $MOUNT/renamed" || return 1
126 run_test 8 "touch: drop rep (bug 1423)"
130 pause_bulk "cp /etc/profile $MOUNT" || return 1
131 do_facet client "cp /etc/termcap $MOUNT" || return 2
132 do_facet client "sync"
133 do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
135 run_test 9 "pause bulk on OST (bug 1420)"
139 do_facet client mcreate $MOUNT/f10 || return 1
140 drop_bl_callback "chmod 0777 $MOUNT/f10" || return 2
141 # wait for the mds to evict the client
142 #echo "sleep $(($TIMEOUT*2))"
143 #sleep $(($TIMEOUT*2))
144 do_facet client touch $MOUNT/f10 || echo "touch failed, evicted"
145 do_facet client checkstat -v -p 0777 $MOUNT/f10 || return 3
146 do_facet client "munlink $MOUNT/f10"
148 run_test 10 "finish request on server after client eviction (bug 1521)"
151 # wake up a thread waiting for completion after eviction
153 do_facet client multiop $MOUNT/$tfile Ow || return 1
154 do_facet client multiop $MOUNT/$tfile or || return 2
158 do_facet client multiop $MOUNT/$tfile or || return 3
159 drop_bl_callback multiop $MOUNT/$tfile Ow ||
160 echo "client evicted, as expected"
162 do_facet client munlink $MOUNT/$tfile || return 4
164 run_test 11 "wake up a thread waiting for completion after eviction (b=2460)"
168 $LCTL mark multiop $MOUNT/$tfile OS_c
169 do_facet mds "sysctl -w lustre.fail_loc=0x115"
170 clear_failloc mds $((TIMEOUT * 2)) &
171 multiop $MOUNT/$tfile OS_c &
173 #define OBD_FAIL_MDS_CLOSE_NET 0x115
176 echo "waiting for multiop $PID"
177 wait $PID || return 2
178 do_facet client munlink $MOUNT/$tfile || return 3
180 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
182 # Bug 113, check that readdir lost recv timeout works.
184 mkdir /mnt/lustre/readdir || return 1
185 touch /mnt/lustre/readdir/newentry || return
186 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
187 do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
188 ls /mnt/lustre/readdir || return 3
189 do_facet mds "sysctl -w lustre.fail_loc=0"
190 rm -rf /mnt/lustre/readdir || return 4
192 run_test 13 "mdc_readpage restart test (bug 1138)"
194 # Bug 113, check that readdir lost send timeout works.
196 mkdir /mnt/lustre/readdir
197 touch /mnt/lustre/readdir/newentry
198 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
199 do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
200 ls /mnt/lustre/readdir || return 1
201 do_facet mds "sysctl -w lustre.fail_loc=0"
203 run_test 14 "mdc_readpage resend test (bug 1138)"
206 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
207 touch $DIR/$tfile && return 1
210 run_test 15 "failed open (-ENOMEM)"
212 READ_AHEAD=`cat /proc/fs/lustre/llite/*/max_read_ahead_mb | head -n 1`
214 for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do
220 for f in /proc/fs/lustre/llite/*/max_read_ahead_mb; do
221 echo $READ_AHEAD > $f
226 do_facet client cp /etc/termcap $MOUNT
230 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
231 sysctl -w lustre.fail_loc=0x80000504
233 # will get evicted here
234 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
235 sysctl -w lustre.fail_loc=0
236 # give recovery a chance to finish (shouldn't take long)
238 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
241 run_test 16 "timeout bulk put, evict client (2732)"
244 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
245 # client will get evicted here
246 sysctl -w lustre.fail_loc=0x80000503
247 # need to write enough to ensure we send an RPC
248 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=1024k count=2
251 sysctl -w lustre.fail_loc=0
252 do_facet client "df $DIR"
254 do_facet client "cmp /etc/termcap $DIR/$tfile" && return 1
255 do_facet client "rm $DIR/$tfile" || return 2
258 run_test 17 "timeout bulk get, evict client (2732)"
261 do_facet client mkdir -p $MOUNT/$tdir
262 f=$MOUNT/$tdir/$tfile
265 pgcache_empty || return 1
268 lfs setstripe $f $((128 * 1024)) 1 1
270 do_facet client cp /etc/termcap $f
272 local osc2_dev=`$LCTL device_list | \
273 awk '(/ost2.*client_facet/){print $4}' `
274 $LCTL --device %$osc2_dev deactivate
275 # my understanding is that there should be nothing in the page
276 # cache after the client reconnects?
278 pgcache_empty || rc=2
279 $LCTL --device %$osc2_dev activate
283 run_test 18a "manual ost invalidate clears page cache immediately"
286 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
287 do_facet client mkdir -p $MOUNT/$tdir
288 f=$MOUNT/$tdir/$tfile
289 f2=$MOUNT/$tdir/${tfile}-2
292 pgcache_empty || return 1
294 # shouldn't have to set stripe size of count==1
295 lfs setstripe $f $((128 * 1024)) 0 1
296 lfs setstripe $f2 $((128 * 1024)) 0 1
298 do_facet client cp /etc/termcap $f
300 # just use this write to trigger the client's eviction from the ost
301 sysctl -w lustre.fail_loc=0x80000503
302 do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
304 sysctl -w lustre.fail_loc=0
305 # allow recovery to complete
306 sleep $((TIMEOUT + 2))
307 # my understanding is that there should be nothing in the page
308 # cache after the client reconnects?
310 pgcache_empty || rc=2
314 run_test 18b "eviction and reconnect clears page cache (2766)"
318 do_facet client mcreate $f || return 1
319 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
321 do_facet client checkstat -v -p 0777 $f || echo evicted
322 # let the client reconnect
324 do_facet client "munlink $f"
326 run_test 19a "test expired_lock_main on mds (2867)"
330 do_facet client multiop $f Ow || return 1
331 do_facet client multiop $f or || return 2
335 do_facet client multiop $f or || return 3
336 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
338 do_facet client munlink $f || return 4
340 run_test 19b "test expired_lock_main on ost (2867)"
342 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
344 multiop $DIR/$tdir/${tfile} O_wc &
348 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
349 do_facet ost sysctl -w lustre.fail_loc=0x80000308
350 kill -USR1 $MULTI_PID
353 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
355 run_test 20a "ldlm_handle_enqueue error (should return error)"
357 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
359 touch $DIR/$tdir/${tfile}
361 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
362 do_facet ost sysctl -w lustre.fail_loc=0x80000308
363 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
364 error "didn't fail open enqueue" || true
366 run_test 20b "ldlm_handle_enqueue error (should return error)"
368 #b_cray run_test 21a "drop close request while close and open are both in flight"
369 #b_cray run_test 21b "drop open request while close and open are both in flight"
370 #b_cray run_test 21c "drop both request while close and open are both in flight"
371 #b_cray run_test 21d "drop close reply while close and open are both in flight"
372 #b_cray run_test 21e "drop open reply while close and open are both in flight"
373 #b_cray run_test 21f "drop both reply while close and open are both in flight"
374 #b_cray run_test 21g "drop open reply and close request while close and open are both in flight"
375 #b_cray run_test 21h "drop open request and close reply while close and open are both in flight"
376 #b_cray run_test 22 "drop close request and do mknod"
377 #b_cray run_test 23 "client hang when close a file after mds crash"
379 test_24() { # bug 2248 - eviction fails writeback but app doesn't see it
382 multiop $DIR/$tdir/$tfile Owyw_yc &
385 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
386 sysctl -w lustre.fail_loc=0x80000503
387 kill -USR1 $MULTI_PID
390 [ $rc -eq 0 ] && error "multiop didn't fail fsync: rc $rc" || true
392 run_test 24 "fsync error (should return error)"