Skip to content

Commit da66126

Browse files
Christoph Hellwigaxboe
authored andcommitted
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: 12f5b93 ("blk-mq: Remove generation seqeunce") Reported-by: Andrew Randrianasulu <[email protected]> Tested-by: Andrew Randrianasulu <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent a347c7a commit da66126

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

block/blk-mq.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ static void __blk_mq_requeue_request(struct request *rq)
671671

672672
if (blk_mq_request_started(rq)) {
673673
WRITE_ONCE(rq->state, MQ_RQ_IDLE);
674+
rq->rq_flags &= ~RQF_TIMED_OUT;
674675
if (q->dma_drain_size && blk_rq_bytes(rq))
675676
rq->nr_phys_segments--;
676677
}
@@ -770,6 +771,7 @@ EXPORT_SYMBOL(blk_mq_tag_to_rq);
770771

771772
static void blk_mq_rq_timed_out(struct request *req, bool reserved)
772773
{
774+
req->rq_flags |= RQF_TIMED_OUT;
773775
if (req->q->mq_ops->timeout) {
774776
enum blk_eh_timer_return ret;
775777

@@ -779,6 +781,7 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved)
779781
WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
780782
}
781783

784+
req->rq_flags &= ~RQF_TIMED_OUT;
782785
blk_add_timer(req);
783786
}
784787

@@ -788,6 +791,8 @@ static bool blk_mq_req_expired(struct request *rq, unsigned long *next)
788791

789792
if (blk_mq_rq_state(rq) != MQ_RQ_IN_FLIGHT)
790793
return false;
794+
if (rq->rq_flags & RQF_TIMED_OUT)
795+
return false;
791796

792797
deadline = blk_rq_deadline(rq);
793798
if (time_after_eq(jiffies, deadline))

include/linux/blkdev.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ typedef __u32 __bitwise req_flags_t;
127127
#define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19))
128128
/* already slept for hybrid poll */
129129
#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20))
130+
/* ->timeout has been called, don't expire again */
131+
#define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21))
130132

131133
/* flags that prevent us from merging requests: */
132134
#define RQF_NOMERGE_FLAGS \

0 commit comments

Comments
 (0)