Whamcloud - gitweb
land 0.5.20.3 b_devel onto HEAD (b_devel will remain)
[fs/lustre-release.git] / lustre / tests / recovery-small.sh
1 #!/bin/sh
2
3 set -ex
4
5 LUSTRE=${LUSTRE:-`dirname $0`/..}
6 PATH=$PATH:$LUSTRE/utils:$LUSTRE/tests
7
8 . $LUSTRE/../ltest/functional/llite/common/common.sh
9
10 PDSH='pdsh -S -w'
11
12 # XXX I wish all this stuff was in some default-config.sh somewhere
13 MDSNODE=${MDSNODE:-mdev6}
14 OSTNODE=${OSTNODE:-mdev7}
15 CLIENT=${CLIENTNODE:-mdev8}
16 NETWORKTYPE=${NETWORKTYPE:-tcp}
17 MOUNTPT=${MOUNTPT:-/mnt/lustre}
18 CONFIG=recovery-small.xml
19 MDSDEV=/tmp/mds
20 OSTDEV=/tmp/ost
21 MDSSIZE=100000
22 OSTSIZE=100000
23
24 do_mds() {
25     $PDSH $MDSNODE "PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests; cd $PWD; $@"
26 }
27
28 do_client() {
29     $PDSH $CLIENT "PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests; cd $PWD; $@"
30 }
31
32 do_ost() {
33     $PDSH $OSTNODE "PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests; cd $PWD; $@"
34 }
35
36 drop_request() {
37     do_mds "echo 0x121 > /proc/sys/lustre/fail_loc"
38     do_client "$1"
39     do_mds "echo 0 > /proc/sys/lustre/fail_loc"
40 }
41
42 drop_reply() {
43     do_mds "echo 0x120 > /proc/sys/lustre/fail_loc"
44     do_client "$@"
45     do_mds "echo 0 > /proc/sys/lustre/fail_loc"
46 }
47
48 make_config() {
49     rm -f $CONFIG
50     for NODE in $CLIENT $MDSNODE $OSTNODE; do
51        lmc -m $CONFIG --add net --node $NODE --nid `h2$NETWORKTYPE $NODE` \
52            --nettype $NETWORKTYPE || exit 4
53     done
54     lmc -m $CONFIG --add mds --node $MDSNODE --mds mds1 --dev $MDSDEV \
55         --size $MDSSIZE || exit 5
56     lmc -m $CONFIG --add ost --node $OSTNODE --ost ost1 --dev $OSTDEV \
57         --size $OSTSIZE || exit 6
58     lmc -m $CONFIG --add mtpt --node $CLIENT --path $MOUNTPT --mds mds1 \
59         --ost ost1 || exit 7
60 }
61
62 start_mds() {
63     do_mds "lconf $@ $CONFIG"
64 }
65
66 shutdown_mds() {
67     do_mds "lconf $@ --cleanup $CONFIG"
68 }
69
70 start_ost() {
71     do_ost "lconf $@ $CONFIG"
72 }
73
74 shutdown_ost() {
75     do_ost "lconf $@ --cleanup $CONFIG"
76 }
77
78 mount_client() {
79     do_client "lconf $@ $CONFIG"
80 }
81
82 unmount_client() {
83     do_client "lconf $@ --cleanup $CONFIG"
84 }
85
86 setup() {
87     make_config
88     start_mds ${REFORMAT:---reformat}
89     start_ost ${REFORMAT:---reformat}
90     # XXX we should write our own upcall, when we move this somewhere better.
91     mount_client --timeout=${TIMEOUT:-5} \
92         --recovery_upcall=$PWD/../../ltest/functional/llite/09/client-upcall.sh
93 }
94
95 cleanup() {
96     do_mds "echo 0 > /proc/sys/lustre/fail_loc"
97     unmount_client $@ || true
98     shutdown_mds $@ || true
99     shutdown_ost $@ || true
100 }
101
102 replay() {
103     do_mds "sync"
104     do_mds 'echo -e "device \$mds1\\nprobe\\nnotransno\\nreadonly" | lctl'
105     do_client "$1" &
106     shutdown_mds -f
107     start_mds
108     wait
109     do_client "df -h $MOUNTPT" # trigger failover, if we haven't already
110 }
111
112 if [ ! -z "$ONLY" ]; then
113     eval "$ONLY"
114     exit $?
115 fi
116
117 setup
118 drop_request "mcreate /mnt/lustre/1"
119 drop_reply "mcreate /mnt/lustre/2"
120 # replay "mcreate /mnt/lustre/3"
121
122 drop_request "tchmod 111 /mnt/lustre/2"
123 drop_reply "tchmod 666 /mnt/lustre/2"
124 # replay "tchmod 444 /mnt/lustre/2"
125
126 drop_request "statone /mnt/lustre/2"
127 drop_reply "statone /mnt/lustre/2"
128 # replay "statone /mnt/lustre/2"
129
130 do_client "cp /etc/resolv.conf /mnt/lustre/resolv.conf"
131 drop_request "cat /mnt/lustre/resolv.conf > /dev/null"
132 drop_reply "cat /mnt/lustre/resolv.conf > /dev/null"
133
134 drop_request "mv /mnt/lustre/resolv.conf /mnt/lustre/renamed"
135 drop_reply "mv /mnt/lustre/renamed /mnt/lustre/renamed-again"
136
137 drop_request "mlink /mnt/lustre/renamed-again /mnt/lustre/link1"
138 drop_reply "mlink /mnt/lustre/renamed-again /mnt/lustre/link2"
139
140 drop_request "munlink /mnt/lustre/link1"
141 drop_reply "munlink /mnt/lustre/link2"
142
143
144 cleanup