From patchwork Wed May 25 07:54:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9134941 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 93D426075C for ; Wed, 25 May 2016 07:55:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86B31282BE for ; Wed, 25 May 2016 07:55:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BC18282DD; Wed, 25 May 2016 07:55:32 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2C1EA282BE for ; Wed, 25 May 2016 07:55:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753227AbcEYHzK (ORCPT ); Wed, 25 May 2016 03:55:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47973 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753229AbcEYHzI (ORCPT ); Wed, 25 May 2016 03:55:08 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5B0F5C0740DA; Wed, 25 May 2016 07:55:07 +0000 (UTC) Received: from rh2.redhat.com (vpn-61-39.rdu2.redhat.com [10.10.61.39]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4P7t4FD009788; Wed, 25 May 2016 03:55:06 -0400 From: mchristi@redhat.com To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie Subject: [PATCH 1/5] blk mq: take ref to q when running it Date: Wed, 25 May 2016 02:54:59 -0500 Message-Id: <1464162903-14735-2-git-send-email-mchristi@redhat.com> In-Reply-To: <1464162903-14735-1-git-send-email-mchristi@redhat.com> References: <1464162903-14735-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 25 May 2016 07:55:07 +0000 (UTC) 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 From: Mike Christie If the __blk_mq_run_hw_queue is a result of a async run or retry then we do not have a reference to the queue. At this time, blk_cleanup_queue could begin tearing it down while the queue_rq function is being run. This patch just has us do a blk_queue_enter call. Signed-off-by: Mike Christie --- block/blk-mq.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 7df9c92..5958a02 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -738,8 +738,13 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) WARN_ON(!cpumask_test_cpu(raw_smp_processor_id(), hctx->cpumask)); - if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) + if (blk_queue_enter(q, false)) { + blk_mq_run_hw_queue(hctx, true); return; + } + + if (unlikely(test_bit(BLK_MQ_S_STOPPED, &hctx->state))) + goto exit_queue; hctx->run++; @@ -832,6 +837,9 @@ static void __blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx) **/ blk_mq_run_hw_queue(hctx, true); } + +exit_queue: + blk_queue_exit(q); } /*