Commit d1b94327 authored by Gu Zheng's avatar Gu Zheng Committed by Benjamin LaHaise

aio: clean up aio ring in the fail path

Clean up the aio ring file in the fail path of aio_setup_ring
and ioctx_alloc. And maybe it can fix the GPF issue reported by
Dave Jones:
https://lkml.org/lkml/2013/11/25/898Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
Signed-off-by: default avatarBenjamin LaHaise <bcrl@kvack.org>
parent ddb8c45b
...@@ -316,9 +316,11 @@ static int aio_setup_ring(struct kioctx *ctx) ...@@ -316,9 +316,11 @@ static int aio_setup_ring(struct kioctx *ctx)
if (nr_pages > AIO_RING_PAGES) { if (nr_pages > AIO_RING_PAGES) {
ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *), ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
GFP_KERNEL); GFP_KERNEL);
if (!ctx->ring_pages) if (!ctx->ring_pages) {
put_aio_ring_file(ctx);
return -ENOMEM; return -ENOMEM;
} }
}
ctx->mmap_size = nr_pages * PAGE_SIZE; ctx->mmap_size = nr_pages * PAGE_SIZE;
pr_debug("attempting mmap of %lu bytes\n", ctx->mmap_size); pr_debug("attempting mmap of %lu bytes\n", ctx->mmap_size);
...@@ -594,7 +596,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) ...@@ -594,7 +596,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
aio_nr + nr_events < aio_nr) { aio_nr + nr_events < aio_nr) {
spin_unlock(&aio_nr_lock); spin_unlock(&aio_nr_lock);
err = -EAGAIN; err = -EAGAIN;
goto err; goto err_ctx;
} }
aio_nr += ctx->max_reqs; aio_nr += ctx->max_reqs;
spin_unlock(&aio_nr_lock); spin_unlock(&aio_nr_lock);
...@@ -611,6 +613,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events) ...@@ -611,6 +613,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
err_cleanup: err_cleanup:
aio_nr_sub(ctx->max_reqs); aio_nr_sub(ctx->max_reqs);
err_ctx:
aio_free_ring(ctx);
err: err:
free_percpu(ctx->cpu); free_percpu(ctx->cpu);
free_percpu(ctx->reqs.pcpu_count); free_percpu(ctx->reqs.pcpu_count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment