Commit 73721865 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] aio: fix io_getevents() timer expiry setting

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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 93c934c0
......@@ -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->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;
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;
}
static inline void clear_timeout(struct timeout *to)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment