* [PATCH 0/3] next round of blk-mq updates
@ 2014-02-20 23:32 Christoph Hellwig
2014-02-20 23:32 ` [PATCH 1/3] blk-mq: remove blk_mq_alloc_rq Christoph Hellwig
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Christoph Hellwig @ 2014-02-20 23:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-scsi
A couple more blkmq updates: a trivial cleanup, a consolidation of two very
similar functions into one, and support for partial request completions,
a feature needed by the work in progress scsi blk-mq support.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] blk-mq: remove blk_mq_alloc_rq
2014-02-20 23:32 [PATCH 0/3] next round of blk-mq updates Christoph Hellwig
@ 2014-02-20 23:32 ` Christoph Hellwig
2014-02-20 23:32 ` [PATCH 2/3] blk-mq: merge blk_mq_insert_request and blk_mq_run_request Christoph Hellwig
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2014-02-20 23:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-scsi
[-- Attachment #1: 0001-blk-mq-remove-blk_mq_alloc_rq.patch --]
[-- Type: text/plain, Size: 1231 bytes --]
There's only one caller, which is a straight wrapper and fits the naming
scheme of the related functions a lot better.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-mq.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1fa9dd1..1e585e3 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -73,8 +73,8 @@ static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx *hctx,
set_bit(ctx->index_hw, hctx->ctx_map);
}
-static struct request *blk_mq_alloc_rq(struct blk_mq_hw_ctx *hctx, gfp_t gfp,
- bool reserved)
+static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
+ gfp_t gfp, bool reserved)
{
struct request *rq;
unsigned int tag;
@@ -193,12 +193,6 @@ static void blk_mq_rq_ctx_init(struct request_queue *q, struct blk_mq_ctx *ctx,
ctx->rq_dispatched[rw_is_sync(rw_flags)]++;
}
-static struct request *__blk_mq_alloc_request(struct blk_mq_hw_ctx *hctx,
- gfp_t gfp, bool reserved)
-{
- return blk_mq_alloc_rq(hctx, gfp, reserved);
-}
-
static struct request *blk_mq_alloc_request_pinned(struct request_queue *q,
int rw, gfp_t gfp,
bool reserved)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] blk-mq: merge blk_mq_insert_request and blk_mq_run_request
2014-02-20 23:32 [PATCH 0/3] next round of blk-mq updates Christoph Hellwig
2014-02-20 23:32 ` [PATCH 1/3] blk-mq: remove blk_mq_alloc_rq Christoph Hellwig
@ 2014-02-20 23:32 ` Christoph Hellwig
2014-02-20 23:32 ` [PATCH 3/3] blk-mq: support partial I/O completions Christoph Hellwig
2014-02-21 16:58 ` [PATCH 0/3] next round of blk-mq updates Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2014-02-20 23:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-scsi
[-- Attachment #1: 0002-blk-mq-merge-blk_mq_insert_request-and-blk_mq_run_re.patch --]
[-- Type: text/plain, Size: 4784 bytes --]
It's almost identical to blk_mq_insert_request, so fold the two into one
slightly more generic function by making the flush special case a bit
smarted.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-exec.c | 2 +-
block/blk-flush.c | 4 ++--
block/blk-mq.c | 53 +++++++++---------------------------------------
block/blk-mq.h | 1 -
include/linux/blk-mq.h | 3 +--
5 files changed, 14 insertions(+), 49 deletions(-)
diff --git a/block/blk-exec.c b/block/blk-exec.c
index c68613b..dbf4502 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -65,7 +65,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
* be resued after dying flag is set
*/
if (q->mq_ops) {
- blk_mq_insert_request(q, rq, at_head, true);
+ blk_mq_insert_request(rq, at_head, true, false);
return;
}
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 66e2b69..f598f79 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -137,7 +137,7 @@ static void mq_flush_run(struct work_struct *work)
rq = container_of(work, struct request, mq_flush_work);
memset(&rq->csd, 0, sizeof(rq->csd));
- blk_mq_run_request(rq, true, false);
+ blk_mq_insert_request(rq, false, true, false);
}
static bool blk_flush_queue_rq(struct request *rq)
@@ -411,7 +411,7 @@ void blk_insert_flush(struct request *rq)
if ((policy & REQ_FSEQ_DATA) &&
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
if (q->mq_ops) {
- blk_mq_run_request(rq, false, true);
+ blk_mq_insert_request(rq, false, false, true);
} else
list_add_tail(&rq->queuelist, &q->queue_head);
return;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 1e585e3..2af8405 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -724,61 +724,28 @@ static void __blk_mq_insert_request(struct blk_mq_hw_ctx *hctx,
blk_mq_add_timer(rq);
}
-void blk_mq_insert_request(struct request_queue *q, struct request *rq,
- bool at_head, bool run_queue)
+void blk_mq_insert_request(struct request *rq, bool at_head, bool run_queue,
+ bool async)
{
+ struct request_queue *q = rq->q;
struct blk_mq_hw_ctx *hctx;
- struct blk_mq_ctx *ctx, *current_ctx;
+ struct blk_mq_ctx *ctx = rq->mq_ctx, *current_ctx;
+
+ current_ctx = blk_mq_get_ctx(q);
+ if (!cpu_online(ctx->cpu))
+ rq->mq_ctx = ctx = current_ctx;
- ctx = rq->mq_ctx;
hctx = q->mq_ops->map_queue(q, ctx->cpu);
- if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA)) {
+ if (rq->cmd_flags & (REQ_FLUSH | REQ_FUA) &&
+ !(rq->cmd_flags & (REQ_FLUSH_SEQ))) {
blk_insert_flush(rq);
} else {
- current_ctx = blk_mq_get_ctx(q);
-
- if (!cpu_online(ctx->cpu)) {
- ctx = current_ctx;
- hctx = q->mq_ops->map_queue(q, ctx->cpu);
- rq->mq_ctx = ctx;
- }
spin_lock(&ctx->lock);
__blk_mq_insert_request(hctx, rq, at_head);
spin_unlock(&ctx->lock);
-
- blk_mq_put_ctx(current_ctx);
}
- if (run_queue)
- __blk_mq_run_hw_queue(hctx);
-}
-EXPORT_SYMBOL(blk_mq_insert_request);
-
-/*
- * This is a special version of blk_mq_insert_request to bypass FLUSH request
- * check. Should only be used internally.
- */
-void blk_mq_run_request(struct request *rq, bool run_queue, bool async)
-{
- struct request_queue *q = rq->q;
- struct blk_mq_hw_ctx *hctx;
- struct blk_mq_ctx *ctx, *current_ctx;
-
- current_ctx = blk_mq_get_ctx(q);
-
- ctx = rq->mq_ctx;
- if (!cpu_online(ctx->cpu)) {
- ctx = current_ctx;
- rq->mq_ctx = ctx;
- }
- hctx = q->mq_ops->map_queue(q, ctx->cpu);
-
- /* ctx->cpu might be offline */
- spin_lock(&ctx->lock);
- __blk_mq_insert_request(hctx, rq, false);
- spin_unlock(&ctx->lock);
-
blk_mq_put_ctx(current_ctx);
if (run_queue)
diff --git a/block/blk-mq.h b/block/blk-mq.h
index ed0035c..72beba1 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -23,7 +23,6 @@ struct blk_mq_ctx {
};
void __blk_mq_complete_request(struct request *rq);
-void blk_mq_run_request(struct request *rq, bool run_queue, bool async);
void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
void blk_mq_init_flush(struct request_queue *q);
void blk_mq_drain_queue(struct request_queue *q);
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 18ba8a6..ff28fe3 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -121,8 +121,7 @@ void blk_mq_init_commands(struct request_queue *, void (*init)(void *data, struc
void blk_mq_flush_plug_list(struct blk_plug *plug, bool from_schedule);
-void blk_mq_insert_request(struct request_queue *, struct request *,
- bool, bool);
+void blk_mq_insert_request(struct request *, bool, bool, bool);
void blk_mq_run_queues(struct request_queue *q, bool async);
void blk_mq_free_request(struct request *rq);
bool blk_mq_can_queue(struct blk_mq_hw_ctx *);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] blk-mq: support partial I/O completions
2014-02-20 23:32 [PATCH 0/3] next round of blk-mq updates Christoph Hellwig
2014-02-20 23:32 ` [PATCH 1/3] blk-mq: remove blk_mq_alloc_rq Christoph Hellwig
2014-02-20 23:32 ` [PATCH 2/3] blk-mq: merge blk_mq_insert_request and blk_mq_run_request Christoph Hellwig
@ 2014-02-20 23:32 ` Christoph Hellwig
2014-02-21 16:58 ` [PATCH 0/3] next round of blk-mq updates Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2014-02-20 23:32 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel, linux-scsi
[-- Attachment #1: 0003-blk-mq-support-partial-I-O-completions.patch --]
[-- Type: text/plain, Size: 2703 bytes --]
Add a new blk_mq_end_io_partial function to partially complete requests
as needed by the SCSI layer. We do this by reusing blk_update_request
to advance the bio instead of having a simplified version of it in
the blk-mq code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-mq.c | 37 +++++--------------------------------
include/linux/blk-mq.h | 8 +++++++-
2 files changed, 12 insertions(+), 33 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 2af8405..1b8b50d 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -283,38 +283,10 @@ void blk_mq_free_request(struct request *rq)
__blk_mq_free_request(hctx, ctx, rq);
}
-static void blk_mq_bio_endio(struct request *rq, struct bio *bio, int error)
+bool blk_mq_end_io_partial(struct request *rq, int error, unsigned int nr_bytes)
{
- if (error)
- clear_bit(BIO_UPTODATE, &bio->bi_flags);
- else if (!test_bit(BIO_UPTODATE, &bio->bi_flags))
- error = -EIO;
-
- if (unlikely(rq->cmd_flags & REQ_QUIET))
- set_bit(BIO_QUIET, &bio->bi_flags);
-
- /* don't actually finish bio if it's part of flush sequence */
- if (!(rq->cmd_flags & REQ_FLUSH_SEQ))
- bio_endio(bio, error);
-}
-
-void blk_mq_end_io(struct request *rq, int error)
-{
- struct bio *bio = rq->bio;
- unsigned int bytes = 0;
-
- trace_block_rq_complete(rq->q, rq);
-
- while (bio) {
- struct bio *next = bio->bi_next;
-
- bio->bi_next = NULL;
- bytes += bio->bi_iter.bi_size;
- blk_mq_bio_endio(rq, bio, error);
- bio = next;
- }
-
- blk_account_io_completion(rq, bytes);
+ if (blk_update_request(rq, error, blk_rq_bytes(rq)))
+ return true;
blk_account_io_done(rq);
@@ -322,8 +294,9 @@ void blk_mq_end_io(struct request *rq, int error)
rq->end_io(rq, error);
else
blk_mq_free_request(rq);
+ return false;
}
-EXPORT_SYMBOL(blk_mq_end_io);
+EXPORT_SYMBOL(blk_mq_end_io_partial);
static void __blk_mq_complete_request_remote(void *data)
{
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index ff28fe3..2ff2e8d 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -133,7 +133,13 @@ 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_reg *, unsigned int);
void blk_mq_free_single_hw_queue(struct blk_mq_hw_ctx *, unsigned int);
-void blk_mq_end_io(struct request *rq, int error);
+bool blk_mq_end_io_partial(struct request *rq, int error,
+ unsigned int nr_bytes);
+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);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] next round of blk-mq updates
2014-02-20 23:32 [PATCH 0/3] next round of blk-mq updates Christoph Hellwig
` (2 preceding siblings ...)
2014-02-20 23:32 ` [PATCH 3/3] blk-mq: support partial I/O completions Christoph Hellwig
@ 2014-02-21 16:58 ` Jens Axboe
3 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2014-02-21 16:58 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, linux-scsi
On Thu, Feb 20 2014, Christoph Hellwig wrote:
> A couple more blkmq updates: a trivial cleanup, a consolidation of two very
> similar functions into one, and support for partial request completions,
> a feature needed by the work in progress scsi blk-mq support.
Thanks, applied all 3. The end_io is a bit fatter than it was before,
which is a shame. But on the plus side, it's consistent...
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-21 16:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 23:32 [PATCH 0/3] next round of blk-mq updates Christoph Hellwig
2014-02-20 23:32 ` [PATCH 1/3] blk-mq: remove blk_mq_alloc_rq Christoph Hellwig
2014-02-20 23:32 ` [PATCH 2/3] blk-mq: merge blk_mq_insert_request and blk_mq_run_request Christoph Hellwig
2014-02-20 23:32 ` [PATCH 3/3] blk-mq: support partial I/O completions Christoph Hellwig
2014-02-21 16:58 ` [PATCH 0/3] next round of blk-mq updates Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox