From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751382AbdLITZm (ORCPT ); Sat, 9 Dec 2017 14:25:42 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:40082 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbdLITZh (ORCPT ); Sat, 9 Dec 2017 14:25:37 -0500 X-Google-Smtp-Source: AGs4zMZLC0SLl/KYNMe+u9yR+/475Uiit9gY87UbYhCoopf+Ucj9RxDxUN2yCrjtz0IWQSbDIgOLUg== From: Tejun Heo To: axboe@kernel.dk Cc: linux-kernel@vger.kernel.org, oleg@redhat.com, peterz@infradead.org, kernel-team@fb.com, osandov@fb.com, Tejun Heo Subject: [PATCH 1/6] blk-mq: protect completion path with RCU Date: Sat, 9 Dec 2017 11:25:20 -0800 Message-Id: <20171209192525.982030-2-tj@kernel.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171209192525.982030-1-tj@kernel.org> References: <20171209192525.982030-1-tj@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.9.5