]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
aio: simplify read_events()
authorOleg Nesterov <oleg@redhat.com>
Thu, 31 Dec 2020 22:04:43 +0000 (22:04 +0000)
committerJohannes Weiner <hannes@cmpxchg.org>
Thu, 31 Dec 2020 22:04:43 +0000 (22:04 +0000)
Change wait_event_hrtimeout() to not call __wait_event_hrtimeout() if
timeout == 0, this matches other _timeout() helpers in wait.h.

This allows to simplify its only user, read_events(), it no longer needs
to optimize the "until == 0" case by hand.

Note: this patch doesn't use ___wait_cond_timeout because _hrtimeout()
also differs in that it returns 0 if succeeds and -ETIME on timeout.
Perhaps we should change this to make it fully compatible with other
helpers.

Link: http://lkml.kernel.org/r/20190607175413.GA29187@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Laight <David.Laight@ACULAB.COM>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Eric Wong <e@80x24.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/aio.c
include/linux/wait.h

index 1f32da13d39ee603cfd42e3d2af8f318f8bb0ea3..d213be7b8a7e6cacc09744e3edc8e011b98d0b55 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1289,12 +1289,9 @@ static long read_events(struct kioctx *ctx, long min_nr, long nr,
         * the ringbuffer empty. So in practice we should be ok, but it's
         * something to be aware of when touching this code.
         */
-       if (until == 0)
-               aio_read_events(ctx, min_nr, nr, event, &ret);
-       else
-               wait_event_interruptible_hrtimeout(ctx->wait,
-                               aio_read_events(ctx, min_nr, nr, event, &ret),
-                               until);
+       wait_event_interruptible_hrtimeout(ctx->wait,
+                       aio_read_events(ctx, min_nr, nr, event, &ret),
+                       until);
        return ret;
 }
 
index fe10e8570a522166903411cfd9ab02f4109813fe..cffb6f8d3b0b2bd0bf404bfefeb8e98af43565d1 100644 (file)
@@ -555,7 +555,7 @@ do {                                                                                \
 ({                                                                             \
        int __ret = 0;                                                          \
        might_sleep();                                                          \
-       if (!(condition))                                                       \
+       if (!(condition) && (timeout))                                          \
                __ret = __wait_event_hrtimeout(wq_head, condition, timeout,     \
                                               TASK_UNINTERRUPTIBLE);           \
        __ret;                                                                  \
@@ -581,7 +581,7 @@ do {                                                                                \
 ({                                                                             \
        long __ret = 0;                                                         \
        might_sleep();                                                          \
-       if (!(condition))                                                       \
+       if (!(condition) && (timeout))                                          \
                __ret = __wait_event_hrtimeout(wq, condition, timeout,          \
                                               TASK_INTERRUPTIBLE);             \
        __ret;                                                                  \