All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* + aio-io_getevents-should-return-if-io_destroy-is-invoked.patch added to -mm tree
@ 2008-04-15 19:55 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2008-04-15 19:55 UTC (permalink / raw
  To: mm-commits; +Cc: jmoyer, bcrl, x, zach.brown


The patch titled
     aio: io_getevents() should return if io_destroy() is invoked
has been added to the -mm tree.  Its filename is
     aio-io_getevents-should-return-if-io_destroy-is-invoked.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: aio: io_getevents() should return if io_destroy() is invoked
From: Jeff Moyer <jmoyer@redhat.com>

This patch wakes up a thread waiting in io_getevents if another thread
destroys the context.  This was tested using a small program that spawns a
thread to wait in io_getevents while the parent thread destroys the io context
and then waits for the getevents thread to exit.  Without this patch, the
program hangs indefinitely.  With the patch, the program exits as expected.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Christopher Smith <x@xman.org>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/aio.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff -puN fs/aio.c~aio-io_getevents-should-return-if-io_destroy-is-invoked fs/aio.c
--- a/fs/aio.c~aio-io_getevents-should-return-if-io_destroy-is-invoked
+++ a/fs/aio.c
@@ -1177,7 +1177,10 @@ retry:
 				break;
 			if (min_nr <= i)
 				break;
-			ret = 0;
+			if (unlikely(ctx->dead)) {
+				ret = -EINVAL;
+				break;
+			}
 			if (to.timed_out)	/* Only check after read evt */
 				break;
 			/* Try to only show up in io wait if there are ops
@@ -1242,6 +1245,13 @@ static void io_destroy(struct kioctx *io
 
 	aio_cancel_all(ioctx);
 	wait_for_all_aios(ioctx);
+
+	/*
+	 * Wake up any waiters.  The setting of ctx->dead must be seen
+	 * by other CPUs at this point.  Right now, we rely on the
+	 * locking done by the above calls to ensure this consistency.
+	 */
+	wake_up(&ioctx->wait);
 	put_ioctx(ioctx);	/* once for the lookup */
 }
 
_

Patches currently in -mm which might be from jmoyer@redhat.com are

aio-io_getevents-should-return-if-io_destroy-is-invoked.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-15 19:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-15 19:55 + aio-io_getevents-should-return-if-io_destroy-is-invoked.patch added to -mm tree akpm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.