From patchwork Sat Dec 16 12:07:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 10116933 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 4D2B7603B5 for ; Sat, 16 Dec 2017 12:09:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F09F2950A for ; Sat, 16 Dec 2017 12:09:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33C5A29D31; Sat, 16 Dec 2017 12:09:18 +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 DA3A32950A for ; Sat, 16 Dec 2017 12:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756789AbdLPMHi (ORCPT ); Sat, 16 Dec 2017 07:07:38 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:43184 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756759AbdLPMHd (ORCPT ); Sat, 16 Dec 2017 07:07:33 -0500 Received: by mail-qt0-f195.google.com with SMTP id w10so15096948qtb.10; Sat, 16 Dec 2017 04:07:33 -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=mOCmIt3C98K7aA2L5EoC9lvpbNY++t7ehANdC7fz2+E=; b=osrGL8a4KYnQGWJNdXEU9+/73GdIfXOB/FGlNDIMUG/aX8jLZrBa3FR7fEu81AQ/Zz dnqAKcMQmAibwmz08HLqVKIAXWv5NyZWqFEQg8GE1mlno3bsJp07JKG1rl4zT1+NXwSQ J4fUhvQ67i/FqEire5ouA5YVwvt4/VNH9gyxLTBQwCsdhifnrJ/1hBTYDaTiEkae/8ts dO33wB3P0Dyt9ORy7xxhj0E66csiaWTTl4JJIlrCOjWQ4IQr1cab1+R6tRPsTRcloIrJ F5JBNkEBc/JDL0rOLE583fs64KJHWlgHu8wIjdhFm4o3S3qP3c28Z96T+5HcofMmL+ZA GSBA== 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=mOCmIt3C98K7aA2L5EoC9lvpbNY++t7ehANdC7fz2+E=; b=EWw9F8mY8EQir8sEzmv5upqbrY2G1IZtX45K7qMALVn9l4y+rXfhXXFh8YpXtGPDY7 oVVyw8PD1mCl0/NRuzfjPZUwWyoaLLOE17LiJNheE7zRhGuvOPcVT3EYiPX42qu0dX9q i9mBOR/EDudeCqFHT+EFPMfbGkfFOnih7gHL3m2KuBN72r2IUf8pYkAfCizDPhNZ7jvk GZMyUTbyruyZE+4vlKIFdp35iOFxoiBsXT27LVV69bNoJhsYlWNMZ7RDFwNdLiC+fmCW 2kj5xKjYJq8pvDUt6raTQVkvaby0sGbv5B+n33z+HZPk+Op/9ANyZ4Ws32cG3gkpC9Mh /NMA== X-Gm-Message-State: AKGB3mLrVLtqDFjoGX8ZWMYIvQb3hLPPviLj3wMEUGbzBNEcpVkUZg0q 6aAUFALWyJDA3dpbjy9Q0aI= X-Google-Smtp-Source: ACJfBouFp5u02Uf7BiZt5/+0To1L7f61J4xTi++9o0TURY2HUhlZrmbOI/ioJlxMtR5b/G02S2qJuA== X-Received: by 10.200.28.82 with SMTP id j18mr748317qtk.133.1513426053050; Sat, 16 Dec 2017 04:07:33 -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 j1sm5393861qkc.5.2017.12.16.04.07.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Dec 2017 04:07:32 -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, Tejun Heo Subject: [PATCH 1/7] blk-mq: protect completion path with RCU Date: Sat, 16 Dec 2017 04:07:20 -0800 Message-Id: <20171216120726.517153-2-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171216120726.517153-1-tj@kernel.org> References: <20171216120726.517153-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 Currently, blk-mq protects only the issue path with RCU. This patch puts the completion path under the same RCU protection. This will be used to synchronize issue/completion against timeout by later patches, which will also add the comments. Signed-off-by: Tejun Heo --- block/blk-mq.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1109747..acf4fbb 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -568,11 +568,23 @@ static void __blk_mq_complete_request(struct request *rq) void blk_mq_complete_request(struct request *rq) { struct request_queue *q = rq->q; + struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, rq->mq_ctx->cpu); + int srcu_idx; if (unlikely(blk_should_fake_timeout(q))) return; - if (!blk_mark_rq_complete(rq)) - __blk_mq_complete_request(rq); + + if (!(hctx->flags & BLK_MQ_F_BLOCKING)) { + rcu_read_lock(); + if (!blk_mark_rq_complete(rq)) + __blk_mq_complete_request(rq); + rcu_read_unlock(); + } else { + srcu_idx = srcu_read_lock(hctx->queue_rq_srcu); + if (!blk_mark_rq_complete(rq)) + __blk_mq_complete_request(rq); + srcu_read_unlock(hctx->queue_rq_srcu, srcu_idx); + } } EXPORT_SYMBOL(blk_mq_complete_request);