9313cd557e02b8deb2698e03d2b14316cb944b05
[openwrt/staging/yousong.git] /
1 From 1b7fc2c0069f3864a3dda15430b7aded31c0bfcc Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Tue, 20 Sep 2016 10:36:15 +0200
4 Subject: [PATCH] ubifs: Use dirty_writeback_interval value for wbuf timer
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Right now wbuf timer has hardcoded timeouts and there is no place for
10 manual adjustments. Some projects / cases many need that though. Few
11 file systems allow doing that by respecting dirty_writeback_interval
12 that can be set using sysctl (dirty_writeback_centisecs).
13
14 Lowering dirty_writeback_interval could be some way of dealing with user
15 space apps lacking proper fsyncs. This is definitely *not* a perfect
16 solution but we don't have ideal (user space) world. There were already
17 advanced discussions on this matter, mostly when ext4 was introduced and
18 it wasn't behaving as ext3. Anyway, the final decision was to add some
19 hacks to the ext4, as trying to fix whole user space or adding new API
20 was pointless.
21
22 We can't (and shouldn't?) just follow ext4. We can't e.g. sync on close
23 as this would cause too many commits and flash wearing. On the other
24 hand we still should allow some trade-off between -o sync and default
25 wbuf timeout. Respecting dirty_writeback_interval should allow some sane
26 cutomizations if used warily.
27
28 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
29 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
30 Signed-off-by: Richard Weinberger <richard@nod.at>
31 ---
32 fs/ubifs/io.c | 8 ++++----
33 fs/ubifs/ubifs.h | 4 ----
34 2 files changed, 4 insertions(+), 8 deletions(-)
35
36 --- a/fs/ubifs/io.c
37 +++ b/fs/ubifs/io.c
38 @@ -452,11 +452,11 @@ static enum hrtimer_restart wbuf_timer_c
39 */
40 static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
41 {
42 - ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
43 - unsigned long long delta;
44 + ktime_t softlimit = ms_to_ktime(dirty_writeback_interval * 10);
45 + unsigned long long delta = dirty_writeback_interval;
46
47 - delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
48 - delta *= 1000000000ULL;
49 + /* centi to milli, milli to nano, then 10% */
50 + delta *= 10ULL * NSEC_PER_MSEC / 10ULL;
51
52 ubifs_assert(!hrtimer_active(&wbuf->timer));
53 ubifs_assert(delta <= ULONG_MAX);
54 --- a/fs/ubifs/ubifs.h
55 +++ b/fs/ubifs/ubifs.h
56 @@ -106,10 +106,6 @@
57 */
58 #define BGT_NAME_PATTERN "ubifs_bgt%d_%d"
59
60 -/* Write-buffer synchronization timeout interval in seconds */
61 -#define WBUF_TIMEOUT_SOFTLIMIT 3
62 -#define WBUF_TIMEOUT_HARDLIMIT 5
63 -
64 /* Maximum possible inode number (only 32-bit inodes are supported now) */
65 #define MAX_INUM 0xFFFFFFFF
66