From: Christoph Hellwig <hch@infradead.org>
To: Ming Lei <tom.leiming@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Jens Axboe <axboe@kernel.dk>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 4/4] blk-mq: add a exit_request method
Date: Wed, 19 Mar 2014 00:56:58 -0700 [thread overview]
Message-ID: <20140319075658.GB25529@infradead.org> (raw)
In-Reply-To: <CACVXFVNx=s1na1o7cPgjqL2rMcT73gVjmUOYyZdzE3KQ+MZH9Q@mail.gmail.com>
On Wed, Mar 19, 2014 at 01:22:07PM +0800, Ming Lei wrote:
> exit_request definition is missed.
oops that accidentally went into another commit.
New version below:
---
From: Christoph Hellwig <hch@infradead.org>
Subject: blk-mq: add a exit_request method
This gives drivers an easy way to free any ressources allocated in
->init_request.
Signed-off-by: Christoph Hellwig <hch@lst.de>
diff --git a/block/blk-mq.c b/block/blk-mq.c
index c2ce99b..c7e723e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1000,6 +1000,16 @@ static void blk_mq_free_rq_map(struct blk_mq_hw_ctx *hctx)
{
struct page *page;
+ if (hctx->rqs && hctx->queue->mq_ops->exit_request) {
+ int i;
+
+ for (i = 0; i < hctx->queue_depth; i++) {
+ if (!hctx->rqs[i])
+ continue;
+ hctx->queue->mq_ops->exit_request(hctx, hctx->rqs[i]);
+ }
+ }
+
while (!list_empty(&hctx->page_list)) {
page = list_first_entry(&hctx->page_list, struct page, lru);
list_del_init(&page->lru);
@@ -1332,7 +1342,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg,
}
if (blk_mq_init_hw_queues(q, reg, driver_data))
- goto err_flush_rq;
+ goto err_flush_rq_init;
blk_mq_map_swqueue(q);
@@ -1342,6 +1352,9 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_reg *reg,
return q;
+err_flush_rq_init:
+ if (reg->ops->exit_request)
+ reg->ops->exit_request(NULL, q->flush_rq);
err_flush_rq:
kfree(q->flush_rq);
err_hw:
@@ -1387,6 +1400,9 @@ void blk_mq_free_queue(struct request_queue *q)
mutex_lock(&all_q_mutex);
list_del_init(&q->all_q_node);
mutex_unlock(&all_q_mutex);
+
+ if (q->mq_ops->exit_request)
+ q->mq_ops->exit_request(NULL, q->flush_rq);
}
/* Basically redo blk_mq_init_queue with queue frozen */
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 4d34957..ff194f8 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -68,6 +68,7 @@ typedef int (init_hctx_fn)(struct blk_mq_hw_ctx *, void *, unsigned int);
typedef void (exit_hctx_fn)(struct blk_mq_hw_ctx *, unsigned int);
typedef int (init_request_fn)(void *, struct blk_mq_hw_ctx *,
struct request *, unsigned int);
+typedef void (exit_request_fn)(struct blk_mq_hw_ctx *, struct request *);
struct blk_mq_ops {
/*
@@ -104,8 +105,10 @@ struct blk_mq_ops {
/*
* Called for every command allocated by the block layer to allow
* the driver to set up driver specific data.
+ * Ditto for exit/teardown.
*/
init_request_fn *init_request;
+ exit_request_fn *exit_request;
};
enum {
prev parent reply other threads:[~2014-03-19 7:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-17 13:18 [PATCH 0/4] blk-mq updates Christoph Hellwig
2014-03-17 13:18 ` [PATCH 1/4] blk-mq: fix blk_mq_end_io_partial Christoph Hellwig
2014-03-17 13:18 ` [PATCH 2/4] blk-mq: initialize resid_len Christoph Hellwig
2014-03-17 13:18 ` [PATCH 3/4] blk-mq: replace blk_mq_init_commands with a ->init_request method Christoph Hellwig
2014-03-19 3:08 ` Ming Lei
2014-03-19 7:54 ` Christoph Hellwig
2014-03-19 8:48 ` Ming Lei
2014-03-19 16:08 ` Christoph Hellwig
2014-03-17 13:18 ` [PATCH 4/4] blk-mq: add a exit_request method Christoph Hellwig
2014-03-19 5:22 ` Ming Lei
2014-03-19 7:56 ` Christoph Hellwig [this message]
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=20140319075658.GB25529@infradead.org \
--to=hch@infradead.org \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.leiming@gmail.com \
/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
Powered by JetHome