From patchwork Thu Sep 13 12:15:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10599349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 164AF14F9 for ; Thu, 13 Sep 2018 12:16:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06EB62AABC for ; Thu, 13 Sep 2018 12:16:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EED032AAC0; Thu, 13 Sep 2018 12:16:02 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 824852AABD for ; Thu, 13 Sep 2018 12:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727365AbeIMRZN (ORCPT ); Thu, 13 Sep 2018 13:25:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37674 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727194AbeIMRZN (ORCPT ); Thu, 13 Sep 2018 13:25:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD4CB3005145; Thu, 13 Sep 2018 12:16:00 +0000 (UTC) Received: from localhost (ovpn-8-34.pek2.redhat.com [10.72.8.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1F9F104C529; Thu, 13 Sep 2018 12:15:56 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, Ming Lei , Alan Stern , Christoph Hellwig , Bart Van Assche , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Adrian Hunter , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH V3 01/17] blk-mq: allow to pass default queue flags for creating & initializing queue Date: Thu, 13 Sep 2018 20:15:30 +0800 Message-Id: <20180913121546.5710-2-ming.lei@redhat.com> In-Reply-To: <20180913121546.5710-1-ming.lei@redhat.com> References: <20180913121546.5710-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Thu, 13 Sep 2018 12:16:01 +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 Prepare for converting the flag of BLK_MQ_F_NO_SCHED into per-queue flag, since the following patches need this way for supporting per-host admin queue. Cc: Alan Stern Cc: Christoph Hellwig Cc: Bart Van Assche Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Adrian Hunter Cc: "James E.J. Bottomley" Cc: "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org Signed-off-by: Ming Lei --- block/blk-mq.c | 16 +++++++++------- include/linux/blk-mq.h | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 85a1c1a59c72..d524efc5d1bc 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2476,7 +2476,8 @@ void blk_mq_release(struct request_queue *q) free_percpu(q->queue_ctx); } -struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) +struct request_queue *__blk_mq_init_queue(struct blk_mq_tag_set *set, + unsigned long def_flags) { struct request_queue *uninit_q, *q; @@ -2484,13 +2485,13 @@ struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) if (!uninit_q) return ERR_PTR(-ENOMEM); - q = blk_mq_init_allocated_queue(set, uninit_q); + q = __blk_mq_init_allocated_queue(set, uninit_q, def_flags); if (IS_ERR(q)) blk_cleanup_queue(uninit_q); return q; } -EXPORT_SYMBOL(blk_mq_init_queue); +EXPORT_SYMBOL(__blk_mq_init_queue); static int blk_mq_hw_ctx_size(struct blk_mq_tag_set *tag_set) { @@ -2564,8 +2565,9 @@ static void blk_mq_realloc_hw_ctxs(struct blk_mq_tag_set *set, blk_mq_sysfs_register(q); } -struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, - struct request_queue *q) +struct request_queue *__blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, + struct request_queue *q, + unsigned long def_flags) { /* mark the queue as mq asap */ q->mq_ops = set->ops; @@ -2599,7 +2601,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->nr_queues = nr_cpu_ids; - q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT; + q->queue_flags |= def_flags; if (!(set->flags & BLK_MQ_F_SG_MERGE)) queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q); @@ -2649,7 +2651,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, q->mq_ops = NULL; return ERR_PTR(-ENOMEM); } -EXPORT_SYMBOL(blk_mq_init_allocated_queue); +EXPORT_SYMBOL(__blk_mq_init_allocated_queue); void blk_mq_free_queue(struct request_queue *q) { diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 1da59c16f637..7f6ecd7b35ce 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -200,9 +200,22 @@ enum { ((policy & ((1 << BLK_MQ_F_ALLOC_POLICY_BITS) - 1)) \ << BLK_MQ_F_ALLOC_POLICY_START_BIT) -struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *); -struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, - struct request_queue *q); +struct request_queue *__blk_mq_init_queue(struct blk_mq_tag_set *, unsigned long); +struct request_queue *__blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, + struct request_queue *q, + unsigned long def_flags); + +static inline struct request_queue *blk_mq_init_queue(struct blk_mq_tag_set *set) +{ + return __blk_mq_init_queue(set, QUEUE_FLAG_MQ_DEFAULT); +} + +static inline struct request_queue * +blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, struct request_queue *q) +{ + return __blk_mq_init_allocated_queue(set, q, QUEUE_FLAG_MQ_DEFAULT); +} + int blk_mq_register_dev(struct device *, struct request_queue *); void blk_mq_unregister_dev(struct device *, struct request_queue *);