1 #include <linux/fault-inject.h>
2 #include <linux/slab.h>
5 struct fault_attr attr
;
8 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
9 struct dentry
*ignore_gfp_wait_file
;
10 struct dentry
*cache_filter_file
;
13 .attr
= FAULT_ATTR_INITIALIZER
,
18 bool should_failslab(size_t size
, gfp_t gfpflags
, unsigned long cache_flags
)
20 if (gfpflags
& __GFP_NOFAIL
)
23 if (failslab
.ignore_gfp_wait
&& (gfpflags
& __GFP_WAIT
))
26 if (failslab
.cache_filter
&& !(cache_flags
& SLAB_FAILSLAB
))
29 return should_fail(&failslab
.attr
, size
);
32 static int __init
setup_failslab(char *str
)
34 return setup_fault_attr(&failslab
.attr
, str
);
36 __setup("failslab=", setup_failslab
);
38 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
39 static int __init
failslab_debugfs_init(void)
41 mode_t mode
= S_IFREG
| S_IRUSR
| S_IWUSR
;
45 err
= init_fault_attr_dentries(&failslab
.attr
, "failslab");
48 dir
= failslab
.attr
.dentries
.dir
;
50 failslab
.ignore_gfp_wait_file
=
51 debugfs_create_bool("ignore-gfp-wait", mode
, dir
,
52 &failslab
.ignore_gfp_wait
);
54 failslab
.cache_filter_file
=
55 debugfs_create_bool("cache-filter", mode
, dir
,
56 &failslab
.cache_filter
);
58 if (!failslab
.ignore_gfp_wait_file
||
59 !failslab
.cache_filter_file
) {
61 debugfs_remove(failslab
.cache_filter_file
);
62 debugfs_remove(failslab
.ignore_gfp_wait_file
);
63 cleanup_fault_attr_dentries(&failslab
.attr
);
69 late_initcall(failslab_debugfs_init
);
71 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */
This page took 0.040838 seconds and 5 git commands to generate.