Skip to content

Commit 47cdee2

Browse files
Ming Leiaxboe
authored andcommitted
block: move blk_exit_queue into __blk_release_queue
Commit 498f665 ("block: Fix a race between the cgroup code and request queue initialization") moves what blk_exit_queue does into blk_cleanup_queue() for fixing issue caused by changing back queue lock. However, after legacy request IO path is killed, driver queue lock won't be used at all, and there isn't story for changing back queue lock. Then the issue addressed by Commit 498f665 doesn't exist any more. So move move blk_exit_queue into __blk_release_queue. This patch basically reverts the following two commits: 498f665 block: Fix a race between the cgroup code and request queue initialization 24ecc35 block: Ensure that a request queue is dissociated from the cgroup controller Cc: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 31cb1d6 commit 47cdee2

3 files changed

Lines changed: 32 additions & 53 deletions

File tree

‎block/blk-core.c‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -282,35 +282,6 @@ void blk_set_queue_dying(struct request_queue *q)
282282
}
283283
EXPORT_SYMBOL_GPL(blk_set_queue_dying);
284284

285-
/* Unconfigure the I/O scheduler and dissociate from the cgroup controller. */
286-
void blk_exit_queue(struct request_queue *q)
287-
{
288-
/*
289-
* Since the I/O scheduler exit code may access cgroup information,
290-
* perform I/O scheduler exit before disassociating from the block
291-
* cgroup controller.
292-
*/
293-
if (q->elevator) {
294-
ioc_clear_queue(q);
295-
elevator_exit(q, q->elevator);
296-
q->elevator = NULL;
297-
}
298-
299-
/*
300-
* Remove all references to @q from the block cgroup controller before
301-
* restoring @q->queue_lock to avoid that restoring this pointer causes
302-
* e.g. blkcg_print_blkgs() to crash.
303-
*/
304-
blkcg_exit_queue(q);
305-
306-
/*
307-
* Since the cgroup code may dereference the @q->backing_dev_info
308-
* pointer, only decrease its reference count after having removed the
309-
* association with the block cgroup controller.
310-
*/
311-
bdi_put(q->backing_dev_info);
312-
}
313-
314285
/**
315286
* blk_cleanup_queue - shutdown a request queue
316287
* @q: request queue to shutdown
@@ -346,14 +317,6 @@ void blk_cleanup_queue(struct request_queue *q)
346317
del_timer_sync(&q->backing_dev_info->laptop_mode_wb_timer);
347318
blk_sync_queue(q);
348319

349-
/*
350-
* I/O scheduler exit is only safe after the sysfs scheduler attribute
351-
* has been removed.
352-
*/
353-
WARN_ON_ONCE(q->kobj.state_in_sysfs);
354-
355-
blk_exit_queue(q);
356-
357320
if (queue_is_mq(q))
358321
blk_mq_exit_queue(q);
359322

‎block/blk-sysfs.c‎

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,36 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)
840840
kmem_cache_free(blk_requestq_cachep, q);
841841
}
842842

843+
/* Unconfigure the I/O scheduler and dissociate from the cgroup controller. */
844+
static void blk_exit_queue(struct request_queue *q)
845+
{
846+
/*
847+
* Since the I/O scheduler exit code may access cgroup information,
848+
* perform I/O scheduler exit before disassociating from the block
849+
* cgroup controller.
850+
*/
851+
if (q->elevator) {
852+
ioc_clear_queue(q);
853+
elevator_exit(q, q->elevator);
854+
q->elevator = NULL;
855+
}
856+
857+
/*
858+
* Remove all references to @q from the block cgroup controller before
859+
* restoring @q->queue_lock to avoid that restoring this pointer causes
860+
* e.g. blkcg_print_blkgs() to crash.
861+
*/
862+
blkcg_exit_queue(q);
863+
864+
/*
865+
* Since the cgroup code may dereference the @q->backing_dev_info
866+
* pointer, only decrease its reference count after having removed the
867+
* association with the block cgroup controller.
868+
*/
869+
bdi_put(q->backing_dev_info);
870+
}
871+
872+
843873
/**
844874
* __blk_release_queue - release a request queue
845875
* @work: pointer to the release_work member of the request queue to be released
@@ -860,23 +890,10 @@ static void __blk_release_queue(struct work_struct *work)
860890
blk_stat_remove_callback(q, q->poll_cb);
861891
blk_stat_free_callback(q->poll_cb);
862892

863-
if (!blk_queue_dead(q)) {
864-
/*
865-
* Last reference was dropped without having called
866-
* blk_cleanup_queue().
867-
*/
868-
WARN_ONCE(blk_queue_init_done(q),
869-
"request queue %p has been registered but blk_cleanup_queue() has not been called for that queue\n",
870-
q);
871-
blk_exit_queue(q);
872-
}
873-
874-
WARN(blk_queue_root_blkg(q),
875-
"request queue %p is being released but it has not yet been removed from the blkcg controller\n",
876-
q);
877-
878893
blk_free_queue_stats(q->stats);
879894

895+
blk_exit_queue(q);
896+
880897
blk_queue_free_zone_bitmaps(q);
881898

882899
if (queue_is_mq(q))

‎block/blk.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q,
5050
int node, int cmd_size, gfp_t flags);
5151
void blk_free_flush_queue(struct blk_flush_queue *q);
5252

53-
void blk_exit_queue(struct request_queue *q);
5453
void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
5554
struct bio *bio);
5655
void blk_freeze_queue(struct request_queue *q);

0 commit comments

Comments
 (0)