From patchwork Wed Aug 28 02:29: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: 11117705 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 B616213B1 for ; Wed, 28 Aug 2019 02:29:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 963252173E for ; Wed, 28 Aug 2019 02:29:51 +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="nA7KfzWE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726234AbfH1C3u (ORCPT ); Tue, 27 Aug 2019 22:29:50 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27195 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfH1C3u (ORCPT ); Tue, 27 Aug 2019 22:29:50 -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=1566959390; x=1598495390; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Jnx10mJxJJVLtKURaXUM0JtZUxRwO0n/yri+8mElRJo=; b=nA7KfzWE8YY8+MnO0CW/MTuHR7Wy4KjabOl4UKOBgYXMWsNHcv/pWO1W e5l4ON8MhzIFoknC2/5iVHsuWdAg3hII48iPG2QzEw9IqDwoNi+3di3D8 m4gVb8w4nlby84nD9XNiTMKABubVzytUe1vXKN1AROYyaw7bLW6MKdPO0 EdV+jdRbG3/3eSuv5YZGCRUW506/V1NbkaM+amMyYUKcmmv3HcVHpciMt AW2wBELsIB7qJl4RFfWspSDjiiZs5YywP+oKkKlURdtE0rDZgxIOYRdv+ rukylCDU7qixtdQCjrLtJ9xu20SSecRYmZf3f0x3im3t7azezkkxtbkta w==; IronPort-SDR: WROYpWo7uKVV/aAeKy1F8COZfYqL+2ufX4JPlBlGTqTG4ELcirxB1WT4L7syUCPd13iCxsXKP/ /RwBFRO8RZThFP6m/5A4ILyOm306/TkzYAL7u2oApsXKS70KRpO+AGvYJIhasaE5SuqW8kWde5 IvpCJumXnr5I8aeWzBsPvuwDgz8X/MpcLQXN8NfW/Vh8iELflAtQJx9UrvuNGkEaan6AqHhN6t 4HHEMYOHZUB0tsN9UaPB74wl0Og7nFMhEO6bLClQhIT3bltPmWdV8KIUM0xEnJ1IDxcNbFWDb2 qoI= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475480" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:49 +0800 IronPort-SDR: 3x3KY+foa19leborgWL98+XMABuHuYZpt2Q3zQVvlPqkw0RfdogqvCKrAAwXkCUfyTTbufglwn CNzVYy2WWp+8CDafb6DqpqYB24l3hYvAcPyp3QAz+IV+NrH1CqtSu4/sb7SXSPiSn3m2jj3E03 zBDkQCnxFVRhDBS/wzsmWzff4AudBThkR9jWSKgYCFDYYsAkngasm3YOurp087UASCmOfAx9mA b01auV1Je6LASJvHYiD70sCAyvHWgm7v32YxxnqLpCBk6w47C0TKAW44gWKvxIP+7PILvMz/qz AGhCigvwJ7JoRYlPikkCMbnB Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:00 -0700 IronPort-SDR: PUtsaQcfH4jRh+wiP72a432piAVR+WZPm/FSKMdYHNSlJf9WdxA8CqGw7M7rnqibsoHYGJ5SNr Xl2jd4h9cW2TcphycbLwt2Qn3SkIxYIoMhzZv5/Q77sUsg/xgHA+gIqhAb4PnOzT9oUFiGisTz rmRvQNhbaCFLyEAnybTXCW+nbiexUwYGKGIrOa+70iJGTLuzJRX8Qkng4xRvcKWcq7AYYQsQu5 Pxh7iSlXrn8QMs4s8ZxdQVtS0VqiT8Bd7wk9L/aKhtdUIvT3MPNYza73NThg5hUUriX+aNwl52 x8A= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:49 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 1/7] block: Cleanup elevator_init_mq() use Date: Wed, 28 Aug 2019 11:29:41 +0900 Message-Id: <20190828022947.23364-2-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 f6620a30752e..de3aeafe48eb 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2895,11 +2895,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 4781c4205a5d..ab4d50c0ed43 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -633,16 +633,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; @@ -720,13 +730,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 Aug 28 02:29: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: 11117709 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 56B5313B1 for ; Wed, 28 Aug 2019 02:29:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 376BF2189D for ; Wed, 28 Aug 2019 02:29:53 +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="PJ9M+Eei" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726254AbfH1C3w (ORCPT ); Tue, 27 Aug 2019 22:29:52 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27195 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbfH1C3w (ORCPT ); Tue, 27 Aug 2019 22:29:52 -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=1566959391; x=1598495391; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=zD6IYX5E4kT9Lcea1baEsf6zJZ2xUVtyiirh9rFfybM=; b=PJ9M+EeiMLnqJ9NiEb53rdztmwrqMRRmk9GH7qtzlMles8al6IVOoSxa 7St1g7xAzzgJDAP72wysymLy6IsjYTY1Y8pUXtOOWMbJxYMOcTtML+k0J 3altWXzzBYvq/xudL1EVvTTtONbsBOgVw3oE4AnOr87KPqdWS3awtcRXr VRjemKb/55Q5JbnIfnp04tpKTq+lU4SyJTZ/m6JDeYSgSm+HonVJoXNEq SlkpxAOkjcrcVT/mDH1hKcLT9Co8xEgZtmKjWzLwj+q32Lo0QzbTDxnCU W0kItkXe9U9VjpPGRkes+UHT3JbwLi5Kj9iX2KhHea/ABv80/pwVMyKWc g==; IronPort-SDR: sghL1eSXiCy93niXk9bpstWSUBaEIkXv4cgAns8MoxZFZkxaMgSZgB5T9AV9q6lYXYsiGNaSVM XYH1+WifJhoM5T/T9mKRPDqbQtyq/L5WPkFLv508FJoG7xZDRAh7G4B4t61RJO1xtoeLmYByMr +sw3A/v0Kjlu++wbz57vIzAeyb3/TQnkzadkXmgHKqdqoit4ZgyYc1onz7pfETUhWN1OIcLsrd DO2j1aUDtWSZj8QMJUdCzqwckmrfg+MNGaT3cMzrVXc3Bd6TVQ8eypmsjC94XbQqi7nQtrpEca Qrc= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475482" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:50 +0800 IronPort-SDR: s9qVa7hiucnjq6hfQ0K965jxFryaUHYbXPxIumbpwrFoDlkOit+pXOu8Uc3fs8WpentZSXbqb+ G9ImWq34ptXYD2jcxSM3tTJvkLpuWjsSJoRIFASs9BkLZswCRY17fFXKqo13GI1UJKOizgAb28 XRE42kR8ik24GwAYSeyOs4r9KNUKMKOGqIL0MqYF1Jdz1kSXfAAKTaQzWsiZp8XSDm0tp9IRTY vYrCLHAQCpw4vmZ9NCvZNF7BghM1O2YLw7K9USiqjUdoLfBT9MIqWWC98DiWfuB5GxToPnNjac PtKVfXBIxfmbufDs73ZllM5I Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:01 -0700 IronPort-SDR: MXJsheLImXE2Er/AEAjD0h0/GT3MygN1doH0yjuJPq3SUVMiA3K1p/DoyaXS2DIVAplvVUbGqH /2ttyqPWLRxnc19vYqAtE+nzwWakMRice8mCUyrDnVwivURnxuuxOkX4eMDsi37Y1yDbL9khVs mhVhRHB0xTX6uItHMCe3pT0zWcN/DGDpLD1XJ5IcHMVBeToV+0Fvjddy7Mx45cuT1HR4bTADom UfKEFaSzCDRywhw2o+7xcYWRCX13BjumXxyRCHqUbRcMgBpsOAgqe2/UOGfQLNECkHkW+w+kdf VA4= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:50 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 2/7] block: Change elevator_init_mq() to always succeed Date: Wed, 28 Aug 2019 11:29:42 +0900 Message-Id: <20190828022947.23364-3-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 de3aeafe48eb..0c9b1f403db8 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2833,8 +2833,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; @@ -2895,14 +2893,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 ab4d50c0ed43..06b70981a054 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -642,34 +642,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 Aug 28 02:29: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: 11117713 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 12A2A1800 for ; Wed, 28 Aug 2019 02:29:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEF762173E for ; Wed, 28 Aug 2019 02:29:53 +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="Rg0omMwj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726250AbfH1C3w (ORCPT ); Tue, 27 Aug 2019 22:29:52 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27202 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfH1C3w (ORCPT ); Tue, 27 Aug 2019 22:29:52 -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=1566959392; x=1598495392; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=3WM2tyF+XDMXOFfAQCnxEvBehFoLyiwE4GvEEGlDcA8=; b=Rg0omMwjh6AkjRQefTsVcy0zNHzENuOai4W98bP5xoRjJGdYAdP59Cc7 xncPYnvwmz3nAX/F8OjgPQFlBybk3yj48LCHFy0mL93sPymMsgSH+uMTC ojCemGfb+ZzDN0GV/LGxgSPLjtkFt4SA7WGybpVyrqrQ4qIkzCXydAILm gEade/ddvGuKCjLc5kFlFomIhBYSSGiwJObAV8xtWOg3qhZfJmwZphep0 tuiWpuoqrLATjxrrsNcfu948A5hPoacITNNrKEbGtHNmYaDp+gChmx5u/ IeoGjG7mh3nwzWiEQf4vDdqsp2aXWM6A2CjXuFzZO6WKhZvUNvvBZEUA0 w==; IronPort-SDR: KerU6NYMPYEgjWoWTYk5cWWPYb1W0/kc+AP23TC1vUCt511e7rR49zxzrKBOls57PiKO5cf2Se QBIcTwyGE70XZCoMb96f32XNFecxU+Y+MyanSo8R8z8skFkC4qa/sR6GQmP+c5C4UVmRfPARSa TZ1acqAV09M8J7NRLNN/T6OBzO6SizSoOVipFtSLfL6NZyXlKWW6ccdogQjVcEjvHIQdKP86VX LzOMZOKsLwCBXQoFdWGywtxP/YAXidySKjWtdaeKWKzCGBs4FdZy6foC9LfwGjalq67Epml4JU 2LU= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475485" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:51 +0800 IronPort-SDR: OaQaDXWSzeAeEVWfIfXX1T1dmTCOyhUk2Pog7YXCc81JvfRLrA6JHvIvYI49x0QkmjYQcnrFqk C+ZozkiPvN9QkoHcAa3Qm7N/wfms3CKv1743Jo35zyRFK8hk73kIWRIWfj03we/gGS5FcsxgJH CRp9p1Di2J5RbSU0FBKNWaBVCAxvtmf7MRN2rzu1wq07hxx6mlyhQNjg1DdydVRpPcHa08toRg DqprbhgKkvB4KJOh7pBznGp8NWx4ZiT9xB8DWXdDnxCYkUDnyv6koCDPjVNhO34WVX6lSIh7fP BVsvihTSmkZQ4hfICh/tbzeA Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:02 -0700 IronPort-SDR: OryDp8wu/zSQCHYugsEb37/KB/Zk+0TNHdMkyC+ZcM3FJ/g9+z7Of5jH5/VJMqmRc7Z+uxqoZO C65YhfbOX03jTgpYeD4YsgVX9kMzsQFk22djn3EkNhhTbfMCN2sRF7qkCXiQMZ7oNNqyMhT0et ag4uakrohbNr0yUT1Le0gxygVJsrgmUOSJFOVeGCs5jqmn9JOL+37CAfyiRzyzJ0TUJojhKQWM z6R+fRS4xf4BjXqybbMCQo2qR3SAHYMkQkoilCvqj7QAQRzcd6Du4k1pSZwiv/yh+Ftm1e6O5v yYg= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:51 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 3/7] block: Introduce elevator features Date: Wed, 28 Aug 2019 11:29:43 +0900 Message-Id: <20190828022947.23364-4-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 2c1831207a8f..ed76dd4cb5d0 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 06b70981a054..2235dfe6755b 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)) @@ -539,7 +563,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; @@ -723,7 +747,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; } @@ -763,11 +788,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 2a2a2e82832e..a17466f310f4 100644 --- a/block/mq-deadline.c +++ b/block/mq-deadline.c @@ -795,6 +795,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 1ac790178787..c0fea94acc76 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -492,6 +492,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. @@ -1086,6 +1088,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 Aug 28 02:29: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: 11117717 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 015AE13B1 for ; Wed, 28 Aug 2019 02:29:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D5C9A2173E for ; Wed, 28 Aug 2019 02:29:55 +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="rSTcij9Z" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbfH1C3z (ORCPT ); Tue, 27 Aug 2019 22:29:55 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27205 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfH1C3x (ORCPT ); Tue, 27 Aug 2019 22:29:53 -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=1566959393; x=1598495393; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=14KBgK6sEfrhkErHEFF5RolwRhVpkLH6Q2DFKYot8N0=; b=rSTcij9Z1nfpE7ETDQ75HYecjpjK0GV61IvBJMc8+5lDAuuWiixF0Xq+ DoxhZF+e6sTmDBa/osq6zpzWji5JwGVHCVBpdfu8b8WsvI6eL0O46FihM OrOzrsfcDWWY4ZZ/tjCBqsGO1crVHlOm9VPkfu991wHGXgiTH7ZEp8beG DZRVoDtNp34Tc07oszc8TufchACwpWZ6bHH20kNSiGn1LOoDBRlucvKj2 GcgOWrdIF+aRsc+i7BTsvMA5B9asM++/NAD5j7YvraQxPb3Y5KEpEKb3A 7Y0JN4OM/ZDrhQws8iTN2DNasFelMzpKQToSh0PBrO6UF8tM51XsPYMhC Q==; IronPort-SDR: kxtEMteMl4LwAyN7uUM1Dg28uA4185XMp33TIMfhsuMlo/CVcwvmK9Hwkq3AwWebO7mhq+h+dk AcHRL3xBbf329yawCrFJNamUErdfA3aT3s7/Sk+XdoyfsjCLJyDeidrj08XcL0e8NAsezyR4r/ CxjkcIW2vjssKgtUl4uE1CgM2RO0nssa521/bFGKArBgxVdJkZuKaK9y79V/EylBuxSjoV1FL0 jqO9tU+lCJ4Yt3IC4lXhMu8jyYWW12BN/F3nSM0CpAtJDpTuI0GaRT/H6ilo7le74IGHansKPX 0LM= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475486" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:52 +0800 IronPort-SDR: 9avGSX5f1w6hSuxnbMZ/Ycd3+xSGK+GBLDI4fp4kNvo3tU5FkLw65kKcri2R72KV+N4mnJSV+F 98Y0yKUuBvZb5NszrGWauwHuOZWYLYyjsLCeXnRnO0wnUePRQW0/HcM2oyFfHqZovfa3ZHE+Hf pJvmZ/AIld0syUr5mLP+APjChhbAjYqwQjgbDkmBd0UIKgswAhy4Z8MYyEi896ttjwD1FmnRM1 IooeY0cmTa4F+30afKcJMSIhYoKOfxKVyAVm6fHbFF2sj7QdbchhLQuTPbcG+SQq1P8DsTTZb1 gdv8rubn1udKQWAFCKf2XZOZ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:03 -0700 IronPort-SDR: eXtu997fIjzfm6NB84BvXLExuk9fZhrI5lvNPFFcnEQ4nHr+68uk4akqGYZB/fO3C23RXdNvm3 qQrrc5F4PTfwIA1BOyVF3cyNj1OLCCSM4ED4H4dz/w9iSwkKm8+8ovuj0acMvtlcJkER4RztXK S36flbc079puM0CCNR3QEFcfiDW98akbcTrvNkyvmU75aU7Z6hSUpk+CC75fp7+z2Q6XbfPcpG eI+jcgdOsgp/es8SM2d2CuIbGrCJbQavS3q7zKgH3mJza/p+PgqOInwR0x0jPHmX8Xnu6ifbNe pd4= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:52 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 4/7] block: Improve default elevator selection Date: Wed, 28 Aug 2019 11:29:44 +0900 Message-Id: <20190828022947.23364-5-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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: Christoph Hellwig --- block/elevator.c | 48 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/block/elevator.c b/block/elevator.c index 2235dfe6755b..81d0877dbc34 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -665,9 +665,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) { @@ -685,7 +722,10 @@ void elevator_init_mq(struct request_queue *q) 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 Aug 28 02:29: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: 11117725 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 A880613B1 for ; Wed, 28 Aug 2019 02:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 860C1214DA for ; Wed, 28 Aug 2019 02:29:57 +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="p1pZcsW0" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726331AbfH1C34 (ORCPT ); Tue, 27 Aug 2019 22:29:56 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27210 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726272AbfH1C3z (ORCPT ); Tue, 27 Aug 2019 22:29:55 -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=1566959395; x=1598495395; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=zuaGrHzLFfFwh6t8l98WhH8u3qcFJURYB3rVEoJTqok=; b=p1pZcsW0GGbtKf4vyHBoSGbHwLOUexXnY54pBqZaQndI2erz18BGQRyU BmWVFWDbfpu6EAcW5zAjW5t6u5JAviQ7KJOYPelsEQAtlEvNE1UkKwGhz bZ2xIPfYC6hh8fCQIEsCZ9FJvj67TzA8eLFYzuTMNWwg/n/4JcpiBbuor b4P5+utSkDjOrF1COa2OfCF8TEsBZI0I+iEABPijoWhgGRCrN9AgJx/Pk tT0jO7MdAQfZlSTN/fmr+LwPsUUPRkklgeG5Jq6zXFa67cFi6sCFGQQ0g A3ogbHti8zXDmIen/AoyFbHFYGS0ie3qI/z1QzMx+ixGWlA/EpsCK+X6i w==; IronPort-SDR: UL702fvGIcFMDinc0pXsQwirr3DbOu8D03yvVVGrN+DYxcsCvRODfDoAME0S3a26Z4KNkIDPfa HuRSh4bOph/Vi0miCPJwYb0SIUqQl1fNw0v/Az78sNFiETcz5OCnlC0fFMF3DrjOA53MF7M+wc gL/gnGB5OjTn0Uw6akvu7FNkBDe9ofsRUACiXmB/gKoUZmt0L+G0eCGujqJPYVjSofbL52BPEi 6b1UvSfC3Rto4VSRH2v59Pb/umZeHZ/uAEFYEoanDghLdNiBjh61ww5vo3j9dQJZuDYme8euAo B1k= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475488" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:53 +0800 IronPort-SDR: GyvU8HWSfoAPEZODSXxZ2fWRD8d5p7Qm4UAAO8YPvk7H6HZf/d6CBKKVyOWzhWPqFEGK0ZxRAc LXWL5eQmWALXxfFMQFAhrfR6aaEsLsnEAI8wL1ONfhJSXEafuaxn/qBRcYFN8IBkv6KPtwCfon FmzCSfomvLgSHTtUmhAjnnEkLxUUiqS3BAp/FTF98luf+77EFEOOhnKUHx3WB6vkrNDZAxQ+U0 zoDmNWcTXq6K2G40tujKoMbG526L8ziLBoA9jurJQ8y0zpbqbXUVFyTXL9910CB9sHzSANk+Tt sj/XtBqfzt58G7jy39SFV9xc Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:04 -0700 IronPort-SDR: HXII3iPkzyRKsxh7C2BU010VdYUSsC+2z3LjCXKCp7b8fHT/jKA/FU1y3KDUmm1yYGHOKlzNlX 6L2vlwEc8bG3P94I2f0yvRRXeGdDQdE9P4ZCKvaa86h2/r31TQsnfH0bgKXCEPPmIHUt0ojsca oOHkmJXao0m8LvizhFtgz66W94WvYNyE9v/dsLy6CTAa3L9Ff6Ca+7geSPCPi8A4/wMs3hEO0c xAUBEyblKTx/g3lsnhohIb16oYvgBkmEp0ngEdYSvK86564LceQgPnvPUgEtrqWzcjKcCKLQLO AT8= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:53 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 5/7] block: Delay default elevator initialization Date: Wed, 28 Aug 2019 11:29:45 +0900 Message-Id: <20190828022947.23364-6-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 --- block/blk-mq.c | 2 -- block/elevator.c | 7 +++++++ block/genhd.c | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 0c9b1f403db8..baf0c9cd8237 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2893,8 +2893,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 81d0877dbc34..433ce722cf0a 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -729,7 +729,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..d2114c25dccd 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -734,6 +734,9 @@ static void __device_add_disk(struct device *parent, struct gendisk *disk, exact_match, exact_lock, disk); } register_disk(parent, disk, groups); + + elevator_init_mq(disk->queue); + if (register_queue) blk_register_queue(disk); From patchwork Wed Aug 28 02:29: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: 11117723 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 79F101800 for ; Wed, 28 Aug 2019 02:29:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A2712173E for ; Wed, 28 Aug 2019 02:29:57 +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="S9iGmRKX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726357AbfH1C34 (ORCPT ); Tue, 27 Aug 2019 22:29:56 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27205 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726331AbfH1C3z (ORCPT ); Tue, 27 Aug 2019 22:29:55 -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=1566959395; x=1598495395; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Zf0MDQJRBxCXI8NccwOPMOrHOvfBpcXR5EU39nZ7Dyg=; b=S9iGmRKXxQY1JlBL+o+1S5io795eB4lcYw+JbpxNXDQSnxZvYLwyTLuh Z3xQBYSXNrYUbQAdlooCVq+qSFRSqZluHTuxjX3ZPzB7qFsz5ZauuNbuQ yObvuMPprKG1HnlU7FMyqKdcD3KU6in4Ead2RSoqC2uvvg8JjAb2Cs5EC l+keUIrzyYYjvtNFtVUNGyG4JdoALIUTx0n7mlCRhNY0izeownLy8UZGG o9aTeUoa/aGQpLYMLNVGNyN2AIoXpKwI20hJju5UehUl2lc8vxfyzSvi2 zVFrza0ixUi+p9CnswW1boWRxSURgCLCSpLzQkx+23BwrljHi/jphX0Io w==; IronPort-SDR: qVtdCY6WFUPRmbH45zPor39j+2gRxxD0aj/MEKxSvXOoX/Ip1b3y0sUo8cNNfkw8KGJWfE9Ogh 1Tvvyfys1RRkl++OVm7qZGligqknijP9+xB5id6jvhri2cxNc2A6ZEUIVUY3FYJcd7jBlkXWDP 2jD+M2C/E7NHPqsD0dNv81X4KdK4ztNmclND3fRFmUrhMJtn+eCv53BkZj23ZBkMY/weFWNMZR xtyS9yx3GY4gGv3Th9+UaKgnrzgxEHmgb8Z6Il+zukyhvULRRajIR0JzIdDooG77TmYkVXukeU aOs= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475489" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:54 +0800 IronPort-SDR: PivQC/MBfjxKhW3RnhHzhpsyNbB70PzT+w2SrfNcPsbkLi2vy5qR08pihBKMJWUOVmqu8NwbXX MswBSlH8j5D+mKUoQfOXTXwcSgR4OsTQ9O845BnoeqrXq58GjXahxfFKtP8rOVq8OpvOXnv70R qS491c/F72CxD3CXa+4dG5TfuW8q3xPadvMXa9GrN+fJm0LWYItz2eURSIw1oSNqa7F1STfMq3 JiFkh33oKwHDqiZHSNmYTcVwSdU3CPdRKYAhxprzdb3tKY0JxBQzlJB8XkfqQq9jIop6lM+pqy OYtiAqkzU0BWp75RSNKXUlMc Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:05 -0700 IronPort-SDR: kmSQCPvY9Yl0P/qLqPk/7Ph9bHEtL1zCCQibdcjMqEsQEPdKNFI36yY1BDK4OqFTfBSXa3f/Ib DXDfkhZgtbulqDbiuBT8r6Y/WOqxV40j8mr+DJTiXMlzniXlTnLfDN/rMdqDF4XY1q6ah+EcNa g+urg21gD9iHa4LNwY2EV1N68n/SRMWdoU4HH1+IWcA+uwe7YePUgjGM5XxUG71iydSHBgPcCy 0dQiZ0QLZPyY+786x8Di2QFzAcxB2lMfdqJglkRKJq7IixXRCh8qg1zKFOLXT7nDdSEl44rAM6 cu8= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:54 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 6/7] block: Set ELEVATOR_F_ZBD_SEQ_WRITE for nullblk zoned disks Date: Wed, 28 Aug 2019 11:29:46 +0900 Message-Id: <20190828022947.23364-7-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 Wed Aug 28 02:29: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: 11117729 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 6034713B1 for ; Wed, 28 Aug 2019 02:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 418D42189D for ; Wed, 28 Aug 2019 02:29:59 +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="mMvyqrC+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726391AbfH1C36 (ORCPT ); Tue, 27 Aug 2019 22:29:58 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:27210 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726178AbfH1C34 (ORCPT ); Tue, 27 Aug 2019 22:29:56 -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=1566959395; x=1598495395; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=OfotJnMRsLgxqnsb0ALm0ooV/tnerfPYqKG+KQ8XLzo=; b=mMvyqrC+CxaclqsBG0D/770ixwZwgDcB8Af5Y9vW8wN5/caZCH/NvgzJ 9gfYZbbvWaR9ATdYnYDb828IcRZW++1KXcLr9XC6XH4F72qQHJ4o6tmHO UMM++oW7XTF1jZgpcuV+61IAOw+lyii5HN0pFPJzHtaEemaVXkN+n68/+ 7C/2CtvyQKH821b49IK7L5fITNyHBG3EbSPhl/jW6XmJe2OerjcNX6ML0 slVUaE8YyNWWrXx0fzd6C9QQedSzRi7bF8297wZGsFJIm4/rSMq9wMToO y0IZp9RKMRXOrP3iZgNlw0/YMFrllfgHHKryTn7RLWo/rzMLLdk0H8B+y A==; IronPort-SDR: v8ECnTyxFzVAjXUp81uLzlP2FlNzYd/W9mrVfjYtG/E+t0GzgKn6b4dD1vcqiK6ZkWrAGSGZPM ZRs191Pj4EHw5TRkAsU34qOk0maRb1f72cWA3/Qmc1YT0QaAeR1gMOH25KuQU7hHoG9FFmvAlC VgYawWcNkX6USopD+06rcpKqnYKjNKi4Qq68IHErJhkfOjOGeH80GvrekPV/lFFP6X5x35n/w+ j2sFDYa9j0vfwSp5peSSwmVPycD5ItlDz8TXg/pfxaLLYTEcufq322d+vxuGWvFY3FQhGsGpNv ous= X-IronPort-AV: E=Sophos;i="5.64,439,1559491200"; d="scan'208";a="223475493" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 28 Aug 2019 10:29:55 +0800 IronPort-SDR: 9CZgos8OF4Uus0NGPjtJ/6KgXQD53+RbLtbD5kGmPDZCHtNxbW8raNpzJUTL2G79QJDqi2I1df 2l8R0BAmgbjmm2lBXTWcr1MlyC0uY4qSqtoCDtNpzMawATt2bdpqo21zZYYYqKWkXEWBY5njaO M3wllVvvtN4HoharGrK9LckFRwHPsoD3JmHRVTQyEoT4d52msoCGYMzxfB256QwH0XI2GyW3nf UjkW4n/7Dm58tmuS9zdipJ8suYdvuQTxVAm0azuLw+CvYmNrGfXVM8qeG97KJPltU77ktq6bLW EtMjwq4ksYghDHzsUzQqkzfZ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2019 19:27:06 -0700 IronPort-SDR: OxfdaPKtErLUOmeJXPjFRG0QeJZ46k5uZk8BFVrkxmxpxaf8OnsbH+NZzGiYehdORVmyl/zpSl yJbi+RW4DC4s11m1nFhDvdKVgdN+L/WjofH6dW/VqVGNpsDG8beLbS1TqQp8LORr6wa+5ON4fX 8qY0QQom5PPieWcHeGAhOreX4Vm/PBQHFdZKVtdgDPWEj0Ax99shKBJysAhZDC/m22fiiztICy L8hQfBJmWTZ+IHDCfs/nHehBvbM7xtC892XRjqI2KYCQf9V0TsbhHG4EzmaNvkk8RMiGJcunJj BGY= WDCIronportException: Internal Received: from washi.fujisawa.hgst.com ([10.149.53.254]) by uls-op-cesaip01.wdc.com with ESMTP; 27 Aug 2019 19:29:55 -0700 From: Damien Le Moal To: linux-block@vger.kernel.org, Jens Axboe , linux-scsi@vger.kernel.org, "Martin K . Petersen" Subject: [PATCH v2 7/7] scsi: Set ELEVATOR_F_ZBD_SEQ_WRITE for ZBC disks Date: Wed, 28 Aug 2019 11:29:47 +0900 Message-Id: <20190828022947.23364-8-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190828022947.23364-1-damien.lemoal@wdc.com> References: <20190828022947.23364-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 */