direct-io: always call ->end_io if non-NULL

This way we can pass back errors to the file system, and allow for
cleanup required for all direct I/O invocations.

Also allow the ->end_io handlers to return errors on their own, so that
I/O completion errors can be passed on to the callers.

Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Dave Chinner <[email protected]>
Signed-off-by: Dave Chinner <[email protected]>
This commit is contained in:
Christoph Hellwig 2016-02-08 14:40:51 +11:00 • committed by Dave Chinner
commit 187372a3b9
6 changed files with 35 additions and 14 deletions

View file

@ -253,8 +253,13 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
if (ret == 0)
ret = transferred;
if (dio->end_io && dio->result)
dio->end_io(dio->iocb, offset, transferred, dio->private);
if (dio->end_io) {
int err;
err = dio->end_io(dio->iocb, offset, ret, dio->private);
if (err)
ret = err;
}
if (!(dio->flags & DIO_SKIP_DIO_COUNT))
inode_dio_end(dio->inode);