Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3756021pxt; Tue, 10 Aug 2021 10:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkCQZrYt5HAQQ2ImITajoaJ4+Q1ReIDkVhe1SxBigzEbWT9Ks+1n7/yltH2iB92zZdYfqv X-Received: by 2002:a17:906:138f:: with SMTP id f15mr11183849ejc.233.1628616866327; Tue, 10 Aug 2021 10:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628616866; cv=none; d=google.com; s=arc-20160816; b=dT1dhrzX++GxMGRE/CV9mABiJvEkPQHcZ0vRJgTq3g5sZKKS7dXeyRKT9ySsmt4PRt wPr+HQw1b2KOrsMeHHStlXjXFdQrItaPCWGN+SM36zYH/hEwpwv2HoF2XR5w1PXC74qK wk2CNlG6cYLnyukSJkPKVTasSSTYMzle157lkqNFOvyajnctcQG6XolkfXqfdTfpLwU4 jikPXMuHW+Ss4cbkG/Yi5VwVncXvTsXvbbq2qSE2m2gXs7jen+75TBeHu25g/641wsxZ 5tF+3Ql0OXoXvCBsXpv+rvfwzoU53l3KkhigXthGAdho2CCnyk25M2HMF6o+perZFfsN ef/Q== 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=B2/uOaCLkEnEfailqoMnPe+Pwqg/J7NX1MqfufvY8vY=; b=yIek1eH3BFzpdWZRINaos4SLMIHp1j4P6uiwRABWZR7XpyRMCx7HqnxEwCTEkZfGAo Vl3K8i3hFe2BPiVJtK0kAjTVx/BtsCjWCtiQ/TXCICzFDuaKPthEod0nX+ItqkkK2Kp/ HkEbzogS9IZRBIVZK+AM3X30baSfiIVt4AFqSpktptV70F4QsEaaUKwU0SGc1LGu04+6 Jv8K/605ikFCCweoVLEvsJrvf434R8Pl/m+b5fL8pxXvcBC8AMoG0BYKDmPkd9xVZby2 1iQVGX8IJZE5FWd1Z+wQH1QnkZnABsgppA+jFk2zahogJuODMbQc/DWI+aUEXeqq8dSW 6/ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=snMiXVpx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si22424247edi.195.2021.08.10.10.34.02; Tue, 10 Aug 2021 10:34:26 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=snMiXVpx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbhHJRcc (ORCPT + 99 others); Tue, 10 Aug 2021 13:32:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231378AbhHJRcZ (ORCPT ); Tue, 10 Aug 2021 13:32:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C797D60EBD; Tue, 10 Aug 2021 17:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616723; bh=PShQlVGMPaAenVHYXxAYxeX2uPj4ZEzFUew4cTnd/ZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snMiXVpxDJE7xg8Dx2bKeVpfNsiM+euIU6zsAbPL6vUsIw/utvTPtQKSWtak5LqVk rZott3itUZVexCEzM8tW5fSvrh1FPyCQGUbpuzqCFVpGEa2xXL2pv3motxXW+jzUpg V9c5Yt8S04Uk0HobGHHUKJ7hmEkJRESgkx+9bpDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yu Kuai , Tejun Heo , Jens Axboe , Sasha Levin Subject: [PATCH 4.19 19/54] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() Date: Tue, 10 Aug 2021 19:30:13 +0200 Message-Id: <20210810172944.811282415@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172944.179901509@linuxfoundation.org> References: <20210810172944.179901509@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yu Kuai [ Upstream commit 8d75d0eff6887bcac7225e12b9c75595e523d92d ] 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 Acked-by: Tejun Heo Link: https://lore.kernel.org/r/20210805124645.543797-1-yukuai3@huawei.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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 0529e94a20f7..019cf002ecee 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -800,7 +800,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.30.2