From patchwork Fri Jul 27 16:20:41 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: 10547423 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 5E5D3A639 for ; Fri, 27 Jul 2018 16:20:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F4B82C182 for ; Fri, 27 Jul 2018 16:20:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DD4B2C196; Fri, 27 Jul 2018 16:20:46 +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 7B3612C1A3 for ; Fri, 27 Jul 2018 16:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730852AbeG0RnV (ORCPT ); Fri, 27 Jul 2018 13:43:21 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:25831 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730205AbeG0RnU (ORCPT ); Fri, 27 Jul 2018 13:43:20 -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=1532708445; x=1564244445; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=so2lHTrgKsqQdoGB70nxcnRg/12FGY4SdqecLSd6OxY=; b=r1iIVzzBHqwrhAKbp8jU//gdLcyguwrSDVJG3us6UGE2tMLg6ujNQ87f vLU4nmii7gug1U6cNm9y6vFjxS4/MWcDaYGa5K9PXXflHpKdi34SKmA2l VYD8KkWo+scsfiAeUfvFUXoF771mtNfdK10ti9UcrerV+VkBuZRKnLfjc vgFo4jUxu0hH7W+Ycgiymj3pcNm9qVSBxvSUxno/6h59Lsk0rTc0TCeiF OP7kDI268i/g9ts2GhLtmev253g6va9sR8x3+n236pqhmLgk5MMBKKjf2 9mYLP12wy7EBHaDzuoJ5/zi0nEkJmuYBCagJd1yReUjBpIzur433WliWG Q==; X-IronPort-AV: E=Sophos;i="5.51,410,1526313600"; d="scan'208";a="86000774" 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; 28 Jul 2018 00:20:44 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP; 27 Jul 2018 09:09:17 -0700 Received: from thinkpad-bart.sdcorp.global.sandisk.com ([10.111.67.248]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Jul 2018 09:20:43 -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 4/5] block: Simplify blk_add_timer() and blk_mq_add_timer() Date: Fri, 27 Jul 2018 09:20:41 -0700 Message-Id: <20180727162042.13425-5-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180727162042.13425-1-bart.vanassche@wdc.com> References: <20180727162042.13425-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 527670f2f985..02d7e3427369 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -219,34 +219,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); } /** @@ -259,32 +246,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); }