Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1967512ybh; Tue, 14 Jul 2020 11:54:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJxWAbciME0MNN5iHisI2eTe7PWHqIcPIzPGZxtkMopVftGF/OuAvdUY+7H2+yWqBWo7+1 X-Received: by 2002:a17:906:1e85:: with SMTP id e5mr5898197ejj.76.1594752884696; Tue, 14 Jul 2020 11:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594752884; cv=none; d=google.com; s=arc-20160816; b=gsWDAujbNRhpBTxGxykh+oRfZymwrw3w4gGzc+yFnDKwr/I+Ng5hbszLqDULsJZ5H7 6oXjaqpiPTaEMjbqonL/LaJBTOoxhFvJERAHDFf62u8HfDo41Yd71SeKFqNzTvz5Wbyh ty4SA6KemMDZV4mKgsm+u9DKYfOicE5l0Jq2c4xPIsgxULb3Y7VABUadijDWSj9Ljs2/ PpR5VWCVLhu2WlafQvioUN2JZOWc6N9YHVTCbuFf7SGZKLpnIyidnGnG2BhQ83VC9Vcd BsNCUo5HZUrZZAEUrNcF3c15cBpdKLq8FKVSQgu4rD6thR51SQ44pWPWcX+zZbJy9Cz4 /mFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ajoWZe2j53FfS74olC9BEbFdh6KPBFjymwJ4WYqRQhY=; b=daLqmk0d5FfOp642uiiXvVRSopXF3cFKyRFwVks0xPsJiK28exuDR8f/v68tjdVwr3 wsHKcTX3OsTbzCdejq7ruMBx9M2HLv5dBQbE5qN7ZtvARn0fV7zNwmcB9HjWhvb0ZD9w C3AEQ3RkZl6chdBojcdHcDyBvddYwp76b5Y/KHdJkKD+/7HyEYccAaSoe/AVsgYIMwc+ u1ykSk2KoZ/xgSHwKJhz1AxZXjD7e09+ksS5TR4su8uq9JI4EI59O0Ph99To8CtHvDOi xcPaofhx7hcRnVBy24vjtz0H9enTYE0EOvwTwVmTn4ECAntzFYKhBJLTrvNy9kUEScqS ldXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1u2l2dvO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h24si12391025ejk.168.2020.07.14.11.54.21; Tue, 14 Jul 2020 11:54:44 -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=@kernel.org header.s=default header.b=1u2l2dvO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730575AbgGNSw7 (ORCPT + 99 others); Tue, 14 Jul 2020 14:52:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730132AbgGNSwv (ORCPT ); Tue, 14 Jul 2020 14:52:51 -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 5388222B4D; Tue, 14 Jul 2020 18:52:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752770; bh=PeEl4ee3ukWwHBYOjv0FvZ8gt+uoagbNQbI0Jek4OAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1u2l2dvO0ted0rOPFS3REG0ED0Y6yzYYNHEMSj5Dp9vHExcq8aDSaMKx+1gK0XPjQ j0JXC27OnujLUTSiIEFoT0Y9zbSORQkUK5+ugKefmLXGZKanY4zFrPF5ydDPzqlBdl wboXOQde+iu6lk5FpKXH9V6+US92W1ApYRnMkYvU= 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.4 103/109] blk-mq: consider non-idle request as "inflight" in blk_mq_rq_inflight() Date: Tue, 14 Jul 2020 20:44:46 +0200 Message-Id: <20200714184110.498166191@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184105.507384017@linuxfoundation.org> References: <20200714184105.507384017@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 @@ -829,10 +829,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;