fault-injection cleanup
Subsystems (6)
Akinobu Mita
maintainercover fault-injection cleanup
This collection of cleanup patches removes about 100 lines of code without reducing any functionalities of fault-injection.
Akinobu Mita (7):
fault-injection: do not include unneeded header
fault-injection: remove nonexistent function extern
fault-injection: cleanup simple attribute of stacktrace_depth
fault-injection: use debugfs_remove_recursive
failslab: simplify debugfs initialization
fail_page_alloc: simplify debugfs initialization
fail_make_request: cleanup should_fail_request
block/blk-core.c | 26 ++++---- include/linux/fault-inject.h | 19 +----- lib/fault-inject.c | 144 ++++++++++++------------------------------ mm/failslab.c | 31 +++------ mm/page_alloc.c | 51 +++++---------- 5 files changed, 82 insertions(+), 189 deletions(-)
Signature · 1 line
1.7.4.4
Akinobu Mita
maintainerPATCH 1/7 fault-injection: do not include unneeded header
No need to include linux/kallsyms.h.
--- lib/fault-inject.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
lib/fault-inject.c +0 -1
@@ -8,7 +8,6 @@#include <linux/module.h> #include <linux/interrupt.h> #include <linux/stacktrace.h> -#include <linux/kallsyms.h> #include <linux/fault-inject.h> /*
Signature · 1 line
1.7.4.4
Akinobu Mita
maintainerPATCH 2/7 fault-injection: remove nonexistent function extern
In reply to Akinobu Mitashould_fail_srandom() does not exist.
--- include/linux/fault-inject.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
include/linux/fault-inject.h +0 -1
@@ -57,7 +57,6 @@ struct fault_attr {#define DECLARE_FAULT_ATTR (name) struct fault_attr name = FAULT_ATTR_INITIALIZERint setup_fault_attr (struct fault_attr *attr,char *str); -void should_fail_srandom (unsigned long entropy);bool should_fail (struct fault_attr *attr,ssize_t size);#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
Signature · 1 line
1.7.4.4
Akinobu Mita
maintainerPATCH 3/7 fault-injection: cleanup simple attribute of stacktrace_depth
In reply to Akinobu MitaMinor cosmetic changes for simple attribute of stacktrace_depth:
- use min_t()
- reduce #ifdef by moving a function
- do not use partly capitalized function name
--- lib/fault-inject.c | 30 +++++++++++++++--------------- 1 files changed, 15 insertions(+), 15 deletions(-)
lib/fault-inject.c +15 -15
@@ -139,16 +139,6 @@ static int debugfs_ul_set(void *data, u64 val)return 0 ; } -#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER -static int debugfs_ul_set_MAX_STACK_TRACE_DEPTH (void *data,u64 val) -{ - *(unsigned long *)data = - val <MAX_STACK_TRACE_DEPTH ? - val :MAX_STACK_TRACE_DEPTH ; -return 0 ; -} -#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ -static int debugfs_ul_get (void *data,u64 *val) { *val = *(unsigned long *)data;
@@ -164,16 +154,26 @@ static struct dentry *debugfs_create_ul(const char *name, mode_t mode, }#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER -DEFINE_SIMPLE_ATTRIBUTE (fops_ul_MAX_STACK_TRACE_DEPTH, debugfs_ul_get, - debugfs_ul_set_MAX_STACK_TRACE_DEPTH,"%llu\n" ); -static struct dentry *debugfs_create_ul_MAX_STACK_TRACE_DEPTH ( +static int debugfs_stacktrace_depth_set (void *data,u64 val) +{ + *(unsigned long *)data = + min_t(unsigned long, val, MAX_STACK_TRACE_DEPTH); + +return 0 ; +} + +DEFINE_SIMPLE_ATTRIBUTE (fops_stacktrace_depth, debugfs_ul_get, + debugfs_stacktrace_depth_set,"%llu\n" ); + +static struct dentry *debugfs_create_stacktrace_depth (const char *name,mode_t mode,struct dentry *parent,unsigned long *value) {return debugfs_create_file (name, mode, parent, value, - &fops_ul_MAX_STACK_TRACE_DEPTH); + &fops_stacktrace_depth); } +#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ static int debugfs_atomic_t_set (void *data,u64 val)
@@ -281,7 +281,7 @@ int init_fault_attr_dentries(struct fault_attr *attr, const char *name)#ifdef CONFIG_FAULT_INJECTION_STACKTRACE_FILTER attr->dentries.stacktrace_depth_file = -debugfs_create_ul_MAX_STACK_TRACE_DEPTH ( +debugfs_create_stacktrace_depth ("stacktrace-depth" , mode, dir, &attr->stacktrace_depth); attr->dentries.require_start_file =
Signature · 1 line
1.7.4.4
Akinobu Mita
maintainerPATCH 4/7 fault-injection: use debugfs_remove_recursive
In reply to Akinobu MitaUse debugfs_remove_recursive() to simplify initialization and deinitialization of fault injection debugfs files.
--- include/linux/fault-inject.h | 18 +------ lib/fault-inject.c | 115 ++++++++++-------------------------------- mm/failslab.c | 2 +- mm/page_alloc.c | 2 +- 4 files changed, 30 insertions(+), 107 deletions(-)
include/linux/fault-inject.h +1 -17
@@ -27,23 +27,7 @@ struct fault_attr {unsigned long count;#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS - -struct { -struct dentry *dir; - -struct dentry *probability_file; -struct dentry *interval_file; -struct dentry *times_file; -struct dentry *space_file; -struct dentry *verbose_file; -struct dentry *task_filter_file; -struct dentry *stacktrace_depth_file; -struct dentry *require_start_file; -struct dentry *require_end_file; -struct dentry *reject_start_file; -struct dentry *reject_end_file; - } dentries; - +struct dentry *dir;#endif };
lib/fault-inject.c +27 -88
141 lines not on this page · raw message
mm/failslab.c +1 -1
@@ -45,7 +45,7 @@ static int __init failslab_debugfs_init(void) err =init_fault_attr_dentries (&failslab.attr,"failslab" );if (err)return err; - dir = failslab.attr.dentries.dir; + dir = failslab.attr.dir; failslab.ignore_gfp_wait_file = debugfs_create_bool("ignore-gfp-wait", mode, dir,
mm/page_alloc.c +1 -1
@@ -1424,7 +1424,7 @@ static int __init fail_page_alloc_debugfs(void) "fail_page_alloc");if (err)return err; - dir = fail_page_alloc.attr.dentries.dir; + dir = fail_page_alloc.attr.dir; fail_page_alloc.ignore_gfp_wait_file = debugfs_create_bool("ignore-gfp-wait", mode, dir,
Signature · 1 line
1.7.4.4
Akinobu Mita
maintainerPATCH 5/7 failslab: simplify debugfs initialization
In reply to Akinobu MitaNow cleanup_fault_attr_dentries() recursively removes a directory, So we can simplify the error handling in the initialization code and no need to hold dentry structs for each debugfs file.
--- mm/failslab.c | 31 ++++++++++--------------------- 1 files changed, 10 insertions(+), 21 deletions(-)
mm/failslab.c +10 -21
@@ -5,10 +5,6 @@ static struct {struct fault_attr attr;u32 ignore_gfp_wait;int cache_filter; -#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS -struct dentry *ignore_gfp_wait_file; -struct dentry *cache_filter_file; -#endif } failslab = { .attr = FAULT_ATTR_INITIALIZER, .ignore_gfp_wait = 1,
@@ -39,31 +35,24 @@ __setup("failslab=", setup_failslab);static int __init failslab_debugfs_init (void ) {mode_t mode =S_IFREG |S_IRUSR |S_IWUSR ; -struct dentry *dir;int err; err =init_fault_attr_dentries (&failslab.attr,"failslab" );if (err)return err; - dir = failslab.attr.dir; - - failslab.ignore_gfp_wait_file = -debugfs_create_bool ("ignore-gfp-wait" , mode, dir, - &failslab.ignore_gfp_wait); - failslab.cache_filter_file = -debugfs_create_bool ("cache-filter" , mode, dir, - &failslab.cache_filter); +if (!debugfs_create_bool ("ignore-gfp-wait" , mode, failslab.attr.dir, + &failslab.ignore_gfp_wait)) + goto fail; +if (!debugfs_create_bool ("cache-filter" , mode, failslab.attr.dir, + &failslab.cache_filter)) + goto fail; -if (!failslab.ignore_gfp_wait_file || - !failslab.cache_filter_file) { - err = -ENOMEM ; -debugfs_remove (failslab.cache_filter_file); -debugfs_remove (failslab.ignore_gfp_wait_file); -cleanup_fault_attr_dentries (&failslab.attr); - } +return 0 ; +fail: +cleanup_fault_attr_dentries (&failslab.attr); -return err; +return -ENOMEM ; }late_initcall (failslab_debugfs_init);
Signature · 8 lines
1.7.4.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Akinobu Mita
maintainerPATCH 6/7 fail_page_alloc: simplify debugfs initialization
In reply to Akinobu MitaNow cleanup_fault_attr_dentries() recursively removes a directory, So we can simplify the error handling in the initialization code and no need to hold dentry structs for each debugfs file.
--- mm/page_alloc.c | 47 ++++++++++++++++------------------------------- 1 files changed, 16 insertions(+), 31 deletions(-)
mm/page_alloc.c +16 -31
@@ -1370,21 +1370,12 @@ failed:#ifdef CONFIG_FAIL_PAGE_ALLOC -static struct fail_page_alloc_attr { +static struct {struct fault_attr attr;u32 ignore_gfp_highmem;u32 ignore_gfp_wait;u32 min_order; - -#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS - -struct dentry *ignore_gfp_highmem_file; -struct dentry *ignore_gfp_wait_file; -struct dentry *min_order_file; - -#endif /* CONFIG_FAULT_INJECTION_DEBUG_FS */ - } fail_page_alloc = { .attr =FAULT_ATTR_INITIALIZER , .ignore_gfp_wait = 1,
@@ -1424,30 +1415,24 @@ static int __init fail_page_alloc_debugfs(void) "fail_page_alloc");if (err)return err; + dir = fail_page_alloc.attr.dir; - fail_page_alloc.ignore_gfp_wait_file = -debugfs_create_bool ("ignore-gfp-wait" , mode, dir, - &fail_page_alloc.ignore_gfp_wait); - - fail_page_alloc.ignore_gfp_highmem_file = -debugfs_create_bool ("ignore-gfp-highmem" , mode, dir, - &fail_page_alloc.ignore_gfp_highmem); - fail_page_alloc.min_order_file = -debugfs_create_u32 ("min-order" , mode, dir, - &fail_page_alloc.min_order); - -if (!fail_page_alloc.ignore_gfp_wait_file || - !fail_page_alloc.ignore_gfp_highmem_file || - !fail_page_alloc.min_order_file) { - err = -ENOMEM ; -debugfs_remove (fail_page_alloc.ignore_gfp_wait_file); -debugfs_remove (fail_page_alloc.ignore_gfp_highmem_file); -debugfs_remove (fail_page_alloc.min_order_file); -cleanup_fault_attr_dentries (&fail_page_alloc.attr); - } +if (!debugfs_create_bool ("ignore-gfp-wait" , mode, dir, + &fail_page_alloc.ignore_gfp_wait)) + goto fail; +if (!debugfs_create_bool ("ignore-gfp-highmem" , mode, dir, + &fail_page_alloc.ignore_gfp_highmem)) + goto fail; +if (!debugfs_create_u32 ("min-order" , mode, dir, + &fail_page_alloc.min_order)) + goto fail; + +return 0 ; +fail: +cleanup_fault_attr_dentries (&fail_page_alloc.attr); -return err; +return -ENOMEM ; }late_initcall (fail_page_alloc_debugfs);
Signature · 8 lines
1.7.4.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Akinobu Mita
maintainerPATCH 7/7 fail_make_request: cleanup should_fail_request
In reply to Akinobu MitaThis changes should_fail_request() to more usable wrapper function of should_fail(). It can avoid putting #ifdef CONFIG_FAIL_MAKE_REQUEST in the middle of a function.
--- block/blk-core.c | 26 ++++++++++++-------------- 1 files changed, 12 insertions(+), 14 deletions(-)
block/blk-core.c +12 -14
@@ -1357,14 +1357,9 @@ static int __init setup_fail_make_request(char *str) }__setup ("fail_make_request=" , setup_fail_make_request); -static int should_fail_request (struct bio *bio) +static bool should_fail_request (struct hd_struct *part,unsigned int bytes) { -struct hd_struct *part = bio->bi_bdev->bd_part; - -if (part_to_disk (part)->part0.make_it_fail || part->make_it_fail) -return should_fail (&fail_make_request, bio->bi_size); - -return 0 ; +return part->make_it_fail &&should_fail (&fail_make_request, bytes); }static int __init fail_make_request_debugfs (void )
@@ -1377,9 +1372,10 @@ late_initcall(fail_make_request_debugfs);#else /* CONFIG_FAIL_MAKE_REQUEST */ -static inline int should_fail_request (struct bio *bio) +static inline bool should_fail_request (struct hd_struct *part, +unsigned int bytes) { -return 0 ; +return false; }#endif /* CONFIG_FAIL_MAKE_REQUEST */
@@ -1462,6 +1458,7 @@ static inline void __generic_make_request(struct bio *bio) old_dev =0 ; do { char b[BDEVNAME_SIZE]; + struct hd_struct *part; q = bdev_get_queue(bio->bi_bdev); if (unlikely(!q)) {
@@ -1485,7 +1482,10 @@ static inline void __generic_make_request(struct bio *bio)if (unlikely (test_bit (QUEUE_FLAG_DEAD , &q->queue_flags))) goto end_io; -if (should_fail_request (bio)) + part = bio->bi_bdev->bd_part; +if (should_fail_request (part, bio->bi_size) || +should_fail_request (&part_to_disk (part)->part0, + bio->bi_size)) goto end_io;/*
@@ -1700,11 +1700,9 @@ int blk_insert_cloned_request(struct request_queue *q, struct request *rq)if (blk_rq_check_limits (q, rq))return -EIO ; -#ifdef CONFIG_FAIL_MAKE_REQUEST -if (rq->rq_disk && rq->rq_disk->part0.make_it_fail && -should_fail (&fail_make_request,blk_rq_bytes (rq))) +if (rq->rq_disk && +should_fail_request (&rq->rq_disk->part0,blk_rq_bytes (rq)))return -EIO ; -#endif spin_lock_irqsave (q->queue_lock, flags);
Signature · 1 line
1.7.4.4