aha/Documentation/fault-injection/failmodule.sh
Akinobu Mita de1ba09b21 [PATCH] fault injection: documentation and scripts
This patch set provides some fault-injection capabilities.

- kmalloc() failures

- alloc_pages() failures

- disk IO errors

We can see what really happens if those failures happen.

In order to enable these fault-injection capabilities:

1. Enable relevant config options (CONFIG_FAILSLAB, CONFIG_PAGE_ALLOC,
   CONFIG_MAKE_REQUEST) and if you want to configure them via debugfs,
   enable CONFIG_FAULT_INJECTION_DEBUG_FS.

2. Build and boot with this kernel

3. Configure fault-injection capabilities behavior by boot option or debugfs

   - Boot option

     failslab=
     fail_page_alloc=
     fail_make_request=

   - Debugfs

     /debug/failslab/*
     /debug/fail_page_alloc/*
     /debug/fail_make_request/*

   Please refer to the Documentation/fault-injection/fault-injection.txt
   for details.

4. See what really happens.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Don Mullis <dwm@meer.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 08:29:02 -08:00

31 lines
774 B
Bash

#!/bin/bash
#
# Usage: failmodule <failname> <modulename> [stacktrace-depth]
#
# <failname>: "failslab", "fail_alloc_page", or "fail_make_request"
#
# <modulename>: module name that you want to inject faults.
#
# [stacktrace-depth]: the maximum number of stacktrace walking allowed
#
STACKTRACE_DEPTH=5
if [ $# -gt 2 ]; then
STACKTRACE_DEPTH=$3
fi
if [ ! -d /debug/$1 ]; then
echo "Fault-injection $1 does not exist" >&2
exit 1
fi
if [ ! -d /sys/module/$2 ]; then
echo "Module $2 does not exist" >&2
exit 1
fi
# Disable any fault injection
echo 0 > /debug/$1/stacktrace-depth
echo `cat /sys/module/$2/sections/.text` > /debug/$1/address-start
echo `cat /sys/module/$2/sections/.exit.text` > /debug/$1/address-end
echo $STACKTRACE_DEPTH > /debug/$1/stacktrace-depth