Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4380689pxb; Mon, 21 Feb 2022 19:42:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBziiqu+voD7xfwWjQM/FjpaBrDEj55wZNmTp1pD7q9CUwljVu5hCCRchiWBy8L1C6lNtB X-Received: by 2002:a05:6a00:8c4:b0:4e1:5ee9:59a1 with SMTP id s4-20020a056a0008c400b004e15ee959a1mr23020600pfu.51.1645501330635; Mon, 21 Feb 2022 19:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645501330; cv=none; d=google.com; s=arc-20160816; b=scoofN5WC671ucenFC2mi8uD1oda7Gy+fFqCTZRrYzkzF6WqGFSA013R+j1GALs8zF gYdqAvSf/l7v9TdQU3fsDxrXpFOpBde4P4qXV6ggCXsIvaVLZOw8oGQDpTpy4yqvE8y5 2ncGS0i+PWXzdmCBFW/nT9twiFYbhvNXAmU7G008bL2BYVLSVEarW0ddXND3c4hC+ZQR OSUf0BpRxAiw9SPff8qoU+Se4IGvd1HAmYrFtjT7iEbAlAfnbmXLGI9haPUaS/3s/1Ld ScmuPGz7eRWxGNybS8uG4BzXYTS1Loo8PjYQrkRCmH2LvN1b/LZ5wTVXZkOuRNwoscex hAgA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YvGK17BrltnuhB4DMmVnBPzWQN1CKqOmDv3xfMxkTUU=; b=tcyXEqX06xRp/xMHwIH00O4hRNjdjyw+idsw4gNQaua+xfH+9r5phZ1CdkOs7xmBmG oGz3itrteNNi6mrQ5tNy/rYlr4gEBNYRs4QIhJY3k4fVctpPjKjPkYq0qny36SBDbPuH eWfenQIJS3EHUTkglBOF9gRsCQ+ns8983yH7ilboQCE3JM+bTEgAWkrkQosWx6UDlev7 iKzRjg0qut/h4ijeiz5eHExkUd32y/w0S9w+Ih/IowHB6UjnS8XVAYtW0izyzCY/7qVn 7DLj89pc5XgH6e4mEfs3quFuSAuhW+BSaNmoNPlhQ0aMhsWKoow8MDoqjqjLdt3u/hc5 lltw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Eae0NM+8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t22si10131846pfc.18.2022.02.21.19.41.54; Mon, 21 Feb 2022 19:42:10 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Eae0NM+8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347856AbiBUJOM (ORCPT + 99 others); Mon, 21 Feb 2022 04:14:12 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347851AbiBUJJA (ORCPT ); Mon, 21 Feb 2022 04:09:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D5C9E86; Mon, 21 Feb 2022 01:01:19 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C5BB66112B; Mon, 21 Feb 2022 09:01:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB16FC340EB; Mon, 21 Feb 2022 09:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645434078; bh=U7JjSvTUWGqSGweRc+H/rnqFWAD75e7iJl6LXlqWTls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eae0NM+8IOHX/ZYD6E2GJKA1uoJXCT0f7AfMwJQ3aYKRp+WZUef204HDxJggtNKa+ dCkufFUHt4zI90UmznSEq7Jqn1uCazh2MwIQUigIns8myFgC2ql5jfSlVGS9vze+tO 86jKNyDr6291+RzJOmyLVqNqH99jfDhS3ATieDmc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Christoph Hellwig , Laibin Qiu , Jens Axboe Subject: [PATCH 5.4 54/80] block/wbt: fix negative inflight counter when remove scsi device Date: Mon, 21 Feb 2022 09:49:34 +0100 Message-Id: <20220221084917.347343341@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084915.554151737@linuxfoundation.org> References: <20220221084915.554151737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Laibin Qiu commit e92bc4cd34de2ce454bdea8cd198b8067ee4e123 upstream. Now that we disable wbt by set WBT_STATE_OFF_DEFAULT in wbt_disable_default() when switch elevator to bfq. And when we remove scsi device, wbt will be enabled by wbt_enable_default. If it become false positive between wbt_wait() and wbt_track() when submit write request. The following is the scenario that triggered the problem. T1 T2 T3 elevator_switch_mq bfq_init_queue wbt_disable_default <= Set rwb->enable_state (OFF) Submit_bio blk_mq_make_request rq_qos_throttle <= rwb->enable_state (OFF) scsi_remove_device sd_remove del_gendisk blk_unregister_queue elv_unregister_queue wbt_enable_default <= Set rwb->enable_state (ON) q_qos_track <= rwb->enable_state (ON) ^^^^^^ this request will mark WBT_TRACKED without inflight add and will lead to drop rqw->inflight to -1 in wbt_done() which will trigger IO hung. Fix this by move wbt_enable_default() from elv_unregister to bfq_exit_queue(). Only re-enable wbt when bfq exit. Fixes: 76a8040817b4b ("blk-wbt: make sure throttle is enabled properly") Remove oneline stale comment, and kill one oneshot local variable. Signed-off-by: Ming Lei Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/linux-block/20211214133103.551813-1-qiulaibin@huawei.com/ Signed-off-by: Laibin Qiu Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/bfq-iosched.c | 2 ++ block/elevator.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -6389,6 +6389,8 @@ static void bfq_exit_queue(struct elevat spin_unlock_irq(&bfqd->lock); #endif + wbt_enable_default(bfqd->queue); + kfree(bfqd); } --- a/block/elevator.c +++ b/block/elevator.c @@ -522,8 +522,6 @@ void elv_unregister_queue(struct request kobject_del(&e->kobj); e->registered = 0; - /* Re-enable throttling in case elevator disabled it */ - wbt_enable_default(q); } }