From patchwork Tue Oct 18 01:43:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 3864 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1724002wrs; Mon, 17 Oct 2022 18:25:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Q0l0tppkCe9zNtEmS00ZGuOhScFVQhj9pRT1s/y23h3yq2OWLoT502eVjGuPUTWOzYkeR X-Received: by 2002:a05:6402:1a42:b0:458:b430:7e70 with SMTP id bf2-20020a0564021a4200b00458b4307e70mr387198edb.293.1666056314288; Mon, 17 Oct 2022 18:25:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666056314; cv=none; d=google.com; s=arc-20160816; b=hnnvDHL/JGEjq+GhfcR6fMUkBdr8qcRTfxsRbBnDEroByZL2yAF/VEs/UA0H9tKJ3k z509K6V/wlDUxHxLpM807P7w3vbPf7D8eMfDgSPHpl+Rv18rNBouYYfxxKDBzUeG+O4N ZKDodybGI6Nge54oUoBv7/vc0iGjmj8Hs8D8SQyBZ7uWR4jCuT+LVhQtq9FqjshyNRX7 R4jKiQLW20YdBq2t3n9WYcXOg0kuv/zauEceF4CPXQfcdW/SNfkLKPum30XSuVGcDRsk aUfcmQEcADqHJkiGL2UmMi+rJnUY3BgmMxpt6ydNhtOUEpHgqVUN5gfKK18nYfjZ2Iom v28w== 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=Gd0r5wjE/WX4SB1nN7XNqWwJJ6PQmtCxZEDWBZXFaT0=; b=X1vUXjytgfjkkqIuCiQy4UnF2Ka8hQM6eu8bv1F/8TpevKbZQYs20qrVtxVYlHL9z/ 1dJwNz3DzTNgAlkJvjdpRAO21ANrFThI/dLmk5OnMuLYFJzngjijBuZzwoQ17ga4b5YQ Q91dtP0WYlB4qKr3o9ZdVRBmi1iX3trtU9quVmdFmcjIGuRUQPIngiAOWdxZheUDjLYz zQDRb8mWau6MBHUs3w4WwyaUIDRGB/aRv7lepKhCkkp9Jf/zdVkTNl9BvIDBSadoJqs4 JFNxK6n6ixaQO0bLRwI7ESi4TiBcGJvO396Tht3ewM75lNpeJGb6TjfNlwKIBGDReMJh 3obg== 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 jg16-20020a170907971000b00782686da1d1si9727933ejc.761.2022.10.17.18.24.50; Mon, 17 Oct 2022 18:25:14 -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 S229935AbiJRBVh (ORCPT + 99 others); Mon, 17 Oct 2022 21:21:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229950AbiJRBV1 (ORCPT ); Mon, 17 Oct 2022 21:21:27 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE447E817; Mon, 17 Oct 2022 18:21:24 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Mrwxk6T88zl0ks; Tue, 18 Oct 2022 09:19:22 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgAXCzKR_01jxSkfAA--.17823S5; Tue, 18 Oct 2022 09:21:23 +0800 (CST) From: Yu Kuai To: gregkh@linuxfoundation.org, axboe@kernel.dk, yukuai3@huawei.com Cc: stable@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@hawei.com Subject: [PATCH 5.10 1/3] block: wbt: Remove unnecessary invoking of wbt_update_limits in wbt_init Date: Tue, 18 Oct 2022 09:43:24 +0800 Message-Id: <20221018014326.467842-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221018014326.467842-1-yukuai1@huaweicloud.com> References: <20221018014326.467842-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAXCzKR_01jxSkfAA--.17823S5 X-Coremail-Antispam: 1UD129KBjvdXoWrZryxWF43WF18Jw17uFW7Arb_yoWfGwbEga 1xGrn7AFs5Aa1IyF1kGFWrWa4Ikw48Gw4UuFy8G3sxJ3Z3KF4Ik34xXry5t3y3XFZFkr9x X3s8Xa1Ikr4IqjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb-kFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY02 0Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7MxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbec_DUUUUU== 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?1746986665855925957?= X-GMAIL-MSGID: =?utf-8?q?1746986665855925957?= From: Lei Chen commit 5a20d073ec54a72d9a732fa44bfe14954eb6332f upstream. It's unnecessary to call wbt_update_limits explicitly within wbt_init, because it will be called in the following function wbt_queue_depth_changed. Signed-off-by: Lei Chen Signed-off-by: Jens Axboe Signed-off-by: Yu Kuai --- block/blk-wbt.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 35d81b5deae1..4ec0a018a2ad 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -840,7 +840,6 @@ int wbt_init(struct request_queue *q) rwb->enable_state = WBT_STATE_ON_DEFAULT; rwb->wc = 1; rwb->rq_depth.default_depth = RWB_DEF_DEPTH; - wbt_update_limits(rwb); /* * Assign rwb and add the stats callback. From patchwork Tue Oct 18 01:43:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 3863 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1723960wrs; Mon, 17 Oct 2022 18:25:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7zpEjHEUVsEeZc88nwuZ6oV9EqCKHj16JYSS+p/cmkV3m/FtONFP6geADZYNwoUYUJRg0U X-Received: by 2002:a17:902:ec91:b0:182:8eca:ade2 with SMTP id x17-20020a170902ec9100b001828ecaade2mr488700plg.12.1666056304145; Mon, 17 Oct 2022 18:25:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666056304; cv=none; d=google.com; s=arc-20160816; b=cvzBKngaJWxJyl5huYz0002Xvur4keECC9j8YPmZHt2tKAvGXg3Rztmb3qgAVk2AMn v+foqsGFFxrOanb34fdkE4sME27k2YFhcf7jwvq0yWYH3Ppqqz2xlAzVlnP44X/gUAeQ TKb3LW9+k4IhyxNP/Wsx4gvE6YX7I/Je1lSxuj1C9hNiQ4D99P1JIPoAZnmzGgZLZm6W xyfDx4dfA0Btpt7+IqiqdFComtIEMOizh2/znGfow0NiPh8Ycc/sMAvgph8bPmnBD/+C AIzEQ+npcEjgSF/aUtljj5/6GWqbDktlViz2lRyxxDOT6Bga84WSkluZq+IwkG8x113o lnew== 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=E7yJtNx653LqU0oGFGnN24ny0qjGj6ZxXFWnO+yinKg=; b=eWSxZUS76ZGvKj95oFqpqMv5fO9GSg9i1chJeFTErdsTUTgCRyP4YcZTFMBbvaDLk8 xdcLnQb2LU3bVwMFQUbhB/GHmEtlIy+XVGAnEMIQMjnAg9TzsbTrRlLHHcif63H4DV3T nQoVtcO9ibHZkCalSBvpQ24CDy/2NJ61/187+Mb2T3MuDYEcHKGzB36TE6dp5Z6rnFjS 5GLg8KcMt5YhXYG9GOW0h49SrPxTCc0em2kH/wCfKPMb7/gfGCi587c5xpb3o0Z0vAh2 UEFfCsH5ra/BPEHwgODM6OG4wzm6xIlSSMYhPggSFXlVtbv9PalBOP/Hh/s+GawgjJae CW2w== 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 s140-20020a632c92000000b0042b5035d717si13604449pgs.44.2022.10.17.18.24.51; Mon, 17 Oct 2022 18:25:04 -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 S230170AbiJRBVk (ORCPT + 99 others); Mon, 17 Oct 2022 21:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230107AbiJRBVd (ORCPT ); Mon, 17 Oct 2022 21:21:33 -0400 Received: from dggsgout12.his.huawei.com (unknown [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B5A7EFEB; Mon, 17 Oct 2022 18:21:28 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4MrwxQ0n7Nz6R63t; Tue, 18 Oct 2022 09:19:06 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgAXCzKR_01jxSkfAA--.17823S6; Tue, 18 Oct 2022 09:21:23 +0800 (CST) From: Yu Kuai To: gregkh@linuxfoundation.org, axboe@kernel.dk, yukuai3@huawei.com Cc: stable@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@hawei.com Subject: [PATCH 5.10 2/3] blk-wbt: call rq_qos_add() after wb_normal is initialized Date: Tue, 18 Oct 2022 09:43:25 +0800 Message-Id: <20221018014326.467842-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221018014326.467842-1-yukuai1@huaweicloud.com> References: <20221018014326.467842-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAXCzKR_01jxSkfAA--.17823S6 X-Coremail-Antispam: 1UD129KBjvJXoWxAFyrWryfZr15ZFWrWFW7urg_yoW5Xr4kpa y2kFW5tr42grs2vF4xJr47ZFW3Kws5Jry7ur43G3yFqr9rKryjvanagF15W34rArWkCF43 tr1FvFZ8GFyUZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUc6pPUUUUU= 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?1746986655652766865?= X-GMAIL-MSGID: =?utf-8?q?1746986655652766865?= From: Yu Kuai commit 8c5035dfbb9475b67c82b3fdb7351236525bf52b upstream. Our test found a problem that wbt inflight counter is negative, which will cause io hang(noted that this problem doesn't exist in mainline): t1: device create t2: issue io add_disk blk_register_queue wbt_enable_default wbt_init rq_qos_add // wb_normal is still 0 /* * in mainline, disk can't be opened before * bdev_add(), however, in old kernels, disk * can be opened before blk_register_queue(). */ blkdev_issue_flush // disk size is 0, however, it's not checked submit_bio_wait submit_bio blk_mq_submit_bio rq_qos_throttle wbt_wait bio_to_wbt_flags rwb_enabled // wb_normal is 0, inflight is not increased wbt_queue_depth_changed(&rwb->rqos); wbt_update_limits // wb_normal is initialized rq_qos_track wbt_track rq->wbt_flags |= bio_to_wbt_flags(rwb, bio); // wb_normal is not 0,wbt_flags will be set t3: io completion blk_mq_free_request rq_qos_done wbt_done wbt_is_tracked // return true __wbt_done wbt_rqw_done atomic_dec_return(&rqw->inflight); // inflight is decreased commit 8235b5c1e8c1 ("block: call bdev_add later in device_add_disk") can avoid this problem, however it's better to fix this problem in wbt: 1) Lower kernel can't backport this patch due to lots of refactor. 2) Root cause is that wbt call rq_qos_add() before wb_normal is initialized. Fixes: e34cbd307477 ("blk-wbt: add general throttling mechanism") Cc: Signed-off-by: Yu Kuai Link: https://lore.kernel.org/r/20220913105749.3086243-1-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe --- block/blk-wbt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 4ec0a018a2ad..bafdb8098893 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -840,6 +840,10 @@ int wbt_init(struct request_queue *q) rwb->enable_state = WBT_STATE_ON_DEFAULT; rwb->wc = 1; rwb->rq_depth.default_depth = RWB_DEF_DEPTH; + rwb->min_lat_nsec = wbt_default_latency_nsec(q); + + wbt_queue_depth_changed(&rwb->rqos); + wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); /* * Assign rwb and add the stats callback. @@ -847,10 +851,5 @@ int wbt_init(struct request_queue *q) rq_qos_add(q, &rwb->rqos); blk_stat_add_callback(q, rwb->cb); - rwb->min_lat_nsec = wbt_default_latency_nsec(q); - - wbt_queue_depth_changed(&rwb->rqos); - wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); - return 0; } From patchwork Tue Oct 18 01:43:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 3867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1728515wrs; Mon, 17 Oct 2022 18:41:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uVEycPmbcArmcZ8jxF5ZHjBd/Dn/odddw0Ri4Ayon0F+C2nB41Nco46mEbL4PmObuT9X0 X-Received: by 2002:aa7:c054:0:b0:453:98c6:f6c4 with SMTP id k20-20020aa7c054000000b0045398c6f6c4mr464369edo.2.1666057300833; Mon, 17 Oct 2022 18:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666057300; cv=none; d=google.com; s=arc-20160816; b=NfHcM+Q37Xoh+WvZ/xFrKhcs8qGH9IY55X2bRPcJwL7wsYwVQplDWX39VVUGEHIfkY bEvb5Z2f18RLjQzDSzqGRfW/Tnl+5/yzdX73jGzthE2lf0tMUmIhLr8CbVTH4cm2Eu0p /hISwoR3SJ5xVuM2eQv34nw0R25C2YjlRwevpdJ09mBT6arSBksP2Ii7IV6mjlUk7S3C 5rqDYzreWzkROiwqWo+RoPX+vQcUKpTrlt8nBwZt8/D+zBb2UVa30BNiM/aglnGGAp1o 9X/3ByBoe7PDm8OdoCKusos5p9jP9vW2u95rnIc4cjY9rVk3ftFcz0zhMtFxJSLpATqk wZpQ== 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=uSOLkffTcF6qeT5v9T4I0vnGU2x1NrlUXveLmfWLiL8=; b=UDj5kmwkavwj9QxlJ/nnquiUd/x8vQInCa1clmlliO/X7j4rpDWhZJPeu9LyqubZ64 VUScq8ZHRNn499C0lggyQ1LY8bbrqx3cTRb7NURFg+INgBfUtFeC+NjmIHite6rweSe3 jmDKzM1rHllDfzoov+VPOrMLwrBMjLsF45YWVoruiruNJYqAoQYD0v79CyB+JFgNQ+6U ka1za/xIpXClxyj63+wPLXhJRC8KLSvEI1ESvKYE8R9Lo8iPcHhBA+TcCC7MEOjtfRlr 0+x9uyCzS9wRx7pmWidYuU8CqyYC65k3DZWgJ7QcrmcZsWCEc2Mu3L2xyjRHpPKpaL97 c15A== 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 qf38-20020a1709077f2600b007823754ecd5si11410549ejc.43.2022.10.17.18.41.14; Mon, 17 Oct 2022 18:41:40 -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 S230229AbiJRBVq (ORCPT + 99 others); Mon, 17 Oct 2022 21:21:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230119AbiJRBVd (ORCPT ); Mon, 17 Oct 2022 21:21:33 -0400 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1DED7EFFD; Mon, 17 Oct 2022 18:21:28 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4MrwxP0NXNzKHXR; Tue, 18 Oct 2022 09:19:05 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgAXCzKR_01jxSkfAA--.17823S7; Tue, 18 Oct 2022 09:21:26 +0800 (CST) From: Yu Kuai To: gregkh@linuxfoundation.org, axboe@kernel.dk, yukuai3@huawei.com Cc: stable@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com, yi.zhang@hawei.com Subject: [PATCH 5.10 3/3] blk-wbt: fix that 'rwb->wc' is always set to 1 in wbt_init() Date: Tue, 18 Oct 2022 09:43:26 +0800 Message-Id: <20221018014326.467842-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221018014326.467842-1-yukuai1@huaweicloud.com> References: <20221018014326.467842-1-yukuai1@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgAXCzKR_01jxSkfAA--.17823S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ur1kXw48KrWfJFW8CF4fGrg_yoW8Ar17pa yIk3yUGFWjgr4I93WxGa1ruFWDKan5AFy3Cr43Gw15Zay2vr4Uurs29FWUWrykZrZakFWa vr4furWqvFyUGaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9m14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxGrwCFx2 IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v2 6r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67 AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IY s7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr 0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUd8n5UUUUU= 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?1746987700041219755?= X-GMAIL-MSGID: =?utf-8?q?1746987700041219755?= From: Yu Kuai commit 285febabac4a16655372d23ff43e89ff6f216691 upstream. commit 8c5035dfbb94 ("blk-wbt: call rq_qos_add() after wb_normal is initialized") moves wbt_set_write_cache() before rq_qos_add(), which is wrong because wbt_rq_qos() is still NULL. Fix the problem by removing wbt_set_write_cache() and setting 'rwb->wc' directly. Noted that this patch also remove the redundant setting of 'rab->wc'. Fixes: 8c5035dfbb94 ("blk-wbt: call rq_qos_add() after wb_normal is initialized") Reported-by: kernel test robot Link: https://lore.kernel.org/r/202210081045.77ddf59b-yujie.liu@intel.com Signed-off-by: Yu Kuai Reviewed-by: Ming Lei Link: https://lore.kernel.org/r/20221009101038.1692875-1-yukuai1@huaweicloud.com Signed-off-by: Jens Axboe --- block/blk-wbt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/blk-wbt.c b/block/blk-wbt.c index bafdb8098893..6f63920f073c 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -838,12 +838,11 @@ int wbt_init(struct request_queue *q) rwb->last_comp = rwb->last_issue = jiffies; rwb->win_nsec = RWB_WINDOW_NSEC; rwb->enable_state = WBT_STATE_ON_DEFAULT; - rwb->wc = 1; + rwb->wc = test_bit(QUEUE_FLAG_WC, &q->queue_flags); rwb->rq_depth.default_depth = RWB_DEF_DEPTH; rwb->min_lat_nsec = wbt_default_latency_nsec(q); wbt_queue_depth_changed(&rwb->rqos); - wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); /* * Assign rwb and add the stats callback.