LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/2] aio: partial write return
@ 2008-01-27 22:53 Rusty Russell
  2008-01-27 22:55 ` [PATCH 2/2] aio: -EINVAL on negative read/write offset Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2008-01-27 22:53 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Zach Brown

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 18802689361a fs/aio.c
--- a/fs/aio.c	Thu Jan 03 15:22:24 2008 +1100
+++ b/fs/aio.c	Thu Jan 03 18:05:25 2008 +1100
@@ -1346,6 +1350,13 @@ static ssize_t aio_rw_vect_retry(struct 
 	/* This means we must have transferred all that we could */
 	/* No need to retry anymore */
 	if ((ret == 0) || (iocb->ki_left == 0))
+		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] 2+ messages in thread

* [PATCH 2/2] aio: -EINVAL on negative read/write offset
  2008-01-27 22:53 [PATCH 1/2] aio: partial write return Rusty Russell
@ 2008-01-27 22:55 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2008-01-27 22:55 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, Zach Brown

An AIO read or write should return -EINVAL if the offset is negative.
This check matches the one in pread and pwrite.

This was found by the libaio test suite.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 fs/aio.c |    4 ++++
 1 file changed, 4 insertions(+)

diff -r 18802689361a fs/aio.c
--- a/fs/aio.c	Thu Jan 03 15:22:24 2008 +1100
+++ b/fs/aio.c	Thu Jan 03 18:05:25 2008 +1100
@@ -1330,6 +1330,10 @@ static ssize_t aio_rw_vect_retry(struct 
 		opcode = IOCB_CMD_PWRITEV;
 	}
 
+	/* This matches the pread()/pwrite() logic */
+	if (iocb->ki_pos < 0)
+		return -EINVAL;
+
 	do {
 		ret = rw_op(iocb, &iocb->ki_iovec[iocb->ki_cur_seg],
 			    iocb->ki_nr_segs - iocb->ki_cur_seg,

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

end of thread, other threads:[~2008-01-28  1:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-27 22:53 [PATCH 1/2] aio: partial write return Rusty Russell
2008-01-27 22:55 ` [PATCH 2/2] aio: -EINVAL on negative read/write offset Rusty Russell

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