Message ID | 20230809112928.2009183-1-lilingfeng@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [-next,v2] block: remove init_mutex and open-code blk_iolatency_try_init | expand |
On Wed, Aug 09, 2023 at 07:29:28PM +0800, Li Lingfeng <lilingfeng@huaweicloud.com> wrote: > 1 file changed, 10 insertions(+), 24 deletions(-) I like this bottom line. > @@ -861,7 +838,16 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *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. > + */ Perhaps add here lockdep_assert_held(ctx.bdev->bd_queue->rq_qos_mutex); because without that the last sentence of the comment misses the context. > + if (!iolat_rq_qos(ctx.bdev->bd_queue)) > + ret = blk_iolatency_init(ctx.bdev->bd_disk); > if (ret) > goto out; Thanks, Michal
在 2023/8/9 20:11, Michal Koutný 写道: > On Wed, Aug 09, 2023 at 07:29:28PM +0800, Li Lingfeng <lilingfeng@huaweicloud.com> wrote: >> 1 file changed, 10 insertions(+), 24 deletions(-) > I like this bottom line. > >> @@ -861,7 +838,16 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *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. >> + */ > Perhaps add here > lockdep_assert_held(ctx.bdev->bd_queue->rq_qos_mutex); > > because without that the last sentence of the comment misses the > context. Yes, it looks better. Thanks. Li > >> + if (!iolat_rq_qos(ctx.bdev->bd_queue)) >> + ret = blk_iolatency_init(ctx.bdev->bd_disk); >> if (ret) >> goto out; > Thanks, > Michal
diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index fd5fec989e39..e1dbf18a1d1d 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -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, size_t nbytes, loff_t off) { @@ -861,7 +838,16 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *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. + */ + if (!iolat_rq_qos(ctx.bdev->bd_queue)) + ret = blk_iolatency_init(ctx.bdev->bd_disk); if (ret) goto out;