Skip to content

Commit 4316b79

Browse files
committed
block: kill legacy parts of timeout handling
The only user of legacy timing now is BSG, which is invoked from the mq timeout handler. Kill the legacy code, and rename the q->rq_timed_out_fn to q->bsg_job_timeout_fn. Reviewed-by: Hannes Reinecke <hare@suse.com> Tested-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 92bc5a2 commit 4316b79

File tree

6 files changed

+11
-107
lines changed

6 files changed

+11
-107
lines changed

block/blk-core.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id,
656656
laptop_mode_timer_fn, 0);
657657
timer_setup(&q->timeout, blk_rq_timed_out_timer, 0);
658658
INIT_WORK(&q->timeout_work, NULL);
659-
INIT_LIST_HEAD(&q->timeout_list);
660659
INIT_LIST_HEAD(&q->icq_list);
661660
#ifdef CONFIG_BLK_CGROUP
662661
INIT_LIST_HEAD(&q->blkg_list);

block/blk-settings.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout)
3232
}
3333
EXPORT_SYMBOL_GPL(blk_queue_rq_timeout);
3434

35-
void blk_queue_rq_timed_out(struct request_queue *q, rq_timed_out_fn *fn)
36-
{
37-
WARN_ON_ONCE(q->mq_ops);
38-
q->rq_timed_out_fn = fn;
39-
}
40-
EXPORT_SYMBOL_GPL(blk_queue_rq_timed_out);
41-
4235
/**
4336
* blk_set_default_limits - reset limits to default values
4437
* @lim: the queue_limits structure to reset

block/blk-timeout.c

Lines changed: 7 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -78,70 +78,6 @@ void blk_delete_timer(struct request *req)
7878
list_del_init(&req->timeout_list);
7979
}
8080

81-
static void blk_rq_timed_out(struct request *req)
82-
{
83-
struct request_queue *q = req->q;
84-
enum blk_eh_timer_return ret = BLK_EH_RESET_TIMER;
85-
86-
if (q->rq_timed_out_fn)
87-
ret = q->rq_timed_out_fn(req);
88-
switch (ret) {
89-
case BLK_EH_RESET_TIMER:
90-
blk_add_timer(req);
91-
blk_clear_rq_complete(req);
92-
break;
93-
case BLK_EH_DONE:
94-
/*
95-
* LLD handles this for now but in the future
96-
* we can send a request msg to abort the command
97-
* and we can move more of the generic scsi eh code to
98-
* the blk layer.
99-
*/
100-
break;
101-
default:
102-
printk(KERN_ERR "block: bad eh return: %d\n", ret);
103-
break;
104-
}
105-
}
106-
107-
static void blk_rq_check_expired(struct request *rq, unsigned long *next_timeout,
108-
unsigned int *next_set)
109-
{
110-
const unsigned long deadline = blk_rq_deadline(rq);
111-
112-
if (time_after_eq(jiffies, deadline)) {
113-
list_del_init(&rq->timeout_list);
114-
115-
/*
116-
* Check if we raced with end io completion
117-
*/
118-
if (!blk_mark_rq_complete(rq))
119-
blk_rq_timed_out(rq);
120-
} else if (!*next_set || time_after(*next_timeout, deadline)) {
121-
*next_timeout = deadline;
122-
*next_set = 1;
123-
}
124-
}
125-
126-
void blk_timeout_work(struct work_struct *work)
127-
{
128-
struct request_queue *q =
129-
container_of(work, struct request_queue, timeout_work);
130-
unsigned long flags, next = 0;
131-
struct request *rq, *tmp;
132-
int next_set = 0;
133-
134-
spin_lock_irqsave(q->queue_lock, flags);
135-
136-
list_for_each_entry_safe(rq, tmp, &q->timeout_list, timeout_list)
137-
blk_rq_check_expired(rq, &next, &next_set);
138-
139-
if (next_set)
140-
mod_timer(&q->timeout, round_jiffies_up(next));
141-
142-
spin_unlock_irqrestore(q->queue_lock, flags);
143-
}
144-
14581
/**
14682
* blk_abort_request -- Request request recovery for the specified command
14783
* @req: pointer to the request of interest
@@ -153,20 +89,13 @@ void blk_timeout_work(struct work_struct *work)
15389
*/
15490
void blk_abort_request(struct request *req)
15591
{
156-
if (req->q->mq_ops) {
157-
/*
158-
* All we need to ensure is that timeout scan takes place
159-
* immediately and that scan sees the new timeout value.
160-
* No need for fancy synchronizations.
161-
*/
162-
blk_rq_set_deadline(req, jiffies);
163-
kblockd_schedule_work(&req->q->timeout_work);
164-
} else {
165-
if (blk_mark_rq_complete(req))
166-
return;
167-
blk_delete_timer(req);
168-
blk_rq_timed_out(req);
169-
}
92+
/*
93+
* All we need to ensure is that timeout scan takes place
94+
* immediately and that scan sees the new timeout value.
95+
* No need for fancy synchronizations.
96+
*/
97+
blk_rq_set_deadline(req, jiffies);
98+
kblockd_schedule_work(&req->q->timeout_work);
17099
}
171100
EXPORT_SYMBOL_GPL(blk_abort_request);
172101

