From patchwork Fri Oct 28 10:10:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 12195 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp727473wru; Fri, 28 Oct 2022 02:51:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5lwIWLMMkVRJXFBup/7zuSRA2jI9SuWZiilPqh5sOk7LK/wVEf8N1RHaiRsIs6TIDqykB5 X-Received: by 2002:a05:6402:2893:b0:461:59fd:9b4 with SMTP id eg19-20020a056402289300b0046159fd09b4mr33347032edb.389.1666950670709; Fri, 28 Oct 2022 02:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666950670; cv=none; d=google.com; s=arc-20160816; b=NuQrUW0ROzU/kAfUihK73c/j9+slpvTEfH12xoe2wQ1zj/AXLLUCLbi93Ay6ZAgrFC tuh8ExMaXikxjfHDZweb2e82awC0WTH+5b0iq5szHgol5PpVzgHpCi/gHEyGw4+2sw2t Wx6zkHP+EShCZtUzFNOnshuF4KBNpWxW296tnbM6fkhyveVBthiil7ypzTJTmCvTVyf0 huTOK15Rt0/77NjCPcu9GeTxR8UpaHJ6E1FmciaTs81krXpHILLBLw0VaNeoSU0kXexK j55unfQCAspkmObmKONcN6x6AtJOEkv7lFkBtbrYnrcNLRJft9czZWYsKWJkzQNZEUsL HM9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=X1hpJ/LxUMIkiwGyWBHE9M+eXD0u0a+a4ayZsxZFy2Y=; b=JsDMNZSv8zq2kXu9QKxGRH5Ctaz0VMqz//g7tfe4IfGoCREdoZWf34Q1HWlvHgQqQm ddubWYXinR6IoynXX60O/1nF3ty5NLJTSZjJH9TxoLtd5cd4QrfvEwT0AmNaPbkH5gil jnA1LdbgSY2mWeB/KuR94o0G73zdPxeGiUXBjVULRDsH6ja5jZFLDKEneB2DTK9c2rBM livAVblqM7g+nkTsQ4evf4FOoIywpvinio4It6BW/nTbPukaESQ1HXf3O49BYH93XvnL h2DwSMMjflwKYtkgemwcevgJlQ2vn+BiF/IYX91bQEiRGLyMTq7CPtSaqY6KLjZmukX6 CoGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv17-20020a17090760d100b0073d8e26e78bsi4077126ejc.960.2022.10.28.02.50.47; Fri, 28 Oct 2022 02:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229950AbiJ1JtZ (ORCPT + 99 others); Fri, 28 Oct 2022 05:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229799AbiJ1JtJ (ORCPT ); Fri, 28 Oct 2022 05:49:09 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47A731C4ECC; Fri, 28 Oct 2022 02:49:08 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MzHkQ0kfwz6T8tN; Fri, 28 Oct 2022 17:46:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgCntOaQpVtjHAtNAQ--.59885S5; Fri, 28 Oct 2022 17:49:06 +0800 (CST) From: Yu Kuai To: tj@kernel.org, josef@toxicpanda.com, axboe@kernel.dk, yukuai3@huawei.com Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@huawei.com Subject: [PATCH -next 1/5] blk-iocost: cleanup ioc_qos_write() and ioc_cost_model_write() Date: Fri, 28 Oct 2022 18:10:52 +0800 Message-Id: <20221028101056.1971715-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221028101056.1971715-1-yukuai1@huaweicloud.com> References: <20221028101056.1971715-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCntOaQpVtjHAtNAQ--.59885S5 X-Coremail-Antispam: 1UD129KBjvJXoWxur1UJF4rJFy5uFy5ZF18Krg_yoWrCFW8pF WF93yaq3y8Ars7Wr42yF42ga4rCwsrWry7CFWkGr1fZrnFyrnFgF109FyUurW8JFZ3Jrs8 JFZFqrWDCayDA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVW5JVWrJwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r1I6r4UM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUqAp5UUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747924466306137166?= X-GMAIL-MSGID: =?utf-8?q?1747924466306137166?= From: Yu Kuai There are no functional changes, just to make the code a litter cleaner and follow up patches easier. Signed-off-by: Yu Kuai Reviewed-by: Christoph Hellwig --- block/blk-iocost.c | 62 +++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index f01359906c83..fd495e823db2 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3185,7 +3185,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, if (!ioc) { ret = blk_iocost_init(disk); if (ret) - goto err; + goto out; ioc = q_to_ioc(disk->queue); } @@ -3197,6 +3197,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, enable = ioc->enabled; user = ioc->user_qos_params; + ret = -EINVAL; while ((p = strsep(&input, " \t\n"))) { substring_t args[MAX_OPT_ARGS]; char buf[32]; @@ -3218,7 +3219,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, else if (!strcmp(buf, "user")) user = true; else - goto einval; + goto out_unlock; continue; } @@ -3228,39 +3229,39 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, case QOS_WPPM: if (match_strlcpy(buf, &args[0], sizeof(buf)) >= sizeof(buf)) - goto einval; + goto out_unlock; if (cgroup_parse_float(buf, 2, &v)) - goto einval; + goto out_unlock; if (v < 0 || v > 10000) - goto einval; + goto out_unlock; qos[tok] = v * 100; break; case QOS_RLAT: case QOS_WLAT: if (match_u64(&args[0], &v)) - goto einval; + goto out_unlock; qos[tok] = v; break; case QOS_MIN: case QOS_MAX: if (match_strlcpy(buf, &args[0], sizeof(buf)) >= sizeof(buf)) - goto einval; + goto out_unlock; if (cgroup_parse_float(buf, 2, &v)) - goto einval; + goto out_unlock; if (v < 0) - goto einval; + goto out_unlock; qos[tok] = clamp_t(s64, v * 100, VRATE_MIN_PPM, VRATE_MAX_PPM); break; default: - goto einval; + goto out_unlock; } user = true; } if (qos[QOS_MIN] > qos[QOS_MAX]) - goto einval; + goto out_unlock; if (enable) { blk_stat_enable_accounting(disk->queue); @@ -3281,21 +3282,14 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, } ioc_refresh_params(ioc, true); - spin_unlock_irq(&ioc->lock); + ret = nbytes; - blk_mq_unquiesce_queue(disk->queue); - blk_mq_unfreeze_queue(disk->queue); - - blkdev_put_no_open(bdev); - return nbytes; -einval: +out_unlock: spin_unlock_irq(&ioc->lock); - blk_mq_unquiesce_queue(disk->queue); blk_mq_unfreeze_queue(disk->queue); - ret = -EINVAL; -err: +out: blkdev_put_no_open(bdev); return ret; } @@ -3364,7 +3358,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, if (!ioc) { ret = blk_iocost_init(bdev->bd_disk); if (ret) - goto err; + goto out; ioc = q_to_ioc(q); } @@ -3375,6 +3369,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, memcpy(u, ioc->params.i_lcoefs, sizeof(u)); user = ioc->user_cost_model; + ret = -EINVAL; while ((p = strsep(&input, " \t\n"))) { substring_t args[MAX_OPT_ARGS]; char buf[32]; @@ -3392,20 +3387,20 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, else if (!strcmp(buf, "user")) user = true; else - goto einval; + goto out_unlock; continue; case COST_MODEL: match_strlcpy(buf, &args[0], sizeof(buf)); if (strcmp(buf, "linear")) - goto einval; + goto out_unlock; continue; } tok = match_token(p, i_lcoef_tokens, args); if (tok == NR_I_LCOEFS) - goto einval; + goto out_unlock; if (match_u64(&args[0], &v)) - goto einval; + goto out_unlock; u[tok] = v; user = true; } @@ -3416,23 +3411,16 @@ static ssize_t ioc_cost_model_write(struct kernfs_open_file *of, char *input, } else { ioc->user_cost_model = false; } - ioc_refresh_params(ioc, true); - spin_unlock_irq(&ioc->lock); - blk_mq_unquiesce_queue(q); - blk_mq_unfreeze_queue(q); - - blkdev_put_no_open(bdev); - return nbytes; + ioc_refresh_params(ioc, true); + ret = nbytes; -einval: +out_unlock: spin_unlock_irq(&ioc->lock); - blk_mq_unquiesce_queue(q); blk_mq_unfreeze_queue(q); - ret = -EINVAL; -err: +out: blkdev_put_no_open(bdev); return ret; }