aboutsummaryrefslogtreecommitdiffstats
path: root/lib/fault-inject.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2011-08-03 19:21:01 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-08-03 20:25:20 -0400
commitdd48c085c1cdf9446f92826f1fd451167fb6c2fd (patch)
treed62870378cc08af36ea7a41531436bdebddec232 /lib/fault-inject.c
parentf48d1915b86f06a943087e5f9b29542a1ef4cd4d (diff)
fault-injection: add ability to export fault_attr in arbitrary directory
init_fault_attr_dentries() is used to export fault_attr via debugfs. But it can only export it in debugfs root directory. Per Forlin is working on mmc_fail_request which adds support to inject data errors after a completed host transfer in MMC subsystem. The fault_attr for mmc_fail_request should be defined per mmc host and export it in debugfs directory per mmc host like /sys/kernel/debug/mmc0/mmc_fail_request. init_fault_attr_dentries() doesn't help for mmc_fail_request. So this introduces fault_create_debugfs_attr() which is able to create a directory in the arbitrary directory and replace init_fault_attr_dentries(). [akpm@linux-foundation.org: extraneous semicolon, per Randy] Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Tested-by: Per Forlin <per.forlin@linaro.org> Cc: Jens Axboe <axboe@kernel.dk> Cc: Christoph Lameter <cl@linux-foundation.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: Matt Mackall <mpm@selenic.com> Cc: Randy Dunlap <rdunlap@xenotime.net> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib/fault-inject.c')
-rw-r--r--lib/fault-inject.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/fault-inject.c b/lib/fault-inject.c
index 2577b121c7c1..f193b7796449 100644
--- a/lib/fault-inject.c
+++ b/lib/fault-inject.c
@@ -197,21 +197,15 @@ static struct dentry *debugfs_create_atomic_t(const char *name, mode_t mode,
197 return debugfs_create_file(name, mode, parent, value, &fops_atomic_t); 197 return debugfs_create_file(name, mode, parent, value, &fops_atomic_t);
198} 198}
199 199
200void cleanup_fault_attr_dentries(struct fault_attr *attr) 200struct dentry *fault_create_debugfs_attr(const char *name,
201{ 201 struct dentry *parent, struct fault_attr *attr)
202 debugfs_remove_recursive(attr->dir);
203}
204
205int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
206{ 202{
207 mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; 203 mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
208 struct dentry *dir; 204 struct dentry *dir;
209 205
210 dir = debugfs_create_dir(name, NULL); 206 dir = debugfs_create_dir(name, parent);
211 if (!dir) 207 if (!dir)
212 return -ENOMEM; 208 return ERR_PTR(-ENOMEM);
213
214 attr->dir = dir;
215 209
216 if (!debugfs_create_ul("probability", mode, dir, &attr->probability)) 210 if (!debugfs_create_ul("probability", mode, dir, &attr->probability))
217 goto fail; 211 goto fail;
@@ -243,11 +237,11 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name)
243 237
244#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ 238#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */
245 239
246 return 0; 240 return dir;
247fail: 241fail:
248 debugfs_remove_recursive(attr->dir); 242 debugfs_remove_recursive(dir);
249 243
250 return -ENOMEM; 244 return ERR_PTR(-ENOMEM);
251} 245}
252 246
253#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ 247#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */