mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
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 <hch@lst.de> Link: https://lore.kernel.org/r/20221020064819.1469928-2-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
committed by
Jens Axboe
parent
671fae5e51
commit
dd6f7f17bf
@@ -4554,17 +4554,10 @@ static bool blk_mq_elv_switch_none(struct list_head *head,
|
|||||||
|
|
||||||
INIT_LIST_HEAD(&qe->node);
|
INIT_LIST_HEAD(&qe->node);
|
||||||
qe->q = q;
|
qe->q = q;
|
||||||
|
/* keep a reference to the elevator module as we'll switch back */
|
||||||
|
__elevator_get(qe->type);
|
||||||
qe->type = q->elevator->type;
|
qe->type = q->elevator->type;
|
||||||
list_add(&qe->node, head);
|
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);
|
elevator_switch(q, NULL);
|
||||||
mutex_unlock(&q->sysfs_lock);
|
mutex_unlock(&q->sysfs_lock);
|
||||||
|
|
||||||
|
@@ -132,11 +132,6 @@ static struct elevator_type *elevator_find(const char *name,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void elevator_put(struct elevator_type *e)
|
|
||||||
{
|
|
||||||
module_put(e->elevator_owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct elevator_type *elevator_get(struct request_queue *q,
|
static struct elevator_type *elevator_get(struct request_queue *q,
|
||||||
const char *name, bool try_loading)
|
const char *name, bool try_loading)
|
||||||
{
|
{
|
||||||
@@ -152,7 +147,7 @@ static struct elevator_type *elevator_get(struct request_queue *q,
|
|||||||
e = elevator_find(name, q->required_elevator_features);
|
e = elevator_find(name, q->required_elevator_features);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e && !try_module_get(e->elevator_owner))
|
if (e && !elevator_tryget(e))
|
||||||
e = NULL;
|
e = NULL;
|
||||||
|
|
||||||
spin_unlock(&elv_list_lock);
|
spin_unlock(&elv_list_lock);
|
||||||
@@ -659,7 +654,7 @@ static struct elevator_type *elevator_get_by_features(struct request_queue *q)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found && !try_module_get(found->elevator_owner))
|
if (found && !elevator_tryget(found))
|
||||||
found = NULL;
|
found = NULL;
|
||||||
|
|
||||||
spin_unlock(&elv_list_lock);
|
spin_unlock(&elv_list_lock);
|
||||||
|
@@ -84,6 +84,21 @@ struct elevator_type
|
|||||||
struct list_head list;
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline bool elevator_tryget(struct elevator_type *e)
|
||||||
|
{
|
||||||
|
return try_module_get(e->elevator_owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void __elevator_get(struct elevator_type *e)
|
||||||
|
{
|
||||||
|
__module_get(e->elevator_owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void elevator_put(struct elevator_type *e)
|
||||||
|
{
|
||||||
|
module_put(e->elevator_owner);
|
||||||
|
}
|
||||||
|
|
||||||
#define ELV_HASH_BITS 6
|
#define ELV_HASH_BITS 6
|
||||||
|
|
||||||
void elv_rqhash_del(struct request_queue *q, struct request *rq);
|
void elv_rqhash_del(struct request_queue *q, struct request *rq);
|
||||||
|
Reference in New Issue
Block a user