diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-23 05:30:43 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-07-05 11:45:16 -0400 |
commit | 0b335b9d7d5f0b832e90ac469480789c07be80ad (patch) | |
tree | 5001522f18092e1cafb538a74eedae3087c17145 /fs/ubifs | |
parent | 70aee2f153972f70fad5f7025134fec063f9efbe (diff) |
UBIFS: slightly optimize write-buffer timer usage
This patch adds the following minor optimization:
1. If write-buffer does not use the timer, indicate it with the
wbuf->no_timer variable, instead of using the wbuf->softlimit
variable. This is better because wbuf->softlimit is of ktime_t
type, and the ktime_to_ns function contains 64-bit multiplication.
2. Do not call the 'hrtimer_cancel()' function for write-buffers
which do not use timers.
3. Do not cancel the timer in 'ubifs_put_super()' because the
synchronization function does this.
This patch also removes a confusing comment.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/io.c | 9 | ||||
-rw-r--r-- | fs/ubifs/super.c | 6 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 6 |
3 files changed, 9 insertions, 12 deletions
diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c index 2ef689a9a363..9fcf6c38c1bc 100644 --- a/fs/ubifs/io.c +++ b/fs/ubifs/io.c | |||
@@ -312,7 +312,7 @@ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | |||
312 | { | 312 | { |
313 | ubifs_assert(!hrtimer_active(&wbuf->timer)); | 313 | ubifs_assert(!hrtimer_active(&wbuf->timer)); |
314 | 314 | ||
315 | if (!ktime_to_ns(wbuf->softlimit)) | 315 | if (wbuf->no_timer) |
316 | return; | 316 | return; |
317 | dbg_io("set timer for jhead %d, %llu-%llu millisecs", wbuf->jhead, | 317 | dbg_io("set timer for jhead %d, %llu-%llu millisecs", wbuf->jhead, |
318 | ktime_to_ns(wbuf->softlimit)/USEC_PER_SEC, | 318 | ktime_to_ns(wbuf->softlimit)/USEC_PER_SEC, |
@@ -327,11 +327,8 @@ static void new_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | |||
327 | */ | 327 | */ |
328 | static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) | 328 | static void cancel_wbuf_timer_nolock(struct ubifs_wbuf *wbuf) |
329 | { | 329 | { |
330 | /* | 330 | if (wbuf->no_timer) |
331 | * If the syncer is waiting for the lock (from the background thread's | 331 | return; |
332 | * context) and another task is changing write-buffer then the syncing | ||
333 | * should be canceled. | ||
334 | */ | ||
335 | wbuf->need_sync = 0; | 332 | wbuf->need_sync = 0; |
336 | hrtimer_cancel(&wbuf->timer); | 333 | hrtimer_cancel(&wbuf->timer); |
337 | } | 334 | } |
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 79fad43f3c57..5bb272c56a9b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -797,7 +797,7 @@ static int alloc_wbufs(struct ubifs_info *c) | |||
797 | * does not need to be synchronized by timer. | 797 | * does not need to be synchronized by timer. |
798 | */ | 798 | */ |
799 | c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM; | 799 | c->jheads[GCHD].wbuf.dtype = UBI_LONGTERM; |
800 | c->jheads[GCHD].wbuf.softlimit = ktime_set(0, 0); | 800 | c->jheads[GCHD].wbuf.no_timer = 1; |
801 | 801 | ||
802 | return 0; | 802 | return 0; |
803 | } | 803 | } |
@@ -1754,10 +1754,8 @@ static void ubifs_put_super(struct super_block *sb) | |||
1754 | 1754 | ||
1755 | /* Synchronize write-buffers */ | 1755 | /* Synchronize write-buffers */ |
1756 | if (c->jheads) | 1756 | if (c->jheads) |
1757 | for (i = 0; i < c->jhead_cnt; i++) { | 1757 | for (i = 0; i < c->jhead_cnt; i++) |
1758 | ubifs_wbuf_sync(&c->jheads[i].wbuf); | 1758 | ubifs_wbuf_sync(&c->jheads[i].wbuf); |
1759 | hrtimer_cancel(&c->jheads[i].wbuf.timer); | ||
1760 | } | ||
1761 | 1759 | ||
1762 | /* | 1760 | /* |
1763 | * On fatal errors c->ro_media is set to 1, in which case we do | 1761 | * On fatal errors c->ro_media is set to 1, in which case we do |
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 1bf01d820066..97bc9d09d54b 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h | |||
@@ -654,7 +654,8 @@ typedef int (*ubifs_lpt_scan_callback)(struct ubifs_info *c, | |||
654 | * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit | 654 | * @delta: hard and soft timeouts delta (the timer expire inteval is @softlimit |
655 | * and @softlimit + @delta) | 655 | * and @softlimit + @delta) |
656 | * @timer: write-buffer timer | 656 | * @timer: write-buffer timer |
657 | * @need_sync: it is set if its timer expired and needs sync | 657 | * @no_timer: non-zero if this write-buffer does not timer |
658 | * @need_sync: non-zero if its timer expired and needs sync | ||
658 | * @next_ino: points to the next position of the following inode number | 659 | * @next_ino: points to the next position of the following inode number |
659 | * @inodes: stores the inode numbers of the nodes which are in wbuf | 660 | * @inodes: stores the inode numbers of the nodes which are in wbuf |
660 | * | 661 | * |
@@ -683,7 +684,8 @@ struct ubifs_wbuf { | |||
683 | ktime_t softlimit; | 684 | ktime_t softlimit; |
684 | unsigned long long delta; | 685 | unsigned long long delta; |
685 | struct hrtimer timer; | 686 | struct hrtimer timer; |
686 | int need_sync; | 687 | unsigned int no_timer:1; |
688 | unsigned int need_sync:1; | ||
687 | int next_ino; | 689 | int next_ino; |
688 | ino_t *inodes; | 690 | ino_t *inodes; |
689 | }; | 691 | }; |