diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-27 01:13:10 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-30 05:18:17 +0200 |
commit | d2988bd412fac87859f0b68f5ea328fb0f09c216 (patch) | |
tree | 1a0df5ecf1d4c9400613e328e02d204ca01aa7a2 /fs/aio.c | |
parent | aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the ... (diff) | |
download | linux-d2988bd412fac87859f0b68f5ea328fb0f09c216.tar.xz linux-d2988bd412fac87859f0b68f5ea328fb0f09c216.zip |
aio_read_events_ring(): make a bit more readable
The logics for 'avail' is
* not past the tail of cyclic buffer
* no more than asked
* not past the end of buffer
* not past the end of a page
Unobfuscate the last part.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/aio.c')
-rw-r--r-- | fs/aio.c | 7 |
1 files changed, 3 insertions, 4 deletions
@@ -1197,14 +1197,13 @@ static long aio_read_events_ring(struct kioctx *ctx, if (head == tail) break; - avail = min(avail, nr - ret); - avail = min_t(long, avail, AIO_EVENTS_PER_PAGE - - ((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE)); - pos = head + AIO_EVENTS_OFFSET; page = ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]; pos %= AIO_EVENTS_PER_PAGE; + avail = min(avail, nr - ret); + avail = min_t(long, avail, AIO_EVENTS_PER_PAGE - pos); + ev = kmap(page); copy_ret = copy_to_user(event + ret, ev + pos, sizeof(*ev) * avail); |