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 <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
This commit is contained in:
Christoph Hellwig
2016-02-08 14:40:51 +11:00
committed by Dave Chinner
parent 36f90b0a2d
commit 187372a3b9
6 changed files with 35 additions and 14 deletions

View File

@@ -1645,7 +1645,7 @@ out_end_io:
* case the completion can be called in interrupt context, whereas if we have an
* ioend we will always be called in task context (i.e. from a workqueue).
*/
STATIC void
STATIC int
xfs_end_io_direct_write(
struct kiocb *iocb,
loff_t offset,
@@ -1655,15 +1655,19 @@ xfs_end_io_direct_write(
struct inode *inode = file_inode(iocb->ki_filp);
struct xfs_ioend *ioend = private;
if (size <= 0)
return 0;
trace_xfs_gbmap_direct_endio(XFS_I(inode), offset, size,
ioend ? ioend->io_type : 0, NULL);
if (!ioend) {
ASSERT(offset + size <= i_size_read(inode));
return;
return 0;
}
__xfs_end_io_direct_write(inode, ioend, offset, size);
return 0;
}
static inline ssize_t
@@ -1672,10 +1676,7 @@ xfs_vm_do_dio(
struct kiocb *iocb,
struct iov_iter *iter,
loff_t offset,
void (*endio)(struct kiocb *iocb,
loff_t offset,
ssize_t size,
void *private),
dio_iodone_t endio,
int flags)
{
struct block_device *bdev;