Whamcloud - gitweb
Land b_smallfix onto HEAD (20040330_2312)
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -e
4
5 # 17 = bug 2732   2986
6 ALWAYS_EXCEPT="17 19b"
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 REFORMAT=--reformat $SETUP
74 unset REFORMAT
75
76 test_1() {
77     drop_request "mcreate $MOUNT/1"  || return 1
78     drop_reply "mcreate $MOUNT/2"    || return 2
79 }
80 run_test 1 "mcreate: drop req, drop rep"
81
82 test_2() {
83     drop_request "tchmod 111 $MOUNT/2"  || return 1
84     drop_reply "tchmod 666 $MOUNT/2"    || return 2
85 }
86 run_test 2 "chmod: drop req, drop rep"
87
88 test_3() {
89     drop_request "statone $MOUNT/2" || return 1
90     drop_reply "statone $MOUNT/2"   || return 2
91 }
92 run_test 3 "stat: drop req, drop rep"
93
94 test_4() {
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
98 }
99 run_test 4 "open: drop req, drop rep"
100
101 test_5() {
102     drop_request "mv $MOUNT/resolv.conf $MOUNT/renamed" || return 1
103     drop_reply "mv $MOUNT/renamed $MOUNT/renamed-again" || return 2
104     do_facet client "checkstat -v $MOUNT/renamed-again"  || return 3
105 }
106 run_test 5 "rename: drop req, drop rep"
107
108 test_6() {
109     drop_request "mlink $MOUNT/renamed-again $MOUNT/link1" || return 1
110     drop_reply "mlink $MOUNT/renamed-again $MOUNT/link2"   || return 2
111 }
112 run_test 6 "link: drop req, drop rep"
113
114 test_7() {
115     drop_request "munlink $MOUNT/link1"   || return 1
116     drop_reply "munlink $MOUNT/link2"     || return 2
117 }
118 run_test 7 "unlink: drop req, drop rep"
119
120
121 #bug 1423
122 test_8() {
123     drop_reply "touch $MOUNT/renamed"    || return 1
124 }
125 run_test 8 "touch: drop rep (bug 1423)"
126
127
128 #bug 1420
129 test_9() {
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
134 }
135 run_test 9 "pause bulk on OST (bug 1420)"
136
137 #bug 1521
138 test_10() {
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"
147 }
148 run_test 10 "finish request on server after client eviction (bug 1521)"
149
150 #bug 2460
151 # wake up a thead waiting for completion after eviction
152 test_11(){
153     do_facet client multiop $MOUNT/$tfile Ow  || return 1
154     do_facet client multiop $MOUNT/$tfile or  || return 2
155
156     cancel_lru_locks OSC
157
158     do_facet client multiop $MOUNT/$tfile or  || return 3
159     drop_bl_callback multiop $MOUNT/$tfile Ow  || 
160         echo "client evicted, as expected"
161
162     do_facet client munlink $MOUNT/$tfile  || return 4
163 }
164 run_test 11 "wake up a thead waiting for completion after eviction (b=2460)"
165
166 #b=2494
167 test_12(){
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  &
172     PID=$!
173 #define OBD_FAIL_MDS_CLOSE_NET           0x115
174     sleep 2
175     kill -USR1 $PID
176     echo "waiting for multiop $PID"
177     wait $PID || return 2
178     do_facet client munlink $MOUNT/$tfile  || return 3
179 }
180 run_test 12 "recover from timed out resend in ptlrpcd (b=2494)"
181
182 # Bug 113, check that readdir lost recv timeout works.
183 test_13() {
184     mkdir /mnt/lustre/readdir
185     touch /mnt/lustre/readdir/newentry
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 1
189     do_facet mds "sysctl -w lustre.fail_loc=0"
190     rm -rf /mnt/lustre/readdir
191 }
192 run_test 13 "mdc_readpage restart test (bug 1138)"
193
194 # Bug 113, check that readdir lost send timeout works.
195 test_14() {
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"
202 }
203 run_test 14 "mdc_readpage resend test (bug 1138)"
204
205 test_15() {
206     do_facet mds "sysctl -w lustre.fail_loc=0x80000128"
207     touch $DIR/$tfile && return 1
208     return 0
209 }
210 run_test 15 "failed open (-ENOMEM)"
211
212 test_16() {
213     do_facet client cp /etc/termcap $MOUNT
214     sync
215
216 #define OBD_FAIL_PTLRPC_BULK_PUT_NET 0x504 | OBD_FAIL_ONCE
217     sysctl -w lustre.fail_loc=0x80000504
218     cancel_lru_locks OSC
219     # will get evicted here
220     do_facet client "diff /etc/termcap $MOUNT/termcap"  && return 1
221     sysctl -w lustre.fail_loc=0
222     do_facet client "diff /etc/termcap $MOUNT/termcap"  || return 2
223 }
224 run_test 16 "timeout bulk put, evict client (2732)"
225
226 test_17() {
227 # OBD_FAIL_PTLRPC_BULK_GET_NET | OBD_FAIL_ONCE
228     # wil get evicted here
229     sysctl -w lustre.fail_loc=0x80000503
230     do_facet client cp /etc/termcap $MOUNT && return 1
231
232     do_facet client "diff /etc/termcap $MOUNT/termcap"  && return 1
233     sysctl -w lustre.fail_loc=0
234     do_facet client "diff /etc/termcap $MOUNT/termcap"  || return 2
235
236 }
237 run_test 17 "timeout bulk get, evict client (2732)"
238
239 test_18a() {
240     do_facet client mkdir -p $MOUNT/$tdir
241     f=$MOUNT/$tdir/$tfile
242
243     cancel_lru_locks OSC
244     pgcache_empty || return 1
245
246     # 1 stripe on ost2
247     lfs setstripe $f $((128 * 1024)) 1 1
248
249     do_facet client cp /etc/termcap $f
250     sync
251     local osc2_dev=`$LCTL device_list | \
252         awk '(/ost2.*client_facet/){print $4}' `
253     $LCTL --device %$osc2_dev deactivate
254     # my understanding is that there should be nothing in the page
255     # cache after the client reconnects?     
256     rc=0
257     pgcache_empty || rc=2
258     $LCTL --device %$osc2_dev activate
259     rm -f $f
260     return $rc
261 }
262 run_test 18a "manual ost invalidate clears page cache immediately"
263
264 test_18b() {
265 # OBD_FAIL_PTLRPC_BULK_PUT_NET|OBD_FAIL_ONCE
266     do_facet client mkdir -p $MOUNT/$tdir
267     f=$MOUNT/$tdir/$tfile
268     f2=$MOUNT/$tdir/${tfile}-2
269
270     cancel_lru_locks OSC
271     pgcache_empty || return 1
272
273     # shouldn't have to set stripe size of count==1
274     lfs setstripe $f $((128 * 1024)) 0 1
275     lfs setstripe $f2 $((128 * 1024)) 0 1
276
277     do_facet client cp /etc/termcap $f
278     sync
279     # just use this write to trigger the client's eviction from the ost
280     sysctl -w lustre.fail_loc=0x80000503
281     do_facet client dd if=/dev/zero of=$f2 bs=4k count=1
282     sync
283     sysctl -w lustre.fail_loc=0
284     # allow recovery to complete
285     sleep $((TIMEOUT + 2))
286     # my understanding is that there should be nothing in the page
287     # cache after the client reconnects?     
288     rc=0
289     pgcache_empty || rc=2
290     rm -f $f $f2
291     return $rc
292 }
293 run_test 18b "eviction and reconnect clears page cache (2766)"
294
295 test_19a() {    # bug 2983 - ldlm_handle_enqueue cleanup
296         mkdir -p $DIR/$tdir
297         multiop $DIR/$tdir/${tfile} O_wc &
298         MULTI_PID=$!
299         usleep 500
300         cancel_lru_locks OSC
301 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
302         do_facet ost sysctl -w lustre.fail_loc=0x80000308
303         set -vx
304         kill -USR1 $MULTI_PID
305         wait $MULTI_PID
306         rc=$?
307         [ $rc -eq 0 ] && error "multiop didn't fail enqueue: rc $rc" || true
308         set +vx
309 }
310 run_test 19a "ldlm_handle_enqueue error (should return error)" 
311
312 test_19b() {    # bug 2986 - ldlm_handle_enqueue error during open
313         mkdir $DIR/$tdir
314         touch $DIR/$tdir/${tfile}
315         cancel_lru_locks OSC
316 #define OBD_FAIL_LDLM_ENQUEUE_EXTENT_ERR 0x308
317         do_facet ost sysctl -w lustre.fail_loc=0x80000308
318         dd if=/etc/hosts of=$DIR/$tdir/$tfile && \
319                 error "didn't fail open enqueue" || true
320 }
321 run_test 19b "ldlm_handle_enqueue error (should return error)"
322
323
324 $CLEANUP