diff options
author | Ming Lei <ming.lei@canonical.com> | 2014-09-25 11:23:40 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2014-09-25 17:22:35 -0400 |
commit | f355265571440a7db16e784b6edf4e7d26971a03 (patch) | |
tree | 79b20c37c734b5932dcecc9e85850847b0a69855 /block | |
parent | 1bcb1eada4f11a713cbe586d1b5a5d93a48277cb (diff) |
block: introduce blk_init_flush and its pair
These two temporary functions are introduced for holding flush
initialization and de-initialization, so that we can
introduce 'flush queue' easier in the following patch. And
once 'flush queue' and its allocation/free functions are ready,
they will be removed for sake of code readability.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/blk-core.c | 5 | ||||
-rw-r--r-- | block/blk-flush.c | 19 | ||||
-rw-r--r-- | block/blk-mq.c | 2 | ||||
-rw-r--r-- | block/blk-mq.h | 1 | ||||
-rw-r--r-- | block/blk-sysfs.c | 4 | ||||
-rw-r--r-- | block/blk.h | 3 |
6 files changed, 26 insertions, 8 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index 6946a4275e6f..0a9d17269957 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -705,8 +705,7 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn, | |||
705 | if (!q) | 705 | if (!q) |
706 | return NULL; | 706 | return NULL; |
707 | 707 | ||
708 | q->flush_rq = kzalloc(sizeof(struct request), GFP_KERNEL); | 708 | if (blk_init_flush(q)) |
709 | if (!q->flush_rq) | ||
710 | return NULL; | 709 | return NULL; |
711 | 710 | ||
712 | if (blk_init_rl(&q->root_rl, q, GFP_KERNEL)) | 711 | if (blk_init_rl(&q->root_rl, q, GFP_KERNEL)) |
@@ -742,7 +741,7 @@ blk_init_allocated_queue(struct request_queue *q, request_fn_proc *rfn, | |||
742 | return q; | 741 | return q; |
743 | 742 | ||
744 | fail: | 743 | fail: |
745 | kfree(q->flush_rq); | 744 | blk_exit_flush(q); |
746 | return NULL; | 745 | return NULL; |
747 | } | 746 | } |
748 | EXPORT_SYMBOL(blk_init_allocated_queue); | 747 | EXPORT_SYMBOL(blk_init_allocated_queue); |
diff --git a/block/blk-flush.c b/block/blk-flush.c index 55028a707927..c72ab32fd8eb 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c | |||
@@ -472,7 +472,7 @@ int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask, | |||
472 | } | 472 | } |
473 | EXPORT_SYMBOL(blkdev_issue_flush); | 473 | EXPORT_SYMBOL(blkdev_issue_flush); |
474 | 474 | ||
475 | int blk_mq_init_flush(struct request_queue *q) | 475 | static int blk_mq_init_flush(struct request_queue *q) |
476 | { | 476 | { |
477 | struct blk_mq_tag_set *set = q->tag_set; | 477 | struct blk_mq_tag_set *set = q->tag_set; |
478 | 478 | ||
@@ -485,3 +485,20 @@ int blk_mq_init_flush(struct request_queue *q) | |||
485 | return -ENOMEM; | 485 | return -ENOMEM; |
486 | return 0; | 486 | return 0; |
487 | } | 487 | } |
488 | |||
489 | int blk_init_flush(struct request_queue *q) | ||
490 | { | ||
491 | if (q->mq_ops) | ||
492 | return blk_mq_init_flush(q); | ||
493 | |||
494 | q->flush_rq = kzalloc(sizeof(struct request), GFP_KERNEL); | ||
495 | if (!q->flush_rq) | ||
496 | return -ENOMEM; | ||
497 | |||
498 | return 0; | ||
499 | } | ||
500 | |||
501 | void blk_exit_flush(struct request_queue *q) | ||
502 | { | ||
503 | kfree(q->flush_rq); | ||
504 | } | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index 78bcf8bfb22a..2758cdf2de94 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
@@ -1859,7 +1859,7 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) | |||
1859 | 1859 | ||
1860 | blk_mq_add_queue_tag_set(set, q); | 1860 | blk_mq_add_queue_tag_set(set, q); |
1861 | 1861 | ||
1862 | if (blk_mq_init_flush(q)) | 1862 | if (blk_init_flush(q)) |
1863 | goto err_hw_queues; | 1863 | goto err_hw_queues; |
1864 | 1864 | ||
1865 | blk_mq_map_swqueue(q); | 1865 | blk_mq_map_swqueue(q); |
diff --git a/block/blk-mq.h b/block/blk-mq.h index ecac69c08937..d567d5283ffa 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h | |||
@@ -27,7 +27,6 @@ struct blk_mq_ctx { | |||
27 | 27 | ||
28 | void __blk_mq_complete_request(struct request *rq); | 28 | void __blk_mq_complete_request(struct request *rq); |
29 | void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); | 29 | void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); |
30 | int blk_mq_init_flush(struct request_queue *q); | ||
31 | void blk_mq_freeze_queue(struct request_queue *q); | 30 | void blk_mq_freeze_queue(struct request_queue *q); |
32 | void blk_mq_free_queue(struct request_queue *q); | 31 | void blk_mq_free_queue(struct request_queue *q); |
33 | void blk_mq_clone_flush_request(struct request *flush_rq, | 32 | void blk_mq_clone_flush_request(struct request *flush_rq, |
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 17f5c84ce7bf..949075952119 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c | |||
@@ -517,11 +517,11 @@ static void blk_release_queue(struct kobject *kobj) | |||
517 | if (q->queue_tags) | 517 | if (q->queue_tags) |
518 | __blk_queue_free_tags(q); | 518 | __blk_queue_free_tags(q); |
519 | 519 | ||
520 | blk_exit_flush(q); | ||
521 | |||
520 | if (q->mq_ops) | 522 | if (q->mq_ops) |
521 | blk_mq_free_queue(q); | 523 | blk_mq_free_queue(q); |
522 | 524 | ||
523 | kfree(q->flush_rq); | ||
524 | |||
525 | blk_trace_shutdown(q); | 525 | blk_trace_shutdown(q); |
526 | 526 | ||
527 | bdi_destroy(&q->backing_dev_info); | 527 | bdi_destroy(&q->backing_dev_info); |
diff --git a/block/blk.h b/block/blk.h index e515a285d4c9..c6fa3d4c6a89 100644 --- a/block/blk.h +++ b/block/blk.h | |||
@@ -22,6 +22,9 @@ static inline void __blk_get_queue(struct request_queue *q) | |||
22 | kobject_get(&q->kobj); | 22 | kobject_get(&q->kobj); |
23 | } | 23 | } |
24 | 24 | ||
25 | int blk_init_flush(struct request_queue *q); | ||
26 | void blk_exit_flush(struct request_queue *q); | ||
27 | |||
25 | int blk_init_rl(struct request_list *rl, struct request_queue *q, | 28 | int blk_init_rl(struct request_list *rl, struct request_queue *q, |
26 | gfp_t gfp_mask); | 29 | gfp_t gfp_mask); |
27 | void blk_exit_rl(struct request_list *rl); | 30 | void blk_exit_rl(struct request_list *rl); |