diff options
author | Bart Van Assche <bart.vanassche@wdc.com> | 2018-08-09 10:53:37 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-08-09 11:12:59 -0400 |
commit | 4cf6324b17e96b7b7ab4021c6929500934d46750 (patch) | |
tree | 90cb9d674a125eaea0aff01df982da74dd933e1b | |
parent | 6bad9b210a228d2fe0e0efe26d9b115348529cee (diff) |
block: Introduce blk_exit_queue()
This patch does not change any functionality.
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Omar Sandoval <osandov@fb.com>
Cc: Alexandru Moise <00moses.alexander00@gmail.com>
Cc: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-core.c | 54 | ||||
-rw-r--r-- | block/blk.h | 1 |
2 files changed, 31 insertions, 24 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index f9ad73d8573c..49af34bf2119 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
@@ -715,6 +715,35 @@ void blk_set_queue_dying(struct request_queue *q) | |||
715 | } | 715 | } |
716 | EXPORT_SYMBOL_GPL(blk_set_queue_dying); | 716 | EXPORT_SYMBOL_GPL(blk_set_queue_dying); |
717 | 717 | ||
718 | /* Unconfigure the I/O scheduler and dissociate from the cgroup controller. */ | ||
719 | void blk_exit_queue(struct request_queue *q) | ||
720 | { | ||
721 | /* | ||
722 | * Since the I/O scheduler exit code may access cgroup information, | ||
723 | * perform I/O scheduler exit before disassociating from the block | ||
724 | * cgroup controller. | ||
725 | */ | ||
726 | if (q->elevator) { | ||
727 | ioc_clear_queue(q); | ||
728 | elevator_exit(q, q->elevator); | ||
729 | q->elevator = NULL; | ||
730 | } | ||
731 | |||
732 | /* | ||
733 | * Remove all references to @q from the block cgroup controller before | ||
734 | * restoring @q->queue_lock to avoid that restoring this pointer causes | ||
735 | * e.g. blkcg_print_blkgs() to crash. | ||
736 | */ | ||
737 | blkcg_exit_queue(q); | ||
738 | |||
739 | /* | ||
740 | * Since the cgroup code may dereference the @q->backing_dev_info | ||
741 | * pointer, only decrease its reference count after having removed the | ||
742 | * association with the block cgroup controller. | ||
743 | */ | ||
744 | bdi_put(q->backing_dev_info); | ||
745 | } | ||
746 | |||
718 | /** | 747 | /** |
719 | * blk_cleanup_queue - shutdown a request queue | 748 | * blk_cleanup_queue - shutdown a request queue |
720 | * @q: request queue to shutdown | 749 | * @q: request queue to shutdown |
@@ -784,30 +813,7 @@ void blk_cleanup_queue(struct request_queue *q) | |||
784 | */ | 813 | */ |
785 | WARN_ON_ONCE(q->kobj.state_in_sysfs); | 814 | WARN_ON_ONCE(q->kobj.state_in_sysfs); |
786 | 815 | ||
787 | /* | 816 | blk_exit_queue(q); |
788 | * Since the I/O scheduler exit code may access cgroup information, | ||
789 | * perform I/O scheduler exit before disassociating from the block | ||
790 | * cgroup controller. | ||
791 | */ | ||
792 | if (q->elevator) { | ||
793 | ioc_clear_queue(q); | ||
794 | elevator_exit(q, q->elevator); | ||
795 | q->elevator = NULL; | ||
796 | } | ||
797 | |||
798 | /* | ||
799 | * Remove all references to @q from the block cgroup controller before | ||
800 | * restoring @q->queue_lock to avoid that restoring this pointer causes | ||
801 | * e.g. blkcg_print_blkgs() to crash. | ||
802 | */ | ||
803 | blkcg_exit_queue(q); | ||
804 | |||
805 | /* | ||
806 | * Since the cgroup code may dereference the @q->backing_dev_info | ||
807 | * pointer, only decrease its reference count after having removed the | ||
808 | * association with the block cgroup controller. | ||
809 | */ | ||
810 | bdi_put(q->backing_dev_info); | ||
811 | 817 | ||
812 | if (q->mq_ops) | 818 | if (q->mq_ops) |
813 | blk_mq_free_queue(q); | 819 | blk_mq_free_queue(q); |
diff --git a/block/blk.h b/block/blk.h index 69b14cd2bb22..d4d67e948920 100644 --- a/block/blk.h +++ b/block/blk.h | |||
@@ -130,6 +130,7 @@ void blk_free_flush_queue(struct blk_flush_queue *q); | |||
130 | int blk_init_rl(struct request_list *rl, struct request_queue *q, | 130 | int blk_init_rl(struct request_list *rl, struct request_queue *q, |
131 | gfp_t gfp_mask); | 131 | gfp_t gfp_mask); |
132 | void blk_exit_rl(struct request_queue *q, struct request_list *rl); | 132 | void blk_exit_rl(struct request_queue *q, struct request_list *rl); |
133 | void blk_exit_queue(struct request_queue *q); | ||
133 | void blk_rq_bio_prep(struct request_queue *q, struct request *rq, | 134 | void blk_rq_bio_prep(struct request_queue *q, struct request *rq, |
134 | struct bio *bio); | 135 | struct bio *bio); |
135 | void blk_queue_bypass_start(struct request_queue *q); | 136 | void blk_queue_bypass_start(struct request_queue *q); |