From patchwork Wed Feb 7 19:41:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Lyle X-Patchwork-Id: 10205897 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 4F66A602D8 for ; Wed, 7 Feb 2018 19:42:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E9D9290F6 for ; Wed, 7 Feb 2018 19:42:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 317BC29104; Wed, 7 Feb 2018 19:42:09 +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,DKIM_SIGNED, DKIM_VALID,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 BA443290F6 for ; Wed, 7 Feb 2018 19:42:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754349AbeBGTmH (ORCPT ); Wed, 7 Feb 2018 14:42:07 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:40855 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049AbeBGTmE (ORCPT ); Wed, 7 Feb 2018 14:42:04 -0500 Received: by mail-pf0-f194.google.com with SMTP id a14so769260pfi.7 for ; Wed, 07 Feb 2018 11:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyle-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EGkbpWSAPnAgpOVpiSa4d4nF7o9XRAtE1WYE5c3lAvE=; b=xj3qqzNsmJrPyz6pq8duQcBE6hv1nY41DjPVNKl5Pb4Y/a3LtCdtmPOJycv2Kq+Qxp ldCPTXLpyVYa+ubC/wkxjOO9//G8/3Dy44n5mo7QUCHoxomzWm2Fhiweea6WDxPTEEKg jKLc5/ZtAsXHA67TsgEfdDH+6yGrHfa6h3CCKSPa0B8Lcl67M8B/gfV321RRAZJAI0YR y9ZEwlLaiuFSDqScHVs9plxhKqrJIceQzOmEBkDJVS0L4RqSquw59nmPkd0oTO0BFrTh exuj5vpTCqtEk5xfQ+yktI4fn88H7nfejrXJlZBgOxjC0wiEH69Oqo6MmwHIE/xGJrns 7Pjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EGkbpWSAPnAgpOVpiSa4d4nF7o9XRAtE1WYE5c3lAvE=; b=HQPoT5lipeJzy2XTB00ggGlb2mXmcOJRZUAwMXYcO//drrF6yAFe2f2GjH82tte+xl LELWjjo/9qvgS9Fkq+jGXMLk6k+mzoDrcB76l5b8C9aJyY+15KHZLA+uQaLxVDqYaoRx 5itA9w4N0FTZAmmZonLmjxkXG05oUEqCd4ERTD2wiT7NB6gsiTFAD1Oq9DkctawMZJjK zCOVQy6Twl+IRspQ1R3Jeo+9HRxUGOwWkuHizinqh/a5PfOi2oljjEu2CktqaEMRiU1Y sJSFTiXMq3xaZ5Vb+ThxON0foeXrdnhW4XOWs3GunXdYqnOovff01BoHLHg8Cbzg5SIf Fgsg== X-Gm-Message-State: APf1xPDxKcsVbvgEyRMO5kjMObHyb5WBNZEPQDYAPaMmPsEAf31pEvok 3ZiZynbDuHoxOG87OQmETgHjog== X-Google-Smtp-Source: AH8x22696I14gG/ERCx5IA2hesWoV/GbakTIJNJXxRfYW/PpTvbWdj50BYd4f6NOVdBXYuk2oz8GYw== X-Received: by 10.98.141.208 with SMTP id p77mr6390115pfk.5.1518032524178; Wed, 07 Feb 2018 11:42:04 -0800 (PST) Received: from midnight.lan (2600-6c52-6200-09b7-0000-0000-0000-0d66.dhcp6.chtrptr.net. [2600:6c52:6200:9b7::d66]) by smtp.gmail.com with ESMTPSA id q24sm6136554pgn.46.2018.02.07.11.42.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Feb 2018 11:42:03 -0800 (PST) From: Michael Lyle To: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org Cc: axboe@fb.com, Coly Li Subject: [PATCH 6/8] bcache: set writeback_rate_update_seconds in range [1, 60] seconds Date: Wed, 7 Feb 2018 11:41:44 -0800 Message-Id: <20180207194146.5095-7-mlyle@lyle.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180207194146.5095-1-mlyle@lyle.org> References: <20180207194146.5095-1-mlyle@lyle.org> 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 From: Coly Li dc->writeback_rate_update_seconds can be set via sysfs and its value can be set to [1, ULONG_MAX]. It does not make sense to set such a large value, 60 seconds is long enough value considering the default 5 seconds works well for long time. Because dc->writeback_rate_update is a special delayed work, it re-arms itself inside the delayed work routine update_writeback_rate(). When stopping it by cancel_delayed_work_sync(), there should be a timeout to wait and make sure the re-armed delayed work is stopped too. A small max value of dc->writeback_rate_update_seconds is also helpful to decide a reasonable small timeout. This patch limits sysfs interface to set dc->writeback_rate_update_seconds in range of [1, 60] seconds, and replaces the hand-coded number by macros. Changelog: v2: fix a rebase typo in v4, which is pointed out by Michael Lyle. v1: initial version. Signed-off-by: Coly Li Reviewed-by: Hannes Reinecke Reviewed-by: Michael Lyle --- drivers/md/bcache/sysfs.c | 4 +++- drivers/md/bcache/writeback.c | 2 +- drivers/md/bcache/writeback.h | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index c524305cc9a7..4a6a697e1680 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c @@ -218,7 +218,9 @@ STORE(__cached_dev) sysfs_strtoul_clamp(writeback_rate, dc->writeback_rate.rate, 1, INT_MAX); - d_strtoul_nonzero(writeback_rate_update_seconds); + sysfs_strtoul_clamp(writeback_rate_update_seconds, + dc->writeback_rate_update_seconds, + 1, WRITEBACK_RATE_UPDATE_SECS_MAX); d_strtoul(writeback_rate_i_term_inverse); d_strtoul_nonzero(writeback_rate_p_term_inverse); diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c index 58218f7e77c3..f1d2fc15abcc 100644 --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -655,7 +655,7 @@ void bch_cached_dev_writeback_init(struct cached_dev *dc) dc->writeback_rate.rate = 1024; dc->writeback_rate_minimum = 8; - dc->writeback_rate_update_seconds = 5; + dc->writeback_rate_update_seconds = WRITEBACK_RATE_UPDATE_SECS_DEFAULT; dc->writeback_rate_p_term_inverse = 40; dc->writeback_rate_i_term_inverse = 10000; diff --git a/drivers/md/bcache/writeback.h b/drivers/md/bcache/writeback.h index 66f1c527fa24..587b25599856 100644 --- a/drivers/md/bcache/writeback.h +++ b/drivers/md/bcache/writeback.h @@ -8,6 +8,9 @@ #define MAX_WRITEBACKS_IN_PASS 5 #define MAX_WRITESIZE_IN_PASS 5000 /* *512b */ +#define WRITEBACK_RATE_UPDATE_SECS_MAX 60 +#define WRITEBACK_RATE_UPDATE_SECS_DEFAULT 5 + /* * 14 (16384ths) is chosen here as something that each backing device * should be a reasonable fraction of the share, and not to blow up