]> git.hungrycats.org Git - linux/commitdiff
[PATCH] aio: fix io_getevents() timer expiry setting
authorAndrew Morton <akpm@osdl.org>
Thu, 3 Jun 2004 01:01:14 +0000 (18:01 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 3 Jun 2004 01:01:14 +0000 (18:01 -0700)
From: William Lee Irwin III <wli@holomorphy.com>

start_jiffies was not respected by set_timeout(), which reread jiffies
instead of respecting what read_events() passed it.  This difference can be
significant, particularly if the calling process slept during the
copy_to_user() operation in read_events().  To correct this, this patch
teaches it to respect its argument, with the additional bonus of converting
it to use timespec_to_jiffies() instead of open-coding it.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/aio.c

index a2cf98648111f5842934fa5359f6cd73f98d7cff..0b37d24c9341a67860fbf9306be94bdae762a619 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -777,19 +777,11 @@ static inline void init_timeout(struct timeout *to)
 static inline void set_timeout(long start_jiffies, struct timeout *to,
                               const struct timespec *ts)
 {
-       unsigned long how_long;
-
-       if (ts->tv_sec < 0 || (!ts->tv_sec && !ts->tv_nsec)) {
+       to->timer.expires = start_jiffies + timespec_to_jiffies(ts);
+       if (time_after(to->timer.expires, jiffies))
+               add_timer(&to->timer);
+       else
                to->timed_out = 1;
-               return;
-       }
-
-       how_long = ts->tv_sec * HZ;
-#define HZ_NS (1000000000 / HZ)
-       how_long += (ts->tv_nsec + HZ_NS - 1) / HZ_NS;
-       
-       to->timer.expires = jiffies + how_long;
-       add_timer(&to->timer);
 }
 
 static inline void clear_timeout(struct timeout *to)