Skip to content

Commit d2988bd

Browse files
author
Al Viro
committed
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>
1 parent 9061d14 commit d2988bd

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

‎fs/aio.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,14 +1197,13 @@ static long aio_read_events_ring(struct kioctx *ctx,
11971197
if (head == tail)
11981198
break;
11991199

1200-
avail = min(avail, nr - ret);
1201-
avail = min_t(long, avail, AIO_EVENTS_PER_PAGE -
1202-
((head + AIO_EVENTS_OFFSET) % AIO_EVENTS_PER_PAGE));
1203-
12041200
pos = head + AIO_EVENTS_OFFSET;
12051201
page = ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE];
12061202
pos %= AIO_EVENTS_PER_PAGE;
12071203

1204+
avail = min(avail, nr - ret);
1205+
avail = min_t(long, avail, AIO_EVENTS_PER_PAGE - pos);
1206+
12081207
ev = kmap(page);
12091208
copy_ret = copy_to_user(event + ret, ev + pos,
12101209
sizeof(*ev) * avail);

0 commit comments

Comments
 (0)