[PATCH 2.5.71-mm1] aio process hang on EINVAL

Daniel McNeil
2003-06-17T00:29:27Z

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

Andrew,

Here is a patch to fix EINVAL handling in io_submit_one() that was
causing a process hang when attempting AIO to a device not able
to handle aio. I hit this doing a AIO read from /dev/zero. The
process would hang on exit in wait_for_all_aios(). The fix is
to check for EINVAL coming back from aio_setup_iocb() in addition
to the EFAULT and EBADF already there. This causes the io_submit
to fail with EINVAL. That check looks error prone.
Are there other error return values where it should jump to the
aio_put_req()? Should the check be:

if (ret != 0 && ret != -EIOCBQUEUED)
goto out_put_req;

Thanks,

Daniel McNeil <daniel@osdl.org>

[-- Attachment #2: patch.2.5.71-mm1.aio --]
[-- Type: text/x-patch, Size: 512 bytes --]

diff -rupN -X /home/daniel_nfs/dontdiff linux-2.5.71-mm1/fs/aio.c linux-2.5.71-mm1.patch/fs/aio.c
--- linux-2.5.71-mm1/fs/aio.c 2003-06-16 15:17:22.000000000 -0700
+++ linux-2.5.71-mm1.patch/fs/aio.c 2003-06-16 16:46:27.515255621 -0700
@@ -1504,7 +1504,7 @@ int io_submit_one(struct kioctx *ctx, st

ret = aio_setup_iocb(req, iocb);

- if ((-EBADF == ret) || (-EFAULT == ret))
+ if ((-EBADF == ret) || (-EFAULT == ret) || (-EINVAL == ret))
goto out_put_req;

spin_lock_irq(&ctx->ctx_lock);