Skip to content

Commit 5448aca

Browse files
committed
null_blk: wire up timeouts
This is needed to ensure that we actually handle timeouts. Without it, the queue_mode=1 path will never call blk_add_timer(), and the queue_mode=2 path will continually just return EH_RESET_TIMER and we never actually complete the offending request. This was used to test the new timeout code, and the changes around killing off REQ_ATOM_COMPLETE. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 8abef10 commit 5448aca

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

drivers/block/null_blk.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,12 @@ static blk_qc_t null_queue_bio(struct request_queue *q, struct bio *bio)
13411341
return BLK_QC_T_NONE;
13421342
}
13431343

1344+
static enum blk_eh_timer_return null_rq_timed_out_fn(struct request *rq)
1345+
{
1346+
pr_info("null: rq %p timed out\n", rq);
1347+
return BLK_EH_HANDLED;
1348+
}
1349+
13441350
static int null_rq_prep_fn(struct request_queue *q, struct request *req)
13451351
{
13461352
struct nullb *nullb = q->queuedata;
@@ -1371,6 +1377,12 @@ static void null_request_fn(struct request_queue *q)
13711377
}
13721378
}
13731379

1380+
static enum blk_eh_timer_return null_timeout_rq(struct request *rq, bool res)
1381+
{
1382+
pr_info("null: rq %p timed out\n", rq);
1383+
return BLK_EH_HANDLED;
1384+
}
1385+
13741386
static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
13751387
const struct blk_mq_queue_data *bd)
13761388
{
@@ -1394,6 +1406,7 @@ static blk_status_t null_queue_rq(struct blk_mq_hw_ctx *hctx,
13941406
static const struct blk_mq_ops null_mq_ops = {
13951407
.queue_rq = null_queue_rq,
13961408
.complete = null_softirq_done_fn,
1409+
.timeout = null_timeout_rq,
13971410
};
13981411

13991412
static void cleanup_queue(struct nullb_queue *nq)
@@ -1654,6 +1667,7 @@ static int null_add_dev(struct nullb_device *dev)
16541667
if (rv)
16551668
goto out_cleanup_queues;
16561669

1670+
nullb->tag_set->timeout = 5 * HZ;
16571671
nullb->q = blk_mq_init_queue(nullb->tag_set);
16581672
if (IS_ERR(nullb->q)) {
16591673
rv = -ENOMEM;
@@ -1679,6 +1693,8 @@ static int null_add_dev(struct nullb_device *dev)
16791693
}
16801694
blk_queue_prep_rq(nullb->q, null_rq_prep_fn);
16811695
blk_queue_softirq_done(nullb->q, null_softirq_done_fn);
1696+
blk_queue_rq_timed_out(nullb->q, null_rq_timed_out_fn);
1697+
nullb->q->rq_timeout = 5 * HZ;
16821698
rv = init_driver_queues(nullb);
16831699
if (rv)
16841700
goto out_cleanup_blk_queue;

0 commit comments

Comments
 (0)