Commit da661267 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-mq: don't time out requests again that are in the timeout handler

We can currently call the timeout handler again on a request that has
already been handed over to the timeout handler.  Prevent that with a new
flag.

Fixes: 12f5b931 ("blk-mq: Remove generation seqeunce")
Reported-by: default avatarAndrew Randrianasulu <randrianasulu@gmail.com>
Tested-by: default avatarAndrew Randrianasulu <randrianasulu@gmail.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent a347c7ad
...@@ -671,6 +671,7 @@ static void __blk_mq_requeue_request(struct request *rq) ...@@ -671,6 +671,7 @@ static void __blk_mq_requeue_request(struct request *rq)
if (blk_mq_request_started(rq)) { if (blk_mq_request_started(rq)) {
WRITE_ONCE(rq->state, MQ_RQ_IDLE); WRITE_ONCE(rq->state, MQ_RQ_IDLE);
rq->rq_flags &= ~RQF_TIMED_OUT;
if (q->dma_drain_size && blk_rq_bytes(rq)) if (q->dma_drain_size && blk_rq_bytes(rq))
rq->nr_phys_segments--; rq->nr_phys_segments--;
} }
...@@ -770,6 +771,7 @@ EXPORT_SYMBOL(blk_mq_tag_to_rq); ...@@ -770,6 +771,7 @@ EXPORT_SYMBOL(blk_mq_tag_to_rq);
static void blk_mq_rq_timed_out(struct request *req, bool reserved) static void blk_mq_rq_timed_out(struct request *req, bool reserved)
{ {
req->rq_flags |= RQF_TIMED_OUT;
if (req->q->mq_ops->timeout) { if (req->q->mq_ops->timeout) {
enum blk_eh_timer_return ret; enum blk_eh_timer_return ret;
...@@ -779,6 +781,7 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved) ...@@ -779,6 +781,7 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved)
WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER); WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
} }
req->rq_flags &= ~RQF_TIMED_OUT;
blk_add_timer(req); blk_add_timer(req);
} }
...@@ -788,6 +791,8 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next) ...@@ -788,6 +791,8 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)
if (blk_mq_rq_state(rq) != MQ_RQ_IN_FLIGHT) if (blk_mq_rq_state(rq) != MQ_RQ_IN_FLIGHT)
return false; return false;
if (rq->rq_flags & RQF_TIMED_OUT)
return false;
deadline = blk_rq_deadline(rq); deadline = blk_rq_deadline(rq);
if (time_after_eq(jiffies, deadline)) if (time_after_eq(jiffies, deadline))
......
...@@ -127,6 +127,8 @@ typedef __u32 __bitwise req_flags_t; ...@@ -127,6 +127,8 @@ typedef __u32 __bitwise req_flags_t;
#define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19)) #define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19))
/* already slept for hybrid poll */ /* already slept for hybrid poll */
#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20)) #define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20))
/* ->timeout has been called, don't expire again */
#define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21))
/* flags that prevent us from merging requests: */ /* flags that prevent us from merging requests: */
#define RQF_NOMERGE_FLAGS \ #define RQF_NOMERGE_FLAGS \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment