Whamcloud - gitweb
Minor changes to sync b1_2 with HEAD that shouldn't affect anything.
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -e
4
5 #         bug 2732 2986 2762 2766
6 ALWAYS_EXCEPT="17   20b  16   18"
7
8
9 LUSTRE=${LUSTRE:-`dirname $0`/..}
10 UPCALL=${UPCALL:-$PWD/recovery-small-upcall.sh}
11 . $LUSTRE/tests/test-framework.sh
12
13 init_test_env $@
14
15 . ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
16
17 build_test_filter
18
19
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"}
24
25
26 make_config() {
27     rm -f $XMLCONFIG
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
34 }
35
36 setup() {
37     make_config
38     start ost --reformat $OSTLCONFARGS 
39     start ost2 --reformat $OSTLCONFARGS 
40     [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
41     start mds $MDSLCONFARGS --reformat
42     zconf_mount `hostname`  $MOUNT
43 }
44
45 cleanup() {
46     zconf_umount `hostname` $MOUNT
47     stop mds ${FORCE} $MDSLCONFARGS
48     stop ost2 ${FORCE} --dump cleanup.log
49     stop ost ${FORCE} --dump cleanup.log
50 }
51
52 replay() {
53     do_mds "sync"
54     do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
55     do_client "$1" &
56     shutdown_mds -f
57     start_mds
58     wait
59     do_client "df -h $MOUNT" # trigger failover, if we haven't already
60 }
61
62 if [ ! -z "$EVAL" ]; then
63     eval "$EVAL"
64     exit $?
65 fi
66
67 if [ "$ONLY" == "cleanup" ]; then
68     sysctl -w portals.debug=0 || true
69     cleanup
70     exit
71 fi
72
73 if [ "$ONLY" == "cleanup" ]; then
74     sysctl -w portals.debug=0 || true
75     cleanup
76     exit
77 fi
78
79 REFORMAT=--reformat $SETUP
80 unset REFORMAT
81
82 test_1() {
83     drop_request "mcreate $MOUNT/1"  || return 1
84     drop_reply "mcreate $MOUNT/2"    || return 2
85 }
86 run_test 1 "mcreate: drop req, drop rep"
87
88 test_2() {
89     drop_request "tchmod 111 $MOUNT/2"  || return 1
90     drop_reply "tchmod 666 $MOUNT/2"    || return 2
91 }
92 run_test 2 "chmod: drop req, drop rep"
93
94 test_3() {
95     drop_request "statone $MOUNT/2" || return 1
96     drop_reply "statone $MOUNT/2"   || return 2
97 }
98 run_test 3 "stat: drop req, drop rep"
99
100 test_4() {
101     do_facet client "cp /etc/resolv.conf $MOUNT/resolv.conf" || return 1
102     drop_request "cat $MOUNT/resolv.conf > /dev/null"   || return 2
103     drop_reply "cat $MOUNT/resolv.conf > /dev/null"     || return 3
104 }
105 run_test 4 "open: drop req, drop rep"
106
107 test_5() {
108     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
109     drop_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
110     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
111 }
112 run_test 5 "rename: drop req, drop rep"
113
114 test_6() {
115     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
116     drop_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
117 }
118 run_test 6 "link: drop req, drop rep"
119
120 test_7() {
121     drop_request "munlink $MOUNT/link1"   || return 1
122     drop_reply "munlink $MOUNT/link2"     || return 2
123 }
124 run_test 7 "unlink: drop req, drop rep"
125
126 #bug 1423
127 test_8() {
128     drop_reply "touch $MOUNT/renamed"    || return 1
129 }
130 run_test 8 "touch: drop rep (bug 1423)"
131
132 #bug 1420
133 test_9() {
134     pause_bulk "cp /etc/profile $MOUNT"       || return 1
135     do_facet client "cp /etc/termcap $MOUNT"  || return 2
136     do_facet client "sync"
137     do_facet client "rm $MOUNT/termcap $MOUNT/profile" || return 3
138 }
139 run_test 9 "pause bulk on OST (bug 1420)"
140
141 #bug 1521
142 test_10() {
143     do_facet client mcreate $MOUNT/f10        || return 1
144     drop_bl_callback "chmod 0777 $MOUNT/f10"  || return 2
145     # wait for the mds to evict the client
146     #echo "sleep $(($TIMEOUT*2))"
147     #sleep $(($TIMEOUT*2))
148     do_facet client touch  $MOUNT/f10 || echo "touch failed, evicted"
149     do_facet client checkstat -v -p 0777 $MOUNT/f10  || return 3
150     do_facet client "munlink $MOUNT/f10"
151 }
152 run_test 10 "finish request on server after client eviction (bug 1521)"
153
154 #bug 2460
155 # wake up a thead waiting for completion after eviction
156 test_11(){
157     do_facet client multiop $MOUNT/$tfile Ow  || return 1
158     do_facet client multiop $MOUNT/$tfile or  || return 2
159
160     cancel_lru_locks OSC
161
162     do_facet client multiop $MOUNT/$tfile or  || return 3
163     drop_bl_callback multiop $MOUNT/$tfile Ow  || 
164         echo "client evicted, as expected"
165
166     do_facet client munlink $MOUNT/$tfile  || return 4
167 }
168 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
169
170 #b=2494
171 test_12(){
172     $LCTL mark multiop $MOUNT/$tfile OS_c 
173     do_facet mds "sysctl -w lustre.fail_loc=0x115"
174     clear_failloc mds $((TIMEOUT * 2)) &
175     multiop $MOUNT/$tfile OS_c  &
176     PID=$!
177 #define OBD_FAIL_MDS_CLOSE_NET           0x115
178     sleep 2
179     kill -USR1 $PID
180     echo "waiting for multiop $PID"
181     wait $PID || return 2
182     do_facet client munlink $MOUNT/$tfile  || return 3
183 }
184 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
185
186 # Bug 113, check that readdir lost recv timeout works.
187 test_13() {
188     mkdir /mnt/lustre/readdir
189     touch /mnt/lustre/readdir/newentry
190 # OBD_FAIL_MDS_READPAGE_NET|OBD_FAIL_ONCE
191     do_facet mds "sysctl -w lustre.fail_loc=0x80000104"
192     ls /mnt/lustre/readdir || return 1
193     do_facet mds "sysctl -w lustre.fail_loc=0"
194     rm -rf /mnt/lustre/readdir
195 }
196 run_test 13 "mdc_readpage restart test (bug 1138)"
197
198 # Bug 113, check that readdir lost send timeout works.
199 test_14() {
200     mkdir /mnt/lustre/readdir
201     touch /mnt/lustre/readdir/newentry
202 # OBD_FAIL_MDS_SENDPAGE|OBD_FAIL_ONCE
203     do_facet mds "sysctl -w lustre.fail_loc=0x80000106"
204     ls /mnt/lustre/readdir || return 1
205     do_facet mds "sysctl -w lustre.fail_loc=0"
206 }
207 run_test 14 "mdc_readpage resend test (bug 1138)"
208
209 test_15() {
210     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
211     touch $DIR/$tfile && return 1
212     return 0
213 }
214 run_test 15 "failed open (-ENOMEM)"
215
216 test_16() {
217     do_facet client cp /etc/termcap $MOUNT
218     sync
219
220 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
221     sysctl -w lustre.fail_loc=0x80000504
222     cancel_lru_locks OSC
223     # will get evicted here
224     do_facet client "diff /etc/termcap $MOUNT/termcap"  && return 1
225     sysctl -w lustre.fail_loc=0
226     do_facet client "diff /etc/termcap $MOUNT/termcap"  || return 2
227 }
228 run_test 16 "timeout bulk put, evict client (2732)"
229
230 test_17() {
231 # OBD_FAIL_PTLRPC_BULK_GET_NET 0x0503 | OBD_FAIL_ONCE
232     # will get evicted here
233     sysctl -w lustre.fail_loc=0x80000503
234     do_facet client cp /etc/termcap $MOUNT && return 1
235
236     do_facet client "diff /etc/termcap $MOUNT/termcap"  && return 1
237     sysctl -w lustre.fail_loc=0
238     do_facet client "diff /etc/termcap $MOUNT/termcap"  || return 2
239 }
240 run_test 17 "timeout bulk get, evict client (2732)"
241
242 test_18a() {
243     do_facet client mkdir -p $MOUNT/$tdir
244     f=$MOUNT/$tdir/$tfile
245
246     cancel_lru_locks OSC
247     pgcache_empty || return 1
248
249     # 1 stripe on ost2
250     lfs setstripe $f $((128 * 1024)) 1 1
251
252     do_facet client cp /etc/termcap $f
253     sync
254     local osc2_dev=`$LCTL device_list | \
255         awk '(/ost2.*client_facet/){print $4}' `
256     $LCTL --device %$osc2_dev deactivate
257     # my understanding is that there should be nothing in the page
258     # cache after the client reconnects?     
259     rc=0
260     pgcache_empty || rc=2
261     $LCTL --device %$osc2_dev activate
262     rm -f $f
263     return $rc
264 }
265 run_test 18a "manual ost invalidate clears page cache immediately"
266
267 test_18b() {
268 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
269     do_facet client mkdir -p $MOUNT/$tdir
270     f=$MOUNT/$tdir/$tfile
271     f2=$MOUNT/$tdir/${tfile}-2
272
273     cancel_lru_locks OSC
274     pgcache_empty || return 1
275
276     # shouldn't have to set stripe size of count==1
277     lfs setstripe $f $((128 * 1024)) 0 1
278     lfs setstripe $f2 $((128 * 1024)) 0 1
279
280     do_facet client cp /etc/termcap $f
281     sync
282     # just use this write to trigger the client's eviction from the ost
283     sysctl -w lustre.fail_loc=0x80000503
284     do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
285     sync
286     sysctl -w lustre.fail_loc=0
287     # allow recovery to complete
288     sleep $((TIMEOUT + 2))
289     # my understanding is that there should be nothing in the page
290     # cache after the client reconnects?     
291     rc=0
292     pgcache_empty || rc=2
293     rm -f $f $f2
294     return $rc
295 }
296 run_test 18b "eviction and reconnect clears page cache (2766)"
297
298 test_19a() {
299     f=$MOUNT/$tfile
300     do_facet client mcreate $f        || return 1
301     drop_ldlm_cancel "chmod 0777 $f"  || echo evicted
302
303     do_facet client checkstat -v -p 0777 $f  || echo evicted
304     do_facet client "munlink $f"
305 }
306 run_test 19a "test expired_lock_main on mds (2867)"
307
308 test_19b() {
309     f=$MOUNT/$tfile
310     do_facet client multiop $f Ow  || return 1
311     do_facet client multiop $f or  || return 2
312
313     cancel_lru_locks OSC
314
315     do_facet client multiop $f or  || return 3
316     drop_ldlm_cancel multiop $f Ow  || echo "client evicted, as expected"
317
318     do_facet client munlink $f  || return 4
319 }
320 run_test 19b "test expired_lock_main on ost (2867)"
321
322 test_20a() {    # bug 2983 - ldlm_handle_enqueue cleanup
323         mkdir -p $DIR/$tdir
324         multiop $DIR/$tdir/${tfile} O_wc &
325         MULTI_PID=$!
326         usleep 500
327         cancel_lru_locks OSC
328 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
329         do_facet ost sysctl -w lustre.fail_loc=0x80000308
330         set -vx
331         kill -USR1 $MULTI_PID
332         wait $MULTI_PID
333         rc=$?
334         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
335         set +vx
336 }
337 run_test 20a "ldlm_handle_enqueue error (should return error)" 
338
339 test_20b() {    # bug 2986 - ldlm_handle_enqueue error during open
340         mkdir -p $DIR/$tdir
341         touch $DIR/$tdir/${tfile}
342         cancel_lru_locks OSC
343 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
344         do_facet ost sysctl -w lustre.fail_loc=0x80000308
345         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
346                 error "didn't fail open enqueue" || true
347 }
348 run_test 20b "ldlm_handle_enqueue error (should return error)"
349
350 $CLEANUP