Skip to content

Commit 854826c

Browse files
Rafał Miłeckirichardweinberger
authored andcommitted
ubifs: Drop softlimit and delta fields from struct ubifs_wbuf
Values of these fields are set during init and never modified. They are used (read) in a single function only. There isn't really any reason to keep them in a struct. It only makes struct just a bit bigger without any visible gain. Signed-off-by: Rafał Miłecki <rafal@milecki.pl> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 6a34e4d commit 854826c

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

fs/ubifs/io.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,22 @@ static enum hrtimer_restart wbuf_timer_callback_nolock(struct hrtimer *timer)
452452
*/
453453
static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf)
454454
{
455+
ktime_t softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
456+
unsigned long long delta;
457+
458+
delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
459+
delta *= 1000000000ULL;
460+
455461
ubifs_assert(!hrtimer_active(&wbuf->timer));
462+
ubifs_assert(delta <= ULONG_MAX);
456463

457464
if (wbuf->no_timer)
458465
return;
459466
dbg_io("set timer for jhead %s, %llu-%llu millisecs",
460467
dbg_jhead(wbuf->jhead),
461-
div_u64(ktime_to_ns(wbuf->softlimit), USEC_PER_SEC),
462-
div_u64(ktime_to_ns(wbuf->softlimit) + wbuf->delta,
463-
USEC_PER_SEC));
464-
hrtimer_start_range_ns(&wbuf->timer, wbuf->softlimit, wbuf->delta,
468+
div_u64(ktime_to_ns(softlimit), USEC_PER_SEC),
469+
div_u64(ktime_to_ns(softlimit) + delta, USEC_PER_SEC));
470+
hrtimer_start_range_ns(&wbuf->timer, softlimit, delta,
465471
HRTIMER_MODE_REL);
466472
}
467473

@@ -1059,10 +1065,6 @@ int ubifs_wbuf_init(struct ubifs_info *c, struct ubifs_wbuf *wbuf)
10591065

10601066
hrtimer_init(&wbuf->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
10611067
wbuf->timer.function = wbuf_timer_callback_nolock;
1062-
wbuf->softlimit = ktime_set(WBUF_TIMEOUT_SOFTLIMIT, 0);
1063-
wbuf->delta = WBUF_TIMEOUT_HARDLIMIT - WBUF_TIMEOUT_SOFTLIMIT;
1064-
wbuf->delta *= 1000000000ULL;
1065-
ubifs_assert(wbuf->delta <= ULONG_MAX);
10661068
return 0;
10671069
}
10681070

fs/ubifs/ubifs.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,6 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c,
645645
* @io_mutex: serializes write-buffer I/O
646646
* @lock: serializes @buf, @lnum, @offs, @avail, @used, @next_ino and @inodes
647647
* fields
648-
* @softlimit: soft write-buffer timeout interval
649-
* @delta: hard and soft timeouts delta (the timer expire interval is @softlimit
650-
* and @softlimit + @delta)
651648
* @timer: write-buffer timer
652649
* @no_timer: non-zero if this write-buffer does not have a timer
653650
* @need_sync: non-zero if the timer expired and the wbuf needs sync'ing
@@ -676,8 +673,6 @@ struct ubifs_wbuf {
676673
int (*sync_callback)(struct ubifs_info *c, int lnum, int free, int pad);
677674
struct mutex io_mutex;
678675
spinlock_t lock;
679-
ktime_t softlimit;
680-
unsigned long long delta;
681676
struct hrtimer timer;
682677
unsigned int no_timer:1;
683678
unsigned int need_sync:1;

0 commit comments

Comments
 (0)