Commit 63151a44 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

blk-mq: allow drivers to hook into I/O completion

Split out the bottom half of blk_mq_end_io so that drivers can perform
work when they know a request has been completed, but before it has been
freed.  This also obsoletes blk_mq_end_io_partial as drivers can now
pass any value to blk_update_request directly.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 6700a678
...@@ -294,20 +294,24 @@ void blk_mq_clone_flush_request(struct request *flush_rq, ...@@ -294,20 +294,24 @@ void blk_mq_clone_flush_request(struct request *flush_rq,
hctx->cmd_size); hctx->cmd_size);
} }
bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes) inline void __blk_mq_end_io(struct request *rq, int error)
{ {
if (blk_update_request(rq, error, blk_rq_bytes(rq)))
return true;
blk_account_io_done(rq); blk_account_io_done(rq);
if (rq->end_io) if (rq->end_io)
rq->end_io(rq, error); rq->end_io(rq, error);
else else
blk_mq_free_request(rq); blk_mq_free_request(rq);
return false;
} }
EXPORT_SYMBOL(blk_mq_end_io_partial); EXPORT_SYMBOL(__blk_mq_end_io);
void blk_mq_end_io(struct request *rq, int error)
{
if (blk_update_request(rq, error, blk_rq_bytes(rq)))
BUG();
__blk_mq_end_io(rq, error);
}
EXPORT_SYMBOL(blk_mq_end_io);
static void __blk_mq_complete_request_remote(void *data) static void __blk_mq_complete_request_remote(void *data)
{ {
......
...@@ -149,13 +149,8 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_ind ...@@ -149,13 +149,8 @@ struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *, const int ctx_ind
struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int); struct blk_mq_hw_ctx *blk_mq_alloc_single_hw_queue(struct blk_mq_tag_set *, unsigned int);
void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int); void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int);
bool blk_mq_end_io_partial(struct request *rq, int error, void blk_mq_end_io(struct request *rq, int error);
unsigned int nr_bytes); void __blk_mq_end_io(struct request *rq, int error);
static inline void blk_mq_end_io(struct request *rq, int error)
{
bool done = !blk_mq_end_io_partial(rq, error, blk_rq_bytes(rq));
BUG_ON(!done);
}
void blk_mq_complete_request(struct request *rq); void blk_mq_complete_request(struct request *rq);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment