1 #include <linux/fault-inject.h>
5 struct fault_attr attr
;
7 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
8 struct dentry
*ignore_gfp_wait_file
;
11 .attr
= FAULT_ATTR_INITIALIZER
,
15 bool should_failslab(size_t size
, gfp_t gfpflags
)
17 if (gfpflags
& __GFP_NOFAIL
)
20 if (failslab
.ignore_gfp_wait
&& (gfpflags
& __GFP_WAIT
))
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
;
40 err
= init_fault_attr_dentries(&failslab
.attr
, "failslab");
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
) {
51 debugfs_remove(failslab
.ignore_gfp_wait_file
);
52 cleanup_fault_attr_dentries(&failslab
.attr
);
58 late_initcall(failslab_debugfs_init
);
60 #endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */