From patchwork Wed Sep 4 08:42:41 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: 11129637 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 8FA0B16B1 for ; Wed, 4 Sep 2019 08:43:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F0972339D for ; Wed, 4 Sep 2019 08:43:01 +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="AizpY/OO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728196AbfIDInA (ORCPT ); Wed, 4 Sep 2019 04:43:00 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39226 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfIDInA (ORCPT ); Wed, 4 Sep 2019 04:43:00 -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=1567586580; x=1599122580; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=qtVWwALxJeFLEm5MyqWAjj8rH1FAELNGevTMV0H6ZXk=; b=AizpY/OOU8V8qroDZC9GAQzE+WZtQ2M+tXozw/tcoUCcjjEvM66kOJZ3 4/4fPKb490e3G6M3ExnuFRPnKmyyIoqNeeiImyY08xjU8NgcKCaHo+B/c 0CblYZX1MBLAR92aoZo5Lg6rgkSDUnCcEXS+U0ZsPTFi7vgH9WYSH3bCB cEpxloSKZEyzn07UKoNb01MdVdQ37+IMc/CecHNiuKPmXX705UaDavUPF fH1GGlqFf19H+d+JVkXyZyM/CLFIAGrlXbWe7PwNAKRJ271UQcVE14fv0 umTTwjTLg2ULVHXyrZZ5x512ajhKmmuILMCMNwJ10tjl+EhtaHFQRnmm1 w==; IronPort-SDR: uz3MnwZ/a4iJzBgHgEgg0QK6lb4s6zDdmv7N+of/QB7SNHeFxZMMTFU4wD4ULt8wRiPWUsLKby hCa+yI95Yl9laDnkP8jzGkcIx4yElxauCymtpGZA8IvwLUNUrLsMSpXtmYJaiETWfvGId9Ds4j K+EhiI26vR8e3vWJNj+rFLWnkmL+AXKGUhxvGTv4FirANlf07a4+uGh3OOx6n0Ar9Ro/a+PT8R rjtk9FRLnwn3PAzh/Pa5qix77eNSVuEBBW+QJs3AZS5MGWw7iUFBSMnrmTdF2WCe9EIpqCVwCA s/Q= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374677" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:49 +0800 IronPort-SDR: 0oSNPKM9hyUH+YHT3/k3dveijA7Vmp7C7+x6ZeBbBGq/iU5cwAoiFVohtHt8jinvcPIrF3hJKC kJIx3TiD6f6cccCsdlqAFRODLUSmO87g7BaZwPTJxTKRTDCC6BX9yi0GvVMg9N6DmyaXCp3e2G P8sV5cuudbCOYwaOoZF+EEoybCYwdGE/SOOQBfcRRwlUXTbIAfUIBTBl4W9XIPOXpEmuRkzJ1s gBxj91DlETJ+atVty7885UHeNqMiniMyefHwxEJsMJdPd3u/qDf4WsvLPgapLTHelC3CrFQWlc I+o7sOE3iWJmKycJ1tdssluE Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:48 -0700 IronPort-SDR: zyRqs9lkXoQT6UkPn9rQ6bjsnr3ldKkUQUxQyEkHJnbV/4PPb4wMp0RwKU/eJdxBuTxC87FXot PGkXHd4b7B1cu1tfk66bWDzDfhsJw7ur6ciapl1EejYilbkD0eOjF1MyvYnrop/TbKB57ncI92 la80YatRJJowklS9vv9jeE595tEZWkxSs6iNTZE/Sspvnx75YOfZ0f/9VSCjlGvIBJUW1JBCxb gHJkTQkDWlP7KoNrXso0C2MvEwjzLrjP8BQy4s9LLU8e1ls5bp4x8e+//5QGanid4RzA7twmpM wAM= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:48 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 1/7] block: Cleanup elevator_init_mq() use Date: Wed, 4 Sep 2019 17:42:41 +0900 Message-Id: <20190904084247.23338-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Reviewed-by: Ming Lei --- 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 Wed Sep 4 08:42:42 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: 11129641 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 4151B14F7 for ; Wed, 4 Sep 2019 08:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1ECE122DBF for ; Wed, 4 Sep 2019 08:43:02 +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="hb4hSmXJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39226 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727722AbfIDInA (ORCPT ); Wed, 4 Sep 2019 04:43:00 -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=1567586580; x=1599122580; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=4es099Tzn+1lybmV19FyhcM0o6YKAGlTweyIXLI8G2M=; b=hb4hSmXJAI9v2SzUejVrhUQjNeH/jUdAUo40zmTe614Ubg6sH0AH0WNO FcHhpgKMKgQgpqIZjQufFO4IBCfNpVntvVPCY0hllEFZ0BJuLF7z1l1eb N6K6kEWaHKjzzt9oy+RillbY3j03dMN4BfDjAZdnZabkIpuxI/zUmOEcI bIluRo7ZrI2DX/Js0oJuPwBr2IMUxnXIpR4OQ5gXeGhmrHGP5EH5leAek v+fKte/AirgrEWqMdyv53Ixo7ZDPGrMo7jg27OJWirLwelzrbGzY0wmSv SMUcsm+GfbakXD6NkM9UoXjkiAeFEYC7ECIcDSc5djozn1lhPtWugTJFG g==; IronPort-SDR: ujBneVbbV2b/88zzuzswt699GYI82j7GOb1XgHm5WFrBIZ57X+1ZX44fCsrhVrXNmWtbbHRoy4 9w9R/GUG3WVIzov93Iry4sR3gfAIGj24Kc9Id9dd0z0V59iQ4fA8UALA/uKkRJc1HGnTpClGcE iyyyVMUgGBAd3BOTNeT+NOsCYorVi6Qu414u4RuO5secEX5FBn0z/b0jksbnCqrKw1C67r9J/x 7HQWu+32xTvPRp5myO6wl2eBEVe7sswTLLjNAE87SQbSs2LxjtxSkSMY3WY5a6RzCzjnH+qBSx zas= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374678" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:50 +0800 IronPort-SDR: LjYDXfPL4bwqTodKbRL9BsVQg0G6x40IGBdzr13cgXI/zWsiQfsLC9YcQKltrwRw+AZrCCx/wb Ig6dG3Mbegh8VIHXPk3vFs1HCnJkzk/Vr5mf+gqm6/4o0IaM7hKVWsrDN1YdYEZl/qHAhTyx4l C+mJyrb6X3oUZ4UXffZ1hM7ghT+k72Q22MQBL7yqfRU94rgK/3x7uaUzOnUOESMDYwNlb2RTW6 1KhDuBl99OXZTtXtgnBGrhyC2Bh00NcrGOm6VVUbSA5Ml4+xkwANh82/RXl/TFhBRPSbhPe2RC dh3hdto/b6ffkZ8ihc6ADNVk Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:49 -0700 IronPort-SDR: AaNK2TxyhgB647U85QFUVTisRiGpWXWtLYtEPE5FZP9ppSsE23o0k7/HNBpaS2Sd7Elji6lraP MczZhOupjkvfMngI+hKkHloMNyhzwmMuX20OHV1Z9nYYmXdEfBHSjCFKrWMlpTY8idn13ss0/4 pazxnawPEskWLr3xdZtdF4fBLodyf2nuPL6ZBqBjL8o5OTNLnxLqpIHclnPbZXmpLQLNqyQaQt ZoJAT8DcgF2nvt6YtBPyFWgvJS4aJc+6jAmwubYHbYp/ysCOsVCrXchfz5mspZYk7mxAQNdWEV V2g= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:49 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 2/7] block: Change elevator_init_mq() to always succeed Date: Wed, 4 Sep 2019 17:42:42 +0900 Message-Id: <20190904084247.23338-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Reviewed-by: Ming Lei --- 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 Wed Sep 4 08:42:43 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: 11129663 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 D163116B1 for ; Wed, 4 Sep 2019 08:43:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B1EE822DBF for ; Wed, 4 Sep 2019 08:43: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="oncLdinM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729209AbfIDInC (ORCPT ); Wed, 4 Sep 2019 04:43:02 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39226 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -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=1567586581; x=1599122581; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=lXmNGw+0DXKWd3/CW5QfLTARK01VfROVWdtvZQJsTFQ=; b=oncLdinMiHPlW1Of87pFyqeNb0X4vkG9lYlxcaIJU4J7lXUgkf1rWCpD mBMENxegp5ndWjzJGZbBk2zlUL4DOjbMq3nQy7jmCGPu1KPh8Zlx7QQUT J0zkVkjJM6ITMZYYidWzGVwUOZ3fmiy+wT+jxT0eBmPr+KaC515YKpH6C 885Pzh+CDsvRMrbzaUCrGLG2MESIHq7Yvr3u4PZxLtlxWUsRq43PfXgE5 aZzPljRmn4Ba3eDO3d0lzq8H5rLl2sCFWkzI1Ef+Kz4EG3GZqIoDHtYYn Kqny99PbgAF5IHOXWa8JN0VA8EwBPfm/yRjJgft6lVyVIWATD17oHtSkT w==; IronPort-SDR: eoRU6uHPcQ4FTEJmcoxNKUaJ0bm7UQfu3v39A9ORoXwGVG4zO6dC3By/PeBbUcNqPlxNZ/WtnN 746OYB3i8PAVkMvoRGapvRghl3Ge4WIOV3LjcJ9nlCh/ro9UZ0CnDASIpaJV6LkL5w37vEKK/Z 1UXR7BEjbwIZXQtdgSS9ymNBjyZHbm5WK1PyWH840sMYqPmSbsTaUC+E+70i4MOd0DPXmM71Ta fPgUk6SkWSE/3ypQH2zGX2s2dzeVH/x5AQ0NdKVb0Xznoq7tj+VqV/O29HWw0V3bBSE4SOM3p8 fS8= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374680" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:52 +0800 IronPort-SDR: KGWOoTYRrMxIRd2uj/AIGVXQAq4aW240H/Pg91VTTgvFgXBhK8uHuU/1QZkgk/TQo02WO2OXg8 34Y6AzMkXMRjLxV6GNYZsZ4M6AIwLN50dG9avEtBWrteT6KeeFSfMaUVqRZz3oT6wntE1BiVSj oDPL7Ku6IS4Ap2oG7XhbFDcBnOlxHEgEZWEYwRIcA/2onjT8ZYXPNnS5Xx8jEZXFbCJKIm9/sH vaZNaedeXVqcQIl8SAbmsgjEqJB2kQ9YjZ64Tm9pHJGcmJpFrPEH4Cy/d5ltpIyy3ZW/zlRY2D RxxqkNroYnfFo0oOR1LKMgaN Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:50 -0700 IronPort-SDR: Sjs1gmQf32XnslO1hjHgHtUIret/HA6AQ+8t+vqeyFWnsJIZGWnkPSUnTaiyQB3atY9r3dNVFw Bt1P2daWmctuAUjmHQ5Q+ZcMbVbNd4nioAQv6UonWJYgG6iGItPYFOhMqWwxq7wTPoW9zeHCw2 3wpeUUd0uXdJXU0ou2HUXMYNdEtvJUx1oVZNIRlUs7+WP/RcDr6RIphRKEa/GaDTMhcP+4upCC GaH6BXv314nxxKTiHhSa16fqpvShjY/CRRwwINYk65nMqJUTDVr9HLBP6TPDvj5+nbVDp92NhY aeg= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:50 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 3/7] block: Introduce elevator features Date: Wed, 4 Sep 2019 17:42:43 +0900 Message-Id: <20190904084247.23338-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Wed Sep 4 08:42:44 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: 11129645 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 D53E21805 for ; Wed, 4 Sep 2019 08:43:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B444F2339D for ; Wed, 4 Sep 2019 08:43:02 +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="oAVWZHp5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39238 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727929AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -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=1567586580; x=1599122580; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=fyqaXKmTgfoQv/FSTOhGEWhXUip2jSRO9hudTs5/bE4=; b=oAVWZHp5qb5u1wJ3lV35Szu5hbwW+mWy+/HEBRdfWReqyWb9p7PZxWZp u4mhPs9BsIG3uHsL/PLdoYfA6tLrlI236vLDFe3ct8y1DJKbm4mvffUMC /ep/5/3bNMWlR4oB3j4IGm3GvgHh8Vh7aYrxetVpGhl+N7V+NJPEFpodo +d/sAoLAwB/60VyXqsCB/vhsgb3csN03yIKnDT7DyCzAu0uxmdjnfEFWJ V+nzKT9HMlKkNywzReNR0CqKcNGHFq/5dDRtPHnh1GU3Y9TTH6TmmlNXx Hu4yVSNgp1lqZ/iPtHs8TmVY7b/8BR0HwAo7JtO51ECGiyicRb1O8yRx7 g==; IronPort-SDR: 20UvYgXyLGk1nK6pjQDWs5S3dlYpPHy4jYPdHVXpxOW8uk4aPVa+6Kf0AxHKBhgsin767UjVck iJ38LWj8wzlyJYwKPbmqvoC+mPG97L0wsmTsiEW95RaVlzbKmUtWTo26AKAk2S6x7prJmiPzwI 4MPuKU0GFidQzawynjIa2vrDnZBfafk7bkU5fZnxWOmqsUW0u2fzC7/ENoOwjoWEPn56h1RGLx Q25cegd/tVVAAOiMqPNKA2utm3+a/Q1U5xX3E5L/ItjcNvUURQwnePzZEr4EWF3GUW34c38pgz 4PY= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374683" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:53 +0800 IronPort-SDR: ioznrVdYbmeOyISeMzoZu5lfjgpRo+VjMd4yP7XxhmaMy/Xz4qBfVvZEHGIMedmv0M56UBIiNd 5CV3w6yRTJxkpucOIO5VNZeViOitslXpV4Oceorc98wnyiBs7lX/08fpmUj6TzZNCk3pKoXuQ4 4MlOvonWfwuCkulpJNBpgmON6gYv0rNUlyZzXbWFt4UBATvNWMyhSYvcECdyPrlvZxVG2kNyqC v1KdcGMujv4U+140x9Z6bvPGrSRcPwEJmGvetMwgO52HIKYOm5vjLAzTAqDUqdYu4hpwWu+IHV 12axxkdQEIsOsKnmVGEd6kYY Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:51 -0700 IronPort-SDR: gybW6RVAYE3RomyMxGkOijCkXQC/kkxJdeF3wj/6TVK8qy/zBKU5foJIOCjfyNbH9H7ojYLQY1 5w62kqAAtizTNOXtR1enHTbznoU5gUkjALcf1NUi5n77sZ4ZW6onpy6b9rA4NBEOn2rmxwM2/f G6jaMN1X9TYBDDSRNWvw0nRYn1xZ5jNhXXmwz2M/2S9OWhO6QY7EpLjrMXhDsc0TVaklSEWwRT Ebo1/GG6MrXvftN4pCM2/OfT2vd/e038pNQpF43EaGNoFsyvV56+zGuc6aX0zgWpXkWcud2upR zRI= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:51 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 4/7] block: Improve default elevator selection Date: Wed, 4 Sep 2019 17:42:44 +0900 Message-Id: <20190904084247.23338-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Reviewed-by: Johannes Thumshirn --- 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 Wed Sep 4 08:42:45 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: 11129647 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 4AE5016B1 for ; Wed, 4 Sep 2019 08:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2AAA222DBF for ; Wed, 4 Sep 2019 08:43:03 +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="l/Lo/jwO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbfIDInC (ORCPT ); Wed, 4 Sep 2019 04:43:02 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39238 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728448AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -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=1567586581; x=1599122581; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=fh2X6sgqVyA/YgEaWwJn5yd67V2WgvSpchuXNuvnbp4=; b=l/Lo/jwOWc/bmQprdXHUO4rYmeEhpaex930AZiykMZduq3oDKfJp5Soz nWOSh9Guq+UyP3rEVzwlSTUnTuGeEaA/OLGQcEjQ3jS3SQ3j2GA82KTER UICp0yX+X7+O71/r4EUnr662LsUu55FD+vvFjj4Yf8pBJgaCPvz4TO5Ch LMyr1OwrDZiORxAhhaYhkQ3Wrt8FFXZZ6Kuh+O5lS8fSqk7rY1V1t/kcg AU/P5baI/g6Eg/b0pVyVGRKopDdvGLARrRDWqk75MAa5XKcP4rJt+u68y ME8ksp5ZXpom5RNImIr/yzYUL4RlgykVoW3mPfoNkG6t6umaHmCBBhsHA A==; IronPort-SDR: q7rl7ihhzsAm9pnM3iKXUdaDMTieZvohZMRD6tKesqHxRPVkfDSAXy9+WNWyccp9MyaIOenGNK rTJ09TaGgxdOUUDFR5FXSyY8VqccVuWHduBCAY0HlInhAtASBtzd/1uKiYDUpsOhFGQBrgc5pd BNb0oXANl5IMaymaIreVWr5jwNgJY+6JlNmsv/ZFIt/eK7c/2pPqAZIKxyC7gkhHrn17zWntKz pOb39zCdNfc+HxJC8Bi/kc3AYkqLqTddSlDc0nHRZ1bcx2/JPeg7xahAs8bJiBpgto2rmQI4J1 rw4= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374685" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:54 +0800 IronPort-SDR: 3DAFxzdsO3kNmYow1Dxy+bCLVK4L2MQtafUsBJtYBes1ihiXrbIacFzGU6++cNC/IrsMBqAiHB R4MgJZzLbUAvd8D3+RTt/0gKvWmU/imIBgO1Qh+Ujb50O2iZe/DpFjkqTNeEKGEr1e+AU8QRcL diqUgimM4OIDeVuOffmqzRac4U3EhTtt9u1ctc1oI233NzW2Y5B6NL4kN4uzdFnoEC4vSJ69LB 7Grk2C9jFyhQryfxSK5l+gyZU/6WV2PCTXEuIVMlecxgWYu0TmSZCLPKNeBsnE+gIQcZ3XoQdp xpSPV4T7Yzsy/LSMfgCgQyFv Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:52 -0700 IronPort-SDR: blnx04rCNK6PSIJNFSPMdCGTO2BygABGR9ZMqg7LFcOSekPqR7JdvT0W0iNCbXOWoZ3hkO9pbw NJbKXx6AJ5OGRO8jAebtR4J3PMnvWU2yYd7WEI0XyG/ClP858COeqnuq3VKv0pdwztbYB5olg/ 2BBTt5KkEmSbeET/8a7/rdIAqm5Y1cxXOnC//FvHjLJf6mSE0+oNWNeFbJQ+KxG7+u0ulAUzkY pv9B13F62+U+YyiB+73K0fBZG84b3COPybZ+vpGn2CUAPm0nN7m0qbtuYnFBZUfAGGMmG08UZH m+c= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:53 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 5/7] block: Delay default elevator initialization Date: Wed, 4 Sep 2019 17:42:45 +0900 Message-Id: <20190904084247.23338-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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. Also 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 executing blk_mq_init_sched(). Signed-off-by: Damien Le Moal Reviewed-by: Johannes Thumshirn --- block/blk-mq.c | 2 -- block/elevator.c | 7 +++++++ block/genhd.c | 8 ++++++++ 3 files changed, 15 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..7380dd7b2257 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -695,6 +695,13 @@ 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. + */ + 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. @@ -734,6 +741,7 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk, exact_match, exact_lock, disk); } register_disk(parent, disk, groups); + if (register_queue) blk_register_queue(disk); From patchwork Wed Sep 4 08:42:46 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: 11129657 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 D7B0518A6 for ; Wed, 4 Sep 2019 08:43:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B567122DBF for ; Wed, 4 Sep 2019 08:43:04 +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="NMvcF6sO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726834AbfIDInC (ORCPT ); Wed, 4 Sep 2019 04:43:02 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39226 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728598AbfIDInB (ORCPT ); Wed, 4 Sep 2019 04:43:01 -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=1567586581; x=1599122581; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pKvixMi0uvmO9/2ZT4Cg0TZHXdkq6iCNQjN+mXlVvMo=; b=NMvcF6sOqTUwKr5KqcxangNyiVeMf2zusZRCu9b6OZuGayVfJMjAi+p8 iv6R/Yl38JUi2fzUWvoFpIWGwxg9gwP8K5arQfGEBqND+dwTVo62eIL96 BFhH0M1CfKt2gw7NURKgGU+sMYV18wEkvxMa0BSSD1DvTe55fvepTP6S4 OAPIGoXv6wXkGiMCKepXBkNjvR0F8PR8hugzKGs96XVXC/7JBi1W27NwK h4Z9e1H1qnGDevqp/pFXJC+1LF+5P3sH2K5gczaDtlmhA2ytYr8k8Ii0h 8FwcEn0FP/ogg74SAsLznqtkWnNmbA8XOQN6A/+Sfho53WfAk6PTMBNKV w==; IronPort-SDR: XyX3EL/jPe3evEHejNKr/e2V5FGjdw1sL/fiY1Bd18OoZV1z4U/klAukWaTndTa4SSJ1W2Rjis EdxrGeI4TUSujIkrouKPcYzDhr9k+yEk4BU5I8sch18CqI6Cs1vcwhfJQmFa5Fwoxp/zycGwRT HUEJK/bLV2uUn37kFnrYpKAE8wofYOIYbauDT7zIrJgNQmP6dq7knU9tLzker9Kvm3CKoqOtT3 ya5QJM2oW9c6621KbSbvWDlZI7nwYTs8cK2f8IS8VKC8oJvB134TDL/vy5hY4dIUOYZFIZjksP hAo= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374688" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:55 +0800 IronPort-SDR: H3PI/oYHlBAf4xDa66yKtVOhCpUTEMFoMIYey/uMAiSRO7L+CTp14cPmdkkHSB/F3GzeXjXmjm VNRO5Hj4FIzJGeoOhZ4yLGMeGCHEWU0KtRA5Iq/t4J+PnM6oJF9xOBmpN6OUjWCil9u43SIEam vSAM6pkQIDcYVWbtgN75SrdIzSI1HE4OUnh6UfrFGP3BEz9+ZKtkym3H8Gk1vk0xrD8Kma8iZr aLHsy9tK9lRmB3ye921wJer/B3eYaUmqxZq/mcR8HF3UAwGGMlRwlmgE6J6xNZWsfOpfWd+rba nY4bL5hb6W7e2wl3w/+m7Zn4 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:53 -0700 IronPort-SDR: BnRiekJ3Sz+YVudHETO9KdEIEhLczKv4/nQyCHt42YNogu9rDA3b6WfL7l8h+YDuzApENsZWG+ wpUA0d5Tkl5pxpRQU7GkUec+XytgSvM6iK9EFQs/YnLe/iqJ2OHthPJpWH3H3TqGshhAUaUzVV uzv/7iD+Ov10NH19HiVgWZIw0cEZgfSTwGKPssXp8UyB7IPjS2P3zs8mJw/VToEf7fcXvXhZmi pGNfqt/LsixkaM4JZ9TeTpbXfOrjTfX7a54iHDHggbYvyHSOBpkAJvc+SKbqmYI2e0cS9WkjDS eD0= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:54 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 6/7] block: Set ELEVATOR_F_ZBD_SEQ_WRITE for nullblk zoned disks Date: Wed, 4 Sep 2019 17:42:46 +0900 Message-Id: <20190904084247.23338-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Reviewed-by: Johannes Thumshirn --- 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 Wed Sep 4 08:42:47 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: 11129653 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 E1B8B1920 for ; Wed, 4 Sep 2019 08:43:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C1A0223400 for ; Wed, 4 Sep 2019 08:43:03 +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="YHJn0MQx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728448AbfIDInD (ORCPT ); Wed, 4 Sep 2019 04:43:03 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:39226 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727929AbfIDInC (ORCPT ); Wed, 4 Sep 2019 04:43:02 -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=1567586582; x=1599122582; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=65sWvjk5mPPhDUCeQo2jzp42YPYH5RvbY9fx3ldHQWY=; b=YHJn0MQxDs/v4stNLENfO0q5iEVwdgY3nFKdfjQ9jMEHyJOFKpvY2URh aFhOdGRy1ABIqLShfmJQp8J9WE3vOt/X2F5PaySC78FtwnpYV2t8+xFM5 uaaCp2pub06JGINrLuDEPsfBKH/n+qtBpeVDw/BCOBhBKn3ubR/l3KCqm XEq/fzf7NQBvYivBD9Cni7aD/kOFMlta+ZIWBf1UAUalVYMczNZR4Ma/R C9dcoIQOo8d2+UwKzzjggz016D1EXZvrkyqD9uYZrOmyn0TGVXs12u8iJ h2px0Tq1HrMv6er41BnXZTJQ4wMHe/pFMwXUfWFeWmxSdlbezsOSjpp81 g==; IronPort-SDR: fW2ClYUlOf5U/4T+uwYAGTZc17TbPMqvpvGs+9o5wUjAirlUSXXUodoxkOcIUd7PhNh3ZuAGOd JeJUABggq7XyNlFFNfcxA3HNlHdkBL6ICrmk0JSCkh3qm1zcC0ttodYPqrHOcaBJl14/7aIFEr 02chGCP26UP6P2KODNxz8y9FLvLxAvpFYtkiBMH4dqeerczoXR0pzd0o2CkDHdblZ7k1hd/EHD VMp+va54AJoOJxSu6p1URdJK9ae2VJehS1Wxb4KAnNo06sPmDdB2KJq7ceoMK90CdWrb5OsjhC 3xg= X-IronPort-AV: E=Sophos;i="5.64,465,1559491200"; d="scan'208";a="117374689" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 04 Sep 2019 16:42:56 +0800 IronPort-SDR: D76xAKBuOxsMiJKEnJs9r+66lSxkXGRLhPT7aQPS4T1p90cnnZAbVlhFPUzYL1n76DfjewX7Eh t+bheACs51qxVrjAcbFa/4AlbHTMc4Fq0Mht1y7au2xOTb+/0bk3UJTNJi1BfvotDOFZGq8M4B zLtKcpCtcgfCkyV7VWJn0htFMJt75prqPZSZESRkEByfJ3uVgK1w75VmcD3ueclxfBgHPpcot8 +PbyxZQxYSd3Z6/u56dIdTJ4Vkd4sbmTfNgnR8sV/ClPawuBqktpHgtBjTkFWr0sa6nrKtWxKU YRAOU786riM4FN5TkHSf2owj Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2019 01:39:54 -0700 IronPort-SDR: gF/tvgc9dPWmXlj5N6N9a7caqNGW332k+/U/Yrz/Nvuoe7JK35iVWpBqGdtdHtOAvSjhpTY6Jm XZ4GfaX0L8d0C0GQ5UQ0iO68x4OUq6RR63SXxFZAWzv2AH+5S39oaqcYmWREMdF5Gj0FJOPgUw FHrl+3VGKobfXZBMFyd1mY56Lejzmxr7TCyo7CgrhMG3a7AiDUsNvafA3+x8MHYb9AZHeI38wq h+OJ0r6Yh+Gjq/SOzzwe9iPbqkdILIskJUk5K4/q5WR8pUZ/TftNVZjI0PQuQxgSUkI1Y0V85N vDw= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip02.wdc.com with ESMTP; 04 Sep 2019 01:42:55 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v3 7/7] sd: Set ELEVATOR_F_ZBD_SEQ_WRITE for ZBC disks Date: Wed, 4 Sep 2019 17:42:47 +0900 Message-Id: <20190904084247.23338-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190904084247.23338-1-damien.lemoal@wdc.com> References: <20190904084247.23338-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 Reviewed-by: Johannes Thumshirn --- 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 */