From patchwork Mon Feb 12 17:02:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10213597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 187B960329 for ; Mon, 12 Feb 2018 17:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 094DD28CFA for ; Mon, 12 Feb 2018 17:02:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F205828D09; Mon, 12 Feb 2018 17:02:22 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 6C3B128CFA for ; Mon, 12 Feb 2018 17:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbeBLRCV (ORCPT ); Mon, 12 Feb 2018 12:02:21 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:16545 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751211AbeBLRCU (ORCPT ); Mon, 12 Feb 2018 12:02:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1518454942; x=1549990942; h=from:to:cc:subject:date:message-id; bh=ov3OBZLQXGf87GQahHxNDhQD067cQv3MXpJJGPvu2NE=; b=qNQ9pv7D+70/ycpzwnSDP2TLn4hjFjY1d5YNRqo5g5X9NkqyggkjdP2o 30pfFRShWS6WHuQ4BZF6okea01wpqsFKb7WVZc506wfMFqqhGVlO5gynk 60AgKfy7NwSxW95pOT55faOF/pykCljtYlXHeHF8auXlXIDt7xnUJRYxY 8iZU+gMdLfsXOjxFtsZiG5Kj/V7US8CRonreWNoFgP7/gxbCXrWALDy9O tz/0KJMThYyQkunIpb3egosK+jNxKO6demWa19/VY+ltLYUKbUGruiRzR yFdsFY2DFedMciVGbGh7k0jJawtA4Dxxd1CIOS39vbU1NJ5CEnrI4/pkH Q==; X-IronPort-AV: E=Sophos;i="5.46,503,1511798400"; d="scan'208";a="71067933" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 13 Feb 2018 01:02:02 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 12 Feb 2018 08:56:38 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip02.wdc.com with ESMTP; 12 Feb 2018 09:02:02 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Hannes Reinecke , Johannes Thumshirn , "Martin K . Petersen" Subject: [PATCH] blk-mq-debugfs: Also show requests that have not yet been started Date: Mon, 12 Feb 2018 09:02:00 -0800 Message-Id: <20180212170200.13131-1-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.16.1 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 When debugging e.g. the SCSI timeout handler it is important that requests that have not yet been started or that already have completed are also reported through debugfs. This patch depends on a patch that went upstream in kernel v4.15, namely commit 14e3062fb185 ("scsi: core: Fix a scsi_show_rq() NULL pointer dereference"). Signed-off-by: Bart Van Assche Cc: Ming Lei Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Martin K. Petersen --- block/blk-mq-debugfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index c62a3704515b..bcb64b2f8090 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -401,6 +401,12 @@ struct show_busy_params { }; /* + * Show "busy" requests - these are the requests owned by the block driver. + * The test list_empty(&rq->queuelist) is used to figure out whether or not + * a request is owned by the block driver. That test works because the block + * layer core uses list_del_init() consistently to remove a request from one + * of the request lists. + * * Note: the state of a request may change while this function is in progress, * e.g. due to a concurrent blk_mq_finish_request() call. */ @@ -409,7 +415,7 @@ static void hctx_show_busy_rq(struct request *rq, void *data, bool reserved) const struct show_busy_params *params = data; if (blk_mq_map_queue(rq->q, rq->mq_ctx->cpu) == params->hctx && - blk_mq_rq_state(rq) != MQ_RQ_IDLE) + list_empty(&rq->queuelist)) __blk_mq_debugfs_rq_show(params->m, list_entry_rq(&rq->queuelist)); }