4 #include <linux/kernel.h>
5 #include <linux/module.h>
11 #ifdef CONFIG_FAIL_IO_TIMEOUT
13 static DECLARE_FAULT_ATTR(fail_io_timeout);
15 static int __init setup_fail_io_timeout(
char *
str)
19 __setup(
"fail_io_timeout=", setup_fail_io_timeout);
23 if (!
test_bit(QUEUE_FLAG_FAIL_IO, &q->queue_flags))
29 static int __init fail_io_timeout_debugfs(
void)
31 struct dentry *
dir = fault_create_debugfs_attr(
"fail_io_timeout",
32 NULL, &fail_io_timeout);
34 return IS_ERR(dir) ? PTR_ERR(dir) : 0;
42 struct gendisk *disk = dev_to_disk(dev);
43 int set =
test_bit(QUEUE_FLAG_FAIL_IO, &disk->queue->queue_flags);
45 return sprintf(buf,
"%d\n",
set != 0);
51 struct gendisk *disk = dev_to_disk(dev);
56 char *
p = (
char *) buf;
59 spin_lock_irq(q->queue_lock);
61 queue_flag_set(QUEUE_FLAG_FAIL_IO, q);
63 queue_flag_clear(QUEUE_FLAG_FAIL_IO, q);
64 spin_unlock_irq(q->queue_lock);
79 list_del_init(&req->timeout_list);
82 static void blk_rq_timed_out(
struct request *
req)
85 enum blk_eh_timer_return
ret;
87 ret = q->rq_timed_out_fn(req);
92 case BLK_EH_RESET_TIMER:
93 blk_clear_rq_complete(req);
96 case BLK_EH_NOT_HANDLED:
121 list_del_init(&rq->timeout_list);
126 if (blk_mark_rq_complete(rq))
128 blk_rq_timed_out(rq);
129 }
else if (!next_set ||
time_after(next, rq->deadline)) {
138 spin_unlock_irqrestore(q->queue_lock, flags);
152 if (blk_mark_rq_complete(req))
155 blk_rq_timed_out(req);
170 unsigned long expiry;
172 if (!q->rq_timed_out_fn)
175 BUG_ON(!list_empty(&req->timeout_list));
183 req->timeout = q->rq_timeout;
185 req->deadline =
jiffies + req->timeout;
195 if (!timer_pending(&q->timeout) ||