aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Moyer <jmoyer@redhat.com>2008-04-28 05:12:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:17 -0400
commite92adcba261fd391591bb63c1703185a04a41554 (patch)
tree83cd94eaa57931da66137a65089a0bcdddf20533
parent180c06efce691f2b721dd0d965079827bdd7ee03 (diff)
aio: io_getevents() should return if io_destroy() is invoked
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> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/aio.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 228368610dfa..ae94e1dea266 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1166,7 +1166,10 @@ retry:
1166 break; 1166 break;
1167 if (min_nr <= i) 1167 if (min_nr <= i)
1168 break; 1168 break;
1169 ret = 0; 1169 if (unlikely(ctx->dead)) {
1170 ret = -EINVAL;
1171 break;
1172 }
1170 if (to.timed_out) /* Only check after read evt */ 1173 if (to.timed_out) /* Only check after read evt */
1171 break; 1174 break;
1172 /* Try to only show up in io wait if there are ops 1175 /* Try to only show up in io wait if there are ops
@@ -1231,6 +1234,13 @@ static void io_destroy(struct kioctx *ioctx)
1231 1234
1232 aio_cancel_all(ioctx); 1235 aio_cancel_all(ioctx);
1233 wait_for_all_aios(ioctx); 1236 wait_for_all_aios(ioctx);
1237
1238 /*
1239 * Wake up any waiters. The setting of ctx->dead must be seen
1240 * by other CPUs at this point. Right now, we rely on the
1241 * locking done by the above calls to ensure this consistency.
1242 */
1243 wake_up(&ioctx->wait);
1234 put_ioctx(ioctx); /* once for the lookup */ 1244 put_ioctx(ioctx); /* once for the lookup */
1235} 1245}
1236 1246