Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp4425042pxb; Mon, 21 Feb 2022 21:12:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8onmLu96Z1OO4LuyDJtM/uo5eX0V39aEMJFxkTiD4kbpzEpN1nJU+5/dRNkM+QyDh6fQE X-Received: by 2002:aa7:8d08:0:b0:4e1:5fb5:b15 with SMTP id j8-20020aa78d08000000b004e15fb50b15mr22980745pfe.70.1645506749223; Mon, 21 Feb 2022 21:12:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645506749; cv=none; d=google.com; s=arc-20160816; b=dP91rimwGIe8/KUkkiYhvzKWwG77zjhiuhR/Lq4+0/oTpi9udcTO8CzfO3TFBRyBtw gmQuxaj+LGrAY+XF+DKJmhw/xfyAHZirGMjYUsWIvOhgi3BcZ5x9ETPzEdMnb2+L6yeq LCL/1IiH3uJblTFcdeeX3M5XzwJjdP0iFYbkC1sUnTQg2J263yByTUEekJ718ZnW8S/i rujVVrTCsR9iZtKOV4bxo3KVlZ5BjVEPPCctOSp8tZcOSl8FVTVW5nnGxEUlJr1WX9/f qju9rErdCsRv1A1y5dmxY9oxJQH6psYxTsFIGDluLqYVsHIcui2c8n8uTuwFqXY3gjs2 jkbw== 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=qTvckZzePgt0U3wrQM5hXzGkgeBORa26XFUN6cMkfgg=; b=D/3xyViaJg9oG1DnLRQsYJNsgu2xVdstZnbJ122y3ekhSEqrgctZ2LSgvWyIvcEUqA a7WZl3wbGmorGexsBxQlEFJp24QxtAMdA7JGwa2yIvRYykdxG+JvvK30Zk4FUL4rC3Pm lxUXkr/L8NGZ4KsXFyR0cXg6Z/fbf+kdvPiwJuwcp3/MCPmy7DOzzWUxyi69gzRw+URz tHqrKg/qNZQdAAl8Qb5A3jVY60ELOJuUpClQGZiCawBa0cnLtUMP5WWitfAW+wqwN8gY PlFiVJp+m8zqAJwFV4LGGz9M+rTQx8diH8ys8l4wc4osXRX5n8LKPpjD6ngxk4YHbNL7 Sypw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="O/qWeRmj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 204si9547524pgg.613.2022.02.21.21.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 21:12:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="O/qWeRmj"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29F3BD64C4; Mon, 21 Feb 2022 20:45:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352899AbiBUKBJ (ORCPT + 99 others); Mon, 21 Feb 2022 05:01:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352333AbiBUJxx (ORCPT ); Mon, 21 Feb 2022 04:53:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8E337006; Mon, 21 Feb 2022 01:23:44 -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 EF2CA60FBA; Mon, 21 Feb 2022 09:23:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8FBAC340E9; Mon, 21 Feb 2022 09:23:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645435423; bh=w+UicoM5DkkuhGVLBhKd8GylSa81D5HTmjneWjIRTwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O/qWeRmjDSJI2U1r4/Mf2tGMbu6vbsfxDk4HNvDgnVYK4VBzbsu8ZdqYgCH97whVT vNPZuZSipgNZhv2C2Pn30ZIZIyjr1JJGuM5Oci4QaK/ljsjbRnfroNP13hFIYAyoS0 THCCsMccVZRTNdZyzKNFVt5TaRCOkBsPg7onZd7k= 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.16 159/227] block/wbt: fix negative inflight counter when remove scsi device Date: Mon, 21 Feb 2022 09:49:38 +0100 Message-Id: <20220221084940.107272851@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220221084934.836145070@linuxfoundation.org> References: <20220221084934.836145070@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 @@ -6878,6 +6878,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 @@ -523,8 +523,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); } }