block: check for an unchanged elevator earlier in __elevator_change

No need to find the actual elevator_type struct for this comparism,
the name is all that is needed.

Signed-off-by: Jinlong Chen <nickyc975@zju.edu.cn>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20221020064819.1469928-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Jinlong Chen 2022-10-20 08:48:18 +02:00 committed by Jens Axboe
parent 58367c8a5f
commit b54c2ad9b7

View File

@ -751,16 +751,13 @@ static int elevator_change(struct request_queue *q, const char *elevator_name)
return elevator_switch(q, NULL);
}
if (q->elevator && elevator_match(q->elevator->type, elevator_name, 0))
return 0;
e = elevator_get(q, elevator_name, true);
if (!e)
return -EINVAL;
if (q->elevator &&
elevator_match(q->elevator->type, elevator_name, 0)) {
elevator_put(e);
return 0;
}
return elevator_switch(q, e);
}