9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
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
48 stop ost2 ${FORCE} --dump cleanup.log
49 stop ost ${FORCE} --dump cleanup.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
77 drop_request "mcreate $MOUNT/1" || return 1
78 drop_reint_reply "mcreate $MOUNT/2" || return 2
80 run_test 1 "mcreate: drop req, drop rep"
83 drop_request "tchmod 111 $MOUNT/2" || return 1
84 drop_reint_reply "tchmod 666 $MOUNT/2" || return 2
86 run_test 2 "chmod: drop req, drop rep"
89 drop_request "statone $MOUNT/2" || return 1
90 drop_reply "statone $MOUNT/2" || return 2
92 run_test 3 "stat: drop req, drop rep"
95 do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
96 drop_request "cat $MOUNT/resolv.conf > /dev/null" || return 2
97 drop_reply "cat $MOUNT/resolv.conf > /dev/null" || return 3
99 run_test 4 "open: drop req, drop rep"
102 drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
103 drop_reint_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
104 do_facet client "checkstat -v $MOUNT/renamed-again" || return 3
106 run_test 5 "rename: drop req, drop rep"
109 drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
110 drop_reint_reply "mlink $MOUNT/renamed-again $MOUNT/link2" || return 2
112 run_test 6 "link: drop req, drop rep"
115 drop_request "munlink $MOUNT/link1" || return 1
116 drop_reint_reply "munlink $MOUNT/link2" || return 2
118 run_test 7 "unlink: drop req, drop rep"
122 drop_reint_reply "touch $MOUNT/renamed" || return 1
124 run_test 8 "touch: drop rep (bug 1423)"
128 pause_bulk "cp /etc/profile $MOUNT" || return 1
129 do_facet client "cp /etc/termcap $MOUNT" || return 2
130 do_facet client "sync"
131 do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
133 run_test 9 "pause bulk on OST (bug 1420)"
137 do_facet client mcreate $MOUNT/f10 || return 1
138 drop_bl_callback "chmod 0777 $MOUNT/f10" || return 2
139 # wait for the mds to evict the client
140 #echo "sleep $(($TIMEOUT*2))"
141 #sleep $(($TIMEOUT*2))
142 do_facet client touch $MOUNT/f10 || echo "touch failed, evicted"
143 do_facet client checkstat -v -p 0777 $MOUNT/f10 || return 3
144 do_facet client "munlink $MOUNT/f10"
146 run_test 10 "finish request on server after client eviction (bug 1521)"
149 # wake up a thead waiting for completion after eviction
151 do_facet client multiop $MOUNT/$tfile Ow || return 1
152 do_facet client multiop $MOUNT/$tfile or || return 2
156 do_facet client multiop $MOUNT/$tfile or || return 3
157 drop_bl_callback multiop $MOUNT/$tfile Ow ||
158 echo "client evicted, as expected"
160 do_facet client munlink $MOUNT/$tfile || return 4
162 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
166 $LCTL mark multiop $MOUNT/$tfile OS_c
167 do_facet mds "sysctl -w lustre.fail_loc=0x115"
168 clear_failloc mds $((TIMEOUT * 2)) &
169 multiop $MOUNT/$tfile OS_c &
171 #define OBD_FAIL_MDS_CLOSE_NET 0x115
174 echo "waiting for multiop $PID"
175 wait $PID || return 2
176 do_facet client munlink $MOUNT/$tfile || return 3
178 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
180 # Bug 113, check that readdir lost recv timeout works.
182 mkdir /mnt/lustre/readdir
183 touch /mnt/lustre/readdir/newentry
184 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
185 do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
186 ls /mnt/lustre/readdir || return 1
187 do_facet mds "sysctl -w lustre.fail_loc=0"
188 rm -rf /mnt/lustre/readdir
190 run_test 13 "mdc_readpage restart test (bug 1138)"
192 # Bug 113, check that readdir lost send timeout works.
194 mkdir /mnt/lustre/readdir
195 touch /mnt/lustre/readdir/newentry
196 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
197 do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
198 ls /mnt/lustre/readdir || return 1
199 do_facet mds "sysctl -w lustre.fail_loc=0"
201 run_test 14 "mdc_readpage resend test (bug 1138)"
204 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
205 touch $DIR/$tfile && return 1
208 run_test 15 "failed open (-ENOMEM)"
211 do_facet client cp /etc/termcap $MOUNT
214 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
215 sysctl -w lustre.fail_loc=0x80000504
217 # will get evicted here
218 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
219 sysctl -w lustre.fail_loc=0
220 # give recovery a chance to finish (shouldn't take long)
222 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
224 run_test 16 "timeout bulk put, evict client (2732)"
227 #define OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
228 # will get evicted here
229 sysctl -w lustre.fail_loc=0x80000503
230 do_facet client cp /etc/termcap $MOUNT && return 1
232 do_facet client "cmp /etc/termcap $MOUNT/termcap" && return 1
233 sysctl -w lustre.fail_loc=0
234 do_facet client "cmp /etc/termcap $MOUNT/termcap" || return 2
236 run_test 17 "timeout bulk get, evict client (2732)"
239 do_facet client mkdir -p $MOUNT/$tdir
240 f=$MOUNT/$tdir/$tfile
243 pgcache_empty || return 1
246 lfs setstripe $f $((128 * 1024)) 1 1
248 do_facet client cp /etc/termcap $f
250 local osc2_dev=`$LCTL device_list | \
251 awk '(/ost2.*client_facet/){print $4}' `
252 $LCTL --device %$osc2_dev deactivate
253 # my understanding is that there should be nothing in the page
254 # cache after the client reconnects?
256 pgcache_empty || rc=2
257 $LCTL --device %$osc2_dev activate
261 run_test 18a "manual ost invalidate clears page cache immediately"
264 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
265 do_facet client mkdir -p $MOUNT/$tdir
266 f=$MOUNT/$tdir/$tfile
267 f2=$MOUNT/$tdir/${tfile}-2
270 pgcache_empty || return 1
272 # shouldn't have to set stripe size of count==1
273 lfs setstripe $f $((128 * 1024)) 0 1
274 lfs setstripe $f2 $((128 * 1024)) 0 1
276 do_facet client cp /etc/termcap $f
278 # just use this write to trigger the client's eviction from the ost
279 sysctl -w lustre.fail_loc=0x80000503
280 do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
282 sysctl -w lustre.fail_loc=0
283 # allow recovery to complete
284 sleep $((TIMEOUT + 2))
285 # my understanding is that there should be nothing in the page
286 # cache after the client reconnects?
288 pgcache_empty || rc=2
292 run_test 18b "eviction and reconnect clears page cache (2766)"
296 do_facet client mcreate $f || return 1
297 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
299 do_facet client checkstat -v -p 0777 $f || echo evicted
300 do_facet client "munlink $f"
302 run_test 19a "test expired_lock_main on mds (2867)"
306 do_facet client multiop $f Ow || return 1
307 do_facet client multiop $f or || return 2
311 do_facet client multiop $f or || return 3
312 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
314 do_facet client munlink $f || return 4
316 run_test 19b "test expired_lock_main on ost (2867)"
318 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
320 multiop $DIR/$tdir/${tfile} O_wc &
324 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
325 do_facet ost sysctl -w lustre.fail_loc=0x80000308
326 kill -USR1 $MULTI_PID
329 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
331 run_test 20a "ldlm_handle_enqueue error (should return error)"
333 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
335 touch $DIR/$tdir/${tfile}
337 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
338 do_facet ost sysctl -w lustre.fail_loc=0x80000308
339 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
340 error "didn't fail open enqueue" || true
342 run_test 20b "ldlm_handle_enqueue error (should return error)"