From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kara Subject: [PATCH] aio: Do not return ERESTARTSYS as a result of AIO (v2) Date: Thu, 9 Sep 2010 21:36:10 +0200 Message-ID: <1284060970-26829-1-git-send-email-jack@suse.cz> Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig , Jeff Moyer , Jan Kara To: Andrew Morton Return-path: Received: from cantor2.suse.de ([195.135.220.15]:46350 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751730Ab0IIThM (ORCPT ); Thu, 9 Sep 2010 15:37:12 -0400 Sender: linux-fsdevel-owner@vger.kernel.org List-ID: OCFS2 can return ERESTARTSYS from its write function when the process is signalled while waiting for a cluster lock (and the filesystem is mounted with intr mount option). Generally, it seems reasonable to allow filesystems to return this error code from its IO functions. As we must not leak ERESTARTSYS (and similar error codes) to userspace as a result of an AIO operation, we have to properly convert it to EINTR inside AIO code (restarting the syscall isn't really an option because other AIO could have been already submitted by the same io_submit syscall). Signed-off-by: Jan Kara --- fs/aio.c | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-) Andrew, I'm not sure what happened with the old version of the patch (I had a feeling you carried it in -mm but I cannot see it there now). Anyway, here's a new version with better changelog as several people raised questions about the previous one. Please consider merging it. Thanks. diff --git a/fs/aio.c b/fs/aio.c index 3006b5b..b73c9b5 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -712,8 +712,16 @@ 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