8 LUSTRE=${LUSTRE:-`dirname $0`/..}
9 UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
10 . $LUSTRE/tests/test-framework.sh
14 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
19 # Allow us to override the setup if we already have a mounted system by
20 # setting SETUP=" " and CLEANUP=" "
21 SETUP=${SETUP:-"setup"}
22 CLEANUP=${CLEANUP:-"cleanup"}
27 add_mds mds --dev $MDSDEV --size $MDSSIZE
28 add_lov lov1 mds --stripe_sz $STRIPE_BYTES\
29 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
30 add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE
31 add_ost ost2 --lov lov1 --dev ${OSTDEV}-2 --size $OSTSIZE
32 add_client client mds --lov lov1 --path $MOUNT
37 start ost --reformat $OSTLCONFARGS
38 start ost2 --reformat $OSTLCONFARGS
39 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
40 start mds $MDSLCONFARGS --reformat
41 zconf_mount `hostname` $MOUNT
45 zconf_umount `hostname` $MOUNT
46 stop mds ${FORCE} $MDSLCONFARGS
47 stop ost2 ${FORCE} --dump cleanup.log
48 stop ost ${FORCE} --dump cleanup.log
53 do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
58 do_client "df -h $MOUNT" # trigger failover, if we haven't already
61 if [ ! -z "$EVAL" ]; then
66 REFORMAT=--reformat $SETUP
70 drop_request "mcreate $MOUNT/1" || return 1
71 drop_reply "mcreate $MOUNT/2" || return 2
73 run_test 1 "mcreate: drop req, drop rep"
76 drop_request "tchmod 111 $MOUNT/2" || return 1
77 drop_reply "tchmod 666 $MOUNT/2" || return 2
79 run_test 2 "chmod: drop req, drop rep"
82 drop_request "statone $MOUNT/2" || return 1
83 drop_reply "statone $MOUNT/2" || return 2
85 run_test 3 "stat: drop req, drop rep"
88 do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
89 drop_request "cat $MOUNT/resolv.conf > /dev/null" || return 2
90 drop_reply "cat $MOUNT/resolv.conf > /dev/null" || return 3
92 run_test 4 "open: drop req, drop rep"
95 drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
96 drop_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
97 do_facet client "checkstat -v $MOUNT/renamed-again" || return 3
99 run_test 5 "rename: drop req, drop rep"
102 drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
103 drop_reply "mlink $MOUNT/renamed-again $MOUNT/link2" || return 2
105 run_test 6 "link: drop req, drop rep"
108 drop_request "munlink $MOUNT/link1" || return 1
109 drop_reply "munlink $MOUNT/link2" || return 2
111 run_test 7 "unlink: drop req, drop rep"
116 drop_reply "touch $MOUNT/renamed" || return 1
118 run_test 8 "touch: drop rep (bug 1423)"
122 pause_bulk "cp /etc/profile $MOUNT" || return 1
123 do_facet client "cp /etc/termcap $MOUNT" || return 2
124 do_facet client "sync"
125 do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
127 run_test 9 "pause bulk on OST (bug 1420)"
131 do_facet client mcreate $MOUNT/f10 || return 1
132 drop_bl_callback "chmod 0777 $MOUNT/f10" || return 2
133 # wait for the mds to evict the client
134 #echo "sleep $(($TIMEOUT*2))"
135 #sleep $(($TIMEOUT*2))
136 do_facet client touch $MOUNT/f10 || echo "touch failed, evicted"
137 do_facet client checkstat -v -p 0777 $MOUNT/f10 || return 3
138 do_facet client "munlink $MOUNT/f10"
140 run_test 10 "finish request on server after client eviction (bug 1521)"
143 # wake up a thead waiting for completion after eviction
145 do_facet client multiop $MOUNT/$tfile Ow || return 1
146 do_facet client multiop $MOUNT/$tfile or || return 2
150 do_facet client multiop $MOUNT/$tfile or || return 3
151 drop_bl_callback multiop $MOUNT/$tfile Ow ||
152 echo "client evicted, as expected"
154 do_facet client munlink $MOUNT/$tfile || return 4
156 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
160 $LCTL mark multiop $MOUNT/$tfile OS_c
161 do_facet mds "sysctl -w lustre.fail_loc=0x115"
162 clear_failloc mds $((TIMEOUT * 2)) &
163 multiop $MOUNT/$tfile OS_c &
165 #define OBD_FAIL_MDS_CLOSE_NET 0x115
168 echo "waiting for multiop $PID"
169 wait $PID || return 2
170 do_facet client munlink $MOUNT/$tfile || return 3
172 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
174 # Bug 113, check that readdir lost recv timeout works.
176 mkdir /mnt/lustre/readdir
177 touch /mnt/lustre/readdir/newentry
178 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
179 do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
180 ls /mnt/lustre/readdir || return 1
181 do_facet mds "sysctl -w lustre.fail_loc=0"
182 rm -rf /mnt/lustre/readdir
184 run_test 13 "mdc_readpage restart test (bug 1138)"
186 # Bug 113, check that readdir lost send timeout works.
188 mkdir /mnt/lustre/readdir
189 touch /mnt/lustre/readdir/newentry
190 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
191 do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
192 ls /mnt/lustre/readdir || return 1
193 do_facet mds "sysctl -w lustre.fail_loc=0"
195 run_test 14 "mdc_readpage resend test (bug 1138)"
198 do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
199 touch $DIR/$tfile && return 1
202 run_test 15 "failed open (-ENOMEM)"
205 do_facet client cp /etc/termcap $MOUNT
208 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
209 sysctl -w lustre.fail_loc=0x80000504
211 # will get evicted here
212 do_facet client "diff /etc/termcap $MOUNT/termcap" && return 1
213 sysctl -w lustre.fail_loc=0
214 do_facet client "diff /etc/termcap $MOUNT/termcap" || return 2
216 run_test 16 "timeout bulk put, evict client (2732)"
219 #define OBD_FAIL_PTLRPC_BULK_GET_NET 0x504 | OBD_FAIL_ONCE
220 # will get evicted here
221 sysctl -w lustre.fail_loc=0x80000503
222 do_facet client cp /etc/termcap $MOUNT && return 1
224 do_facet client "diff /etc/termcap $MOUNT/termcap" && return 2
225 sysctl -w lustre.fail_loc=0
226 do_facet client "diff /etc/termcap $MOUNT/termcap" || return 3
228 run_test 17 "timeout bulk get, evict client (2732)"
231 do_facet client mkdir -p $MOUNT/$tdir
232 f=$MOUNT/$tdir/$tfile
235 pgcache_empty || return 1
238 lfs setstripe $f $((128 * 1024)) 1 1
240 do_facet client cp /etc/termcap $f
242 local osc2_dev=`$LCTL device_list | \
243 awk '(/ost2.*client_facet/){print $4}' `
244 $LCTL --device %$osc2_dev deactivate
245 # my understanding is that there should be nothing in the page
246 # cache after the client reconnects?
248 pgcache_empty || rc=2
249 $LCTL --device %$osc2_dev activate
253 run_test 18a "manual ost invalidate clears page cache immediately"
256 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
257 do_facet client mkdir -p $MOUNT/$tdir
258 f=$MOUNT/$tdir/$tfile
259 f2=$MOUNT/$tdir/${tfile}-2
262 pgcache_empty || return 1
264 # shouldn't have to set stripe size of count==1
265 lfs setstripe $f $((128 * 1024)) 0 1
267 sysctl -w lustre.fail_loc=0
268 # allow recovery to complete
269 sleep $((TIMEOUT + 2))
270 # my understanding is that there should be nothing in the page
271 # cache after the client reconnects?
273 pgcache_empty || rc=2
277 run_test 18b "eviction and reconnect clears page cache (2766)"
281 do_facet client mcreate $f || return 1
282 drop_ldlm_cancel "chmod 0777 $f" || echo evicted
284 do_facet client checkstat -v -p 0777 $f || echo evicted
285 do_facet client "munlink $f"
287 run_test 19a "test expired_lock_main on mds (2867)"
291 do_facet client multiop $f Ow || return 1
292 do_facet client multiop $f or || return 2
296 do_facet client multiop $f or || return 3
297 drop_ldlm_cancel multiop $f Ow || echo "client evicted, as expected"
299 do_facet client munlink $f || return 4
301 run_test 19b "test expired_lock_main on ost (2867)"
303 test_20a() { # bug 2983 - ldlm_handle_enqueue cleanup
305 multiop $DIR/$tdir/${tfile} O_wc &
309 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
310 do_facet ost sysctl -w lustre.fail_loc=0x80000308
312 kill -USR1 $MULTI_PID
315 [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
318 run_test 20a "ldlm_handle_enqueue error (should return error)"
320 test_20b() { # bug 2986 - ldlm_handle_enqueue error during open
322 touch $DIR/$tdir/${tfile}
324 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
325 do_facet ost sysctl -w lustre.fail_loc=0x80000308
326 dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
327 error "didn't fail open enqueue" || true
329 run_test 20b "ldlm_handle_enqueue error (should return error)"