aboutsummaryrefslogtreecommitdiffstats
path: root/block/ll_rw_blk.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/ll_rw_blk.c')
-rw-r--r--block/ll_rw_blk.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 31512cd9f3ad..4f83fd922377 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -28,6 +28,7 @@
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/cpu.h> 29#include <linux/cpu.h>
30#include <linux/blktrace_api.h> 30#include <linux/blktrace_api.h>
31#include <linux/fault-inject.h>
31 32
32/* 33/*
33 * for max sense size 34 * for max sense size
@@ -3056,6 +3057,42 @@ static void handle_bad_sector(struct bio *bio)
3056 set_bit(BIO_EOF, &bio->bi_flags); 3057 set_bit(BIO_EOF, &bio->bi_flags);
3057} 3058}
3058 3059
3060#ifdef CONFIG_FAIL_MAKE_REQUEST
3061
3062static DECLARE_FAULT_ATTR(fail_make_request);
3063
3064static int __init setup_fail_make_request(char *str)
3065{
3066 return setup_fault_attr(&fail_make_request, str);
3067}
3068__setup("fail_make_request=", setup_fail_make_request);
3069
3070static int should_fail_request(struct bio *bio)
3071{
3072 if ((bio->bi_bdev->bd_disk->flags & GENHD_FL_FAIL) ||
3073 (bio->bi_bdev->bd_part && bio->bi_bdev->bd_part->make_it_fail))
3074 return should_fail(&fail_make_request, bio->bi_size);
3075
3076 return 0;
3077}
3078
3079static int __init fail_make_request_debugfs(void)
3080{
3081 return init_fault_attr_dentries(&fail_make_request,
3082 "fail_make_request");
3083}
3084
3085late_initcall(fail_make_request_debugfs);
3086
3087#else /* CONFIG_FAIL_MAKE_REQUEST */
3088
3089static inline int should_fail_request(struct bio *bio)
3090{
3091 return 0;
3092}
3093
3094#endif /* CONFIG_FAIL_MAKE_REQUEST */
3095
3059/** 3096/**
3060 * generic_make_request: hand a buffer to its device driver for I/O 3097 * generic_make_request: hand a buffer to its device driver for I/O
3061 * @bio: The bio describing the location in memory and on the device. 3098 * @bio: The bio describing the location in memory and on the device.
@@ -3141,6 +3178,9 @@ end_io:
3141 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags))) 3178 if (unlikely(test_bit(QUEUE_FLAG_DEAD, &q->queue_flags)))
3142 goto end_io; 3179 goto end_io;
3143 3180
3181 if (should_fail_request(bio))
3182 goto end_io;
3183
3144 /* 3184 /*
3145 * If this device has partitions, remap block n 3185 * If this device has partitions, remap block n
3146 * of partition p to block n+start(p) of the disk. 3186 * of partition p to block n+start(p) of the disk.