From patchwork Fri Dec 1 00:08:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10085883 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 3EF6A605D2 for ; Fri, 1 Dec 2017 00:08:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30C632A43F for ; Fri, 1 Dec 2017 00:08:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EE042A447; Fri, 1 Dec 2017 00:08:54 +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 4A8002A448 for ; Fri, 1 Dec 2017 00:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751069AbdLAAIu (ORCPT ); Thu, 30 Nov 2017 19:08:50 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:23712 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbdLAAIt (ORCPT ); Thu, 30 Nov 2017 19:08:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1512086931; x=1543622931; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=N2awpX2KsnRlmSl6mhUKwrk90sXKsGJnM1cGQEuyTLs=; b=pWciLGStXcjSYP1gNu5qT3Tzn2FxhC1ofnPFOftLkAMvWCCGc/ebMeyt n8URmqaATcDmIg3cgmFMqG0uMrEvtzrHsCwGsseCFfhE0EYjk1uovSHkx 1t1xlTjqbwJiDyrDdD7Wx/Fk4I+YgSo7uu5SdoOYBOV+E5mtmiaOIAl+x 19YBT3prITv6gkBPJCr29QEj8EuaTXgoUCbZ4qAlMDyKZLikip10Ovyzj q1bNgQEGTkwjFJffjxqmBRCVyAJems7s+B7VcBzmO09UMYefUnssqIsMy u3t2dqLziyKP1TC+otv3fS5nBKlADXNWK/N1S+P5RIz9R+FBFI5F6K6jC Q==; X-IronPort-AV: E=Sophos;i="5.45,343,1508774400"; d="scan'208";a="63876002" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 01 Dec 2017 08:08:50 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 30 Nov 2017 16:06:06 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.166.51]) by uls-op-cesaip02.wdc.com with ESMTP; 30 Nov 2017 16:08:50 -0800 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Hannes Reinecke , Johannes Thumshirn Subject: [PATCH 2/7] block: Document more locking requirements Date: Thu, 30 Nov 2017 16:08:43 -0800 Message-Id: <20171201000848.2656-3-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171201000848.2656-1-bart.vanassche@wdc.com> References: <20171201000848.2656-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 This patch does not change any functionality. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Johannes Thumshirn --- block/blk-mq.c | 13 +++++++++++-- block/blk-timeout.c | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index e1ca7661daa5..7f290a91a612 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -74,6 +74,8 @@ static bool blk_mq_hctx_has_pending(struct blk_mq_hw_ctx *hctx) static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx) { + lockdep_assert_held(&ctx->lock); + if (!sbitmap_test_bit(&hctx->ctx_map, ctx->index_hw)) sbitmap_set_bit(&hctx->ctx_map, ctx->index_hw); } @@ -81,6 +83,8 @@ static void blk_mq_hctx_mark_pending(struct blk_mq_hw_ctx *hctx, static void blk_mq_hctx_clear_pending(struct blk_mq_hw_ctx *hctx, struct blk_mq_ctx *ctx) { + lockdep_assert_held(&ctx->lock); + sbitmap_clear_bit(&hctx->ctx_map, ctx->index_hw); } @@ -1003,9 +1007,14 @@ bool blk_mq_get_driver_tag(struct request *rq, struct blk_mq_hw_ctx **hctx, static int blk_mq_dispatch_wake(wait_queue_entry_t *wait, unsigned mode, int flags, void *key) { - struct blk_mq_hw_ctx *hctx; + struct blk_mq_hw_ctx *hctx = + container_of(wait, struct blk_mq_hw_ctx, dispatch_wait); + +#ifdef CONFIG_LOCKDEP + struct sbq_wait_state *ws = bt_wait_ptr(&hctx->tags->bitmap_tags, hctx); - hctx = container_of(wait, struct blk_mq_hw_ctx, dispatch_wait); + lockdep_assert_held(&ws->wait.lock); +#endif list_del_init(&wait->entry); blk_mq_run_hw_queue(hctx, true); diff --git a/block/blk-timeout.c b/block/blk-timeout.c index 764ecf9aeb30..77bf0c6e7c7e 100644 --- a/block/blk-timeout.c +++ b/block/blk-timeout.c @@ -77,6 +77,9 @@ ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr, */ void blk_delete_timer(struct request *req) { + lockdep_assert_held(req->q->queue_lock); + WARN_ON_ONCE(req->q->mq_ops); + list_del_init(&req->timeout_list); }