From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B66A9C433E7 for ; Tue, 14 Jul 2020 19:00:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AAA222B37 for ; Tue, 14 Jul 2020 19:00:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594753243; bh=kbSlFT4yADAzoHau1CbFspp9DIIsUrsPcu87ugGuJaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Lb646v1UEl6YHNQDCl6jRgg21F4fs2wdhaFIJ5Rig+4mld+tJrR/gCskCo6NLgOKP eu54y58h2oMz1t7lYfGLx8lARy+n38DfarH/+Ap51teh4MSB9hQvCDKFs/0LZvRNZD 1xuj9b8p17O/ztB7rC0KBZEWmUNXQtKKYEsnDank= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731379AbgGNTAl (ORCPT ); Tue, 14 Jul 2020 15:00:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:59462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731372AbgGNTA3 (ORCPT ); Tue, 14 Jul 2020 15:00:29 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D089122A99; Tue, 14 Jul 2020 19:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594753229; bh=kbSlFT4yADAzoHau1CbFspp9DIIsUrsPcu87ugGuJaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=szdsDkpJwvtxMpvruM90eeUpl2PtCfnI6516DOsYvL3co543rLMen4MeqVTY2UTg2 i+ia7B4emYUZH0JSa9bX2M0gfYhou2MQW/KhE61yJppnl95cM1ZTvM+MrBXfEwgmfN T1LSOLlz/zmbxiu+U4kzJnxXew6xUFRGXuiS3KH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Lei , Mike Snitzer , Jens Axboe Subject: [PATCH 5.7 160/166] blk-mq: consider non-idle request as "inflight" in blk_mq_rq_inflight() Date: Tue, 14 Jul 2020 20:45:25 +0200 Message-Id: <20200714184123.483980264@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184115.844176932@linuxfoundation.org> References: <20200714184115.844176932@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ming Lei commit 05a4fed69ff00a8bd83538684cb602a4636b07a7 upstream. dm-multipath is the only user of blk_mq_queue_inflight(). When dm-multipath calls blk_mq_queue_inflight() to check if it has outstanding IO it can get a false negative. The reason for this is blk_mq_rq_inflight() doesn't consider requests that are no longer MQ_RQ_IN_FLIGHT but that are now MQ_RQ_COMPLETE (->complete isn't called or finished yet) as "inflight". This causes request-based dm-multipath's dm_wait_for_completion() to return before all outstanding dm-multipath requests have actually completed. This breaks DM multipath's suspend functionality because blk-mq requests complete after DM's suspend has finished -- which shouldn't happen. Fix this by considering any request not in the MQ_RQ_IDLE state (so either MQ_RQ_COMPLETE or MQ_RQ_IN_FLIGHT) as "inflight" in blk_mq_rq_inflight(). Fixes: 3c94d83cb3526 ("blk-mq: change blk_mq_queue_busy() to blk_mq_queue_inflight()") Signed-off-by: Ming Lei Signed-off-by: Mike Snitzer Cc: stable@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- block/blk-mq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -803,10 +803,10 @@ static bool blk_mq_rq_inflight(struct bl void *priv, bool reserved) { /* - * If we find a request that is inflight and the queue matches, + * If we find a request that isn't idle and the queue matches, * we know the queue is busy. Return false to stop the iteration. */ - if (rq->state == MQ_RQ_IN_FLIGHT && rq->q == hctx->queue) { + if (blk_mq_request_started(rq) && rq->q == hctx->queue) { bool *busy = priv; *busy = true;