From: Jinlong Chen <nickyc975@xxxxxxxxxx> 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@xxxxxxxxxx> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <hch@xxxxxx> --- block/elevator.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index b7f098f735b6b..887becfe6a8d4 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -755,16 +755,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); } -- 2.30.2