From patchwork Thu Aug 2 17:49:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10554013 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2239139A for ; Thu, 2 Aug 2018 17:50:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDB1B2C411 for ; Thu, 2 Aug 2018 17:50:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF40B2C414; Thu, 2 Aug 2018 17:50:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60AC22C411 for ; Thu, 2 Aug 2018 17:50:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387548AbeHBTmK (ORCPT ); Thu, 2 Aug 2018 15:42:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:42442 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387422AbeHBTmJ (ORCPT ); Thu, 2 Aug 2018 15:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B66B440241FD; Thu, 2 Aug 2018 17:49:59 +0000 (UTC) Received: from localhost (ovpn-12-120.pek2.redhat.com [10.72.12.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36C71215670D; Thu, 2 Aug 2018 17:49:50 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei , Josef Bacik , Christoph Hellwig , Guenter Roeck , Mark Brown , Matt Hart , Johannes Thumshirn , John Garry , Hannes Reinecke , "Martin K. Petersen" , James Bottomley , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 1/2] blk-mq: move blk_mq_request_started() into header file Date: Fri, 3 Aug 2018 01:49:36 +0800 Message-Id: <20180802174937.15444-2-ming.lei@redhat.com> In-Reply-To: <20180802174937.15444-1-ming.lei@redhat.com> References: <20180802174937.15444-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 02 Aug 2018 17:49:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Thu, 02 Aug 2018 17:49:59 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define it as static inline given it might be called in fast path. Suggested-by: James Bottomley Cc: Josef Bacik Cc: Christoph Hellwig Cc: Guenter Roeck Cc: Mark Brown Cc: Matt Hart Cc: Johannes Thumshirn Cc: John Garry Cc: Hannes Reinecke , Cc: "Martin K. Petersen" , Cc: James Bottomley Cc: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Ming Lei Reviewed-by: Bart Van Assche --- block/blk-mq.c | 6 ------ block/blk-mq.h | 9 --------- include/linux/blk-mq.h | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index c92ce06fd565..7afd1c925fa8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -619,12 +619,6 @@ void blk_mq_complete_request(struct request *rq) } EXPORT_SYMBOL(blk_mq_complete_request); -int blk_mq_request_started(struct request *rq) -{ - return blk_mq_rq_state(rq) != MQ_RQ_IDLE; -} -EXPORT_SYMBOL_GPL(blk_mq_request_started); - void blk_mq_start_request(struct request *rq) { struct request_queue *q = rq->q; diff --git a/block/blk-mq.h b/block/blk-mq.h index 9497b47e2526..18bc448b61a3 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -90,15 +90,6 @@ extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx); void blk_mq_release(struct request_queue *q); -/** - * blk_mq_rq_state() - read the current MQ_RQ_* state of a request - * @rq: target request. - */ -static inline enum mq_rq_state blk_mq_rq_state(struct request *rq) -{ - return READ_ONCE(rq->state); -} - static inline struct blk_mq_ctx *__blk_mq_get_ctx(struct request_queue *q, unsigned int cpu) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 1da59c16f637..cc0359b83fb8 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -250,7 +250,6 @@ static inline u16 blk_mq_unique_tag_to_tag(u32 unique_tag) } -int blk_mq_request_started(struct request *rq); void blk_mq_start_request(struct request *rq); void blk_mq_end_request(struct request *rq, blk_status_t error); void __blk_mq_end_request(struct request *rq, blk_status_t error); @@ -303,6 +302,20 @@ static inline bool blk_mq_mark_complete(struct request *rq) MQ_RQ_IN_FLIGHT; } +/** + * blk_mq_rq_state() - read the current MQ_RQ_* state of a request + * @rq: target request. + */ +static inline enum mq_rq_state blk_mq_rq_state(struct request *rq) +{ + return READ_ONCE(rq->state); +} + +static inline int blk_mq_request_started(struct request *rq) +{ + return blk_mq_rq_state(rq) != MQ_RQ_IDLE; +} + /* * Driver command data is immediately after the request. So subtract request * size to get back to the original request, add request size to get the PDU. From patchwork Thu Aug 2 17:49:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10554017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9ED0139A for ; Thu, 2 Aug 2018 17:50:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAD142C416 for ; Thu, 2 Aug 2018 17:50:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8DB02C449; Thu, 2 Aug 2018 17:50:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,URIBL_SBL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60C142C420 for ; Thu, 2 Aug 2018 17:50:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387651AbeHBTmZ (ORCPT ); Thu, 2 Aug 2018 15:42:25 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387422AbeHBTmZ (ORCPT ); Thu, 2 Aug 2018 15:42:25 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91313F2B29; Thu, 2 Aug 2018 17:50:14 +0000 (UTC) Received: from localhost (ovpn-12-120.pek2.redhat.com [10.72.12.120]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D7AE1C71F; Thu, 2 Aug 2018 17:50:01 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei , Josef Bacik , Christoph Hellwig , Guenter Roeck , Mark Brown , Matt Hart , Johannes Thumshirn , John Garry , Hannes Reinecke , "Martin K. Petersen" , James Bottomley , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 2/2] blk-mq: fix blk_mq_tagset_busy_iter Date: Fri, 3 Aug 2018 01:49:37 +0800 Message-Id: <20180802174937.15444-3-ming.lei@redhat.com> In-Reply-To: <20180802174937.15444-1-ming.lei@redhat.com> References: <20180802174937.15444-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 02 Aug 2018 17:50:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 02 Aug 2018 17:50:14 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit d250bf4e776ff09d5("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter") uses 'blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT' to replace 'blk_mq_request_started(req)', this way is wrong, and causes lots of test system hang during booting. Fix the issue by using blk_mq_request_started(req) inside bt_tags_iter(). Fixes: d250bf4e776ff09d5 ("blk-mq: only iterate over inflight requests in blk_mq_tagset_busy_iter") Cc: Josef Bacik Cc: Christoph Hellwig Cc: Guenter Roeck Cc: Mark Brown Cc: Matt Hart Cc: Johannes Thumshirn Cc: John Garry Cc: Hannes Reinecke , Cc: "Martin K. Petersen" , Cc: James Bottomley Cc: linux-scsi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reported-by: Mark Brown Reported-by: Guenter Roeck Signed-off-by: Ming Lei Tested-by: Guenter Roeck Reviewed-by: Bart Van Assche --- block/blk-mq-tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c index 09b2ee6694fb..3de0836163c2 100644 --- a/block/blk-mq-tag.c +++ b/block/blk-mq-tag.c @@ -271,7 +271,7 @@ static bool bt_tags_iter(struct sbitmap *bitmap, unsigned int bitnr, void *data) * test and set the bit before assining ->rqs[]. */ rq = tags->rqs[bitnr]; - if (rq && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) + if (rq && blk_mq_request_started(rq)) iter_data->fn(rq, iter_data->data, reserved); return true;