diff options
author | Christoph Hellwig <hch@lst.de> | 2014-04-14 10:30:08 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-04-15 14:03:02 -0600 |
commit | 8727af4b9d45c7503042e3fbd926c1a173876e9c (patch) | |
tree | e6f2d8b7d9808cfbfb0b67a088b182776518a797 /block/blk-mq.c | |
parent | 9d74e25737d73e93ccddeb5a61bcd56b7b8eb57b (diff) | |
download | lwn-8727af4b9d45c7503042e3fbd926c1a173876e9c.tar.gz lwn-8727af4b9d45c7503042e3fbd926c1a173876e9c.zip |
blk-mq: make ->flush_rq fully transparent to drivers
Drivers shouldn't have to care about the block layer setting aside a
request to implement the flush state machine. We already override the
mq context and tag to make it more transparent, but so far haven't deal
with the driver private data in the request. Make sure to override this
as well, and while we're at it add a proper helper sitting in blk-mq.c
that implements the full impersonation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/blk-mq.c')
-rw-r--r-- | block/blk-mq.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/block/blk-mq.c b/block/blk-mq.c index d9d0984d2f01..e644feec068c 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -275,6 +275,26 @@ void blk_mq_free_request(struct request *rq) __blk_mq_free_request(hctx, ctx, rq); } +/* + * Clone all relevant state from a request that has been put on hold in + * the flush state machine into the preallocated flush request that hangs + * off the request queue. + * + * For a driver the flush request should be invisible, that's why we are + * impersonating the original request here. + */ +void blk_mq_clone_flush_request(struct request *flush_rq, + struct request *orig_rq) +{ + struct blk_mq_hw_ctx *hctx = + orig_rq->q->mq_ops->map_queue(orig_rq->q, orig_rq->mq_ctx->cpu); + + flush_rq->mq_ctx = orig_rq->mq_ctx; + flush_rq->tag = orig_rq->tag; + memcpy(blk_mq_rq_to_pdu(flush_rq), blk_mq_rq_to_pdu(orig_rq), + hctx->cmd_size); +} + bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes) { if (blk_update_request(rq, error, blk_rq_bytes(rq))) |