662584ca61f99e97532da97471a5ccf32a6f5237
[openwrt/openwrt.git] /
1 From 854826c9d526fd81077742c3b000e3f7fcaef3ce 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:14 +0200
4 Subject: [PATCH] ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 Values of these fields are set during init and never modified. They are
10 used (read) in a single function only. There isn't really any reason to
11 keep them in a struct. It only makes struct just a bit bigger without
12 any visible gain.
13
14 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
15 Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
16 Signed-off-by: Richard Weinberger <richard@nod.at>
17 ---
18 fs/ubifs/io.c | 18 ++++++++++--------
19 fs/ubifs/ubifs.h | 5 -----
20 2 files changed, 10 insertions(+), 13 deletions(-)
21
22 --- a/fs/ubifs/io.c
23 +++ b/fs/ubifs/io.c
24 @@ -452,16 +452,22 @@ static enum hrtimer_restart wbuf_timer_c
25 */
26 static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
27 {
28 + ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
29 + unsigned long long delta;
30 +
31 + delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
32 + delta *= 1000000000ULL;
33 +
34 ubifs_assert(!hrtimer_active(&wbuf->timer));
35 + ubifs_assert(delta <= ULONG_MAX);
36
37 if (wbuf->no_timer)
38 return;
39 dbg_io("set timer for jhead %s, %llu-%llu millisecs",
40 dbg_jhead(wbuf->jhead),
41 - div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC),
42 - div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta,
43 - USEC_PER_SEC));
44 - hrtimer_start_range_ns(&wbuf->timer, wbuf->softlimit, wbuf->delta,
45 + div_u64(ktime_to_ns(softlimit), USEC_PER_SEC),
46 + div_u64(ktime_to_ns(softlimit) + delta, USEC_PER_SEC));
47 + hrtimer_start_range_ns(&wbuf->timer, softlimit, delta,
48 HRTIMER_MODE_REL);
49 }
50
51 @@ -1059,10 +1065,6 @@ int ubifs_wbuf_init(struct ubifs_info *c
52
53 hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
54 wbuf->timer.function = wbuf_timer_callback_nolock;
55 - wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
56 - wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
57 - wbuf->delta *= 1000000000ULL;
58 - ubifs_assert(wbuf->delta <= ULONG_MAX);
59 return 0;
60 }
61
62 --- a/fs/ubifs/ubifs.h
63 +++ b/fs/ubifs/ubifs.h
64 @@ -668,9 +668,6 @@ typedef int (*ubifs_lpt_scan_callback)(s
65 * @io_mutex: serializes write-buffer I/O
66 * @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes
67 * fields
68 - * @softlimit: soft write-buffer timeout interval
69 - * @delta: hard and soft timeouts delta (the timer expire interval is @softlimit
70 - * and @softlimit + @delta)
71 * @timer: write-buffer timer
72 * @no_timer: non-zero if this write-buffer does not have a timer
73 * @need_sync: non-zero if the timer expired and the wbuf needs sync'ing
74 @@ -699,8 +696,6 @@ struct ubifs_wbuf {
75 int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad);
76 struct mutex io_mutex;
77 spinlock_t lock;
78 - ktime_t softlimit;
79 - unsigned long long delta;
80 struct hrtimer timer;
81 unsigned int no_timer:1;
82 unsigned int need_sync:1;