From nobody Mon Feb 9 13:36:07 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0CEC275AF3; Fri, 10 Oct 2025 09:15:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760087743; cv=none; b=bfgD34A2NkEYumAQ/rmSNjY7jHQjVtHMhY0g827atzF9WefKASMC7YwvMBAqG2KkatOkUbuoybCMjpl0GRjLKS94J1B6jIIMeAOyt7YpM0WcgXUrDq49fjkiMdVzLBchEVUyqOZtoipNI2MoXpHEWFlHZA3vpKvUgc0fJFXaMdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760087743; c=relaxed/simple; bh=oKPt0bnqcsiByTXgVTcFXXKhtQ5JAVyT2nx9cy0X76Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jsoy0Vn3Es6SH5nw1M3ZrabSO7S1mFTVvvjd500fTomfp5NTM7xVxnNbSo5bSLR0hmF9VSl0fooHxgCFUYMbCzRznCmGlFBcrf+3ZZu1a9gi74284H6ZEtBYUkaDizE8Ly/3qZ0XM2Nj8MzvOZO6vLEAkhlLd3PJ9lhJrsy9PRM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SraVnF5N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SraVnF5N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E737C4CEF8; Fri, 10 Oct 2025 09:15:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1760087743; bh=oKPt0bnqcsiByTXgVTcFXXKhtQ5JAVyT2nx9cy0X76Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SraVnF5NyLo2wRyBwtzb2jLADe9dt/JNLTGOovcsgNAx39qzYE6BVqPBlxbgq2kZn FUArqWYrqUHeeW8hgK48jHbV5R1qOtBmqR3BggSVL7w2SiDS/ipk3/VGg++POXTn1D pSDP7Uog9NKX8piecLSkFb4tXShtJPO6a9ITeoThjcLdex6W6AwT2nekIVkBm7J4l2 BQbNRY5aO5qQMEyxLZDOj/IcbVvJ6jjf0gW6iFZhRCqeV/25SZE+we4Eriuj5Aasdh UVnwLVAlFp7RMokD8gUVo89G4ZFwkW4OBh7y37an0JApPReVGcBWvakw6xY9cSKbhw p/J4odtoS9UTQ== From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, linux-block@vger.kernel.org, cgroups@vger.kernel.org, nilay@linux.ibm.com, bvanassche@acm.org, ming.lei@redhat.com, hch@lst.de Cc: linux-kernel@vger.kernel.org, Yu Kuai Subject: [PATCH v2 18/19] blk-iocost: convert to use blkg_conf_{start, end} Date: Fri, 10 Oct 2025 17:14:43 +0800 Message-ID: <20251010091446.3048529-19-yukuai@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251010091446.3048529-1-yukuai@kernel.org> References: <20251010091446.3048529-1-yukuai@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Yu Kuai No functional changes are intended, make code cleaner. Signed-off-by: Yu Kuai --- block/blk-iocost.c | 47 +++++++++++++++++++++------------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 3593547930cc..de3862acb297 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2931,7 +2931,7 @@ static int blk_iocost_init(struct gendisk *disk) if (ret) goto err_free_ioc; =20 - ret =3D blkcg_activate_policy(disk, &blkcg_policy_iocost); + ret =3D __blkcg_activate_policy(disk, &blkcg_policy_iocost); if (ret) goto err_del_qos; return 0; @@ -3140,12 +3140,15 @@ static ssize_t ioc_weight_write(struct kernfs_open_= file *of, char *buf, } =20 blkg_conf_init(&ctx, buf); - - ret =3D blkg_conf_prep(blkcg, &blkcg_policy_iocost, &ctx); + ret =3D blkg_conf_start(blkcg, &ctx); if (ret) - goto err; + return ret; =20 iocg =3D blkg_to_iocg(ctx.blkg); + if (!iocg) { + ret =3D -EOPNOTSUPP; + goto err; + } =20 if (!strncmp(ctx.body, "default", 7)) { v =3D 0; @@ -3162,13 +3165,13 @@ static ssize_t ioc_weight_write(struct kernfs_open_= file *of, char *buf, weight_updated(iocg, &now); spin_unlock(&iocg->ioc->lock); =20 - blkg_conf_exit(&ctx); + blkg_conf_end(&ctx); return nbytes; =20 einval: ret =3D -EINVAL; err: - blkg_conf_exit(&ctx); + blkg_conf_end(&ctx); return ret; } =20 @@ -3226,22 +3229,19 @@ static const match_table_t qos_tokens =3D { static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, size_t nbytes, loff_t off) { + struct blkcg *blkcg =3D css_to_blkcg(of_css(of)); struct blkg_conf_ctx ctx; struct gendisk *disk; struct ioc *ioc; u32 qos[NR_QOS_PARAMS]; bool enable, user; char *body, *p; - unsigned long memflags; int ret; =20 blkg_conf_init(&ctx, input); - - memflags =3D blkg_conf_open_bdev_frozen(&ctx); - if (IS_ERR_VALUE(memflags)) { - ret =3D memflags; - goto err; - } + ret =3D blkg_conf_start(blkcg, &ctx); + if (ret) + return ret; =20 body =3D ctx.body; disk =3D ctx.bdev->bd_disk; @@ -3358,14 +3358,14 @@ static ssize_t ioc_qos_write(struct kernfs_open_fil= e *of, char *input, =20 blk_mq_unquiesce_queue(disk->queue); =20 - blkg_conf_exit_frozen(&ctx, memflags); + blkg_conf_end(&ctx); return nbytes; einval: spin_unlock_irq(&ioc->lock); blk_mq_unquiesce_queue(disk->queue); ret =3D -EINVAL; err: - blkg_conf_exit_frozen(&ctx, memflags); + blkg_conf_end(&ctx); return ret; } =20 @@ -3418,9 +3418,9 @@ static const match_table_t i_lcoef_tokens =3D { static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *inp= ut, size_t nbytes, loff_t off) { + struct blkcg *blkcg =3D css_to_blkcg(of_css(of)); struct blkg_conf_ctx ctx; struct request_queue *q; - unsigned int memflags; struct ioc *ioc; u64 u[NR_I_LCOEFS]; bool user; @@ -3428,10 +3428,9 @@ static ssize_t ioc_cost_model_write(struct kernfs_op= en_file *of, char *input, int ret; =20 blkg_conf_init(&ctx, input); - - ret =3D blkg_conf_open_bdev(&ctx); + ret =3D blkg_conf_start(blkcg, &ctx); if (ret) - goto err; + return ret; =20 body =3D ctx.body; q =3D bdev_get_queue(ctx.bdev); @@ -3448,10 +3447,9 @@ static ssize_t ioc_cost_model_write(struct kernfs_op= en_file *of, char *input, ioc =3D q_to_ioc(q); } =20 - memflags =3D blk_mq_freeze_queue(q); blk_mq_quiesce_queue(q); - spin_lock_irq(&ioc->lock); + memcpy(u, ioc->params.i_lcoefs, sizeof(u)); user =3D ioc->user_cost_model; =20 @@ -3500,20 +3498,17 @@ static ssize_t ioc_cost_model_write(struct kernfs_o= pen_file *of, char *input, spin_unlock_irq(&ioc->lock); =20 blk_mq_unquiesce_queue(q); - blk_mq_unfreeze_queue(q, memflags); =20 - blkg_conf_exit(&ctx); + blkg_conf_end(&ctx); return nbytes; =20 einval: spin_unlock_irq(&ioc->lock); - blk_mq_unquiesce_queue(q); - blk_mq_unfreeze_queue(q, memflags); =20 ret =3D -EINVAL; err: - blkg_conf_exit(&ctx); + blkg_conf_end(&ctx); return ret; } =20 --=20 2.51.0