diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/fault-injection/failcmd.sh | 4 | ||||
-rw-r--r-- | Documentation/fault-injection/failmodule.sh | 31 | ||||
-rw-r--r-- | Documentation/fault-injection/fault-injection.txt | 105 |
3 files changed, 56 insertions, 84 deletions
diff --git a/Documentation/fault-injection/failcmd.sh b/Documentation/fault-injection/failcmd.sh deleted file mode 100644 index 63177aba8106..000000000000 --- a/Documentation/fault-injection/failcmd.sh +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | echo 1 > /proc/self/make-it-fail | ||
4 | exec $* | ||
diff --git a/Documentation/fault-injection/failmodule.sh b/Documentation/fault-injection/failmodule.sh deleted file mode 100644 index 474a8b971f9c..000000000000 --- a/Documentation/fault-injection/failmodule.sh +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | #!/bin/bash | ||
2 | # | ||
3 | # Usage: failmodule <failname> <modulename> [stacktrace-depth] | ||
4 | # | ||
5 | # <failname>: "failslab", "fail_alloc_page", or "fail_make_request" | ||
6 | # | ||
7 | # <modulename>: module name that you want to inject faults. | ||
8 | # | ||
9 | # [stacktrace-depth]: the maximum number of stacktrace walking allowed | ||
10 | # | ||
11 | |||
12 | STACKTRACE_DEPTH=5 | ||
13 | if [ $# -gt 2 ]; then | ||
14 | STACKTRACE_DEPTH=$3 | ||
15 | fi | ||
16 | |||
17 | if [ ! -d /debug/$1 ]; then | ||
18 | echo "Fault-injection $1 does not exist" >&2 | ||
19 | exit 1 | ||
20 | fi | ||
21 | if [ ! -d /sys/module/$2 ]; then | ||
22 | echo "Module $2 does not exist" >&2 | ||
23 | exit 1 | ||
24 | fi | ||
25 | |||
26 | # Disable any fault injection | ||
27 | echo 0 > /debug/$1/stacktrace-depth | ||
28 | |||
29 | echo `cat /sys/module/$2/sections/.text` > /debug/$1/require-start | ||
30 | echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/require-end | ||
31 | echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth | ||
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt index 36ece095ff17..4bc374a14345 100644 --- a/Documentation/fault-injection/fault-injection.txt +++ b/Documentation/fault-injection/fault-injection.txt | |||
@@ -161,70 +161,77 @@ o add a hook to insert failures | |||
161 | Application Examples | 161 | Application Examples |
162 | -------------------- | 162 | -------------------- |
163 | 163 | ||
164 | o inject slab allocation failures into module init/cleanup code | 164 | o Inject slab allocation failures into module init/exit code |
165 | 165 | ||
166 | ------------------------------------------------------------------------------ | ||
167 | #!/bin/bash | 166 | #!/bin/bash |
168 | 167 | ||
169 | FAILCMD=Documentation/fault-injection/failcmd.sh | 168 | FAILTYPE=failslab |
170 | BLACKLIST="root_plug evbug" | 169 | echo Y > /debug/$FAILTYPE/task-filter |
171 | 170 | echo 10 > /debug/$FAILTYPE/probability | |
172 | FAILNAME=failslab | 171 | echo 100 > /debug/$FAILTYPE/interval |
173 | echo Y > /debug/$FAILNAME/task-filter | 172 | echo -1 > /debug/$FAILTYPE/times |
174 | echo 10 > /debug/$FAILNAME/probability | 173 | echo 0 > /debug/$FAILTYPE/space |
175 | echo 100 > /debug/$FAILNAME/interval | 174 | echo 2 > /debug/$FAILTYPE/verbose |
176 | echo -1 > /debug/$FAILNAME/times | 175 | echo 1 > /debug/$FAILTYPE/ignore-gfp-wait |
177 | echo 2 > /debug/$FAILNAME/verbose | ||
178 | echo 1 > /debug/$FAILNAME/ignore-gfp-wait | ||
179 | 176 | ||
180 | blacklist() | 177 | faulty_system() |
181 | { | 178 | { |
182 | echo $BLACKLIST | grep $1 > /dev/null 2>&1 | 179 | bash -c "echo 1 > /proc/self/make-it-fail && exec $*" |
183 | } | 180 | } |
184 | 181 | ||
185 | oops() | 182 | if [ $# -eq 0 ] |
186 | { | 183 | then |
187 | dmesg | grep BUG > /dev/null 2>&1 | 184 | echo "Usage: $0 modulename [ modulename ... ]" |
188 | } | 185 | exit 1 |
186 | fi | ||
187 | |||
188 | for m in $* | ||
189 | do | ||
190 | echo inserting $m... | ||
191 | faulty_system modprobe $m | ||
189 | 192 | ||
190 | find /lib/modules/`uname -r` -name '*.ko' -exec basename {} .ko \; | | 193 | echo removing $m... |
191 | while read i | 194 | faulty_system modprobe -r $m |
192 | do | 195 | done |
193 | oops && exit 1 | ||
194 | |||
195 | if ! blacklist $i | ||
196 | then | ||
197 | echo inserting $i... | ||
198 | bash $FAILCMD modprobe $i | ||
199 | fi | ||
200 | done | ||
201 | |||
202 | lsmod | awk '{ if ($3 == 0) { print $1 } }' | | ||
203 | while read i | ||
204 | do | ||
205 | oops && exit 1 | ||
206 | |||
207 | if ! blacklist $i | ||
208 | then | ||
209 | echo removing $i... | ||
210 | bash $FAILCMD modprobe -r $i | ||
211 | fi | ||
212 | done | ||
213 | 196 | ||
214 | ------------------------------------------------------------------------------ | 197 | ------------------------------------------------------------------------------ |
215 | 198 | ||
216 | o inject slab allocation failures only for a specific module | 199 | o Inject page allocation failures only for a specific module |
217 | 200 | ||
218 | ------------------------------------------------------------------------------ | ||
219 | #!/bin/bash | 201 | #!/bin/bash |
220 | 202 | ||
221 | FAILMOD=Documentation/fault-injection/failmodule.sh | 203 | FAILTYPE=fail_page_alloc |
204 | module=$1 | ||
222 | 205 | ||
223 | echo injecting errors into the module $1... | 206 | if [ -z $module ] |
207 | then | ||
208 | echo "Usage: $0 <modulename>" | ||
209 | exit 1 | ||
210 | fi | ||
224 | 211 | ||
225 | modprobe $1 | 212 | modprobe $module |
226 | bash $FAILMOD failslab $1 10 | ||
227 | echo 25 > /debug/failslab/probability | ||
228 | 213 | ||
229 | ------------------------------------------------------------------------------ | 214 | if [ ! -d /sys/module/$module/sections ] |
215 | then | ||
216 | echo Module $module is not loaded | ||
217 | exit 1 | ||
218 | fi | ||
219 | |||
220 | cat /sys/module/$module/sections/.text > /debug/$FAILTYPE/require-start | ||
221 | cat /sys/module/$module/sections/.data > /debug/$FAILTYPE/require-end | ||
222 | |||
223 | echo N > /debug/$FAILTYPE/task-filter | ||
224 | echo 10 > /debug/$FAILTYPE/probability | ||
225 | echo 100 > /debug/$FAILTYPE/interval | ||
226 | echo -1 > /debug/$FAILTYPE/times | ||
227 | echo 0 > /debug/$FAILTYPE/space | ||
228 | echo 2 > /debug/$FAILTYPE/verbose | ||
229 | echo 1 > /debug/$FAILTYPE/ignore-gfp-wait | ||
230 | echo 1 > /debug/$FAILTYPE/ignore-gfp-highmem | ||
231 | echo 10 > /debug/$FAILTYPE/stacktrace-depth | ||
232 | |||
233 | trap "echo 0 > /debug/$FAILTYPE/probability" SIGINT SIGTERM EXIT | ||
234 | |||
235 | echo "Injecting errors into the module $module... (interrupt to stop)" | ||
236 | sleep 1000000 | ||
230 | 237 | ||