@@ -478,9 +478,15 @@ static inline int blk_mq_request_started(struct request *rq)
return blk_mq_rq_state(rq) != MQ_RQ_IDLE;
}
+/*
+ * It is often called in abort handler for avoiding double completion,
+ * MQ_RQ_COMPLETE is one transient state because .complete callback
+ * may end or requeue this request, in either way the request is marked
+ * as IDLE. So return true if this request's state become not IN_FLIGHT.
+ */
static inline int blk_mq_request_completed(struct request *rq)
{
- return blk_mq_rq_state(rq) == MQ_RQ_COMPLETE;
+ return blk_mq_rq_state(rq) != MQ_RQ_IN_FLIGHT;
}
void blk_mq_start_request(struct request *rq);