mirror of
https://github.com/torvalds/linux
synced 2024-11-02 18:48:59 +00:00
block: remove init_mutex and open-code blk_iolatency_try_init
Commita13696b83d
("blk-iolatency: Make initialization lazy") adds a mutex named "init_mutex" in blk_iolatency_try_init for the race condition of initializing RQ_QOS_LATENCY. Now a new lock has been add to struct request_queue by commita13bd91be2
("block/rq_qos: protect rq_qos apis with a new lock"). And it has been held in blkg_conf_open_bdev before calling blk_iolatency_init. So it's not necessary to keep init_mutex in blk_iolatency_try_init, just remove it. Since init_mutex has been removed, blk_iolatency_try_init can be open-coded back to iolatency_set_limit() like ioc_qos_write(). Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> Reviewed-by: Michal Koutný <mkoutny@suse.com> Link: https://lore.kernel.org/r/20230810035111.2236335-1-lilingfeng@huaweicloud.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
c8659bbb15
commit
4eb44d1076
1 changed files with 11 additions and 24 deletions
|
@ -824,29 +824,6 @@ static void iolatency_clear_scaling(struct blkcg_gq *blkg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int blk_iolatency_try_init(struct blkg_conf_ctx *ctx)
|
|
||||||
{
|
|
||||||
static DEFINE_MUTEX(init_mutex);
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = blkg_conf_open_bdev(ctx);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* blk_iolatency_init() may fail after rq_qos_add() succeeds which can
|
|
||||||
* confuse iolat_rq_qos() test. Make the test and init atomic.
|
|
||||||
*/
|
|
||||||
mutex_lock(&init_mutex);
|
|
||||||
|
|
||||||
if (!iolat_rq_qos(ctx->bdev->bd_queue))
|
|
||||||
ret = blk_iolatency_init(ctx->bdev->bd_disk);
|
|
||||||
|
|
||||||
mutex_unlock(&init_mutex);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf,
|
static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf,
|
||||||
size_t nbytes, loff_t off)
|
size_t nbytes, loff_t off)
|
||||||
{
|
{
|
||||||
|
@ -861,7 +838,17 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf,
|
||||||
|
|
||||||
blkg_conf_init(&ctx, buf);
|
blkg_conf_init(&ctx, buf);
|
||||||
|
|
||||||
ret = blk_iolatency_try_init(&ctx);
|
ret = blkg_conf_open_bdev(&ctx);
|
||||||
|
if (ret)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* blk_iolatency_init() may fail after rq_qos_add() succeeds which can
|
||||||
|
* confuse iolat_rq_qos() test. Make the test and init atomic.
|
||||||
|
*/
|
||||||
|
lockdep_assert_held(ctx.bdev->bd_queue->rq_qos_mutex);
|
||||||
|
if (!iolat_rq_qos(ctx.bdev->bd_queue))
|
||||||
|
ret = blk_iolatency_init(ctx.bdev->bd_disk);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue