aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/fault-inject.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index a7cb3afd132a..03468609d701 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -5,6 +5,7 @@
5#include <linux/types.h> 5#include <linux/types.h>
6#include <linux/fs.h> 6#include <linux/fs.h>
7#include <linux/module.h> 7#include <linux/module.h>
8#include <linux/interrupt.h>
8#include <linux/fault-inject.h> 9#include <linux/fault-inject.h>
9 10
10/* 11/*
@@ -44,6 +45,11 @@ static void fail_dump(struct fault_attr *attr)
44 45
45#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0) 46#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
46 47
48static int fail_task(struct fault_attr *attr, struct task_struct *task)
49{
50 return !in_interrupt() && task->make_it_fail;
51}
52
47/* 53/*
48 * This code is stolen from failmalloc-1.0 54 * This code is stolen from failmalloc-1.0
49 * http://www.nongnu.org/failmalloc/ 55 * http://www.nongnu.org/failmalloc/
@@ -51,6 +57,9 @@ static void fail_dump(struct fault_attr *attr)
51 57
52int should_fail(struct fault_attr *attr, ssize_t size) 58int should_fail(struct fault_attr *attr, ssize_t size)
53{ 59{
60 if (attr->task_filter && !fail_task(attr, current))
61 return 0;
62
54 if (atomic_read(&attr->times) == 0) 63 if (atomic_read(&attr->times) == 0)
55 return 0; 64 return 0;
56 65
@@ -135,6 +144,9 @@ void cleanup_fault_attr_dentries(struct fault_attr *attr)
135 debugfs_remove(attr->dentries.verbose_file); 144 debugfs_remove(attr->dentries.verbose_file);
136 attr->dentries.verbose_file = NULL; 145 attr->dentries.verbose_file = NULL;
137 146
147 debugfs_remove(attr->dentries.task_filter_file);
148 attr->dentries.task_filter_file = NULL;
149
138 if (attr->dentries.dir) 150 if (attr->dentries.dir)
139 WARN_ON(!simple_empty(attr->dentries.dir)); 151 WARN_ON(!simple_empty(attr->dentries.dir));
140 152
@@ -169,9 +181,12 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
169 attr->dentries.verbose_file = 181 attr->dentries.verbose_file =
170 debugfs_create_ul("verbose", mode, dir, &attr->verbose); 182 debugfs_create_ul("verbose", mode, dir, &attr->verbose);
171 183
184 attr->dentries.task_filter_file = debugfs_create_bool("task-filter",
185 mode, dir, &attr->task_filter);
186
172 if (!attr->dentries.probability_file || !attr->dentries.interval_file 187 if (!attr->dentries.probability_file || !attr->dentries.interval_file
173 || !attr->dentries.times_file || !attr->dentries.space_file 188 || !attr->dentries.times_file || !attr->dentries.space_file
174 || !attr->dentries.verbose_file) 189 || !attr->dentries.verbose_file || !attr->dentries.task_filter_file)
175 goto fail; 190 goto fail;
176 191
177 return 0; 192 return 0;