linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Small bug fix for aio
@ 2003-04-23  1:54 Mingming Cao
  2003-04-24  3:14 ` Benjamin LaHaise
  0 siblings, 1 reply; 3+ messages in thread
From: Mingming Cao @ 2003-04-23  1:54 UTC (permalink / raw)
  To: bcrl, akpm; +Cc: linux-kernel, linux-aio

[-- Attachment #1: Type: text/plain, Size: 199 bytes --]

Hi,

Here is a trivial patch fixed a bug in ioctx_alloc(). If
aio_setup_ring() failed, ioctx_alloc() should pass the return error from
aio_setup_ring() back to sys_io_setup().

Please apply. Thanks.

[-- Attachment #2: aiofix.patch --]
[-- Type: text/x-patch, Size: 887 bytes --]

diff -urNp linux-2.5.68/fs/aio.c 2568/fs/aio.c
--- linux-2.5.68/fs/aio.c	Sat Apr 19 19:49:25 2003
+++ 2568/fs/aio.c	Tue Apr 22 17:52:21 2003
@@ -204,6 +204,7 @@ static struct kioctx *ioctx_alloc(unsign
 {
 	struct mm_struct *mm;
 	struct kioctx *ctx;
+	int ret = 0;
 
 	/* Prevent overflows */
 	if ((nr_events > (0x10000000U / sizeof(struct io_event))) ||
@@ -233,7 +234,8 @@ static struct kioctx *ioctx_alloc(unsign
 	INIT_LIST_HEAD(&ctx->run_list);
 	INIT_WORK(&ctx->wq, aio_kick_handler, ctx);
 
-	if (aio_setup_ring(ctx) < 0)
+	ret = aio_setup_ring(ctx);
+	if (unlikely(ret < 0))
 		goto out_freectx;
 
 	/* limit the number of system wide aios */
@@ -259,7 +261,7 @@ out_cleanup:
 
 out_freectx:
 	kmem_cache_free(kioctx_cachep, ctx);
-	ctx = ERR_PTR(-ENOMEM);
+	ctx = ERR_PTR(ret);
 
 	dprintk("aio: error allocating ioctx %p\n", ctx);
 	return ctx;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Small bug fix for aio
  2003-04-23  1:54 [PATCH] Small bug fix for aio Mingming Cao
@ 2003-04-24  3:14 ` Benjamin LaHaise
  2003-04-24 20:21   ` Mingming Cao
  0 siblings, 1 reply; 3+ messages in thread
From: Benjamin LaHaise @ 2003-04-24  3:14 UTC (permalink / raw)
  To: Mingming Cao; +Cc: akpm, linux-kernel, linux-aio

On Tue, Apr 22, 2003 at 06:54:51PM -0700, Mingming Cao wrote:
> Here is a trivial patch fixed a bug in ioctx_alloc(). If
> aio_setup_ring() failed, ioctx_alloc() should pass the return error from
> aio_setup_ring() back to sys_io_setup().

This particular case was intentional: -ENOMEM really is the right return 
code when the ring cannot be allocated.  Mixing it up with the potential 
return codes from do_mmap or other functions might result in a very 
nonsensical return.  Perhaps someone can provide an arguement in favour 
of propagating the value, but I think it really can only mean "you asked 
the kernel to allocate too much memory or did something stupidly buggy with 
threads".  Cheers,

		-ben
-- 
Junk email?  <a href="mailto:aart@kvack.org">aart@kvack.org</a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Small bug fix for aio
  2003-04-24  3:14 ` Benjamin LaHaise
@ 2003-04-24 20:21   ` Mingming Cao
  0 siblings, 0 replies; 3+ messages in thread
From: Mingming Cao @ 2003-04-24 20:21 UTC (permalink / raw)
  To: Benjamin LaHaise; +Cc: akpm, linux-kernel, linux-aio

On Wed, 2003-04-23 at 20:14, Benjamin LaHaise wrote:
> On Tue, Apr 22, 2003 at 06:54:51PM -0700, Mingming Cao wrote:
> > Here is a trivial patch fixed a bug in ioctx_alloc(). If
> > aio_setup_ring() failed, ioctx_alloc() should pass the return error from
> > aio_setup_ring() back to sys_io_setup().
> 
> This particular case was intentional: -ENOMEM really is the right return 
> code when the ring cannot be allocated.  Mixing it up with the potential 
> return codes from do_mmap or other functions might result in a very 
> nonsensical return.  Perhaps someone can provide an arguement in favour 
> of propagating the value, but I think it really can only mean "you asked 
> the kernel to allocate too much memory or did something stupidly buggy with 
> threads".  Cheers,
> 
> 		-ben

Ok, then I think -ENOMEM makes more sense. Thanks for clarifying.


Mingming


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-24 20:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-23  1:54 [PATCH] Small bug fix for aio Mingming Cao
2003-04-24  3:14 ` Benjamin LaHaise
2003-04-24 20:21   ` Mingming Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).