From patchwork Thu Sep 5 04:28:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132071 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F18C18A6 for ; Thu, 5 Sep 2019 04:29:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C74E208E4 for ; Thu, 5 Sep 2019 04:29:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="ZYF35tSy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729941AbfIEE3E (ORCPT ); Thu, 5 Sep 2019 00:29:04 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62199 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbfIEE3E (ORCPT ); Thu, 5 Sep 2019 00:29:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657743; x=1599193743; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qtVWwALxJeFLEm5MyqWAjj8rH1FAELNGevTMV0H6ZXk=; b=ZYF35tSyqR3gegwj/p9MfvUXIdUN2cFEl4e5Ave/KxfJinH0giZBjfaJ nTNZKn2+X5/HpdeMIbb3KGSwPcBkgS6jvScXVbCn3DhbeyLVC9Pr9vRqP +r91afhD8UcVMvbqm3bOqWZCpUrHtr8wfWdm6S6pgQA5V/cPPnyCI3QYd LAoer56jvTEU4+zJOez+SdAA8mc0au7D0tI3L3aaHBk+LlYT/7ZOrld6I 0xTG+YQLtNcVECK/wTdRKvH7eGG9y+aDhc5k8FNT8L8P8IpDpiG52wuY6 dTfzHACurKT1lQIF+Gi60olepYVRJgRLpY5qLJoMnyL61v28oEh2zk8v/ A==; IronPort-SDR: 09150fBcQvlfxkvSqFX3sn1FZgzQ/leVTjSXFieLou7P4nbQ+UyUmu17jk1GjbaLcJ6LbmtHlw UUVSIHXgZgfCWKRCBIAARdbyDwaPNJ/RRrg4d7qF0GGvcP5DwKCmXsUWH5BJmZNztHZiVkb3F1 eqJn4xZDNtiMYtoYimay5g7Yg2N1PhJiu8kCCZuhwt6RrjMYY6EfLAmIEHs/VilN8Eowv4Xwdx Cg7UEITzTGeTP7X7qDKGQYALl0TQ/RCpPJ1+Gz7WknDPlyuXyuL2Jf3alk4S7Mwmv6nSVL7s7m uYc= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233069" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:03 +0800 IronPort-SDR: f3W0iS3aGjsD1MzllTfijdIA04QC2dd1DU0quxT6y57RBQKCY+lwI4vq9IEvNLt+eC1za6Su2m USslcH2l4pJkl7i7R0swZy2mZLvaOHTGgOqde6kSGRsVHBocRNOwG9DawMCiwXd3u9qHkrrnN+ buGvyNIFiKofab6lAF7zmkpfovy/QXkaZPT1LOQjHrum7LAnn37bUSF6mNcGWoqrIbRuBpnC7j yksfx2QqjC2wB5g+ZHfExDOZjR8JwDcKIGaN6vLx6wE1XAXjvEnTRd/YrMh2G2IMZ0UT6bWT/I J44SeRRYC9eR+O+sQ6a7banb Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:00 -0700 IronPort-SDR: v4B8gCMzULr//ZLaNoU6WtXqF1j6Ep8cTKQbUMXFdawALoDILK0oa5WjDMcJ0KDuN5sLnF6aqV 47qJExAYV1U6EDdunktcB7yHfTULJQbkq8wtXoOrKzqPgHkwwkLmcTRaT0XcDerEE9HQRsFk7x uTSTBvgXBablfbsVyQjz/QGB3CvqzXZiiLSIHQHMSv4JUfIJlxNxMedKPkfz4R/OQid9pYVrvl oBh8zRmljOkTgkv714QLjKWK1fiJTzH6QgC34KzPh/VWitKSimdnldf8vLN3qB3NjOLZJTsvGU erU= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:03 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 1/7] block: Cleanup elevator_init_mq() use Date: Thu, 5 Sep 2019 13:28:55 +0900 Message-Id: <20190905042901.5830-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead of checking a queue tag_set BLK_MQ_F_NO_SCHED flag before calling elevator_init_mq() to make sure that the queue supports IO scheduling, use the elevator.c function elv_support_iosched() in elevator_init_mq(). This does not introduce any functional change but ensure that elevator_init_mq() does the right thing based on the queue settings. Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 8 +++----- block/elevator.c | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index b622029b19ea..13923630e00a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2904,11 +2904,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, blk_mq_add_queue_tag_set(set, q); blk_mq_map_swqueue(q); - if (!(set->flags & BLK_MQ_F_NO_SCHED)) { - ret = elevator_init_mq(q); - if (ret) - goto err_tag_set; - } + ret = elevator_init_mq(q); + if (ret) + goto err_tag_set; return q; diff --git a/block/elevator.c b/block/elevator.c index 86100de88883..4721834815bb 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -619,16 +619,26 @@ int elevator_switch_mq(struct request_queue *q, return ret; } +static inline bool elv_support_iosched(struct request_queue *q) +{ + if (q->tag_set && (q->tag_set->flags & BLK_MQ_F_NO_SCHED)) + return false; + return true; +} + /* - * For blk-mq devices, we default to using mq-deadline, if available, for single - * queue devices. If deadline isn't available OR we have multiple queues, - * default to "none". + * For blk-mq devices supporting IO scheduling, we default to using mq-deadline, + * if available, for single queue devices. If deadline isn't available OR we + * have multiple queues, default to "none". */ int elevator_init_mq(struct request_queue *q) { struct elevator_type *e; int err = 0; + if (!elv_support_iosched(q)) + return 0; + if (q->nr_hw_queues != 1) return 0; @@ -706,13 +716,6 @@ static int __elevator_change(struct request_queue *q, const char *name) return elevator_switch(q, e); } -static inline bool elv_support_iosched(struct request_queue *q) -{ - if (q->tag_set && (q->tag_set->flags & BLK_MQ_F_NO_SCHED)) - return false; - return true; -} - ssize_t elv_iosched_store(struct request_queue *q, const char *name, size_t count) { From patchwork Thu Sep 5 04:28:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132075 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D42FE14DE for ; Thu, 5 Sep 2019 04:29:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B73AC208E4 for ; Thu, 5 Sep 2019 04:29:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Q5tg4z5j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731143AbfIEE3I (ORCPT ); Thu, 5 Sep 2019 00:29:08 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62199 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbfIEE3F (ORCPT ); Thu, 5 Sep 2019 00:29:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657745; x=1599193745; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=4es099Tzn+1lybmV19FyhcM0o6YKAGlTweyIXLI8G2M=; b=Q5tg4z5jfpwQcwbO5s0Tpg7LsZ5Y0dQOW3yElhxBazGRNlSr3Onl7aeP OvLcMR4s9nlvoM+3SjLC/UBpN1kH7sMEZxUbL9GxG45o2pPTknAnslAJP 76EZ5ssKD7DYY7hiYdSTc12IPDNLgxTP5asoNbsH/94Ng8CX2/XnmamDB TaLrtcogkSnziqLwLyxZomnp4EaJHl5Gsl4TsB/E3CUqGiX9kh0Bf+Wmd PnXOccr60hVd0LmDnPRMKy4v9JFxNH7YWOL8CUKv6qTryYVOpAwtSp1le 6m8oLbt7I47WAsB7v0klwDhmkimj31WfZogg3rjzQE7hSnLD3YgsrNivd g==; IronPort-SDR: mDlEBW6ucd9Nvjb9I8HynlO4pizPfyaGNvTxTEWc1DRahFp5wcQD9JBsjQJMm7jvvupApnVkox BeFqXpSb50af0CbIhTdNBEO2PHpz9hJjQ72uHL+o7JDwiGy1et3yOSo/02aqHfjT/iMW7uC7aa NXbbDBR5gvzjrHFbI/vz7sRR91LxEHGS6KCWpeQig+/Qlfjt/W9c29QVhpZ4JbmINzocEohqAv QwqY1qG1Hyj4oMFdCP9h3FeEu4DzoC9kKL1r3x8++FOaa22bj90mxQ0ze3mNndAb5P4Hkx9i9M t/o= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233073" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:04 +0800 IronPort-SDR: gnDPaI8zDUxDx/4zFnOgRWWF/i+XWPB0YNn1UNQDJ20c5NFJaKtxe0mIwBbqULFpphT7RTPYO4 p/PscSviE5qmHNzJvxQPIXF1998ThCcad84HcoWz6+R8bomJ2exDTSSjiaV69a5zBQwRzItWJp wfwZA0MCYHUB5raj8enk3hC+NTv/rbtM63GtJDdfkWbG0QmA7j3IP/QeT9Ccd7rFicGRa/h114 VTXIV9Fzl5OUGj8su686kqT78eIEqMrhxEXFU5hkBuqYmJ6FSwtfmnHFLlQuBdTusMw3CS6GIh rLo19urMWC7gqollPT4ZtY+G Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:01 -0700 IronPort-SDR: swWbFTikVbWqQ4x8Nafg6Dfmxd/Jl7AFEMMKNSU6536CyJS2tqFks9byp/SS90QypqA3a80V48 0VGP1FaTGC1qZuD4MWfvgtMsnZtYh7+t2L5GmRSuB8DKffVtQcpvQpk6q++uk8fq1cWy4U+Uss DqeUiiJQODiWaKo8aFbnzAhDOL0pRSpJD2O3/CE5B60n/6OzpTmmbsujZ23rOz3Zo5rYjWBADg qxeIPt8HUL88A2R5NcDTUvlHBFZVWpmxg+YjWpTu93agR4/xR7XbBl+oaHVuZf/UNH4hj+wfvY J3c= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:04 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 2/7] block: Change elevator_init_mq() to always succeed Date: Thu, 5 Sep 2019 13:28:56 +0900 Message-Id: <20190905042901.5830-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org If the default elevator chosen is mq-deadline, elevator_init_mq() may return an error if mq-deadline initialization fails, leading to blk_mq_init_allocated_queue() returning an error, which in turn will cause the block device initialization to fail and the device not being exposed. Instead of taking such extreme measure, handle mq-deadline initialization failures in the same manner as when mq-deadline is not available (no module to load), that is, default to the "none" scheduler. With this change, elevator_init_mq() return type can be changed to void. Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 8 +------- block/blk.h | 2 +- block/elevator.c | 23 ++++++++++++----------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 13923630e00a..ee4caf0c0807 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2842,8 +2842,6 @@ static unsigned int nr_hw_queues(struct blk_mq_tag_set *set) struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, struct request_queue *q) { - int ret = -ENOMEM; - /* mark the queue as mq asap */ q->mq_ops = set->ops; @@ -2904,14 +2902,10 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, blk_mq_add_queue_tag_set(set, q); blk_mq_map_swqueue(q); - ret = elevator_init_mq(q); - if (ret) - goto err_tag_set; + elevator_init_mq(q); return q; -err_tag_set: - blk_mq_del_queue_tag_set(q); err_hctxs: kfree(q->queue_hw_ctx); q->nr_hw_queues = 0; diff --git a/block/blk.h b/block/blk.h index e4619fc5c99a..ed347f7a97b1 100644 --- a/block/blk.h +++ b/block/blk.h @@ -184,7 +184,7 @@ void blk_account_io_done(struct request *req, u64 now); void blk_insert_flush(struct request *rq); -int elevator_init_mq(struct request_queue *q); +void elevator_init_mq(struct request_queue *q); int elevator_switch_mq(struct request_queue *q, struct elevator_type *new_e); void __elevator_exit(struct request_queue *, struct elevator_queue *); diff --git a/block/elevator.c b/block/elevator.c index 4721834815bb..2944c129760c 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -628,34 +628,35 @@ static inline bool elv_support_iosched(struct request_queue *q) /* * For blk-mq devices supporting IO scheduling, we default to using mq-deadline, - * if available, for single queue devices. If deadline isn't available OR we - * have multiple queues, default to "none". + * if available, for single queue devices. If deadline isn't available OR + * deadline initialization fails OR we have multiple queues, default to "none". */ -int elevator_init_mq(struct request_queue *q) +void elevator_init_mq(struct request_queue *q) { struct elevator_type *e; - int err = 0; + int err; if (!elv_support_iosched(q)) - return 0; + return; if (q->nr_hw_queues != 1) - return 0; + return; WARN_ON_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags)); if (unlikely(q->elevator)) - goto out; + return; e = elevator_get(q, "mq-deadline", false); if (!e) - goto out; + return; err = blk_mq_init_sched(q, e); - if (err) + if (err) { + pr_warn("\"%s\" elevator initialization failed, " + "falling back to \"none\"\n", e->elevator_name); elevator_put(e); -out: - return err; + } } From patchwork Thu Sep 5 04:28:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132081 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5A1516B1 for ; Thu, 5 Sep 2019 04:29:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C67662168B for ; Thu, 5 Sep 2019 04:29:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="pYE+9zbT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731095AbfIEE3I (ORCPT ); Thu, 5 Sep 2019 00:29:08 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62203 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731138AbfIEE3G (ORCPT ); Thu, 5 Sep 2019 00:29:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657745; x=1599193745; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=lXmNGw+0DXKWd3/CW5QfLTARK01VfROVWdtvZQJsTFQ=; b=pYE+9zbTI+ED2HgGavQZhxT+Bi8xsX5A/LjZTJs8tJbYczIOV1Owxk1z fZMyk/GhJl9rZlXaxK7tR0TR2NFN8BG/xg7aBKiObUTaIXJwci4ivxHAE wHdTLnCXQDVMgMGRfPopo7zmYB71nGxSEHa8YJA76dMyDqDuFmif+XnEj n0z2KnYOLU7n5kxi7LWLdA3NOYUgWILCEg1WaB3kihvZt6RR7QNXzTAzf 4rS9uXxVduehvo5d95fYjbk2qaWCqpQUpdnqKOuEomXSwSQqTfeZ9g/nB F+zbeTGpPWQ76A2nD8xxAU0WMbL7yCDkZsY43df4+g+r5MlC2FTQtV9j3 w==; IronPort-SDR: v9or2LihdDVKwJsXjn4xD6xZt9UrrMGSNESO/bYV2QbE9kSwgQBqH9V/0B8OTQLXK8hVVuuQbz k72AwY1srmv4Q/rxycMv2uExdc6bc4ZykevQq8LA966D41hWhV+M4f81XjMXG7u2y3slxWk910 jeULqmbtNJ+jotO1B0BgI75q0BMGySPLo7HZ5xYMvbo2qed6lcCNh2JuA++WRtU1WOVMMNlHfg MNFHuATCvGshfgbZXzwKtPfSB6YfxEjgkyYDZzavJlo5xLwsKbYlPUjRpp3km6fPAM9S2E+aa+ 1p4= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233079" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:05 +0800 IronPort-SDR: JRrICBnRSE58f3j1dbLRbU/Tk2C0Jg3dnMZ7qY5zvnRW/XdE+HuLJP3KLEHkitg9w7toYZ8AGl OytuSFvv1QnhFM0XcuWxtTNpxOlC7J3Fg+u/YSYohtm1XY2fz95v8V/VMAhp7TNw+0U8o6+q/d GKpJEHIFM+VBCyu/SIx97KOxaZVTbF7z25sQH8f5sHMfj1/wJJtiPxDtAMokjs7z2wKzezP6B4 6ZmhPIQhBMOnnaM5EItTUP1cyVUmojFNgywYjKJMCgr0icw4vLe0O/NwtKxrazu9IPY1pW3IRb irWwPRS1tdUeGR96+O0s3lwp Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:02 -0700 IronPort-SDR: XyFJ5o2Lq4Q69aNNKAu7d2uhVR25ydekcrUGYi9Q/+uxsP5qoTLQ2lCLAcWfJn8aapeQ9RwLrX zwiUohAeIaK/Eu7tBeOpQPyd5CW6LEQeVcqbZFay+QeTjlO9+e6Y5m5EzYTBAbiyo+sdgkzS4g H9RnzrKqVlMDWnBlJ82AOrFw+KcJ0ZYtoR+ZbeQOt6WPO4YXonn75GpTvcRdk7go1FOYQGiABr /6b1Q/SeohWTzUfxqtbcEeCtRdgDY4lsKwzv8/A8N8x6ZmdzeIW6YQ7xxgxTqe3XGyPAecv8HJ Gf4= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:05 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 3/7] block: Introduce elevator features Date: Thu, 5 Sep 2019 13:28:57 +0900 Message-Id: <20190905042901.5830-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Introduce the definition of elevator features through the elevator_features flags in the elevator_type structure. Each flag can represent a feature supported by an elevator. The first feature defined by this patch is support for zoned block device sequential write constraint with the flag ELEVATOR_F_ZBD_SEQ_WRITE, which is implemented by the mq-deadline elevator using zone write locking. Other possible features are IO priorities, write hints, latency targets or single-LUN dual-actuator disks (for which the elevator could maintain one LBA ordered list per actuator). The required_elevator_features field is also added to the request_queue structure to allow a device driver to specify elevator feature flags that an elevator must support for the correct operation of the device (e.g. device drivers for zoned block devices can have the ELEVATOR_F_ZBD_SEQ_WRITE flag as a required feature). The helper function blk_queue_required_elevator_features() is defined for setting this new field. With these two new fields in place, the elevator functions elevator_match() and elevator_find() are modified to allow a user to set only an elevator with a set of features that satisfies the device required features. Elevators not matching the device requirements are not shown in the device sysfs queue/scheduler file to prevent their use. The "none" elevator can always be selected as before. Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Reviewed-by: Christoph Hellwig --- block/blk-settings.c | 16 +++++++++++++ block/elevator.c | 49 +++++++++++++++++++++++++++++++--------- block/mq-deadline.c | 1 + include/linux/blkdev.h | 4 ++++ include/linux/elevator.h | 8 +++++++ 5 files changed, 67 insertions(+), 11 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index a058997b9cce..6bd1e3b082d8 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -832,6 +832,22 @@ void blk_queue_write_cache(struct request_queue *q, bool wc, bool fua) } EXPORT_SYMBOL_GPL(blk_queue_write_cache); +/** + * blk_queue_required_elevator_features - Set a queue required elevator features + * @q: the request queue for the target device + * @features: Required elevator features OR'ed together + * + * Tell the block layer that for the device controlled through @q, only the + * only elevators that can be used are those that implement at least the set of + * features specified by @features. + */ +void blk_queue_required_elevator_features(struct request_queue *q, + unsigned int features) +{ + q->required_elevator_features = features; +} +EXPORT_SYMBOL_GPL(blk_queue_required_elevator_features); + static int __init blk_settings_init(void) { blk_max_low_pfn = max_low_pfn - 1; diff --git a/block/elevator.c b/block/elevator.c index 2944c129760c..ac7c8ad580ba 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -83,8 +83,26 @@ bool elv_bio_merge_ok(struct request *rq, struct bio *bio) } EXPORT_SYMBOL(elv_bio_merge_ok); -static bool elevator_match(const struct elevator_type *e, const char *name) +static inline bool elv_support_features(unsigned int elv_features, + unsigned int required_features) { + return (required_features & elv_features) == required_features; +} + +/** + * elevator_match - Test an elevator name and features + * @e: Scheduler to test + * @name: Elevator name to test + * @required_features: Features that the elevator must provide + * + * Return true is the elevator @e name matches @name and if @e provides all the + * the feratures spcified by @required_features. + */ +static bool elevator_match(const struct elevator_type *e, const char *name, + unsigned int required_features) +{ + if (!elv_support_features(e->elevator_features, required_features)) + return false; if (!strcmp(e->elevator_name, name)) return true; if (e->elevator_alias && !strcmp(e->elevator_alias, name)) @@ -93,15 +111,21 @@ static bool elevator_match(const struct elevator_type *e, const char *name) return false; } -/* - * Return scheduler with name 'name' +/** + * elevator_find - Find an elevator + * @name: Name of the elevator to find + * @required_features: Features that the elevator must provide + * + * Return the first registered scheduler with name @name and supporting the + * features @required_features and NULL otherwise. */ -static struct elevator_type *elevator_find(const char *name) +static struct elevator_type *elevator_find(const char *name, + unsigned int required_features) { struct elevator_type *e; list_for_each_entry(e, &elv_list, list) { - if (elevator_match(e, name)) + if (elevator_match(e, name, required_features)) return e; } @@ -120,12 +144,12 @@ static struct elevator_type *elevator_get(struct request_queue *q, spin_lock(&elv_list_lock); - e = elevator_find(name); + e = elevator_find(name, q->required_elevator_features); if (!e && try_loading) { spin_unlock(&elv_list_lock); request_module("%s-iosched", name); spin_lock(&elv_list_lock); - e = elevator_find(name); + e = elevator_find(name, q->required_elevator_features); } if (e && !try_module_get(e->elevator_owner)) @@ -525,7 +549,7 @@ int elv_register(struct elevator_type *e) /* register, don't allow duplicate names */ spin_lock(&elv_list_lock); - if (elevator_find(e->elevator_name)) { + if (elevator_find(e->elevator_name, 0)) { spin_unlock(&elv_list_lock); kmem_cache_destroy(e->icq_cache); return -EBUSY; @@ -709,7 +733,8 @@ static int __elevator_change(struct request_queue *q, const char *name) if (!e) return -EINVAL; - if (q->elevator && elevator_match(q->elevator->type, elevator_name)) { + if (q->elevator && + elevator_match(q->elevator->type, elevator_name, 0)) { elevator_put(e); return 0; } @@ -749,11 +774,13 @@ ssize_t elv_iosched_show(struct request_queue *q, char *name) spin_lock(&elv_list_lock); list_for_each_entry(__e, &elv_list, list) { - if (elv && elevator_match(elv, __e->elevator_name)) { + if (elv && elevator_match(elv, __e->elevator_name, 0)) { len += sprintf(name+len, "[%s] ", elv->elevator_name); continue; } - if (elv_support_iosched(q)) + if (elv_support_iosched(q) && + elevator_match(__e, __e->elevator_name, + q->required_elevator_features)) len += sprintf(name+len, "%s ", __e->elevator_name); } spin_unlock(&elv_list_lock); diff --git a/block/mq-deadline.c b/block/mq-deadline.c index 35e84bc0ec8c..b490f47fd553 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -794,6 +794,7 @@ static struct elevator_type mq_deadline = { .elevator_attrs = deadline_attrs, .elevator_name = "mq-deadline", .elevator_alias = "deadline", + .elevator_features = ELEVATOR_F_ZBD_SEQ_WRITE, .elevator_owner = THIS_MODULE, }; MODULE_ALIAS("mq-deadline-iosched"); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d0ad21e4771b..b196124e3240 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -496,6 +496,8 @@ struct request_queue { struct queue_limits limits; + unsigned int required_elevator_features; + #ifdef CONFIG_BLK_DEV_ZONED /* * Zoned block device information for request dispatch control. @@ -1097,6 +1099,8 @@ extern void blk_queue_dma_alignment(struct request_queue *, int); extern void blk_queue_update_dma_alignment(struct request_queue *, int); extern void blk_queue_rq_timeout(struct request_queue *, unsigned int); extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua); +extern void blk_queue_required_elevator_features(struct request_queue *q, + unsigned int features); /* * Number of physical segments as sent to the device. diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 1dd014c9c87b..901bda352dcb 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h @@ -76,6 +76,7 @@ struct elevator_type struct elv_fs_entry *elevator_attrs; const char *elevator_name; const char *elevator_alias; + const unsigned int elevator_features; struct module *elevator_owner; #ifdef CONFIG_BLK_DEBUG_FS const struct blk_mq_debugfs_attr *queue_debugfs_attrs; @@ -165,5 +166,12 @@ extern struct request *elv_rb_find(struct rb_root *, sector_t); #define rq_entry_fifo(ptr) list_entry((ptr), struct request, queuelist) #define rq_fifo_clear(rq) list_del_init(&(rq)->queuelist) +/* + * Elevator features. + */ + +/* Supports zoned block devices sequential write constraint */ +#define ELEVATOR_F_ZBD_SEQ_WRITE (1U << 0) + #endif /* CONFIG_BLOCK */ #endif From patchwork Thu Sep 5 04:28:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132083 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C68518A6 for ; Thu, 5 Sep 2019 04:29:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3E120208E4 for ; Thu, 5 Sep 2019 04:29:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Tzdm29At" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731151AbfIEE3I (ORCPT ); Thu, 5 Sep 2019 00:29:08 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62208 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731140AbfIEE3I (ORCPT ); Thu, 5 Sep 2019 00:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657747; x=1599193747; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=fyqaXKmTgfoQv/FSTOhGEWhXUip2jSRO9hudTs5/bE4=; b=Tzdm29AtlUJvmXnfoMbZFSWlEAdQQCGvuw1CJHLNLJW/5tvaPz+/Cn1W mMb/3Rativ9kLkbf351ySYOLZYD/2AR2wO0jc7WdTCxFMY1EATQrutTNX OTYXO5ygZATqoa8UlciwtGrPIv0cy/oapex0X44zVwJ37zFRqd4YYrAhu 9MtlQ8zRMlxYHbquqpoxhaenKv3NopSAcEpO8DWuueRhUCVWov/l/1r8y d9c7XBVqY3fnAIqF4vfQRfbPRANy633uGfpOqv2pafrtAJpNQQPuWYn0R O2BQ9TDbRGstXamDx99g+rilZ+WAqKByuMZK85w3X4t/6swYusAwEBQAY g==; IronPort-SDR: NcGkjKrdf3z4V9yChlstFH2KG1sr8HyXKRR3ki83fmkg/vAPK3JhURKg/OPV7wBhNZGEhwMomd T87+TwD2dZnEYQ002G455ImtBJ2goqfHW0cszA3kT2NiV08SzJyumtJwfq5/3mYQQ7yVuffc12 aWQr3MeFJ1gewSqkJWpVQvjUQnjW+c1Zz7mmuKuHo6GL6J4JE9Rsist+AcN28/y9nQd6Rerv4w 6xjRyHaq5ttMU390VsU75Z9Ve1OcphRm5YhQcvBqb1qxkws5X1t684vZ4IwRsFj+jVu8+fyJcc Q+s= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233081" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:06 +0800 IronPort-SDR: g7FpDfEWRDX/u3TEEiQ2nkEcfpWUisk3HkNT4cPi9vfk0JL0BYuVG4q7cLAiiyAE0B2kV/1nxB 7Vmj71WtgpQl9DvNLJmhkTlXc1LgyMoYZhijBUjrKPZEx2rKxRRmss2+UyIgoaJkNy4RMQ2XGh wNB5cyqOLCZRhxo1cw91pC82+IPlHaKxoYm23dNvzO1sLEDu5IRngbhi7G/pcvbt1jJLGTwdQM eKkjBhep0xUjztEKiDdwa2CrfzZLDqW9cd56RHEyd3XXZbAmcADxxB/Hen9pfV9Uf97p1/O4ib JqbOH1C6KWjNu1jqXLcRyPxA Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:03 -0700 IronPort-SDR: 0QxZhPPTCnKUaSwUbfDxnxhuVK5+LKhjklSYQ7k9SQ3lFHGK9sp19qFphWAPtOSvcsPQTf8Om+ LpIPM8742/yJWVHrXTaGSu8CIiYqC0Z5uWt8wE8o3Oro9WrwfjcGxen5QAb3NHwB0Gx/MH5AX7 +rzJ0JZWO1BXBcbG44DDT4E+29QCkcRcf2rwnyjQaTmQ8f53/rPk00vM4e2WM/rd6bAspkhmuc i+a6FOQNc2/jzt6oLmW0nyVLT/gs60tIVuIDmdtPSC09heYtUbLLsaGtI15FSi8T5CAp90Jg8Z EKc= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:06 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 4/7] block: Improve default elevator selection Date: Thu, 5 Sep 2019 13:28:58 +0900 Message-Id: <20190905042901.5830-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org For block devices that do not specify required features, preserve the current default elevator selection (mq-deadline for single queue devices, none for multi-queue devices). However, for devices specifying required features (e.g. zoned block devices ELEVATOR_F_ZBD_SEQ_WRITE feature), select the first available elevator providing the required features. In all cases, default to "none" if no elevator is available or if the initialization of the default elevator fails. Signed-off-by: Damien Le Moal --- block/elevator.c | 51 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index ac7c8ad580ba..520d6b224b74 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -651,9 +651,46 @@ static inline bool elv_support_iosched(struct request_queue *q) } /* - * For blk-mq devices supporting IO scheduling, we default to using mq-deadline, - * if available, for single queue devices. If deadline isn't available OR - * deadline initialization fails OR we have multiple queues, default to "none". + * For single queue devices, default to using mq-deadline. If we have multiple + * queues or mq-deadline is not available, default to "none". + */ +static struct elevator_type *elevator_get_default(struct request_queue *q) +{ + if (q->nr_hw_queues != 1) + return NULL; + + return elevator_get(q, "mq-deadline", false); +} + +/* + * Get the first elevator providing the features required by the request queue. + * Default to "none" if no matching elevator is found. + */ +static struct elevator_type *elevator_get_by_features(struct request_queue *q) +{ + struct elevator_type *e; + + spin_lock(&elv_list_lock); + + list_for_each_entry(e, &elv_list, list) { + if (elv_support_features(e->elevator_features, + q->required_elevator_features)) + break; + } + + if (e && !try_module_get(e->elevator_owner)) + e = NULL; + + spin_unlock(&elv_list_lock); + + return e; +} + +/* + * For a device queue that has no required features, use the default elevator + * settings. Otherwise, use the first elevator available matching the required + * features. If no suitable elevator is find or if the chosen elevator + * initialization fails, fall back to the "none" elevator (no elevator). */ void elevator_init_mq(struct request_queue *q) { @@ -663,15 +700,15 @@ void elevator_init_mq(struct request_queue *q) if (!elv_support_iosched(q)) return; - if (q->nr_hw_queues != 1) - return; - WARN_ON_ONCE(test_bit(QUEUE_FLAG_REGISTERED, &q->queue_flags)); if (unlikely(q->elevator)) return; - e = elevator_get(q, "mq-deadline", false); + if (!q->required_elevator_features) + e = elevator_get_default(q); + else + e = elevator_get_by_features(q); if (!e) return; From patchwork Thu Sep 5 04:28:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132093 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C534614DE for ; Thu, 5 Sep 2019 04:29:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A6B3E2080C for ; Thu, 5 Sep 2019 04:29:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="CyuS7hRY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731163AbfIEE3M (ORCPT ); Thu, 5 Sep 2019 00:29:12 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62199 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731142AbfIEE3I (ORCPT ); Thu, 5 Sep 2019 00:29:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657748; x=1599193748; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=m7BXKq5qJgd2utBtdvuTCMatxO46P3Fit6BBOXMySa0=; b=CyuS7hRYtfc8IQKJMFsA8vhxsZxwcut9NrrZMm5UlPeslxOpK+3Af8S7 QN5tvttcM+HGuJ7Yn9GD18weFnC7Wfi2V3lyHcy05dNILhWxFWLBhOW0z XtFsDQuiBq3gezccVNNoVl3g4NS8dG/v6U+UV67Yy3Spj0+8Dhcw9UlOu jWTSRjzv1jfb28X+0R+h4INDURjREWcAeGN2ViG5eH1E+50lVBvkK4ne6 ofomvGWxH0CKL+OJhxaByKRCoqtwRThKOAckdRIbIhEqPuZCOnRYbnMw8 4qe8w69d/XPIo8UIpS4Yi+a70XWCxGHDRL3l710+qnTWqsMQmJ72fkIE7 Q==; IronPort-SDR: MIV7beewDcJCycWTj2hpK6ZYq7JpV68NMfWCW4BGnJe54vuaKX8VJmAHi7I/ugkzfbDWTwa7tk RTlV3/7ybTcfMWfkZunnRRKFJLI3yfaUyaG7W2KVdm2Tj84wQjDecz6+Ckqcee1AmotGfAToB1 VEdRfnep/jSydSKy8onNRMaOwqaNWUAlxhHfwRkMx37chuLe/UOJFwY73JDNO6iUgLTu4AtYa4 S4kMXzU2qEV6MV+4rHf5lmFix/2VRdnSrAJwmHDbVm5k6v4UAgybJBoWejx1Hku8H/NrGebN91 KO4= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233084" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:07 +0800 IronPort-SDR: rYabwfTwrHH6BEp1xwq6rfxd5R5aTR4MkYzTxPFs+v36CZd3zm/TIkjQux7QI4lsXAYNAIGGQ4 YfaQQ0GU1td57OFcJE+vZ5yXkNKAHt74m2gM1iAvsyCbo88/KMUotTHInJR+c/aUQ8dOXj9+NN tX4aFZkfp8JkvB+Svsz1G2e/5SH/bmZmtWnXnFo4PJSJhhw4zUtuC4Ncvo5vU/4qMzaEqBzm59 brazt0GTc353K2/PL6fW1eCGXx/68SK+2mvAOcCWewdrQ0/J6zk/Kz5wlTJ/GbkikpgWSCLoXK 5eTz2FK8VdCvUe4vODS8QBil Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:04 -0700 IronPort-SDR: rY6+jREtwBTCpnoRJhzOZIGXMJrBOm5iSLoBh8AAluZScqasr4qZSfiW9k2QM4Az956jzXakfv fRBGZB1OUVPT4y1a6x710ouR3iwPJSEvwv7392yMVkshjSjAXHDcY2hdqy9cxUg02AL8lG6hp5 JQfT7qE6U0J50FY3vSOaUuRdayfB0F/W9H91sLjx8ZlTW9tKe1Yw4of2YKqf756+cOivfFTmwq wu/FtjrLzXJoVpGby5bmZrXaOmZE+KE1xDeXSbGv4s/zrVsPWuO7xgg+a6AFukGjRypWAUBawe IVc= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:07 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 5/7] block: Delay default elevator initialization Date: Thu, 5 Sep 2019 13:28:59 +0900 Message-Id: <20190905042901.5830-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org When elevator_init_mq() is called from blk_mq_init_allocated_queue(), the only information known about the device is the number of hardware queues as the block device scan by the device driver is not completed yet. The device type and the device required features are not set yet, preventing to correctly choose the default elevator most suitable for the device. This currently affects all multi-queue zoned block devices which default to the "none" elevator instead of the required "mq-deadline" elevator. These drives currently include host-managed SMR disks connected to a smartpqi HBA and null_blk block devices with zoned mode enabled. Upcoming NVMe Zoned Namespace devices will also be affected. Fix this by moving the execution of elevator_init_mq() from blk_mq_init_allocated_queue() into __device_add_disk() to allow for the device driver to probe the device characteristics and set attributes of the device request queue prior to the elevator initialization. This initialization is skipped for DM devices using device_add_disk_no_queue_reg() as this also skips the queue registration. Additionally, to make sure that the elevator initialization is never done while requests are in-flight (there should be none when the device driver calls device_add_disk()), freeze and quiesce the device request queue before calling blk_mq_init_sched() in elevator_init_mq(). Signed-off-by: Damien Le Moal --- block/blk-mq.c | 2 -- block/elevator.c | 7 +++++++ block/genhd.c | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index ee4caf0c0807..a37503984206 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2902,8 +2902,6 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, blk_mq_add_queue_tag_set(set, q); blk_mq_map_swqueue(q); - elevator_init_mq(q); - return q; err_hctxs: diff --git a/block/elevator.c b/block/elevator.c index 520d6b224b74..096a670d22d7 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -712,7 +712,14 @@ void elevator_init_mq(struct request_queue *q) if (!e) return; + blk_mq_freeze_queue(q); + blk_mq_quiesce_queue(q); + err = blk_mq_init_sched(q, e); + + blk_mq_unquiesce_queue(q); + blk_mq_unfreeze_queue(q); + if (err) { pr_warn("\"%s\" elevator initialization failed, " "falling back to \"none\"\n", e->elevator_name); diff --git a/block/genhd.c b/block/genhd.c index 54f1f0d381f4..26b31fcae217 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -695,6 +695,15 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk, dev_t devt; int retval; + /* + * The disk queue should now be all set with enough information about + * the device for the elevator code to pick an adequate default + * elevator if one is needed, that is, for devices requesting queue + * registration. + */ + if (register_queue) + elevator_init_mq(disk->queue); + /* minors == 0 indicates to use ext devt from part0 and should * be accompanied with EXT_DEVT flag. Make sure all * parameters make sense. From patchwork Thu Sep 5 04:29:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1E321813 for ; Thu, 5 Sep 2019 04:29:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C37AB2082E for ; Thu, 5 Sep 2019 04:29:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="oV/nwFGk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731155AbfIEE3K (ORCPT ); Thu, 5 Sep 2019 00:29:10 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62210 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731138AbfIEE3J (ORCPT ); Thu, 5 Sep 2019 00:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657748; x=1599193748; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pKvixMi0uvmO9/2ZT4Cg0TZHXdkq6iCNQjN+mXlVvMo=; b=oV/nwFGk+U7z1U/Oa4URmDAhZrCi10/vRXW0JYS+1ov+DM5fXbI10zuu 1AIndhXvy9HVh3X+9cgjUttj5T4KLrFyWG63a65oixsbhc3VuHOILNmPk XzzvUTksMXc4x6nEXyOAt5Xykb+g6bAoU3CIpv0qKt8Lac1x6tLVbjyKt 3FM/vQKiX4chd2DixuMo+S/8YZchhpZRhFok7zxQTwaBqxCBuEBw7qs2G 8+QxHgtnBzUt3Qx+/OCSoe6Eh5ZgJ7LIKFs6iPcgJejuNmaQ5s5Ajbn5D 4M/lm1BFfO58h0+zpgWgRgJC7OmaBA1qutoANvkW7FCJglmqQmtyX8qrN A==; IronPort-SDR: q3Fy13O6/y2ZU1Hr0CTNZeYtcmdUcfr3WmBVXZz6a9u01PDTjzPYh579ocRJOyxN+fD9JkEezE 5+MoOx1zUjMXpiJh3DiHHTopTqLLaDGe50OOqlE84U3MquoOrYUzUf0aoexzru9flnVvFeMk3T tO1P/R1N1OTynqO+fgkjd0KQTObKjfV+LWnsSeyJcl4ZlXapiiY8fjALvdi6I/8LI6ZZnZOYoH YH6SafiedTkpuOlK/bfHBmkmuo4Q3zGhGWqeVSqOOF9kPNi3ckD9grus69NVrn44mHJ1MQ6DYC WPs= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233090" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:08 +0800 IronPort-SDR: NtZF9dqfk+lWrQDAwOj1Q7s41q1CW9qtHWCCKnodqawwIGR9xy8wOCKf6nQp4Y0nMNecsNdqGv fK1sEWds2qWu2Qf4qMz+ed5H+IEvesDm2/UZO++V0nx/CdaQdXSYwAa56LDL/GqFe+oGr+Uu0l xudF9zy0t2vEbF8829GFfBVSt7X50M9l2k1p5hRrlt77esDq0YdF9tYX2XTCWCn+CXtip7ofB8 3Itk2kG0dCmt6gKVdAUCOWj6FheZtMhmBh0jJYtD1S85S92lvPYZoTfEyeRAxhFs6yfXIQsA2p ic6v3PLxk2O6EWWcAomA5nTX Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:05 -0700 IronPort-SDR: hHSSPlULnQRM72jOMAx08NVRxVkQyw7SBLaY6+nL4AxzF0Nsru5Q0b22n66AcgxgTnI2fp4W+e dJlsu03W280H8e0PzZKVxnznLb+QFLPCl60+3H98AEBWLTUoCDwyLwqLMy0iLlOXr/tl4Mlbam EHIutRYTlw6JONO6quWeduQ/9KPglQCwP+Xpp0Q8jxhkQakZqYrtvAIRhbvZQcxEQ2oetcVoAn cH96TwmWD6QvjE63AH2gpFXuPNlKuaW8ehfrZ+7CGbOzoml1HTb+LP2Hl5BgcmUnzm6uM4t/PU 7XM= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:08 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 6/7] block: Set ELEVATOR_F_ZBD_SEQ_WRITE for nullblk zoned disks Date: Thu, 5 Sep 2019 13:29:00 +0900 Message-Id: <20190905042901.5830-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Using the helper blk_queue_required_elevator_features(), set the elevator feature ELEVATOR_F_ZBD_SEQ_WRITE as required for the request queue of null_blk devices created with zoned mode enabled. This feature requirement can always be satisfied as the mq-deadline elevator is always selected for in-kernel compilation when CONFIG_BLK_DEV_ZONED (zoned block device support) is enabled. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig --- drivers/block/null_blk_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c index b26a178d064d..b29b273690b0 100644 --- a/drivers/block/null_blk_main.c +++ b/drivers/block/null_blk_main.c @@ -1695,6 +1695,8 @@ static int null_add_dev(struct nullb_device *dev) blk_queue_chunk_sectors(nullb->q, dev->zone_size_sects); nullb->q->limits.zoned = BLK_ZONED_HM; blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, nullb->q); + blk_queue_required_elevator_features(nullb->q, + ELEVATOR_F_ZBD_SEQ_WRITE); } nullb->q->queuedata = nullb; From patchwork Thu Sep 5 04:29:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 11132097 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7668418A6 for ; Thu, 5 Sep 2019 04:29:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56C1A208E4 for ; Thu, 5 Sep 2019 04:29:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="l8aH9mK5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731142AbfIEE3N (ORCPT ); Thu, 5 Sep 2019 00:29:13 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:62214 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731140AbfIEE3J (ORCPT ); Thu, 5 Sep 2019 00:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1567657749; x=1599193749; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=65sWvjk5mPPhDUCeQo2jzp42YPYH5RvbY9fx3ldHQWY=; b=l8aH9mK5aPNCiTRc72gFbv7NMotqYGVCseRQ9f+hMFZHay5ob5glBKkZ +cqD6Xvn6MvyNEIODjX0rfL8MQ6VxI19HwTA9wbSZZIAGZN0cQJhc/QAd 5TI7RJo7AcRNQOeNgTYEll+1KESovzWo91UDRhhc0tjvDsg4xOHWdNtxg z0xu1kNXfAvsidYuBDunTn9w8NQaoCOaJ4gOGOrgCKpx0lWhhQ51d0pUo h0c9ZGbPvoZA2yC5gFc8dX6p5LSIg9twr6YHxwCPzPU0sdOYBz6TWAn/y bczvU0rYXhyJ1ZMGqovw5Sr9Q2dRmJZMeCZf6rfS88cC9xKh+yAdURMWS g==; IronPort-SDR: /EKyNmmf4atwxwTTgUA3YmP0VVAtNmxF6nuKJtMqhf30VnhQvGovWG6UILUtOEbnSN3f8dj8Fj 3IH0KIIQ49QNAapT5NnrUdw00f6aU8RAznrWe2EtojRvaljPF2Nunh3mDfpRW/+Mu5O4syHrQv qtjGXjFjongqZzcE/VsIgC0u9Hzlnv0TFyRKnsEc9jgWqYWU06/Wux/rxcH+spxXoPcDs/EWhi x60Rd0GGQlpgvGtfkKmKjN+gIU0PZdTwI16oHahZQxseAiGXhZEt4KPNhPNV39RY1MHdFTQ8O8 roA= X-IronPort-AV: E=Sophos;i="5.64,469,1559491200"; d="scan'208";a="224233093" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 05 Sep 2019 12:29:09 +0800 IronPort-SDR: MPu1iP1wkf/yMTm7JAI4whcE7h7odByJAJMXQQOOcApZpzK4VukS2xdy0rEJQ8FXYUj0+BYYkk pw8Qk2OEx1uUggQdyZd3CPSTupEUpUAvfT116FeClXZIx2ACTSeMnVRiYmZqaybhcqHjRcy1c1 Dl4giJbNacnb95oNV6ovcHyELF4OzjLnf032EikhcuYyWslliWycBBW66652UgVaUQyE7C7psm FPFbg5L+iuNuJvweAjY6bkz+TQAVMctLx3a/76q7wZiZrDTnE025cx6G9zdS0+Bj+of67vsIVZ M6rlJc3gbKvtML6kVm3yuxsV Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 21:26:06 -0700 IronPort-SDR: 8jLHssMECvseYIfjnYTSMmWNsvyMmOBavRkz5cE4gaygANlGisDWyTDuWrqC/id8k+DIpYx1mi d+KzhDHmELmXjgGW4RRVV7OthK2AT+YAgx+h7N+z80kUnCRp+LzQj7Yn0VtKTteGK3Rz1nhzYu dfU0dPgDPiPooZ6diDBvo6NWOXfy+mn2ZmB0UvO3e3AVGnY8VMY5RLk3cY2Cw4DjeptQhZAU+o UDyCkZmcrkCySMrlThOMCugvk7B2AzKMO0ro73e3UidITI3vOSwXTomY1gvOsgq3WrY6TBx8u3 /TA= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 04 Sep 2019 21:29:09 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v4 7/7] sd: Set ELEVATOR_F_ZBD_SEQ_WRITE for ZBC disks Date: Thu, 5 Sep 2019 13:29:01 +0900 Message-Id: <20190905042901.5830-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190905042901.5830-1-damien.lemoal@wdc.com> References: <20190905042901.5830-1-damien.lemoal@wdc.com> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Using the helper blk_queue_required_elevator_features(), set the elevator feature ELEVATOR_F_ZBD_SEQ_WRITE as required for the request queue of SCSI ZBC disks. This feature requirement can always be satisfied as the mq-deadline elevator is always selected for in-kernel compilation when CONFIG_BLK_DEV_ZONED (zoned block device support) is enabled. Signed-off-by: Damien Le Moal Reviewed-by: Christoph Hellwig --- drivers/scsi/sd_zbc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 367614f0e34f..de4019dc0f0b 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -493,6 +493,8 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf) blk_queue_chunk_sectors(sdkp->disk->queue, logical_to_sectors(sdkp->device, zone_blocks)); blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, sdkp->disk->queue); + blk_queue_required_elevator_features(sdkp->disk->queue, + ELEVATOR_F_ZBD_SEQ_WRITE); nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks); /* READ16/WRITE16 is mandatory for ZBC disks */