Remove duplicate slow protocol define in bond_3ad.h
[linux-2.6.git] / mm / failslab.c
blob9339de5f0a915dc0526e276eddbcc5fb918fb13d
1 #include <linux/fault-inject.h>
2 #include <linux/gfp.h>
4 static struct {
5 struct fault_attr attr;
6 u32 ignore_gfp_wait;
7 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
8 struct dentry *ignore_gfp_wait_file;
9 #endif
10 } failslab = {
11 .attr = FAULT_ATTR_INITIALIZER,
12 .ignore_gfp_wait = 1,
15 bool should_failslab(size_t size, gfp_t gfpflags)
17 if (gfpflags & __GFP_NOFAIL)
18 return false;
20 if (failslab.ignore_gfp_wait && (gfpflags & __GFP_WAIT))
21 return false;
23 return should_fail(&failslab.attr, size);
26 static int __init setup_failslab(char *str)
28 return setup_fault_attr(&failslab.attr, str);
30 __setup("failslab=", setup_failslab);
32 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
34 static int __init failslab_debugfs_init(void)
36 mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
37 struct dentry *dir;
38 int err;
40 err = init_fault_attr_dentries(&failslab.attr, "failslab");
41 if (err)
42 return err;
43 dir = failslab.attr.dentries.dir;
45 failslab.ignore_gfp_wait_file =
46 debugfs_create_bool("ignore-gfp-wait", mode, dir,
47 &failslab.ignore_gfp_wait);
49 if (!failslab.ignore_gfp_wait_file) {
50 err = -ENOMEM;
51 debugfs_remove(failslab.ignore_gfp_wait_file);
52 cleanup_fault_attr_dentries(&failslab.attr);
55 return err;
58 late_initcall(failslab_debugfs_init);
60 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */