2 * Copyright (c) 2011 Bryan Schumaker <bjschuma@netapp.com>
4 * Uses debugfs to create fault injection points for client testing
7 #include <linux/types.h>
9 #include <linux/debugfs.h>
10 #include <linux/module.h>
13 #include "fault_inject.h"
15 struct nfsd_fault_inject_op {
20 static struct nfsd_fault_inject_op inject_ops[] = {
22 .file = "forget_clients",
23 .func = nfsd_forget_clients,
26 .file = "forget_locks",
27 .func = nfsd_forget_locks,
30 .file = "forget_openowners",
31 .func = nfsd_forget_openowners,
34 .file = "forget_delegations",
35 .func = nfsd_forget_delegations,
38 .file = "recall_delegations",
39 .func = nfsd_recall_delegations,
43 static long int NUM_INJECT_OPS = sizeof(inject_ops) / sizeof(struct nfsd_fault_inject_op);
44 static struct dentry *debug_dir;
46 static int nfsd_inject_set(void *op_ptr, u64 val)
48 struct nfsd_fault_inject_op *op = op_ptr;
51 printk(KERN_INFO "NFSD Fault Injection: %s (all)", op->file);
53 printk(KERN_INFO "NFSD Fault Injection: %s (n = %llu)", op->file, val);
59 static int nfsd_inject_get(void *data, u64 *val)
65 DEFINE_SIMPLE_ATTRIBUTE(fops_nfsd, nfsd_inject_get, nfsd_inject_set, "%llu\n");
67 void nfsd_fault_inject_cleanup(void)
69 debugfs_remove_recursive(debug_dir);
72 int nfsd_fault_inject_init(void)
75 struct nfsd_fault_inject_op *op;
76 umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
78 debug_dir = debugfs_create_dir("nfsd", NULL);
82 for (i = 0; i < NUM_INJECT_OPS; i++) {
84 if (!debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd))
90 nfsd_fault_inject_cleanup();