blk-mq: don't time out requests again that are in the timeout handler
authorChristoph Hellwig <hch@lst.de>
Thu, 14 Jun 2018 11:58:45 +0000 (13:58 +0200)
committerJens Axboe <axboe@kernel.dk>
Thu, 14 Jun 2018 14:39:46 +0000 (08:39 -0600)
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: Andrew Randrianasulu <randrianasulu@gmail.com>
Tested-by: Andrew Randrianasulu <randrianasulu@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c
include/linux/blkdev.h

index 2be78cc30ec58617e1f4a2b91d363559aed9acbe..8e57b84e50e95587839d2d2476f5be039da11e2a 100644 (file)
@@ -671,6 +671,7 @@ static void __blk_mq_requeue_request(struct request *rq)
 
        if (blk_mq_request_started(rq)) {
                WRITE_ONCE(rq->state, MQ_RQ_IDLE);
+               rq->rq_flags &= ~RQF_TIMED_OUT;
                if (q->dma_drain_size && blk_rq_bytes(rq))
                        rq->nr_phys_segments--;
        }
@@ -770,6 +771,7 @@ EXPORT_SYMBOL(blk_mq_tag_to_rq);
 
 static void blk_mq_rq_timed_out(struct request *req, bool reserved)
 {
+       req->rq_flags |= RQF_TIMED_OUT;
        if (req->q->mq_ops->timeout) {
                enum blk_eh_timer_return ret;
 
@@ -779,6 +781,7 @@ static void blk_mq_rq_timed_out(struct request *req, bool reserved)
                WARN_ON_ONCE(ret != BLK_EH_RESET_TIMER);
        }
 
+       req->rq_flags &= ~RQF_TIMED_OUT;
        blk_add_timer(req);
 }
 
@@ -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)
                return false;
+       if (rq->rq_flags & RQF_TIMED_OUT)
+               return false;
 
        deadline = blk_rq_deadline(rq);
        if (time_after_eq(jiffies, deadline))
index bca3a92eb55f5bc88c47c65343d595479cebb9c4..fa6f117514309930814e5137927a64d4b5168e85 100644 (file)
@@ -127,6 +127,8 @@ typedef __u32 __bitwise req_flags_t;
 #define RQF_ZONE_WRITE_LOCKED  ((__force req_flags_t)(1 << 19))
 /* already slept for hybrid poll */
 #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: */
 #define RQF_NOMERGE_FLAGS \