Skip to contentSkip to conversation

blk-mq: force completion

PATCH In review Keith Busch 2 participants 4 messages May 29, 2020

Subsystems (2)
lore
Share & tools
lore

Keith Busch

author maintainer
#0 lore raw

v3 cover blk-mq: force completion

I've renamed the newly exported function from __blk_mq_complete_request() to blk_mq_force_complete_rq() and added kerneldoc for its intended usage.

Reviews and Acks from previous versions are not included for PATCH 1/2 since the name changed.

Keith Busch (2):
blk-mq: export blk_mq_force_complete_rq
nvme: force complete cancelled requests

 block/blk-mq.c           | 15 +++++++++++++--
 drivers/nvme/host/core.c |  2 +-
 include/linux/blk-mq.h   |  1 +
 3 files changed, 15 insertions(+), 3 deletions(-)
Signature · 1 line
2.24.1
author maintainer
#1 lore raw

PATCH v3 1/2 blk-mq: export blk_mq_force_complete_rq

For when drivers have a need to bypass error injection.

---
 block/blk-mq.c         | 15 +++++++++++++--
 include/linux/blk-mq.h |  1 +
 2 files changed, 14 insertions(+), 2 deletions(-)
block/blk-mq.c +13 -2
index cac11945f602..560a114a82f8 100644
@@ -556,7 +556,17 @@ static void __blk_mq_complete_request_remote(void *data)
 	q->mq_ops->complete(rq);
 }
 
-static void __blk_mq_complete_request(struct request *rq)
+/**
+ * blk_mq_force_complete_rq() - Force complete the request, bypassing any error
+ * 				injection that could drop the completion.
+ * @rq: Request to be force completed
+ *
+ * Drivers should use blk_mq_complete_request() to complete requests in their
+ * normal IO path. For timeout error recovery, drivers may call this forced
+ * completion routine after they've reclaimed timed out requests to bypass
+ * potentially subsequent fake timeouts.
+ */
+void blk_mq_force_complete_rq(struct request *rq)
 {
 	struct blk_mq_ctx *ctx = rq->mq_ctx;
 	struct request_queue *q = rq->q;
@@ -602,6 +612,7 @@ static void __blk_mq_complete_request(struct request *rq)
 	}
 	put_cpu();
 }
+EXPORT_SYMBOL_GPL(blk_mq_force_complete_rq);
 
 static void hctx_unlock(struct blk_mq_hw_ctx *hctx, int srcu_idx)
 	__releases(hctx->srcu)
@@ -635,7 +646,7 @@ bool blk_mq_complete_request(struct request *rq)
 {
 	if (unlikely(blk_should_fake_timeout(rq->q)))
 		return false;
-	__blk_mq_complete_request(rq);
+	blk_mq_force_complete_rq(rq);
 	return true;
 }
 EXPORT_SYMBOL(blk_mq_complete_request);
include/linux/blk-mq.h +1 -0
index d7307795439a..856bb10993cf 100644
@@ -494,6 +494,7 @@ void blk_mq_requeue_request(struct request *rq, bool kick_requeue_list);
 void blk_mq_kick_requeue_list(struct request_queue *q);
 void blk_mq_delay_kick_requeue_list(struct request_queue *q, unsigned long msecs);
 bool blk_mq_complete_request(struct request *rq);
+void blk_mq_force_complete_rq(struct request *rq);
 bool blk_mq_bio_list_merge(struct request_queue *q, struct list_head *list,
 			   struct bio *bio, unsigned int nr_segs);
 bool blk_mq_queue_stopped(struct request_queue *q);
Signature · 1 line
2.24.1
#2 lore raw

Re: [PATCHv3 1/2] blk-mq: export blk_mq_force_complete_rq

Quoted 1 line · Keith Busch

For when drivers have a need to bypass error injection.

The subject doesn't quite match the content, and the commit log in general could be a little more verbose. The changes itself look fine to me.

author maintainer
#3 lore raw

PATCH v3 2/2 nvme: force complete cancelled requests

In reply to Keith Busch

Use blk_mq_foce_complete_rq() to bypass fake timeout error injection so that request reclaim may proceed.

---
 drivers/nvme/host/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/core.c +1 -1
index ba860efd250d..891e9461bfae 100644
@@ -310,7 +310,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved)
 		return true;
 
 	nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD;
-	blk_mq_complete_request(req);
+	blk_mq_force_complete_rq(req);
 	return true;
 }
 EXPORT_SYMBOL_GPL(nvme_cancel_request);
Signature · 1 line
2.24.1