Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3766142pxt; Tue, 10 Aug 2021 10:49:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLzUmOTmPr1tkbqTd1FbsT1uRUPwO4wiA1XCpVLjekhSJyDIxT1SkibmxOOJa2sspPd/jV X-Received: by 2002:a17:907:7251:: with SMTP id ds17mr29242756ejc.43.1628617748326; Tue, 10 Aug 2021 10:49:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617748; cv=none; d=google.com; s=arc-20160816; b=XKQps8jix1ldZ829TCRSufD/Db9Qh77GNSGortX3kS1NlxcU6VuVa5jFlKWWmvG90J w6Vfqy74Bz09PipkkAAxuwIORVCOeILSqy5LJvnhvaBw2kvkpABO6WuydmmCG0PiK305 iGmQXjRNJm9TvVD/ufdRS7HZF3tS/ryZBthFwGjz23v1U5NmqpOvJGKuOGOoUrn5QZrb bCO9Wp3hbRxXaHtVY+SrOMy3NReT7i6M7xucBho9AhwtkNVwExTm/Op03Joc22uu0FC2 lBTB8T+oYhsX/e+sDooRrUFkbS45vWXww86ShL0mNfe7h2O9CQ5BnRasP3f7+3dPT8jX LbiQ== 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=/wKI25vvUuKYYWTXwzelAukPZNpH13b6IR9kHsKEMUI=; b=iT/L8TOCut3JB/cGhFMCIXunRJhOnxZQ94+/2QJ5J9l69Z3ZrsegQTQ9B79jx11FTV dPG5A/5a2RC2XWhpn8BqGJTugx8wxTuk1jVYm/Gv6K3np/8GjpX/LIxh9Hn/Ow5sd1Ij eHX51gkumHT13MUke32dKNojaH7XvPCTr1CteVPVee/AWDxPAsX3KkQwxlVfcUf158Oy lHM2Qg3YoClSM0j4Br5bzXmM3w01FS72bqUJDZ+KmwLWIbNx/ejMnVbHKoSmXCTRl9gH lzW4DiK5Ly+fL2ylNq6e0CYLy7yejOONfWdsC9hjTLoYT4D85BJsVsP+QYkzeBxI5sZP URjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M8KwvuPI; 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 d7si1175851edm.267.2021.08.10.10.48.44; Tue, 10 Aug 2021 10:49:08 -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=M8KwvuPI; 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 S233394AbhHJRpl (ORCPT + 99 others); Tue, 10 Aug 2021 13:45:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:41304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234947AbhHJRlp (ORCPT ); Tue, 10 Aug 2021 13:41:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1EC88610FF; Tue, 10 Aug 2021 17:38:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617110; bh=7lEfV6ZZF09w7WyNb63TX8EX8X7S/PNGnl8bPVwc9Zc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M8KwvuPIB13Jx3LQX0cpKqBdABEsZbIu5JBfDaCo938zWf7egN+dpuM3Npu8aLt9j nK34Xg+fcTTkiow1H61kRx0lsZ5vYoR8ZvIXgpdSUDYBnF8Ma2VG1Eve05JuERHOKk hx4FHWfHKt5afh/dBRvc9IIsCe/iNFoLCsbsLBj0= 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 5.10 050/135] blk-iolatency: error out if blk_get_queue() failed in iolatency_set_limit() Date: Tue, 10 Aug 2021 19:29:44 +0200 Message-Id: <20210810172957.395910818@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 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.30.2