mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
blk-mq: cleanup disk sysfs registration
Pass a gendisk to the sysfs register/unregister functions and give them descriptive names. Also move the unregistration helper next to the one doing the registration. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20220628171850.1313069-7-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
eaa870f975
commit
8682b92e5a
@ -203,22 +203,6 @@ static int blk_mq_register_hctx(struct blk_mq_hw_ctx *hctx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void blk_mq_unregister_dev(struct device *dev, struct request_queue *q)
|
||||
{
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
unsigned long i;
|
||||
|
||||
lockdep_assert_held(&q->sysfs_dir_lock);
|
||||
|
||||
queue_for_each_hw_ctx(q, hctx, i)
|
||||
blk_mq_unregister_hctx(hctx);
|
||||
|
||||
kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
|
||||
kobject_del(q->mq_kobj);
|
||||
|
||||
q->mq_sysfs_init_done = false;
|
||||
}
|
||||
|
||||
void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx)
|
||||
{
|
||||
kobject_init(&hctx->kobj, &blk_mq_hw_ktype);
|
||||
@ -251,16 +235,16 @@ void blk_mq_sysfs_init(struct request_queue *q)
|
||||
}
|
||||
}
|
||||
|
||||
int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
|
||||
int blk_mq_sysfs_register(struct gendisk *disk)
|
||||
{
|
||||
struct request_queue *q = disk->queue;
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
unsigned long i, j;
|
||||
int ret;
|
||||
|
||||
WARN_ON_ONCE(!q->kobj.parent);
|
||||
lockdep_assert_held(&q->sysfs_dir_lock);
|
||||
|
||||
ret = kobject_add(q->mq_kobj, &dev->kobj, "%s", "mq");
|
||||
ret = kobject_add(q->mq_kobj, &disk_to_dev(disk)->kobj, "mq");
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
@ -288,6 +272,23 @@ int __blk_mq_register_dev(struct device *dev, struct request_queue *q)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void blk_mq_sysfs_unregister(struct gendisk *disk)
|
||||
{
|
||||
struct request_queue *q = disk->queue;
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
unsigned long i;
|
||||
|
||||
lockdep_assert_held(&q->sysfs_dir_lock);
|
||||
|
||||
queue_for_each_hw_ctx(q, hctx, i)
|
||||
blk_mq_unregister_hctx(hctx);
|
||||
|
||||
kobject_uevent(q->mq_kobj, KOBJ_REMOVE);
|
||||
kobject_del(q->mq_kobj);
|
||||
|
||||
q->mq_sysfs_init_done = false;
|
||||
}
|
||||
|
||||
void blk_mq_sysfs_unregister_hctxs(struct request_queue *q)
|
||||
{
|
||||
struct blk_mq_hw_ctx *hctx;
|
||||
|
@ -118,7 +118,8 @@ static inline struct blk_mq_hw_ctx *blk_mq_map_queue(struct request_queue *q,
|
||||
*/
|
||||
extern void blk_mq_sysfs_init(struct request_queue *q);
|
||||
extern void blk_mq_sysfs_deinit(struct request_queue *q);
|
||||
extern int __blk_mq_register_dev(struct device *dev, struct request_queue *q);
|
||||
int blk_mq_sysfs_register(struct gendisk *disk);
|
||||
void blk_mq_sysfs_unregister(struct gendisk *disk);
|
||||
int blk_mq_sysfs_register_hctxs(struct request_queue *q);
|
||||
void blk_mq_sysfs_unregister_hctxs(struct request_queue *q);
|
||||
extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx);
|
||||
|
@ -812,18 +812,17 @@ struct kobj_type blk_queue_ktype = {
|
||||
*/
|
||||
int blk_register_queue(struct gendisk *disk)
|
||||
{
|
||||
int ret;
|
||||
struct device *dev = disk_to_dev(disk);
|
||||
struct request_queue *q = disk->queue;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&q->sysfs_dir_lock);
|
||||
|
||||
ret = kobject_add(&q->kobj, &dev->kobj, "%s", "queue");
|
||||
ret = kobject_add(&q->kobj, &disk_to_dev(disk)->kobj, "queue");
|
||||
if (ret < 0)
|
||||
goto unlock;
|
||||
|
||||
if (queue_is_mq(q))
|
||||
__blk_mq_register_dev(dev, q);
|
||||
blk_mq_sysfs_register(disk);
|
||||
mutex_lock(&q->sysfs_lock);
|
||||
|
||||
mutex_lock(&q->debugfs_mutex);
|
||||
@ -919,7 +918,7 @@ void blk_unregister_queue(struct gendisk *disk)
|
||||
* structures that can be modified through sysfs.
|
||||
*/
|
||||
if (queue_is_mq(q))
|
||||
blk_mq_unregister_dev(disk_to_dev(disk), q);
|
||||
blk_mq_sysfs_unregister(disk);
|
||||
blk_crypto_sysfs_unregister(q);
|
||||
|
||||
mutex_lock(&q->sysfs_lock);
|
||||
|
@ -691,7 +691,6 @@ struct gendisk *blk_mq_alloc_disk_for_queue(struct request_queue *q,
|
||||
struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *);
|
||||
int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
|
||||
struct request_queue *q);
|
||||
void blk_mq_unregister_dev(struct device *, struct request_queue *);
|
||||
void blk_mq_destroy_queue(struct request_queue *);
|
||||
|
||||
int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set);
|
||||
|
Loading…
Reference in New Issue
Block a user