aio: partial write return
PATCH 1/2 aio: partial write return
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 <[email protected]>
Acked-by Zach Brown <[email protected]>
--- fs/aio.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/aio.c +7 -0
@@ -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;
PATCH 2/2 aio: -EINVAL on negative read/write offset
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 <[email protected]>
--- fs/aio.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/aio.c +4 -0
@@ -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,