Skip to content

Commit

Permalink
block: do more work in elevator_exit
Browse files Browse the repository at this point in the history
Move the calls to ioc_clear_queue and blk_mq_sched_free_rqs into
elevator_exit.  Except for one call where we know we can't have io_cq
structures yet these always go together, and that extra call in an
error path is harmless.

Signed-off-by: Christoph Hellwig <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Mar 9, 2022
1 parent 28ce942 commit 2888307
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 3 additions & 3 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ void elevator_exit(struct request_queue *q)
{
struct elevator_queue *e = q->elevator;

ioc_clear_queue(q);
blk_mq_sched_free_rqs(q);

mutex_lock(&e->sysfs_lock);
blk_mq_exit_sched(q, e);
mutex_unlock(&e->sysfs_lock);
Expand Down Expand Up @@ -596,8 +599,6 @@ int elevator_switch_mq(struct request_queue *q,

if (q->elevator) {
elv_unregister_queue(q);
ioc_clear_queue(q);
blk_mq_sched_free_rqs(q);
elevator_exit(q);
}

Expand All @@ -608,7 +609,6 @@ int elevator_switch_mq(struct request_queue *q,
if (new_e) {
ret = elv_register_queue(q, true);
if (ret) {
blk_mq_sched_free_rqs(q);
elevator_exit(q);
goto out;
}
Expand Down
3 changes: 0 additions & 3 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,10 +1115,7 @@ static void disk_release_mq(struct request_queue *q)
* cgroup controller.
*/
if (q->elevator) {
ioc_clear_queue(q);

mutex_lock(&q->sysfs_lock);
blk_mq_sched_free_rqs(q);
elevator_exit(q);
mutex_unlock(&q->sysfs_lock);
}
Expand Down

0 comments on commit 2888307

Please sign in to comment.