Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp760260pxt; Thu, 5 Aug 2021 10:57:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuw7JCwgaooqB4VbcxqqTSMunbHif49Eg5VkLV60LfkC1C4XQH5KguJiePfPFwbt9S3dI2 X-Received: by 2002:a05:6638:1928:: with SMTP id p40mr5858937jal.93.1628186267853; Thu, 05 Aug 2021 10:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628186267; cv=none; d=google.com; s=arc-20160816; b=kvWLzO4A0Wv5x/uQc7xwzTvAUByFnfSaamDAthFJSF22LRpievXMXPd2biee8HSMgf 7+iupGIwEuIwV2xsNWyJjJ2GztBPAo9osn1bBb+qjjDH9nn1j3zUc7QLnRSSX5Ob13+L k7axOTcTcuRcC2SLBl1lxJaVepC2+gzgjt72Uhv/kgm36ECnoX9sP9OgBVaV6hQe8H/9 L6DuxdGuXv8YyHOnygG+C1taiHLnzrhnAmD45B+JbDK6Sw6Xg8qbi/7XfXsFksmOIeUX 7pc3A8eGTdRCdT6OTTinI1PLxDZlC9GNrtFmPh2/3d/VYM95vcXE0Qj/uWHziNFU6G1t +pTg== 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 :message-id:date:subject:cc:to:from; bh=3gG4jqWvQmbNQEh22SD7b10PhCX+cpVuPJsUjOsS1Vo=; b=0iC52FfCl5K8Dsm1AdIHZKmoRLuDwAFkchCiwsGPMI9igA9gR58moWy21Mt+Wc6hy7 qWO5mt14m/+e28zk2Zt7LVvESYpG7+lA5vtn6zryNA8A+aWg7g3d0XZ46rQBj1RiGo+b EuTBV1HmupatFzZwVqEdAaGM/BJ6OH5oI5WCH0Xv9rgNvh5ltFRmgwVJHeEnkQq39k6G az4pfaTKndfn7+Ld8Qh1bb+lT2XZLd2CN/8XaL8QIqA3XOBTJjziJEFTLJR1ES3bfF4A b8il+qus4+kddL/Hji8WmU+5egbwycy45IF9jqlHpkiM55ROX+b4iEq1ri6rJVTH7mQT 1yHQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si6115589ilq.3.2021.08.05.10.57.34; Thu, 05 Aug 2021 10:57:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240416AbhHEMg6 (ORCPT + 99 others); Thu, 5 Aug 2021 08:36:58 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:16051 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240188AbhHEMg5 (ORCPT ); Thu, 5 Aug 2021 08:36:57 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GgSgl1dh3zZxt4; Thu, 5 Aug 2021 20:33:07 +0800 (CST) Received: from dggema762-chm.china.huawei.com (10.1.198.204) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 5 Aug 2021 20:36:41 +0800 Received: from huawei.com (10.175.127.227) by dggema762-chm.china.huawei.com (10.1.198.204) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 5 Aug 2021 20:36:41 +0800 From: Yu Kuai To: , , CC: , , , , Subject: [PATCH] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() Date: Thu, 5 Aug 2021 20:46:45 +0800 Message-ID: <20210805124645.543797-1-yukuai3@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggema762-chm.china.huawei.com (10.1.198.204) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If queue is dying while iolatency_set_limit() is in progress, blk_get_queue() won't increment the refcount of the queue. However, blk_put_queue() will still decrement the refcount later, which will cause the refcout to be unbalanced. Thus error out in such case to fix the problem. Fixes: 8c772a9bfc7c ("blk-iolatency: fix IO hang due to negative inflight counter") Signed-off-by: Yu Kuai --- block/blk-iolatency.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 81be0096411d..d8b0d8bd132b 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -833,7 +833,11 @@ static ssize_t iolatency_set_limit(struct kernfs_open_file *of, char *buf, enable = iolatency_set_min_lat_nsec(blkg, lat_val); if (enable) { - WARN_ON_ONCE(!blk_get_queue(blkg->q)); + if (!blk_get_queue(blkg->q)) { + ret = -ENODEV; + goto out; + } + blkg_get(blkg); } -- 2.31.1