From: "Matias Bjørling" <m@bjorling.me>
To: hch@infradead.org, axboe@fb.com, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org
Cc: javier@paletta.io, keith.busch@intel.com,
"Matias Bjørling" <m@bjorling.me>
Subject: [PATCH 1/5 v2] blk-mq: Add prep/unprep support
Date: Wed, 15 Apr 2015 14:34:40 +0200 [thread overview]
Message-ID: <1429101284-19490-2-git-send-email-m@bjorling.me> (raw)
In-Reply-To: <1429101284-19490-1-git-send-email-m@bjorling.me>
Allow users to hook into prep/unprep functions just before an IO is
dispatched to the device driver. This is necessary for request-based
logic to take place at upper layers.
Signed-off-by: Matias Bjørling <m@bjorling.me>
---
block/blk-mq.c | 28 ++++++++++++++++++++++++++--
include/linux/blk-mq.h | 1 +
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 33c4285..f3dd028 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -338,6 +338,11 @@ EXPORT_SYMBOL(__blk_mq_end_request);
void blk_mq_end_request(struct request *rq, int error)
{
+ struct request_queue *q = rq->q;
+
+ if (q->unprep_rq_fn)
+ q->unprep_rq_fn(q, rq);
+
if (blk_update_request(rq, error, blk_rq_bytes(rq)))
BUG();
__blk_mq_end_request(rq, error);
@@ -753,6 +758,17 @@ static void flush_busy_ctxs(struct blk_mq_hw_ctx *hctx, struct list_head *list)
}
}
+static int blk_mq_prep_rq(struct request_queue *q, struct request *rq)
+{
+ if (!q->prep_rq_fn)
+ return 0;
+
+ if (rq->cmd_flags & REQ_DONTPREP)
+ return 0;
+
+ return q->prep_rq_fn(q, rq);
+}
+
/*
* Run this hardware queue, pulling any software queues mapped to it in.
* Note that this function currently has various problems around ordering
@@ -812,11 +828,15 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx)
bd.list = dptr;
bd.last = list_empty(&rq_list);
- ret = q->mq_ops->queue_rq(hctx, &bd);
+ ret = blk_mq_prep_rq(q, rq);
+ if (likely(!ret))
+ ret = q->mq_ops->queue_rq(hctx, &bd);
switch (ret) {
case BLK_MQ_RQ_QUEUE_OK:
queued++;
continue;
+ case BLK_MQ_RQ_QUEUE_DONE:
+ continue;
case BLK_MQ_RQ_QUEUE_BUSY:
list_add(&rq->queuelist, &rq_list);
__blk_mq_requeue_request(rq);
@@ -1270,10 +1290,14 @@ static void blk_mq_make_request(struct request_queue *q, struct bio *bio)
* error (busy), just add it to our list as we previously
* would have done
*/
- ret = q->mq_ops->queue_rq(data.hctx, &bd);
+ ret = blk_mq_prep_rq(q, rq);
+ if (likely(!ret))
+ ret = q->mq_ops->queue_rq(data.hctx, &bd);
if (ret == BLK_MQ_RQ_QUEUE_OK)
goto done;
else {
+ if (ret == BLK_MQ_RQ_QUEUE_DONE)
+ goto done;
__blk_mq_requeue_request(rq);
if (ret == BLK_MQ_RQ_QUEUE_ERROR) {
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 7aec861..d7b39af 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -140,6 +140,7 @@ enum {
BLK_MQ_RQ_QUEUE_OK = 0, /* queued fine */
BLK_MQ_RQ_QUEUE_BUSY = 1, /* requeue IO for later */
BLK_MQ_RQ_QUEUE_ERROR = 2, /* end IO with error */
+ BLK_MQ_RQ_QUEUE_DONE = 3, /* IO is already handled */
BLK_MQ_F_SHOULD_MERGE = 1 << 0,
BLK_MQ_F_TAG_SHARED = 1 << 1,
--
1.9.1
next prev parent reply other threads:[~2015-04-15 12:36 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-15 12:34 [PATCH 0/5 v2] Support for Open-Channel SSDs Matias Bjørling
2015-04-15 12:34 ` Matias Bjørling [this message]
2015-04-17 6:34 ` [PATCH 1/5 v2] blk-mq: Add prep/unprep support Christoph Hellwig
2015-04-17 8:15 ` Matias Bjørling
2015-04-17 17:46 ` Christoph Hellwig
2015-04-18 6:45 ` Matias Bjorling
2015-04-18 20:16 ` Christoph Hellwig
2015-04-19 18:12 ` Matias Bjorling
2015-04-15 12:34 ` [PATCH 2/5 v2] blk-mq: Support for Open-Channel SSDs Matias Bjørling
2015-04-16 9:10 ` Paul Bolle
2015-04-16 10:23 ` Matias Bjørling
2015-04-16 11:34 ` Paul Bolle
2015-04-16 13:29 ` Matias Bjørling
2015-04-15 12:34 ` [PATCH 3/5 v2] lightnvm: RRPC target Matias Bjørling
2015-04-16 9:12 ` Paul Bolle
2015-04-15 12:34 ` [PATCH 4/5 v2] null_blk: LightNVM support Matias Bjørling
2015-04-15 12:34 ` [PATCH 5/5 v2] nvme: " Matias Bjørling
2015-04-16 14:55 ` Keith Busch
2015-04-16 15:14 ` Javier González
2015-04-16 15:52 ` Keith Busch
2015-04-16 16:01 ` James R. Bergsten
2015-04-16 16:12 ` Keith Busch
2015-04-16 17:17 ` Matias Bjorling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1429101284-19490-2-git-send-email-m@bjorling.me \
--to=m@bjorling.me \
--cc=axboe@fb.com \
--cc=hch@infradead.org \
--cc=javier@paletta.io \
--cc=keith.busch@intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®