Skip to contentSkip to conversation

aio: clean up aio ring in the fail path

PATCH In review Gu Zheng 3 participants 7 messages Dec 4, 2013 – Dec 6, 2013

Subsystems (2)
lore
Share & tools
lore

Gu Zheng

author
#0 lore raw

PATCH 1/1 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/898

---
 fs/aio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
index 08159ed..6efb7f6 100644
@@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
 	if (nr_pages > AIO_RING_PAGES) {
 		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
 					  GFP_KERNEL);
-		if (!ctx->ring_pages)
+		if (!ctx->ring_pages) {
+			put_aio_ring_file(ctx);
 			return -ENOMEM;
+		}
 	}
 
 	ctx->mmap_size = nr_pages * PAGE_SIZE;
@@ -645,7 +647,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 	    aio_nr + nr_events < aio_nr) {
 		spin_unlock(&aio_nr_lock);
 		err = -EAGAIN;
-		goto err;
+		goto err_ctx;
 	}
 	aio_nr += ctx->max_reqs;
 	spin_unlock(&aio_nr_lock);
@@ -662,6 +664,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 
 err_cleanup:
 	aio_nr_sub(ctx->max_reqs);
+err_ctx:
+	aio_free_ring(ctx);
 err:
 	free_percpu(ctx->cpu);
 	free_percpu(ctx->reqs.pcpu_count);
Signature · 1 line
1.7.7
#1 lore raw
Quoted 16 lines · Gu Zheng

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/898

---
 fs/aio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +0 -0
index 08159ed..6efb7f6 100644

fs/aio.c static int aio_setup_ring(struct kioctx *ctx) · line 375

Quoted 10 lines
fs/aio.c +3 -1
@@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
 	if (nr_pages > AIO_RING_PAGES) {
 		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
 					  GFP_KERNEL);
-		if (!ctx->ring_pages)
+		if (!ctx->ring_pages) {
+			put_aio_ring_file(ctx);
 			return -ENOMEM;
+		}
 	}
 

CC fs/aio.o
fs/aio.c: In function ‘aio_setup_ring’:
fs/aio.c:363:4: error: implicit declaration of function ‘put_aio_ring_file’ [-Werror=implicit-function-declaration]

    put_aio_ring_file(ctx);

Is this dependant on another patch ?

Dave

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>

author
#2 lore raw

Hi Dave,

Quoted 31 lines · Dave Jones
Quoted 16 lines · Gu Zheng

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/898

---
 fs/aio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +0 -0
index 08159ed..6efb7f6 100644

fs/aio.c static int aio_setup_ring(struct kioctx *ctx) · line 375

Quoted 10 lines
fs/aio.c +3 -1
@@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
 	if (nr_pages > AIO_RING_PAGES) {
 		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
 					  GFP_KERNEL);
-		if (!ctx->ring_pages)
+		if (!ctx->ring_pages) {
+			put_aio_ring_file(ctx);
 			return -ENOMEM;
+		}
 	}
 

CC fs/aio.o
fs/aio.c: In function ‘aio_setup_ring’:
fs/aio.c:363:4: error: implicit declaration of function ‘put_aio_ring_file’ [-Werror=implicit-function-declaration]

Quoted 4 lines
    put_aio_ring_file(ctx);

Is this dependant on another patch ?

It's applied on 3.12-rc2. Please ignore the previous defective patch I sent before, and try again.

Regards,
Gu

Quoted 9 lines

Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw
Quoted 38 lines · Gu Zheng

Hi Dave,

Quoted 34 lines · Dave Jones
Quoted 16 lines · Gu Zheng

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/898

---
 fs/aio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +0 -0
index 08159ed..6efb7f6 100644

fs/aio.c static int aio_setup_ring(struct kioctx *ctx) · line 375

Quoted 10 lines
fs/aio.c +3 -1
@@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
 	if (nr_pages > AIO_RING_PAGES) {
 		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
 					  GFP_KERNEL);
-		if (!ctx->ring_pages)
+		if (!ctx->ring_pages) {
+			put_aio_ring_file(ctx);
 			return -ENOMEM;
+		}
 	}
 

CC fs/aio.o
fs/aio.c: In function ‘aio_setup_ring’:
fs/aio.c:363:4: error: implicit declaration of function ‘put_aio_ring_file’ [-Werror=implicit-function-declaration]

    put_aio_ring_file(ctx);
Quoted 3 lines
Quoted 1 line

Is this dependant on another patch ?

It's applied on 3.12-rc2. Please ignore the previous defective patch I sent

Sorry, s/3.12-rc2/3.13-rc2/

Quoted 16 lines

before, and try again.

Regards,
Gu

Quoted 9 lines

Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>

maintainer
#4 lore raw
In reply to Gu Zheng
Quoted 4 lines · Gu Zheng

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/898

Good catch. I've applied this to my aio-next tree. It does indeed look like it could be the cause of Dave's GPF -- I'll try to trigger it with some other kernel debug options on and see if the EAGAIN failure case can trip it up.

-ben

Quoted 42 lines
---
 fs/aio.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
fs/aio.c +6 -2
index 08159ed..6efb7f6 100644
@@ -367,8 +367,10 @@ static int aio_setup_ring(struct kioctx *ctx)
 	if (nr_pages > AIO_RING_PAGES) {
 		ctx->ring_pages = kcalloc(nr_pages, sizeof(struct page *),
 					  GFP_KERNEL);
-		if (!ctx->ring_pages)
+		if (!ctx->ring_pages) {
+			put_aio_ring_file(ctx);
 			return -ENOMEM;
+		}
 	}
 
 	ctx->mmap_size = nr_pages * PAGE_SIZE;
@@ -645,7 +647,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 	    aio_nr + nr_events < aio_nr) {
 		spin_unlock(&aio_nr_lock);
 		err = -EAGAIN;
-		goto err;
+		goto err_ctx;
 	}
 	aio_nr += ctx->max_reqs;
 	spin_unlock(&aio_nr_lock);
@@ -662,6 +664,8 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
 
 err_cleanup:
 	aio_nr_sub(ctx->max_reqs);
+err_ctx:
+	aio_free_ring(ctx);
 err:
 	free_percpu(ctx->cpu);
 	free_percpu(ctx->reqs.pcpu_count);
Signature · 1 line
1.7.7
Signature · 7 lines
"Thought is the essence of where you are now."

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to [email protected].  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>
#5 lore raw
Quoted 10 lines · Benjamin LaHaise
Quoted 4 lines · Gu Zheng

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/898

Good catch. I've applied this to my aio-next tree. It does indeed look like it could be the cause of Dave's GPF -- I'll try to trigger it with some other kernel debug options on and see if the EAGAIN failure case can trip it up.

I think I forgot to reply and let you know this seems to fix it for me.

Dave

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>

maintainer
#6 lore raw
Quoted 7 lines · Dave Jones
Quoted 6 lines · Benjamin LaHaise
Quoted 4 lines · Gu Zheng

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/898

Quoted 6 lines
Quoted 4 lines

Good catch. I've applied this to my aio-next tree. It does indeed look like it could be the cause of Dave's GPF -- I'll try to trigger it with some other kernel debug options on and see if the EAGAIN failure case can trip it up.

I think I forgot to reply and let you know this seems to fix it for me.

Excellent! I'll send this out and get it queued up for -stable as well.

-ben

Quoted 1 line

Dave

Signature · 7 lines
"Thought is the essence of where you are now."

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in
the body to [email protected].  For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>