Current direct io allocation behavior is inconvenient. Partial writes are not supported. If we try to issue 10Mb chunk, but only 5Mb is available then we will allocate thees 5Mb until ENOSPC, and then drop such space and return ENOSPC. Partial success was rejected because it wasn't obvious how to distinguish non fatal errors (ENOSPC,EDQUOT,ENOMEM, etc) from fatal ones (EIO,EFAULT, and so on). But in fact there are only two sources of fatal error: 1) from bi_end_io and result in EIO and saved to dio->io_error 2) from get_user_pages_fast and saved to dio->page_errors In case of partial write it is safe to ignore error code because in case of fatal error it will be restored and returned to caller from dio_complete(). Signed-off-by: Dmitry Monakhov <dmonakhov@xxxxxxxxxx> --- fs/direct-io.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index e82adc2..1298dc3 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -230,7 +230,13 @@ static int dio_complete(struct dio *dio, loff_t offset, int ret) if (dio->result) { transferred = dio->result; - + /* + * Ignore non fatal error if some data was written. + * Fatal error was saved in dio structure and will be + * restored later at the bottom of the function. + */ + if (dio->rw & WRITE) + ret = 0; /* Check for short read case */ if ((dio->rw == READ) && ((offset + transferred) > dio->i_size)) transferred = dio->i_size - offset; -- 1.6.6.1 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html