diff options
author | Benjamin LaHaise <bcrl@kvack.org> | 2013-03-02 15:25:57 +1100 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2013-03-07 14:27:34 +1100 |
commit | 0469a6904b0e15d57d4e72c15a0a58b76091c760 (patch) | |
tree | 9d42d3342dddbc323967d728398c70c11a5f5851 /fs | |
parent | 58b3ff8f76eb36b8e28846602ec670bc47fb2fd5 (diff) |
aio: correct calculation of available events
When the number of available events in the ring buffer is calculated, the
avail calculation is incorrect when head == tail. This is harmless in
aio_read_events_ring(), but in free_ioctx() leads to the subsequent
WARN_ON(atomic_read(&ctx->reqs_available) > ctx->nr). Correct this.
Signed-off-by: Benjamin LaHaise <bcrl@kvack.org>
Reviewed-by: Kent Overstreet <koverstreet@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/aio.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -337,7 +337,8 @@ static void free_ioctx(struct kioctx *ctx) while (atomic_read(&ctx->reqs_available) < ctx->nr) { wait_event(ctx->wait, head != ctx->shadow_tail); - avail = (head < ctx->shadow_tail ? ctx->shadow_tail : ctx->nr) - head; + avail = (head <= ctx->shadow_tail ? + ctx->shadow_tail : ctx->nr) - head; atomic_add(avail, &ctx->reqs_available); head += avail; @@ -885,7 +886,7 @@ static long aio_read_events_ring(struct kioctx *ctx, goto out; while (ret < nr) { - long avail = (head < ctx->shadow_tail + long avail = (head <= ctx->shadow_tail ? ctx->shadow_tail : ctx->nr) - head; struct io_event *ev; struct page *page; |