From: Chris Mason While testing fsaio here, I hit an oops in kick_iocb because iocb->mm was null. This was right as the program was exiting. With the patch below, I wasn't able to reproduce, it makes sure we flush the workqueue every time __put_ioctx gets called. Index: linux.t/fs/aio.c =================================================================== --- linux.t.orig/fs/aio.c 2004-03-18 14:30:32.000000000 -0500 +++ linux.t/fs/aio.c 2004-03-18 17:00:05.000000000 -0500 @@ -372,6 +372,7 @@ void fastcall __put_ioctx(struct kioctx if (unlikely(ctx->reqs_active)) BUG(); + flush_workqueue(aio_wq); aio_free_ring(ctx); mmdrop(ctx->mm); ctx->mm = NULL; @@ -1199,11 +1200,6 @@ static void io_destroy(struct kioctx *io aio_cancel_all(ioctx); wait_for_all_aios(ioctx); - /* - * this is an overkill, but ensures we don't leave - * the ctx on the aio_wq - */ - flush_workqueue(aio_wq); put_ioctx(ioctx); /* once for the lookup */ }