Skip to contentSkip to conversation

block-mq: don't re-queue if we get a queue error

PATCH In review Josef Bacik 4 participants 4 messages Mar 28, 2017 – Mar 29, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block-mq: don't re-queue if we get a queue error

When try to issue a request directly and we fail we will requeue the request, but call blk_mq_end_request() as well. This leads to the completed request being on a queuelist and getting ended twice, which causes list corruption in schedulers and other shenanigans.

---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-mq.c +1 -2
index 08a49c6..c5a6985 100644
@@ -1457,8 +1457,6 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
 		return;
 	}
 
-	__blk_mq_requeue_request(rq);
-
 	if (ret == BLK_MQ_RQ_QUEUE_ERROR) {
 		*cookie = BLK_QC_T_NONE;
 		rq->errors = -EIO;
@@ -1466,6 +1464,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
 		return;
 	}
 
+	__blk_mq_requeue_request(rq);
 insert:
 	blk_mq_sched_insert_request(rq, false, true, false, may_sleep);
 }
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Josef Bacik

When try to issue a request directly and we fail we will requeue the request, but call blk_mq_end_request() as well. This leads to the completed request being on a queuelist and getting ended twice, which causes list corruption in schedulers and other shenanigans.

---
 block/blk-mq.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-mq.c +0 -2
index 08a49c6..c5a6985 100644
@@ -1457,8 +1457,6 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
 		return;
 	}
 
-	__blk_mq_requeue_request(rq);
-
 	if (ret == BLK_MQ_RQ_QUEUE_ERROR) {
 		*cookie = BLK_QC_T_NONE;
 		rq->errors = -EIO;

block/blk-mq.c static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie, · line 1470

Quoted 7 lines
block/blk-mq.c +1 -0
@@ -1466,6 +1464,7 @@ static void blk_mq_try_issue_directly(struct request *rq, blk_qc_t *cookie,
 		return;
 	}
 
+	__blk_mq_requeue_request(rq);
 insert:
 	blk_mq_sched_insert_request(rq, false, true, false, may_sleep);
 }
Signature · 1 line
Ming
maintainer
#3 lore raw
In reply to Josef Bacik
Quoted 4 lines · Josef Bacik

When try to issue a request directly and we fail we will requeue the request, but call blk_mq_end_request() as well. This leads to the completed request being on a queuelist and getting ended twice, which causes list corruption in schedulers and other shenanigans.

I think this is purely a cosmetic issue, as it should cause no corruption. But it doesn't make sense to issue a requeue trace, for instance, if we're just going to end the IO anyway. I have applied it for 4.12.

Signature · 1 line
Jens Axboe