@@ -194,13 +123,6 @@ void blk_add_timer(struct request *req)
194123
struct request_queue *q = req->q;
195124
unsigned long expiry;
196125

197-
if (!q->mq_ops)
198-
lockdep_assert_held(q->queue_lock);
199-
200-
/* blk-mq has its own handler, so we don't need ->rq_timed_out_fn */
201-
if (!q->mq_ops && !q->rq_timed_out_fn)
202-
return;
203-
204126
BUG_ON(!list_empty(&req->timeout_list));
205127

206128
/*
@@ -213,13 +135,6 @@ void blk_add_timer(struct request *req)
213135
req->rq_flags &= ~RQF_TIMED_OUT;
214136
blk_rq_set_deadline(req, jiffies + req->timeout);
215137

216-
/*
217-
* Only the non-mq case needs to add the request to a protected list.
218-
* For the mq case we simply scan the tag map.
219-
*/
220-
if (!q->mq_ops)
221-
list_add_tail(&req->timeout_list, &req->q->timeout_list);
222-
223138
/*
224139
* If the timer isn't already pending or this timeout is earlier
225140
* than an existing one, modify the timer. Round up to next nearest

block/blk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ static inline bool bio_integrity_endio(struct bio *bio)
224224
}
225225
#endif /* CONFIG_BLK_DEV_INTEGRITY */
226226

227-
void blk_timeout_work(struct work_struct *work);
228227
unsigned long blk_rq_timeout(unsigned long timeout);
229228
void blk_add_timer(struct request *req);
230229
void blk_delete_timer(struct request *);

block/bsg-lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ static enum blk_eh_timer_return bsg_timeout(struct request *rq, bool reserved)
307307
enum blk_eh_timer_return ret = BLK_EH_DONE;
308308
struct request_queue *q = rq->q;
309309

310-
if (q->rq_timed_out_fn)
311-
ret = q->rq_timed_out_fn(rq);
310+
if (q->bsg_job_timeout_fn)
311+
ret = q->bsg_job_timeout_fn(rq);
312312

313313
return ret;
314314
}
@@ -357,9 +357,9 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
357357

358358
q->queuedata = dev;
359359
q->bsg_job_fn = job_fn;
360+
q->bsg_job_timeout_fn = timeout;
360361
blk_queue_flag_set(QUEUE_FLAG_BIDI, q);
361362
blk_queue_rq_timeout(q, BLK_DEFAULT_SG_TIMEOUT);
362-
q->rq_timed_out_fn = timeout;
363363

364364
ret = bsg_register_queue(q, dev, name, &bsg_transport_ops);
365365
if (ret) {

include/linux/blkdev.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ struct request_queue {
441441
make_request_fn *make_request_fn;
442442
poll_q_fn *poll_fn;
443443
softirq_done_fn *softirq_done_fn;
444-
rq_timed_out_fn *rq_timed_out_fn;
445444
dma_drain_needed_fn *dma_drain_needed;
446445
/* Called just after a request is allocated */
447446
init_rq_fn *init_rq_fn;
@@ -541,7 +540,6 @@ struct request_queue {
541540

542541
struct timer_list timeout;
543542
struct work_struct timeout_work;
544-
struct list_head timeout_list;
545543

546544
struct list_head icq_list;
547545
#ifdef CONFIG_BLK_CGROUP
@@ -601,6 +599,7 @@ struct request_queue {
601599

602600
#if defined(CONFIG_BLK_DEV_BSG)
603601
bsg_job_fn *bsg_job_fn;
602+
rq_timed_out_fn *bsg_job_timeout_fn;
604603
struct bsg_class_device bsg_dev;
605604
#endif
606605

@@ -1156,7 +1155,6 @@ extern void blk_queue_virt_boundary(struct request_queue *, unsigned long);
11561155
extern void blk_queue_dma_alignment(struct request_queue *, int);
11571156
extern void blk_queue_update_dma_alignment(struct request_queue *, int);
11581157
extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
1159-
extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
11601158
extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
11611159
extern void blk_queue_flush_queueable(struct request_queue *q, bool queueable);
11621160
extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);

0 commit comments

Comments
 (0)