diff options
-rw-r--r-- | fs/aio.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -92,8 +92,10 @@ static void aio_free_ring(struct kioctx *ctx) | |||
92 | for (i=0; i<info->nr_pages; i++) | 92 | for (i=0; i<info->nr_pages; i++) |
93 | put_page(info->ring_pages[i]); | 93 | put_page(info->ring_pages[i]); |
94 | 94 | ||
95 | if (info->mmap_size) | 95 | if (info->mmap_size) { |
96 | BUG_ON(ctx->mm != current->mm); | ||
96 | vm_munmap(ctx->mm, info->mmap_base, info->mmap_size); | 97 | vm_munmap(ctx->mm, info->mmap_base, info->mmap_size); |
98 | } | ||
97 | 99 | ||
98 | if (info->ring_pages && info->ring_pages != info->internal_pages) | 100 | if (info->ring_pages && info->ring_pages != info->internal_pages) |
99 | kfree(info->ring_pages); | 101 | kfree(info->ring_pages); |
@@ -386,6 +388,17 @@ void exit_aio(struct mm_struct *mm) | |||
386 | "exit_aio:ioctx still alive: %d %d %d\n", | 388 | "exit_aio:ioctx still alive: %d %d %d\n", |
387 | atomic_read(&ctx->users), ctx->dead, | 389 | atomic_read(&ctx->users), ctx->dead, |
388 | ctx->reqs_active); | 390 | ctx->reqs_active); |
391 | /* | ||
392 | * We don't need to bother with munmap() here - | ||
393 | * exit_mmap(mm) is coming and it'll unmap everything. | ||
394 | * Since aio_free_ring() uses non-zero ->mmap_size | ||
395 | * as indicator that it needs to unmap the area, | ||
396 | * just set it to 0; aio_free_ring() is the only | ||
397 | * place that uses ->mmap_size, so it's safe. | ||
398 | * That way we get all munmap done to current->mm - | ||
399 | * all other callers have ctx->mm == current->mm. | ||
400 | */ | ||
401 | ctx->ring_info.mmap_size = 0; | ||
389 | put_ioctx(ctx); | 402 | put_ioctx(ctx); |
390 | } | 403 | } |
391 | } | 404 | } |