linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] aio: Do not return -ERESTARTSYS (and friends) from AIO
@ 2010-06-23 23:43 Jan Kara
  2010-08-18 18:31 ` Jeff Moyer
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2010-06-23 23:43 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Andrew Morton, hch, viro, Jan Kara

We must not leak ERESTARTSYS (and similar error codes) to userspace as a return
value of IO. Because other AIO could have been already submitted by the same
io_submit syscall, there is no easy way to restart the syscall. So we do not
have much other options than fail the particular IO with EINTR.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/aio.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

 Not sure who should merge it... Andrew?

diff --git a/fs/aio.c b/fs/aio.c
index 1ccf25c..66e2d42 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -712,8 +712,18 @@ static ssize_t aio_run_iocb(struct kiocb *iocb)
 	 */
 	ret = retry(iocb);
 
-	if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED)
+	if (ret != -EIOCBRETRY && ret != -EIOCBQUEUED) {
+		/*
+		 * There's no easy way to restart the syscall since other AIO's
+		 * may be already running. Just fail this IO with EINTR.
+		 */
+		if (unlikely(ret == -ERESTARTSYS ||
+			     ret == -ERESTARTNOINTR ||
+			     ret == -ERESTARTNOHAND ||
+			     ret == -ERESTART_RESTARTBLOCK))
+			ret = -EINTR;
 		aio_complete(iocb, ret, 0);
+	}
 out:
 	spin_lock_irq(&ctx->ctx_lock);
 
-- 
1.6.4.2


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

end of thread, other threads:[~2010-08-18 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-23 23:43 [PATCH] aio: Do not return -ERESTARTSYS (and friends) from AIO Jan Kara
2010-08-18 18:31 ` Jeff Moyer

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).