public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aio_write should tell userspace about partial writes
@ 2008-03-11 22:39 Rusty Russell
  2008-03-12 19:59 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Rusty Russell @ 2008-03-11 22:39 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel, Zach Brown, bcrl, linux-aio

[ Linus, please apply.  This patch was discussed and acked before,
  but somehow got lost. ]

When an AIO write gets a non-retry error after writing some data
(eg. ENOSPC), it should return the amount written already, not the
error.  Just like write() is supposed to.

This was found by the libaio test suite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Acked-By: Zach Brown <zach.brown@oracle.com>
---
 fs/aio.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -r c36fc295bb75 fs/aio.c
--- a/fs/aio.c	Tue Mar 11 09:04:47 2008 +1100
+++ b/fs/aio.c	Tue Mar 11 09:05:54 2008 +1100
@@ -1358,6 +1358,13 @@ static ssize_t aio_rw_vect_retry(struct 
 	    && iocb->ki_nbytes - iocb->ki_left)
 		ret = iocb->ki_nbytes - iocb->ki_left;
 
+	/* If we managed to write some out we return that, rather than
+	 * the eventual error. */
+	if (opcode == IOCB_CMD_PWRITEV
+	    && ret < 0 && ret != -EIOCBQUEUED && ret != -EIOCBRETRY
+	    && iocb->ki_nbytes - iocb->ki_left)
+		ret = iocb->ki_nbytes - iocb->ki_left;
+
 	return ret;
 }
 

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

end of thread, other threads:[~2008-03-12 22:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-11 22:39 [PATCH] aio_write should tell userspace about partial writes Rusty Russell
2008-03-12 19:59 ` Linus Torvalds
2008-03-12 22:12   ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox