From patchwork Thu Feb 14 10:24:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158337 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1172851jaa; Thu, 14 Feb 2019 02:25:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IY6rcyuHIGCFkedLRf4/7XXGGtSYyd05s6juJvzQRifkxO9pOi9N4HW0V8RWxtBga7Jlkc/ X-Received: by 2002:aa7:83c2:: with SMTP id j2mr3196532pfn.119.1550139936942; Thu, 14 Feb 2019 02:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550139936; cv=none; d=google.com; s=arc-20160816; b=0MRZakVtrNdkfFPqM7EDrhZpxzrGicw4rq8xJgQN3j31vpIBzQ/7k4L0EMHfqFzIRI 4D2qK0Q3s3WpDSIn2padCzSx1bMyrYCirOdxuDddJh46qhutQVZJaypSpqTl2w1a3lSJ 7LgCNcp+VDt4tZY6UnBq0FAhtr8BgGTCdVVY4h/XlQidLN/kkyl6spLKRbW57KIL3up9 MiFltawenuk8xet1vC0XIIdlnWdEVb+24dLPGNHKn5nAEJhH5Esnh2awkh7f5AqOlQ8d xL9RKFJ6WTEaeQmshy7/wTGaCgQ/N7Xdg84WZ6C5BQjwoPIszjX3w8yOQBx4bnflTHNI F7OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ogYi8uBO13tA9f3mvzmcxTSxnN7g477z90MxByLFd/A=; b=Y5CJJI4gRHSXDkxDh05bzCHuQOb4zGoQMF6oaY9kqP6vsV7w3JknQNv0PvKkNI5Nii TcLp5zyKO4PqL+HjNMhSkXJkDGmwGGbMkzDznMuMgz5MUHM+gyaiC4oLjxFCD4yJlUqd F2WDq3eBQaprcudsS1JRvhqUSzsSOU+Y1NZJQM4ROiIBgE+5KbKkzhYg5ajFXQwMtmX0 C+ks/p63m22pa5kq6fKKkJpcAqUKiV8pQt9pv0mL3pgnZghmceRt6JtfvXGQuqq15wZs 3hJJDdk1O1wvv+DTE7DNIfMe+HjIx0L/PC4yR/ONdaZnoqcXz4p/xVmXpdbNFRxTZEuG czpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rqsM6pof; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si2132062plv.258.2019.02.14.02.25.29; Thu, 14 Feb 2019 02:25:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rqsM6pof; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390719AbfBNKZ1 (ORCPT + 15 others); Thu, 14 Feb 2019 05:25:27 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:41703 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389001AbfBNKZ1 (ORCPT ); Thu, 14 Feb 2019 05:25:27 -0500 Received: by mail-lj1-f193.google.com with SMTP id e17-v6so4736579lja.8 for ; Thu, 14 Feb 2019 02:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ogYi8uBO13tA9f3mvzmcxTSxnN7g477z90MxByLFd/A=; b=rqsM6poftUwB0M2FI4qlJ7+n9ojuhncItIYDDmFpcC4qM4Oe0sLYJOIHV0jQTAejEE SFQJzWWg1jcWbu+Wo7659su2UvWirJPgIz9Jw62zVRop3fXRpP3/YKp+hXYqueBNOfCc eA7FTxwcWryGhcGOrsxBw+xccaWuyMgQ9kW3RfffGjZh6sTmo5UaTrXl1vdxYv8Aiq/P qjz/BjKpg5jSelG5dUfQbe9p59ntReIQthNCn/7o7Jilq/ro2o1A7yFlC/ILDNDs1n/o bJK+dzWCgZRX1XUfh8YF4Ztxf8U1o2WMaxDRnzA5vqpvgoLO7VvpSsv+/Gj6ITzg77eI je+g== 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:mime-version:content-transfer-encoding; bh=ogYi8uBO13tA9f3mvzmcxTSxnN7g477z90MxByLFd/A=; b=ZoJ7xu34iHWKMRfY6nkJcboeTFF6WB3KhCEcce4fpx0FheN6AsYgXavZfo//uAUjJz HX9n+XEKKaxf6Bsm8ksdxpNGLG2SIpulo04WwPYIkWq9iwiB99EXd/Hj2KQPeqZ2rH0M /FyNHMgNhAC9Duem8bqsrhQnNHwLLpsYzbT7BeW3EW5s8Qa8k2Gm7VSVs92l9AoNTCvq KIkUqiswq1XtF5fwzhul9+8uXm2n25Tyg+7tnC0RM4ZsELLw3yjXIb766Gz4Oi8Q1ySq V0GO1OEzR07To2G7myYP4qBo15PjZL7HGCUIu902oAZJrRglwbihKx1JW8Z1zgK2trdm du9A== X-Gm-Message-State: AHQUAubE/XvlxZCRsoYoytpM5nHjRvi5aV/KB9Zxj+wMULLguIfHXF6q mbNU/y1CXfyzJKag8q/ezWrTrA== X-Received: by 2002:a2e:49d:: with SMTP id a29mr1891065ljf.35.1550139924777; Thu, 14 Feb 2019 02:25:24 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n189sm380392lfn.82.2019.02.14.02.25.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 02:25:23 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Eric Dumazet , Hauke Mehrtens , Dave Taht , Liping Zhang , John Youn , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , James Hughes , Felix Fietkau , Boris Brezillon , Richard Weinberger Subject: [PATCH 06/10] ubifs: Use dirty_writeback_interval value for wbuf timer Date: Thu, 14 Feb 2019 11:24:32 +0100 Message-Id: <20190214102436.5092-7-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214102436.5092-1-linus.walleij@linaro.org> References: <20190214102436.5092-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Rafał Miłecki Right now wbuf timer has hardcoded timeouts and there is no place for manual adjustments. Some projects / cases many need that though. Few file systems allow doing that by respecting dirty_writeback_interval that can be set using sysctl (dirty_writeback_centisecs). Lowering dirty_writeback_interval could be some way of dealing with user space apps lacking proper fsyncs. This is definitely *not* a perfect solution but we don't have ideal (user space) world. There were already advanced discussions on this matter, mostly when ext4 was introduced and it wasn't behaving as ext3. Anyway, the final decision was to add some hacks to the ext4, as trying to fix whole user space or adding new API was pointless. We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close as this would cause too many commits and flash wearing. On the other hand we still should allow some trade-off between -o sync and default wbuf timeout. Respecting dirty_writeback_interval should allow some sane cutomizations if used warily. Signed-off-by: Rafał Miłecki Reviewed-by: Boris Brezillon Signed-off-by: Richard Weinberger --- fs/ubifs/io.c | 8 ++++---- fs/ubifs/ubifs.h | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 4d6ce4a2a4b6..3be28900bf37 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer) */ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) { - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0); - unsigned long long delta; + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10); + unsigned long long delta = dirty_writeback_interval; - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT; - delta *= 1000000000ULL; + /* centi to milli, milli to nano, then 10% */ + delta *= 10ULL * NSEC_PER_MSEC / 10ULL; ubifs_assert(!hrtimer_active(&wbuf->timer)); ubifs_assert(delta <= ULONG_MAX); diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index ade4b3137a1d..b8b18d446a49 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -83,10 +83,6 @@ */ #define BGT_NAME_PATTERN "ubifs_bgt%d_%d" -/* Write-buffer synchronization timeout interval in seconds */ -#define WBUF_TIMEOUT_SOFTLIMIT 3 -#define WBUF_TIMEOUT_HARDLIMIT 5 - /* Maximum possible inode number (only 32-bit inodes are supported now) */ #define MAX_INUM 0xFFFFFFFF