From patchwork Fri Jul 27 22:56:19 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: 10547793 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 086081822 for ; Fri, 27 Jul 2018 22:56:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF6B32C69F for ; Fri, 27 Jul 2018 22:56:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E41B22C6B8; Fri, 27 Jul 2018 22:56:24 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 4C5C82C69F for ; Fri, 27 Jul 2018 22:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731568AbeG1AUZ (ORCPT ); Fri, 27 Jul 2018 20:20:25 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:46623 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388497AbeG1AUZ (ORCPT ); Fri, 27 Jul 2018 20:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1532732184; x=1564268184; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=+s2ISbEVtsuwcoL873Ev03bqXg0Jl8ncUpK3I3HYks8=; b=bVtFEVqagTj4gYEA6WFjCDfHhPra0IkpmSA1/UHb+XlrkRwwT0A5wews OPRtGWtsgEGj2IE8o+vBH8mF0s20qp9vTiTiwNMFXCyNUl9f9S5jkTwnk 8/Gs/Xj4yDMKZXFVxhscEJAb/ylkFpfp2lhl+zcXowG1aIPy4UwdPNGL3 ba2gAnKOC9A1yrYP7Rfo7Qgc8ppUSqq/bp4uiYpgsNgvGekaBQsSSwra/ xw/ZhYfJPlgy0+i1Nwc8RM4pCG6MLgoBKbjTYvx286SFG03apcqHae172 dDoVs3ZuOqnLsvcrKfJ722zZg6zJIpsWXHT2lY4vfEceAAtZNktoMzsN/ A==; X-IronPort-AV: E=Sophos;i="5.51,411,1526313600"; d="scan'208";a="85204236" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Jul 2018 06:56:22 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 27 Jul 2018 15:44:24 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Jul 2018 15:56:22 -0700 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Keith Busch , Jianchao Wang , Ming Lei Subject: [PATCH v2 4/5] block: Simplify blk_add_timer() and blk_mq_add_timer() Date: Fri, 27 Jul 2018 15:56:19 -0700 Message-Id: <20180727225620.17855-5-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180727225620.17855-1-bart.vanassche@wdc.com> References: <20180727225620.17855-1-bart.vanassche@wdc.com> 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 Use the fact that q->mq_ops == NULL for the legacy block layer and also that q->mq_ops != NULL for blk-mq to simplify blk_add_timer and blk_mq_add_timer(). This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Keith Busch Cc: Jianchao Wang Cc: Ming Lei --- block/blk-timeout.c | 54 +++++++++------------------------------------ 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/block/blk-timeout.c b/block/blk-timeout.c index ac0255a70401..8e6661031bc0 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -226,34 +226,21 @@ static void __blk_add_timer(struct request *req, unsigned long deadline) void blk_add_timer(struct request *req) { struct request_queue *q = req->q; + unsigned long deadline; - if (!q->mq_ops) - lockdep_assert_held(q->queue_lock); + lockdep_assert_held(q->queue_lock); - /* blk-mq has its own handler, so we don't need ->rq_timed_out_fn */ - if (!q->mq_ops && !q->rq_timed_out_fn) + if (!q->rq_timed_out_fn) return; - - BUG_ON(!list_empty(&req->timeout_list)); - - /* - * Some LLDs, like scsi, peek at the timeout to prevent a - * command from being retried forever. - */ if (!req->timeout) req->timeout = q->rq_timeout; req->rq_flags &= ~RQF_TIMED_OUT; - blk_rq_set_deadline(req, jiffies + req->timeout); + deadline = jiffies + req->timeout; + blk_rq_set_deadline(req, deadline); + list_add_tail(&req->timeout_list, &req->q->timeout_list); - /* - * Only the non-mq case needs to add the request to a protected list. - * For the mq case we simply scan the tag map. - */ - if (!q->mq_ops) - list_add_tail(&req->timeout_list, &req->q->timeout_list); - - __blk_add_timer(req, blk_rq_deadline(req)); + __blk_add_timer(req, deadline); } /** @@ -266,32 +253,13 @@ void blk_add_timer(struct request *req) void blk_mq_add_timer(struct request *req) { struct request_queue *q = req->q; + unsigned long deadline; - if (!q->mq_ops) - lockdep_assert_held(q->queue_lock); - - /* blk-mq has its own handler, so we don't need ->rq_timed_out_fn */ - if (!q->mq_ops && !q->rq_timed_out_fn) - return; - - BUG_ON(!list_empty(&req->timeout_list)); - - /* - * Some LLDs, like scsi, peek at the timeout to prevent a - * command from being retried forever. - */ if (!req->timeout) req->timeout = q->rq_timeout; req->rq_flags &= ~RQF_TIMED_OUT; - blk_rq_set_deadline(req, jiffies + req->timeout); - - /* - * Only the non-mq case needs to add the request to a protected list. - * For the mq case we simply scan the tag map. - */ - if (!q->mq_ops) - list_add_tail(&req->timeout_list, &req->q->timeout_list); - - __blk_add_timer(req, blk_rq_deadline(req)); + deadline = jiffies + req->timeout; + blk_rq_set_deadline(req, deadline); + __blk_add_timer(req, deadline); }