From dd6f7f17bf5831ac94d2b8ffe3d67dac201a9b97 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Thu, 20 Oct 2022 08:48:16 +0200 Subject: block: add proper helpers for elevator_type module refcount management Make sure we have helpers for all relevant module refcount operations on the elevator_type in elevator.h, and use them. Move the call to the get helper in blk_mq_elv_switch_none a bit so that it is obvious with a less verbose comment. Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20221020064819.1469928-2-hch@lst.de Signed-off-by: Jens Axboe --- block/blk-mq.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'block/blk-mq.c') diff --git a/block/blk-mq.c b/block/blk-mq.c index 33292c01875d..9db8814cdd02 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4554,17 +4554,10 @@ static bool blk_mq_elv_switch_none(struct list_head *head, INIT_LIST_HEAD(&qe->node); qe->q = q; + /* keep a reference to the elevator module as we'll switch back */ + __elevator_get(qe->type); qe->type = q->elevator->type; list_add(&qe->node, head); - - /* - * After elevator_switch, the previous elevator_queue will be - * released by elevator_release. The reference of the io scheduler - * module get by elevator_get will also be put. So we need to get - * a reference of the io scheduler module here to prevent it to be - * removed. - */ - __module_get(qe->type->elevator_owner); elevator_switch(q, NULL); mutex_unlock(&q->sysfs_lock); -- cgit v1.2.3