From: Jan Kara <jack@suse.cz>
To: linux-fsdevel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
hch@infradead.org, viro@ZenIV.linux.org.uk,
Jan Kara <jack@suse.cz>
Subject: [PATCH] aio: Do not return -ERESTARTSYS (and friends) from AIO
Date: Thu, 24 Jun 2010 01:43:47 +0200 [thread overview]
Message-ID: <1277336627-31193-1-git-send-email-jack@suse.cz> (raw)
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
next reply other threads:[~2010-06-23 23:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-23 23:43 Jan Kara [this message]
2010-08-18 18:31 ` [PATCH] aio: Do not return -ERESTARTSYS (and friends) from AIO Jeff Moyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277336627-31193-1-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).