Skip to content

Commit

Permalink
Merge git://git.kvack.org/~bcrl/aio-fixes
Browse files Browse the repository at this point in the history
Pull aio bugfixes from Ben LaHaise:
 "Two small fixes"

* git://git.kvack.org/~bcrl/aio-fixes:
  aio: block exit_aio() until all context requests are completed
  aio: add missing smp_rmb() in read_events_ring
  • Loading branch information
torvalds committed Sep 4, 2014
2 parents 06ee709 + 6098b45 commit b7fece1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion fs/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ void exit_aio(struct mm_struct *mm)

for (i = 0; i < table->nr; ++i) {
struct kioctx *ctx = table->table[i];
struct completion requests_done =
COMPLETION_INITIALIZER_ONSTACK(requests_done);

if (!ctx)
continue;
Expand All @@ -804,7 +806,10 @@ void exit_aio(struct mm_struct *mm)
* that it needs to unmap the area, just set it to 0.
*/
ctx->mmap_size = 0;
kill_ioctx(mm, ctx, NULL);
kill_ioctx(mm, ctx, &requests_done);

/* Wait until all IO for the context are done. */
wait_for_completion(&requests_done);
}

RCU_INIT_POINTER(mm->ioctx_table, NULL);
Expand Down Expand Up @@ -1111,6 +1116,12 @@ static long aio_read_events_ring(struct kioctx *ctx,
tail = ring->tail;
kunmap_atomic(ring);

/*
* Ensure that once we've read the current tail pointer, that
* we also see the events that were stored up to the tail.
*/
smp_rmb();

pr_debug("h%u t%u m%u\n", head, tail, ctx->nr_events);

if (head == tail)
Expand Down

0 comments on commit b7fece1

Please sign in to comment.