All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@canonical.com>
To: Jens Axboe <axboe@kernel.dk>, linux-kernel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Ming Lei <ming.lei@canonical.com>
Subject: [PATCH 1/8] blk-mq: allocate flush_rq in blk_mq_init_flush()
Date: Tue,  9 Sep 2014 21:05:42 +0800	[thread overview]
Message-ID: <1410267949-21904-2-git-send-email-ming.lei@canonical.com> (raw)
In-Reply-To: <1410267949-21904-1-git-send-email-ming.lei@canonical.com>

It is reasonable to allocate flush req in blk_mq_init_flush().

Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 block/blk-flush.c |   11 ++++++++++-
 block/blk-mq.c    |   16 ++++++----------
 block/blk-mq.h    |    2 +-
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/block/blk-flush.c b/block/blk-flush.c
index 3cb5e9e..75ca6cd0 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -474,7 +474,16 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
 }
 EXPORT_SYMBOL(blkdev_issue_flush);
 
-void blk_mq_init_flush(struct request_queue *q)
+int blk_mq_init_flush(struct request_queue *q)
 {
+	struct blk_mq_tag_set *set = q->tag_set;
+
 	spin_lock_init(&q->mq_flush_lock);
+
+	q->flush_rq = kzalloc(round_up(sizeof(struct request) +
+				set->cmd_size, cache_line_size()),
+				GFP_KERNEL);
+	if (!q->flush_rq)
+		return -ENOMEM;
+	return 0;
 }
diff --git a/block/blk-mq.c b/block/blk-mq.c
index b5af123..d500793 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1830,17 +1830,10 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
 	if (set->ops->complete)
 		blk_queue_softirq_done(q, set->ops->complete);
 
-	blk_mq_init_flush(q);
 	blk_mq_init_cpu_queues(q, set->nr_hw_queues);
 
-	q->flush_rq = kzalloc(round_up(sizeof(struct request) +
-				set->cmd_size, cache_line_size()),
-				GFP_KERNEL);
-	if (!q->flush_rq)
-		goto err_hw;
-
 	if (blk_mq_init_hw_queues(q, set))
-		goto err_flush_rq;
+		goto err_hw;
 
 	mutex_lock(&all_q_mutex);
 	list_add_tail(&q->all_q_node, &all_q_list);
@@ -1848,12 +1841,15 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set)
 
 	blk_mq_add_queue_tag_set(set, q);
 
+	if (blk_mq_init_flush(q))
+		goto err_hw_queues;
+
 	blk_mq_map_swqueue(q);
 
 	return q;
 
-err_flush_rq:
-	kfree(q->flush_rq);
+err_hw_queues:
+	blk_mq_exit_hw_queues(q, set, set->nr_hw_queues);
 err_hw:
 	blk_cleanup_queue(q);
 err_hctxs:
diff --git a/block/blk-mq.h b/block/blk-mq.h
index ca4964a..b0bd9bc 100644
--- a/block/blk-mq.h
+++ b/block/blk-mq.h
@@ -27,7 +27,7 @@ struct blk_mq_ctx {
 
 void __blk_mq_complete_request(struct request *rq);
 void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async);
-void blk_mq_init_flush(struct request_queue *q);
+int blk_mq_init_flush(struct request_queue *q);
 void blk_mq_freeze_queue(struct request_queue *q);
 void blk_mq_free_queue(struct request_queue *q);
 void blk_mq_clone_flush_request(struct request *flush_rq,
-- 
1.7.9.5


  reply	other threads:[~2014-09-09 13:06 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 13:05 [PATCH 0/8] block: per-distpatch_queue flush machinery Ming Lei
2014-09-09 13:05 ` Ming Lei [this message]
2014-09-09 18:35   ` [PATCH 1/8] blk-mq: allocate flush_rq in blk_mq_init_flush() Christoph Hellwig
2014-09-09 13:05 ` [PATCH 2/8] block: introduce blk_init_flush and its pair Ming Lei
2014-09-09 18:36   ` Christoph Hellwig
2014-09-09 13:05 ` [PATCH 3/8] block: move flush initialized stuff to blk_flush_init Ming Lei
2014-09-09 18:37   ` Christoph Hellwig
2014-09-09 13:05 ` [PATCH 4/8] block: avoid to use q->flush_rq directly Ming Lei
2014-09-09 18:38   ` Christoph Hellwig
2014-09-09 13:05 ` [PATCH 5/8] block: introduce blk_flush_queue to drive flush machinery Ming Lei
2014-09-09 18:43   ` Christoph Hellwig
2014-09-09 18:55     ` Jens Axboe
2014-09-10  1:25       ` Ming Lei
2014-09-10  1:23     ` Ming Lei
2014-09-09 13:05 ` [PATCH 6/8] block: flush: avoid to figure out flush queue unnecessarily Ming Lei
2014-09-09 18:44   ` Christoph Hellwig
2014-09-09 13:05 ` [PATCH 7/8] block: introduce 'blk_mq_ctx' parameter to blk_get_flush_queue Ming Lei
2014-09-09 13:05 ` [PATCH 8/8] blk-mq: support per-distpatch_queue flush machinery Ming Lei
2014-09-09 18:48   ` Christoph Hellwig
2014-09-10  1:40     ` Ming Lei
2014-09-10 19:02       ` Christoph Hellwig
2014-09-10 23:53         ` Ming Lei
2014-09-09 15:20 ` [PATCH 0/8] block: " Christoph Hellwig
2014-09-09 15:38   ` Ming Lei

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=1410267949-21904-2-git-send-email-ming.lei@canonical.com \
    --to=ming.lei@canonical.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.