From patchwork Tue Jan 9 16:29:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10152853 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 BBA62602CA for ; Tue, 9 Jan 2018 16:31:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9BBF27DCD for ; Tue, 9 Jan 2018 16:31:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE70B28534; Tue, 9 Jan 2018 16:31:36 +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=unavailable 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 6971E27DCD for ; Tue, 9 Jan 2018 16:31:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759473AbeAIQbZ (ORCPT ); Tue, 9 Jan 2018 11:31:25 -0500 Received: from mail-qt0-f196.google.com ([209.85.216.196]:36219 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759539AbeAIQaS (ORCPT ); Tue, 9 Jan 2018 11:30:18 -0500 Received: by mail-qt0-f196.google.com with SMTP id a16so18486912qtj.3; Tue, 09 Jan 2018 08:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=SWXNhUXXDj2iX7DJios/TNKT91446w6cbRgK/hzC0sA=; b=iO2BNdaex1DANvsOq9k6EhfF+ESUyW9FuE96PKDY6+YvdALOWzSFVCPYcZjP5ej6Up GdUxsjXeafv29b9AAhd0UFmuSUwdeR1E9XcPhOWuLKI7ZhjwisZHEGcI8Oz72EHIy0FZ 3E9OnsWLMuD7SyGUZWeH+5CoqADPNPekR6sXtc+k/0q7TV+eVWvhIVqpkWahqYBHi3dT O3GXY5+K/6zzB6BqAZTDp7w1f1JdPuXGZBnytSb/QWml2Ctr1GR6+aGZegQn22kpezdM UApOj4hKBdIV83YYL3N14wE9UTsBfOyAvvg6LB/ndfCRqArykdzmjBaPSypW3rHJ2wN/ UFEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=SWXNhUXXDj2iX7DJios/TNKT91446w6cbRgK/hzC0sA=; b=HgZn7seDQ7s0mcwvwEvp4hJDTVX6hSgvUCcno9iV3qCPZK4MrtXsZyg+mPNaZ9EHb9 uVr3EmXEtZCkIMZjjeJvU3uaihDeGU5RTKbasUBGEZkJP3DfByLsCU2kypC0aP7cM4TB u3poob057r8sf5odUhUA9sKgjn8MlC05jdsXfgu34DkZ08mHiHBffPqAcNK/m+U4twrz uFnhLwC8qMQS+eW/BCFyhEU9m1Hz6SyxeAO7VLfLUKiUUVSueGQdh8BYLvgGFCiUdXO1 En1nSFI0a87wA5S6SVjtkwG5kTgIhCqhFTGw8b/GU46Magx4ecKDoBUBUAnFexa5YBQL 7PnA== X-Gm-Message-State: AKwxyte6weQEeMFMvJOiJQelZfz6+IEuoNLvr5BsSiE9gpjcjMcERHpr SJupS+sDc3TFvBQIayEjR1I= X-Google-Smtp-Source: ACJfBos7XDR+8aUALDEVlNnQ0dLv+sQsOSMfAqfN3ryKm/iwqcqa6bFODT7qLTyBLvoijmvDyZnksA== X-Received: by 10.200.41.131 with SMTP id 3mr21852773qts.247.1515515416750; Tue, 09 Jan 2018 08:30:16 -0800 (PST) Received: from localhost (dhcp-ec-8-6b-ed-7a-cf.cpe.echoes.net. [72.28.5.223]) by smtp.gmail.com with ESMTPSA id r2sm9544457qkb.54.2018.01.09.08.30.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 08:30:16 -0800 (PST) From: Tejun Heo To: jack@suse.cz, axboe@kernel.dk, clm@fb.com, jbacik@fb.com Cc: kernel-team@fb.com, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, peterz@infradead.org, jianchao.w.wang@oracle.com, Bart.VanAssche@wdc.com, linux-block@vger.kernel.org, Tejun Heo , Asai Thambi SP , Stefan Haberland , Jan Hoeppner Subject: [PATCH 5/8] blk-mq: make blk_abort_request() trigger timeout path Date: Tue, 9 Jan 2018 08:29:50 -0800 Message-Id: <20180109162953.1211451-6-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180109162953.1211451-1-tj@kernel.org> References: <20180109162953.1211451-1-tj@kernel.org> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With issue/complete and timeout paths now using the generation number and state based synchronization, blk_abort_request() is the only one which depends on REQ_ATOM_COMPLETE for arbitrating completion. There's no reason for blk_abort_request() to be a completely separate path. This patch makes blk_abort_request() piggyback on the timeout path instead of trying to terminate the request directly. This removes the last dependency on REQ_ATOM_COMPLETE in blk-mq. Note that this makes blk_abort_request() asynchronous - it initiates abortion but the actual termination will happen after a short while, even when the caller owns the request. AFAICS, SCSI and ATA should be fine with that and I think mtip32xx and dasd should be safe but not completely sure. It'd be great if people who know the drivers take a look. v2: - Add comment explaining the lack of synchronization around ->deadline update as requested by Bart. Signed-off-by: Tejun Heo Cc: Asai Thambi SP Cc: Stefan Haberland Cc: Jan Hoeppner Cc: Bart Van Assche --- block/blk-mq.c | 2 +- block/blk-mq.h | 2 -- block/blk-timeout.c | 13 +++++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 51e9704..b419746 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -820,7 +820,7 @@ struct blk_mq_timeout_data { unsigned int nr_expired; }; -void blk_mq_rq_timed_out(struct request *req, bool reserved) +static void blk_mq_rq_timed_out(struct request *req, bool reserved) { const struct blk_mq_ops *ops = req->q->mq_ops; enum blk_eh_timer_return ret = BLK_EH_RESET_TIMER; diff --git a/block/blk-mq.h b/block/blk-mq.h index cf01f6f..6b2d616 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -94,8 +94,6 @@ extern int blk_mq_sysfs_register(struct request_queue *q); extern void blk_mq_sysfs_unregister(struct request_queue *q); extern void blk_mq_hctx_kobj_init(struct blk_mq_hw_ctx *hctx); -extern void blk_mq_rq_timed_out(struct request *req, bool reserved); - void blk_mq_release(struct request_queue *q); /** diff --git a/block/blk-timeout.c b/block/blk-timeout.c index 6427be7..4f04cd1 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -156,12 +156,17 @@ void blk_timeout_work(struct work_struct *work) */ void blk_abort_request(struct request *req) { - if (blk_mark_rq_complete(req)) - return; - if (req->q->mq_ops) { - blk_mq_rq_timed_out(req, false); + /* + * All we need to ensure is that timeout scan takes place + * immediately and that scan sees the new timeout value. + * No need for fancy synchronizations. + */ + req->deadline = jiffies; + mod_timer(&req->q->timeout, 0); } else { + if (blk_mark_rq_complete(req)) + return; blk_delete_timer(req); blk_rq_timed_out(req); }