From nobody Sun Feb 8 21:48:58 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 D363C19F12D; Sun, 16 Nov 2025 04:10:31 +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=1763266231; cv=none; b=Q/5mM9wkz7wxhF6FPtNpFCg19NW0aG4XO0Iaq7xI544SFAWkuzJTooxat3KJBvDzIAFyOAC+S2WUQech5i1yIk7It5b9GCqDP+/eagqVv92CMo3k+SVr/i+AgxvDrrRWRGmqb9qUs0JVVXNUYR5wy/U0UCVXf+hEIwh6AlbUrrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763266231; c=relaxed/simple; bh=oHU5WUeUHVeJ43U86ohqtdr2k0bq20DXDgHXaMlKoLo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cpCLsg2BW2BGxvjfAmU9CmyFgKp425FRLlTfq1gPwS2cPncNwBe/gCndZSka5iaa4MatvCgbQqhi/aglMUGdD/Z9iM/icj7BcyPaYEU9tBaWOBGUWSi+oMPuuQuEhStbVpPb65xKmO3eXbFUDQptkKqnWSp5NHmCNsAZI+kYp48= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B236EC4CEF1; Sun, 16 Nov 2025 04:10:29 +0000 (UTC) From: Yu Kuai To: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com, ming.lei@redhat.com Cc: yukuai@fnnas.com Subject: [PATCH RESEND 1/5] block/blk-rq-qos: add a new helper rq_qos_add_freezed() Date: Sun, 16 Nov 2025 12:10:20 +0800 Message-ID: <20251116041024.120500-2-yukuai@fnnas.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251116041024.120500-1-yukuai@fnnas.com> References: <20251116041024.120500-1-yukuai@fnnas.com> 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" queue should not be freezed under rq_qos_mutex, see example index commit 9730763f4756 ("block: correct locking order for protecting blk-wbt parameters"), which means current implementation of rq_qos_add() is problematic. Add a new helper and prepare to fix this problem in following patches. Signed-off-by: Yu Kuai Reviewed-by: Nilay Shroff --- block/blk-rq-qos.c | 27 +++++++++++++++++++++++++++ block/blk-rq-qos.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 654478dfbc20..353397d7e126 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -322,6 +322,33 @@ void rq_qos_exit(struct request_queue *q) mutex_unlock(&q->rq_qos_mutex); } =20 +int rq_qos_add_freezed(struct rq_qos *rqos, struct gendisk *disk, + enum rq_qos_id id, const struct rq_qos_ops *ops) +{ + struct request_queue *q =3D disk->queue; + + WARN_ON_ONCE(q->mq_freeze_depth =3D=3D 0); + lockdep_assert_held(&q->rq_qos_mutex); + + if (rq_qos_id(q, id)) + return -EBUSY; + + rqos->disk =3D disk; + rqos->id =3D id; + rqos->ops =3D ops; + rqos->next =3D q->rq_qos; + q->rq_qos =3D rqos; + blk_queue_flag_set(QUEUE_FLAG_QOS_ENABLED, q); + + if (rqos->ops->debugfs_attrs) { + mutex_lock(&q->debugfs_mutex); + blk_mq_debugfs_register_rqos(rqos); + mutex_unlock(&q->debugfs_mutex); + } + + return 0; +} + int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id i= d, const struct rq_qos_ops *ops) { diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index b538f2c0febc..4a7fec01600b 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -87,6 +87,8 @@ static inline void rq_wait_init(struct rq_wait *rq_wait) =20 int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id i= d, const struct rq_qos_ops *ops); +int rq_qos_add_freezed(struct rq_qos *rqos, struct gendisk *disk, + enum rq_qos_id id, const struct rq_qos_ops *ops); void rq_qos_del(struct rq_qos *rqos); =20 typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_da= ta); --=20 2.51.0 From nobody Sun Feb 8 21:48:58 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 EB32C19F12D; Sun, 16 Nov 2025 04:10:33 +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=1763266234; cv=none; b=D+zBV8sSrDBuyuZPWsbbFEw79gaRurJOJTr8ToqhLKX9HUORM+IhXZvGKOg0AwPwz+36nGlTGqcEM1kYC10ayQl2ylQYZH58chWHFuSZmOJEOjhXPwz3IkeJ9rVL/u5B4gvW3RalQ07APU9AQ+vtKPubkx0Lh3982Pz03fPFABQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763266234; c=relaxed/simple; bh=Z7O94oijY3strRk71JNZPL0gx2vdpAvUplzCS8521UU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lrpN6YPpJbWog7Jr0I+4n9H1ccDw8LH7tvXUP3Z0XteajLLDTgyJMd6ssmOXgaoBGCFqsIcOVD/FOOebEh4EGm2whDqsxyJYaXeoTdmi3OV5rvO7n1pVoG1Si/u+l4AGe0pIfwOtXUNuBLhIVLGc1njyLBDOXz1VfMtRYYMzq04= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE2A1C113D0; Sun, 16 Nov 2025 04:10:31 +0000 (UTC) From: Yu Kuai To: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com, ming.lei@redhat.com Cc: yukuai@fnnas.com Subject: [PATCH RESEND 2/5] blk-wbt: fix incorrect lock order for rq_qos_mutex and freeze queue Date: Sun, 16 Nov 2025 12:10:21 +0800 Message-ID: <20251116041024.120500-3-yukuai@fnnas.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251116041024.120500-1-yukuai@fnnas.com> References: <20251116041024.120500-1-yukuai@fnnas.com> 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" wbt_init() can be called from sysfs attribute and wbt_enable_default(), however the lock order are inversely. - queue_wb_lat_store() freeze queue first, and then wbt_init() hold rq_qos_mutex. In this case queue will be freezed again inside rq_qos_add(), however, in this case freeze queue recursivly is inoperative; - wbt_enable_default() from elevator switch will hold rq_qos_mutex first, and then rq_qos_add() will freeze queue; Fix this problem by converting to use new helper rq_qos_add_freezed() in wbt_init(), and for wbt_enable_default(), freeze queue before calling wbt_init(). Fixes: a13bd91be223 ("block/rq_qos: protect rq_qos apis with a new lock") Signed-off-by: Yu Kuai Reviewed-by: Nilay Shroff --- block/blk-wbt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index eb8037bae0bd..a784f6d338b4 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -724,8 +724,12 @@ void wbt_enable_default(struct gendisk *disk) if (!blk_queue_registered(q)) return; =20 - if (queue_is_mq(q) && enable) + if (queue_is_mq(q) && enable) { + unsigned int memflags =3D blk_mq_freeze_queue(q); + wbt_init(disk); + blk_mq_unfreeze_queue(q, memflags); + } } EXPORT_SYMBOL_GPL(wbt_enable_default); =20 @@ -922,7 +926,7 @@ int wbt_init(struct gendisk *disk) * Assign rwb and add the stats callback. */ mutex_lock(&q->rq_qos_mutex); - ret =3D rq_qos_add(&rwb->rqos, disk, RQ_QOS_WBT, &wbt_rqos_ops); + ret =3D rq_qos_add_freezed(&rwb->rqos, disk, RQ_QOS_WBT, &wbt_rqos_ops); mutex_unlock(&q->rq_qos_mutex); if (ret) goto err_free; --=20 2.51.0 From nobody Sun Feb 8 21:48:58 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 254A019F12D; Sun, 16 Nov 2025 04:10:36 +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=1763266236; cv=none; b=S2DRjr53oj6TWOqjFEov/cwdswzruzmuQBAeASbX+J+uju6dehAM0ZueZgILzYl7XRxrWor4P2qn1BVsL06CVawiuLyJhCj8Oi7tKSUdeECf1Xyf06Tmr9qndhpwf1lOKo8tQl2L2tArEhfrGdxFKCv2LRzY/lYvb5/hWmXNxXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763266236; c=relaxed/simple; bh=ku3xI7O8F0GyJHOuAdN7mtEFMz7g8bN7QjLzf1OGAMU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f6HPPJRhl/gkkCGfVmHYooViMpo5589q9X46vSu/eTH+EJ2Lm4jCpBJjp1Y75ah34unNhg3vKN+IhOr8PcRbScaYCWiBEPr0EJyfsujFkKhljMn48/+Yq33QlexqV36w1jvKT8znFlT7SJcOyP2gOIyQzfBRzBtRwp7FauzGTS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C338C4CEF5; Sun, 16 Nov 2025 04:10:34 +0000 (UTC) From: Yu Kuai To: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com, ming.lei@redhat.com Cc: yukuai@fnnas.com Subject: [PATCH RESEND 3/5] blk-iocost: fix incorrect lock order for rq_qos_mutex and freeze queue Date: Sun, 16 Nov 2025 12:10:22 +0800 Message-ID: <20251116041024.120500-4-yukuai@fnnas.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251116041024.120500-1-yukuai@fnnas.com> References: <20251116041024.120500-1-yukuai@fnnas.com> 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" Like wbt, rq_qos_add() can be called from two path and the lock order are inversely: - From ioc_qos_write(), queue is already freezed before rq_qos_add(); - From ioc_cost_model_write(), rq_qos_add() is called directly; Fix this problem by converting to use blkg_conf_open_bdev_frozen() from ioc_cost_model_write(), then since all rq_qos_add() callers already freeze queue, convert to use rq_qos_add_freezed. Signed-off-by: Yu Kuai Reviewed-by: Nilay Shroff --- block/blk-iocost.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 5bfd70311359..233c9749bfc9 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2927,7 +2927,7 @@ static int blk_iocost_init(struct gendisk *disk) * called before policy activation completion, can't assume that the * target bio has an iocg associated and need to test for NULL iocg. */ - ret =3D rq_qos_add(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops); + ret =3D rq_qos_add_freezed(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops); if (ret) goto err_free_ioc; =20 @@ -3410,7 +3410,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_ope= n_file *of, char *input, { struct blkg_conf_ctx ctx; struct request_queue *q; - unsigned int memflags; + unsigned long memflags; struct ioc *ioc; u64 u[NR_I_LCOEFS]; bool user; @@ -3419,9 +3419,11 @@ static ssize_t ioc_cost_model_write(struct kernfs_op= en_file *of, char *input, =20 blkg_conf_init(&ctx, input); =20 - ret =3D blkg_conf_open_bdev(&ctx); - if (ret) + memflags =3D blkg_conf_open_bdev_frozen(&ctx); + if (IS_ERR_VALUE(memflags)) { + ret =3D memflags; goto err; + } =20 body =3D ctx.body; q =3D bdev_get_queue(ctx.bdev); @@ -3438,7 +3440,6 @@ static ssize_t ioc_cost_model_write(struct kernfs_ope= n_file *of, char *input, ioc =3D q_to_ioc(q); } =20 - memflags =3D blk_mq_freeze_queue(q); blk_mq_quiesce_queue(q); =20 spin_lock_irq(&ioc->lock); @@ -3490,20 +3491,18 @@ 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_exit_frozen(&ctx, memflags); return nbytes; =20 einval: spin_unlock_irq(&ioc->lock); =20 blk_mq_unquiesce_queue(q); - blk_mq_unfreeze_queue(q, memflags); =20 ret =3D -EINVAL; err: - blkg_conf_exit(&ctx); + blkg_conf_exit_frozen(&ctx, memflags); return ret; } =20 --=20 2.51.0 From nobody Sun Feb 8 21:48:58 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 95E1C19F12D; Sun, 16 Nov 2025 04:10:38 +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=1763266238; cv=none; b=WLm13hfQM0E3UUSe9et1mjSRz5Er81RP0672cpAv6XOTJ2MGLcdAkyotyBPcebb14/25T4baDtefclVg8xuilAFMwNq7QvSQft3DG5Yfb6RDJgy15CGtF49Ff5t0eGtrCpqyxyxbGxJGQRjQjNKb48R/uY833EZcxGHT6xCj4bw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763266238; c=relaxed/simple; bh=7C1jdElV3z6qjeQHdb4I32t7OCyHyKk5pj58qZW9db8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h6Xv/MgN0M/A6YSTlmzUo0W1ygxJpXYcqnf6n0vVCObn7YWYtc3Nknaih2v9IVuNOfxnZFg4TQ3M1XVH4qd3z/oQ/iaSXYGb1qV1zQO1MJDr26fNcmfoTr/oatAC0pdn3cCeqJOlfgbmDlPvLgsHNRlnQgLyhV3Hw9GbAt1cUbU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AF0FC4CEF1; Sun, 16 Nov 2025 04:10:36 +0000 (UTC) From: Yu Kuai To: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com, ming.lei@redhat.com Cc: yukuai@fnnas.com Subject: [PATCH RESEND 4/5] blk-iolatency: fix incorrect lock order for rq_qos_mutex and freeze queue Date: Sun, 16 Nov 2025 12:10:23 +0800 Message-ID: <20251116041024.120500-5-yukuai@fnnas.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251116041024.120500-1-yukuai@fnnas.com> References: <20251116041024.120500-1-yukuai@fnnas.com> 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" Currently blk-iolatency will hold rq_qos_mutex first and then call rq_qos_add() to freeze queue. Fix this problem by converting to use blkg_conf_open_bdev_frozen() from iolatency_set_limit(), and convert to use rq_qos_add_freezed(). Signed-off-by: Yu Kuai Reviewed-by: Nilay Shroff --- block/blk-iolatency.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 45bd18f68541..1565352b176d 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -764,8 +764,8 @@ static int blk_iolatency_init(struct gendisk *disk) if (!blkiolat) return -ENOMEM; =20 - ret =3D rq_qos_add(&blkiolat->rqos, disk, RQ_QOS_LATENCY, - &blkcg_iolatency_ops); + ret =3D rq_qos_add_freezed(&blkiolat->rqos, disk, RQ_QOS_LATENCY, + &blkcg_iolatency_ops); if (ret) goto err_free; ret =3D blkcg_activate_policy(disk, &blkcg_policy_iolatency); @@ -831,16 +831,19 @@ static ssize_t iolatency_set_limit(struct kernfs_open= _file *of, char *buf, struct blkcg_gq *blkg; struct blkg_conf_ctx ctx; struct iolatency_grp *iolat; + unsigned long memflags; char *p, *tok; u64 lat_val =3D 0; u64 oldval; - int ret; + int ret =3D 0; =20 blkg_conf_init(&ctx, buf); =20 - ret =3D blkg_conf_open_bdev(&ctx); - if (ret) + memflags =3D blkg_conf_open_bdev_frozen(&ctx); + if (IS_ERR_VALUE(memflags)) { + ret =3D memflags; goto out; + } =20 /* * blk_iolatency_init() may fail after rq_qos_add() succeeds which can @@ -890,7 +893,7 @@ static ssize_t iolatency_set_limit(struct kernfs_open_f= ile *of, char *buf, iolatency_clear_scaling(blkg); ret =3D 0; out: - blkg_conf_exit(&ctx); + blkg_conf_exit_frozen(&ctx, memflags); return ret ?: nbytes; } =20 --=20 2.51.0 From nobody Sun Feb 8 21:48:58 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 D28B02571D4; Sun, 16 Nov 2025 04:10:40 +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=1763266240; cv=none; b=JT4ODMWAAotw8eEqK6IXzpz5YCZgIENKkFUNdKkYWOy1dLip6ygBYcAMP+wj9ewX7ufhylOkLSek4wYiBs4mhLO5Bm1X2gt0RGfKV64XDeAkyL0boHcLHq4ujQRKSv08BrsrPqbY6IJBSC6EsPqDJZBagW2y0/ONf6cTUIapIsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763266240; c=relaxed/simple; bh=bp2OCGjuLR9VSuQ6uIMPbUSycqO5C4T7uB7lILXZWMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L/LzAb9OckM8Pa/Ns3640jdpyNZka3kO6bOTTxJzq0ibYaCL0ymuUy00+hXkOkNgXE635cpum+lOLPbowM4Qht77M7SgUbuCOKNVLmfilzu3rcWMaWsGUjvDQVnEqQK0rTtmHwQzQ845rgiEBumV+qTkQxucQymUqF0KqAuWoso= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A67A4C4CEFB; Sun, 16 Nov 2025 04:10:38 +0000 (UTC) From: Yu Kuai To: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, tj@kernel.org, nilay@linux.ibm.com, ming.lei@redhat.com Cc: yukuai@fnnas.com Subject: [PATCH RESEND 5/5] block/blk-rq-qos: cleanup rq_qos_add() Date: Sun, 16 Nov 2025 12:10:24 +0800 Message-ID: <20251116041024.120500-6-yukuai@fnnas.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251116041024.120500-1-yukuai@fnnas.com> References: <20251116041024.120500-1-yukuai@fnnas.com> 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" Now that there is no caller of rq_qos_add(), remove it, and also rename rq_qos_add_freezed() back to rq_qos_add(). Signed-off-by: Yu Kuai Reviewed-by: Nilay Shroff --- block/blk-iocost.c | 2 +- block/blk-iolatency.c | 4 ++-- block/blk-rq-qos.c | 42 ++---------------------------------------- block/blk-rq-qos.h | 6 ++---- block/blk-wbt.c | 2 +- 5 files changed, 8 insertions(+), 48 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 233c9749bfc9..0948f628386f 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2927,7 +2927,7 @@ static int blk_iocost_init(struct gendisk *disk) * called before policy activation completion, can't assume that the * target bio has an iocg associated and need to test for NULL iocg. */ - ret =3D rq_qos_add_freezed(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops); + ret =3D rq_qos_add(&ioc->rqos, disk, RQ_QOS_COST, &ioc_rqos_ops); if (ret) goto err_free_ioc; =20 diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 1565352b176d..5b18125e21c9 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -764,8 +764,8 @@ static int blk_iolatency_init(struct gendisk *disk) if (!blkiolat) return -ENOMEM; =20 - ret =3D rq_qos_add_freezed(&blkiolat->rqos, disk, RQ_QOS_LATENCY, - &blkcg_iolatency_ops); + ret =3D rq_qos_add(&blkiolat->rqos, disk, RQ_QOS_LATENCY, + &blkcg_iolatency_ops); if (ret) goto err_free; ret =3D blkcg_activate_policy(disk, &blkcg_policy_iolatency); diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 353397d7e126..3a49af00b738 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -322,8 +322,8 @@ void rq_qos_exit(struct request_queue *q) mutex_unlock(&q->rq_qos_mutex); } =20 -int rq_qos_add_freezed(struct rq_qos *rqos, struct gendisk *disk, - enum rq_qos_id id, const struct rq_qos_ops *ops) +int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, + enum rq_qos_id id, const struct rq_qos_ops *ops) { struct request_queue *q =3D disk->queue; =20 @@ -349,44 +349,6 @@ int rq_qos_add_freezed(struct rq_qos *rqos, struct gen= disk *disk, return 0; } =20 -int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id i= d, - const struct rq_qos_ops *ops) -{ - struct request_queue *q =3D disk->queue; - unsigned int memflags; - - lockdep_assert_held(&q->rq_qos_mutex); - - rqos->disk =3D disk; - rqos->id =3D id; - rqos->ops =3D ops; - - /* - * No IO can be in-flight when adding rqos, so freeze queue, which - * is fine since we only support rq_qos for blk-mq queue. - */ - memflags =3D blk_mq_freeze_queue(q); - - if (rq_qos_id(q, rqos->id)) - goto ebusy; - rqos->next =3D q->rq_qos; - q->rq_qos =3D rqos; - blk_queue_flag_set(QUEUE_FLAG_QOS_ENABLED, q); - - blk_mq_unfreeze_queue(q, memflags); - - if (rqos->ops->debugfs_attrs) { - mutex_lock(&q->debugfs_mutex); - blk_mq_debugfs_register_rqos(rqos); - mutex_unlock(&q->debugfs_mutex); - } - - return 0; -ebusy: - blk_mq_unfreeze_queue(q, memflags); - return -EBUSY; -} - void rq_qos_del(struct rq_qos *rqos) { struct request_queue *q =3D rqos->disk->queue; diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 4a7fec01600b..8bbf178c16b0 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -85,10 +85,8 @@ static inline void rq_wait_init(struct rq_wait *rq_wait) init_waitqueue_head(&rq_wait->wait); } =20 -int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id i= d, - const struct rq_qos_ops *ops); -int rq_qos_add_freezed(struct rq_qos *rqos, struct gendisk *disk, - enum rq_qos_id id, const struct rq_qos_ops *ops); +int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, + enum rq_qos_id id, const struct rq_qos_ops *ops); void rq_qos_del(struct rq_qos *rqos); =20 typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_da= ta); diff --git a/block/blk-wbt.c b/block/blk-wbt.c index a784f6d338b4..d7f1e6ba1790 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -926,7 +926,7 @@ int wbt_init(struct gendisk *disk) * Assign rwb and add the stats callback. */ mutex_lock(&q->rq_qos_mutex); - ret =3D rq_qos_add_freezed(&rwb->rqos, disk, RQ_QOS_WBT, &wbt_rqos_ops); + ret =3D rq_qos_add(&rwb->rqos, disk, RQ_QOS_WBT, &wbt_rqos_ops); mutex_unlock(&q->rq_qos_mutex); if (ret) goto err_free; --=20 2.51.0