Skip to content

Commit 73450d4

Browse files
author
Ming Lei
committed
block: don't call freeze queue in elevator_switch() and elevator_disable()
JIRA: https://issues.redhat.com/browse/RHEL-106845 commit f8e111c Author: Ming Lei <ming.lei@redhat.com> Date: Mon May 5 22:17:41 2025 +0800 block: don't call freeze queue in elevator_switch() and elevator_disable() Both elevator_switch() and elevator_disable() are only called from the two code paths, in which queue is guaranteed to be frozen. So don't call freeze queue in the two functions, also add asserts for queue freeze. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20250505141805.2751237-4-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Ming Lei <ming.lei@redhat.com>
1 parent e0dff41 commit 73450d4

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

block/elevator.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,11 @@ void elevator_init_mq(struct request_queue *q)
615615
*/
616616
int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
617617
{
618-
unsigned int memflags;
619618
int ret;
620619

620+
WARN_ON_ONCE(q->mq_freeze_depth == 0);
621621
lockdep_assert_held(&q->elevator_lock);
622622

623-
memflags = blk_mq_freeze_queue(q);
624623
blk_mq_quiesce_queue(q);
625624

626625
if (q->elevator) {
@@ -641,7 +640,6 @@ int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
641640

642641
out_unfreeze:
643642
blk_mq_unquiesce_queue(q);
644-
blk_mq_unfreeze_queue(q, memflags);
645643

646644
if (ret) {
647645
pr_warn("elv: switch to \"%s\" failed, falling back to \"none\"\n",
@@ -653,11 +651,9 @@ int elevator_switch(struct request_queue *q, struct elevator_type *new_e)
653651

654652
void elevator_disable(struct request_queue *q)
655653
{
656-
unsigned int memflags;
657-
654+
WARN_ON_ONCE(q->mq_freeze_depth == 0);
658655
lockdep_assert_held(&q->elevator_lock);
659656

660-
memflags = blk_mq_freeze_queue(q);
661657
blk_mq_quiesce_queue(q);
662658

663659
elv_unregister_queue(q);
@@ -668,7 +664,6 @@ void elevator_disable(struct request_queue *q)
668664
blk_add_trace_msg(q, "elv switch: none");
669665

670666
blk_mq_unquiesce_queue(q);
671-
blk_mq_unfreeze_queue(q, memflags);
672667
}
673668

674669
/*

0 commit comments

Comments
 (0)