Skip to content

Commit d666ba9

Browse files
committed
blk-mq: add mq_ops->commit_rqs()
blk-mq passes information to the hardware about any given request being the last that we will issue in this sequence. The point is that hardware can defer costly doorbell type writes to the last request. But if we run into errors issuing a sequence of requests, we may never send the request with bd->last == true set. For that case, we need a hook that tells the hardware that nothing else is coming right now. For failures returned by the drivers ->queue_rq() hook, the driver is responsible for flushing pending requests, if it uses bd->last to optimize that part. This works like before, no changes there. Reviewed-by: Omar Sandoval <[email protected]> Reviewed-by: Ming Lei <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ce5b009 commit d666ba9

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

block/blk-mq.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,14 @@ bool blk_mq_dispatch_rq_list(struct request_queue *q, struct list_head *list,
12591259
if (!list_empty(list)) {
12601260
bool needs_restart;
12611261

1262+
/*
1263+
* If we didn't flush the entire list, we could have told
1264+
* the driver there was more coming, but that turned out to
1265+
* be a lie.
1266+
*/
1267+
if (q->mq_ops->commit_rqs)
1268+
q->mq_ops->commit_rqs(hctx);
1269+
12621270
spin_lock(&hctx->lock);
12631271
list_splice_init(list, &hctx->dispatch);
12641272
spin_unlock(&hctx->lock);
@@ -1865,6 +1873,14 @@ void blk_mq_try_issue_list_directly(struct blk_mq_hw_ctx *hctx,
18651873
blk_mq_end_request(rq, ret);
18661874
}
18671875
}
1876+
1877+
/*
1878+
* If we didn't flush the entire list, we could have told
1879+
* the driver there was more coming, but that turned out to
1880+
* be a lie.
1881+
*/
1882+
if (!list_empty(list) && hctx->queue->mq_ops->commit_rqs)
1883+
hctx->queue->mq_ops->commit_rqs(hctx);
18681884
}
18691885

18701886
static void blk_add_rq_to_plug(struct blk_plug *plug, struct request *rq)

include/linux/blk-mq.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct blk_mq_queue_data {
117117

118118
typedef blk_status_t (queue_rq_fn)(struct blk_mq_hw_ctx *,
119119
const struct blk_mq_queue_data *);
120+
typedef void (commit_rqs_fn)(struct blk_mq_hw_ctx *);
120121
/* takes rq->cmd_flags as input, returns a hardware type index */
121122
typedef int (rq_flags_to_type_fn)(struct request_queue *, unsigned int);
122123
typedef bool (get_budget_fn)(struct blk_mq_hw_ctx *);
@@ -144,6 +145,15 @@ struct blk_mq_ops {
144145
*/
145146
queue_rq_fn *queue_rq;
146147

148+
/*
149+
* If a driver uses bd->last to judge when to submit requests to
150+
* hardware, it must define this function. In case of errors that
151+
* make us stop issuing further requests, this hook serves the
152+
* purpose of kicking the hardware (which the last request otherwise
153+
* would have done).
154+
*/
155+
commit_rqs_fn *commit_rqs;
156+
147157
/*
148158
* Return a queue map type for the given request/bio flags
149159
*/

0 commit comments

Comments
 (0)