From patchwork Tue Oct 3 14:04:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9982961 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 A2F1A6029B for ; Tue, 3 Oct 2017 14:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 96012283A5 for ; Tue, 3 Oct 2017 14:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89C1028883; Tue, 3 Oct 2017 14:06:15 +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 261B0283A5 for ; Tue, 3 Oct 2017 14:06:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752129AbdJCOFb (ORCPT ); Tue, 3 Oct 2017 10:05:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42466 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751156AbdJCOF3 (ORCPT ); Tue, 3 Oct 2017 10:05:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B4075780C4; Tue, 3 Oct 2017 14:05:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B4075780C4 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ming.lei@redhat.com Received: from localhost (ovpn-12-19.pek2.redhat.com [10.72.12.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 26BD361F50; Tue, 3 Oct 2017 14:05:19 +0000 (UTC) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org, Christoph Hellwig , linux-scsi@vger.kernel.org, "Martin K . Petersen" , "James E . J . Bottomley" Cc: Bart Van Assche , Oleksandr Natalenko , Johannes Thumshirn , Cathy Avery , Martin Steigerwald , linux-kernel@vger.kernel.org, Hannes Reinecke , Ming Lei , Bart Van Assche Subject: [PATCH V8 6/8] blk-mq: return if queue is frozen via current blk_freeze_queue_start Date: Tue, 3 Oct 2017 22:04:04 +0800 Message-Id: <20171003140406.26060-7-ming.lei@redhat.com> In-Reply-To: <20171003140406.26060-1-ming.lei@redhat.com> References: <20171003140406.26060-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 03 Oct 2017 14:05:28 +0000 (UTC) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need this return value in the following patch to decide if a explicit synchronize_rcu() is needed. Cc: Bart Van Assche Signed-off-by: Ming Lei --- block/blk-mq.c | 13 ++++++++----- block/blk-mq.h | 1 - block/blk.h | 2 +- include/linux/blk-mq.h | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index bf89549074bb..80d6dd99d7f1 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -118,7 +118,7 @@ void blk_mq_in_flight(struct request_queue *q, struct hd_struct *part, blk_mq_queue_tag_busy_iter(q, blk_mq_check_inflight, &mi); } -void blk_freeze_queue_start(struct request_queue *q) +bool blk_freeze_queue_start(struct request_queue *q) { int freeze_depth; @@ -127,7 +127,9 @@ void blk_freeze_queue_start(struct request_queue *q) percpu_ref_kill(&q->q_usage_counter); if (q->mq_ops) blk_mq_run_hw_queues(q, false); + return true; } + return false; } EXPORT_SYMBOL_GPL(blk_freeze_queue_start); @@ -150,7 +152,7 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue_wait_timeout); * Guarantee no request is in use, so we can change any data structure of * the queue afterward. */ -void blk_freeze_queue(struct request_queue *q) +bool blk_freeze_queue(struct request_queue *q) { /* * In the !blk_mq case we are only calling this to kill the @@ -159,17 +161,18 @@ void blk_freeze_queue(struct request_queue *q) * no blk_unfreeze_queue(), and blk_freeze_queue() is not * exported to drivers as the only user for unfreeze is blk_mq. */ - blk_freeze_queue_start(q); + bool ret = blk_freeze_queue_start(q); blk_mq_freeze_queue_wait(q); + return ret; } -void blk_mq_freeze_queue(struct request_queue *q) +bool blk_mq_freeze_queue(struct request_queue *q) { /* * ...just an alias to keep freeze and unfreeze actions balanced * in the blk_mq_* namespace */ - blk_freeze_queue(q); + return blk_freeze_queue(q); } EXPORT_SYMBOL_GPL(blk_mq_freeze_queue); diff --git a/block/blk-mq.h b/block/blk-mq.h index ef15b3414da5..41044a8662ca 100644 --- a/block/blk-mq.h +++ b/block/blk-mq.h @@ -26,7 +26,6 @@ struct blk_mq_ctx { } ____cacheline_aligned_in_smp; void blk_mq_run_hw_queue(struct blk_mq_hw_ctx *hctx, bool async); -void blk_mq_freeze_queue(struct request_queue *q); void blk_mq_free_queue(struct request_queue *q); int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr); void blk_mq_wake_waiters(struct request_queue *q); diff --git a/block/blk.h b/block/blk.h index fcb9775b997d..fa1b33d3fcbd 100644 --- a/block/blk.h +++ b/block/blk.h @@ -65,7 +65,7 @@ void blk_rq_bio_prep(struct request_queue *q, struct request *rq, void blk_queue_bypass_start(struct request_queue *q); void blk_queue_bypass_end(struct request_queue *q); void __blk_queue_free_tags(struct request_queue *q); -void blk_freeze_queue(struct request_queue *q); +bool blk_freeze_queue(struct request_queue *q); static inline void blk_queue_enter_live(struct request_queue *q) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 50c6485cb04f..d6195925e6c3 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -253,9 +253,9 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async); void blk_mq_delay_queue(struct blk_mq_hw_ctx *hctx, unsigned long msecs); void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset, busy_tag_iter_fn *fn, void *priv); -void blk_mq_freeze_queue(struct request_queue *q); +bool blk_mq_freeze_queue(struct request_queue *q); void blk_mq_unfreeze_queue(struct request_queue *q); -void blk_freeze_queue_start(struct request_queue *q); +bool blk_freeze_queue_start(struct request_queue *q); void blk_mq_freeze_queue_wait(struct request_queue *q); int blk_mq_freeze_queue_wait_timeout(struct request_queue *q, unsigned long timeout);