diff options
Diffstat (limited to 'mm/failslab.c')
-rw-r--r-- | mm/failslab.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/mm/failslab.c b/mm/failslab.c index 9339de5f0a91..c5f88f240ddc 100644 --- a/mm/failslab.c +++ b/mm/failslab.c | |||
@@ -1,18 +1,21 @@ | |||
1 | #include <linux/fault-inject.h> | 1 | #include <linux/fault-inject.h> |
2 | #include <linux/gfp.h> | 2 | #include <linux/slab.h> |
3 | 3 | ||
4 | static struct { | 4 | static struct { |
5 | struct fault_attr attr; | 5 | struct fault_attr attr; |
6 | u32 ignore_gfp_wait; | 6 | u32 ignore_gfp_wait; |
7 | int cache_filter; | ||
7 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | 8 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
8 | struct dentry *ignore_gfp_wait_file; | 9 | struct dentry *ignore_gfp_wait_file; |
10 | struct dentry *cache_filter_file; | ||
9 | #endif | 11 | #endif |
10 | } failslab = { | 12 | } failslab = { |
11 | .attr = FAULT_ATTR_INITIALIZER, | 13 | .attr = FAULT_ATTR_INITIALIZER, |
12 | .ignore_gfp_wait = 1, | 14 | .ignore_gfp_wait = 1, |
15 | .cache_filter = 0, | ||
13 | }; | 16 | }; |
14 | 17 | ||
15 | bool should_failslab(size_t size, gfp_t gfpflags) | 18 | bool should_failslab(size_t size, gfp_t gfpflags, unsigned long cache_flags) |
16 | { | 19 | { |
17 | if (gfpflags & __GFP_NOFAIL) | 20 | if (gfpflags & __GFP_NOFAIL) |
18 | return false; | 21 | return false; |
@@ -20,6 +23,9 @@ bool should_failslab(size_t size, gfp_t gfpflags) | |||
20 | if (failslab.ignore_gfp_wait && (gfpflags & __GFP_WAIT)) | 23 | if (failslab.ignore_gfp_wait && (gfpflags & __GFP_WAIT)) |
21 | return false; | 24 | return false; |
22 | 25 | ||
26 | if (failslab.cache_filter && !(cache_flags & SLAB_FAILSLAB)) | ||
27 | return false; | ||
28 | |||
23 | return should_fail(&failslab.attr, size); | 29 | return should_fail(&failslab.attr, size); |
24 | } | 30 | } |
25 | 31 | ||
@@ -30,7 +36,6 @@ static int __init setup_failslab(char *str) | |||
30 | __setup("failslab=", setup_failslab); | 36 | __setup("failslab=", setup_failslab); |
31 | 37 | ||
32 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS | 38 | #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS |
33 | |||
34 | static int __init failslab_debugfs_init(void) | 39 | static int __init failslab_debugfs_init(void) |
35 | { | 40 | { |
36 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; | 41 | mode_t mode = S_IFREG | S_IRUSR | S_IWUSR; |
@@ -46,8 +51,14 @@ static int __init failslab_debugfs_init(void) | |||
46 | debugfs_create_bool("ignore-gfp-wait", mode, dir, | 51 | debugfs_create_bool("ignore-gfp-wait", mode, dir, |
47 | &failslab.ignore_gfp_wait); | 52 | &failslab.ignore_gfp_wait); |
48 | 53 | ||
49 | if (!failslab.ignore_gfp_wait_file) { | 54 | failslab.cache_filter_file = |
55 | debugfs_create_bool("cache-filter", mode, dir, | ||
56 | &failslab.cache_filter); | ||
57 | |||
58 | if (!failslab.ignore_gfp_wait_file || | ||
59 | !failslab.cache_filter_file) { | ||
50 | err = -ENOMEM; | 60 | err = -ENOMEM; |
61 | debugfs_remove(failslab.cache_filter_file); | ||
51 | debugfs_remove(failslab.ignore_gfp_wait_file); | 62 | debugfs_remove(failslab.ignore_gfp_wait_file); |
52 | cleanup_fault_attr_dentries(&failslab.attr); | 63 | cleanup_fault_attr_dentries(&failslab.attr); |
53 | } | 64 | } |