From patchwork Wed Apr 12 08:23:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9676787 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DB6A160383 for ; Wed, 12 Apr 2017 08:23:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB0CF2850E for ; Wed, 12 Apr 2017 08:23:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFED628512; Wed, 12 Apr 2017 08:23:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37F342850E for ; Wed, 12 Apr 2017 08:23:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbdDLIXt (ORCPT ); Wed, 12 Apr 2017 04:23:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:57229 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753371AbdDLIXs (ORCPT ); Wed, 12 Apr 2017 04:23:48 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E767EACB1; Wed, 12 Apr 2017 08:23:46 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7DF671E127D; Wed, 12 Apr 2017 10:23:46 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: , Jan Kara Subject: [PATCH] block: Make writeback throttling defaults consistent for SQ devices Date: Wed, 12 Apr 2017 10:23:37 +0200 Message-Id: <20170412082337.10256-1-jack@suse.cz> X-Mailer: git-send-email 2.12.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When CFQ is used as an elevator, it disables writeback throttling because they don't play well together. Later when a different elevator is chosen for the device, writeback throttling doesn't get enabled again as it should. Add support to NOOP and DEADLINE elevators to enable writeback throttling if user set such defaults. Signed-off-by: Jan Kara --- block/blk-sysfs.c | 19 +------------------ block/blk-wbt.c | 24 ++++++++++++++++++++++++ block/blk-wbt.h | 4 ++++ block/deadline-iosched.c | 7 +++++++ block/noop-iosched.c | 7 +++++++ 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index fc20489f0d2b..f85723332288 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -844,23 +844,6 @@ struct kobj_type blk_queue_ktype = { .release = blk_release_queue, }; -static void blk_wb_init(struct request_queue *q) -{ -#ifndef CONFIG_BLK_WBT_MQ - if (q->mq_ops) - return; -#endif -#ifndef CONFIG_BLK_WBT_SQ - if (q->request_fn) - return; -#endif - - /* - * If this fails, we don't get throttling - */ - wbt_init(q); -} - int blk_register_queue(struct gendisk *disk) { int ret; @@ -908,7 +891,7 @@ int blk_register_queue(struct gendisk *disk) kobject_uevent(&q->kobj, KOBJ_ADD); - blk_wb_init(q); + wbt_enable_default(q); blk_throtl_register_queue(q); diff --git a/block/blk-wbt.c b/block/blk-wbt.c index b3b79149d3a0..22fb33cc35f1 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -665,6 +665,30 @@ void wbt_disable_default(struct request_queue *q) } EXPORT_SYMBOL_GPL(wbt_disable_default); +/* + * Enable wbt if defaults are configured that way + */ +void wbt_enable_default(struct request_queue *q) +{ + if (q->rq_wb) + return; + +#ifndef CONFIG_BLK_WBT_MQ + if (q->mq_ops) + return; +#endif +#ifndef CONFIG_BLK_WBT_SQ + if (q->request_fn) + return; +#endif + + /* + * If this fails, we don't get throttling + */ + wbt_init(q); +} +EXPORT_SYMBOL_GPL(wbt_enable_default); + u64 wbt_default_latency_nsec(struct request_queue *q) { /* diff --git a/block/blk-wbt.h b/block/blk-wbt.h index ad6c78507c3a..df6de50c5d59 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -117,6 +117,7 @@ void wbt_update_limits(struct rq_wb *); void wbt_requeue(struct rq_wb *, struct blk_issue_stat *); void wbt_issue(struct rq_wb *, struct blk_issue_stat *); void wbt_disable_default(struct request_queue *); +void wbt_enable_default(struct request_queue *); void wbt_set_queue_depth(struct rq_wb *, unsigned int); void wbt_set_write_cache(struct rq_wb *, bool); @@ -155,6 +156,9 @@ static inline void wbt_issue(struct rq_wb *rwb, struct blk_issue_stat *stat) static inline void wbt_disable_default(struct request_queue *q) { } +static inline void wbt_enable_default(struct request_queue *q) +{ +} static inline void wbt_set_queue_depth(struct rq_wb *rwb, unsigned int depth) { } diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index c68f6bbc0dcd..71210b66f019 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c @@ -13,6 +13,7 @@ #include #include #include +#include "blk-wbt.h" /* * See Documentation/block/deadline-iosched.txt @@ -363,6 +364,11 @@ static int deadline_init_queue(struct request_queue *q, struct elevator_type *e) return 0; } +static void deadline_registered_queue(struct request_queue *q) +{ + wbt_enable_default(q); +} + /* * sysfs parts below */ @@ -445,6 +451,7 @@ static struct elevator_type iosched_deadline = { .elevator_latter_req_fn = elv_rb_latter_request, .elevator_init_fn = deadline_init_queue, .elevator_exit_fn = deadline_exit_queue, + .elevator_registered_fn = deadline_registered_queue, }, .elevator_attrs = deadline_attrs, diff --git a/block/noop-iosched.c b/block/noop-iosched.c index 2d1b15d89b45..92f747d6b9c2 100644 --- a/block/noop-iosched.c +++ b/block/noop-iosched.c @@ -7,6 +7,7 @@ #include #include #include +#include "blk-wbt.h" struct noop_data { struct list_head queue; @@ -91,6 +92,11 @@ static void noop_exit_queue(struct elevator_queue *e) kfree(nd); } +static void noop_registered_queue(struct request_queue *q) +{ + wbt_enable_default(q); +} + static struct elevator_type elevator_noop = { .ops.sq = { .elevator_merge_req_fn = noop_merged_requests, @@ -100,6 +106,7 @@ static struct elevator_type elevator_noop = { .elevator_latter_req_fn = noop_latter_request, .elevator_init_fn = noop_init_queue, .elevator_exit_fn = noop_exit_queue, + .elevator_registered_fn = noop_registered_queue, }, .elevator_name = "noop", .elevator_owner = THIS_MODULE,