path: root/fs
diff options
authorMatthew Bobrowski <mbobrowski@mbobrowski.org>2019-09-19 15:32:44 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-09-19 15:32:44 -0700
commit6fe7b9901400152238e1b76198747f6716c78aad (patch)
tree08ae8dd10545ba16c4d38a19da5f9d45204fbde8 /fs
parent609488bc979f99f805f34e9a32c1e3b71179d10b (diff)
iomap: split size and error for iomap_dio_rw ->end_io
Modify the calling convention for the iomap_dio_rw ->end_io() callback. Rather than passing either dio->error or dio->size as the 'size' argument, instead pass both the dio->error and the dio->size value separately. In the instance that an error occurred during a write, we currently cannot determine whether any blocks have been allocated beyond the current EOF and data has subsequently been written to these blocks within the ->end_io() callback. As a result, we cannot judge whether we should take the truncate failed write path. Having both dio->error and dio->size will allow us to perform such checks within this callback. Signed-off-by: Matthew Bobrowski <mbobrowski@mbobrowski.org> [hch: minor cleanups] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Diffstat (limited to 'fs')
2 files changed, 8 insertions, 9 deletions
diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
index 10517cea9682..2ccf1c6460d4 100644
--- a/fs/iomap/direct-io.c
+++ b/fs/iomap/direct-io.c
@@ -77,13 +77,10 @@ static ssize_t iomap_dio_complete(struct iomap_dio *dio)
loff_t offset = iocb->ki_pos;
ssize_t ret;
- if (dio->end_io) {
- ret = dio->end_io(iocb,
- dio->error ? dio->error : dio->size,
- dio->flags);
- } else {
+ if (dio->end_io)
+ ret = dio->end_io(iocb, dio->size, dio->error, dio->flags);
+ else
ret = dio->error;
- }
if (likely(!ret)) {
ret = dio->size;
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 28101bbc0b78..74411296f6b5 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -369,21 +369,23 @@ static int
struct kiocb *iocb,
ssize_t size,
+ int error,
unsigned flags)
struct inode *inode = file_inode(iocb->ki_filp);
struct xfs_inode *ip = XFS_I(inode);
loff_t offset = iocb->ki_pos;
unsigned int nofs_flag;
- int error = 0;
trace_xfs_end_io_direct_write(ip, offset, size);
if (XFS_FORCED_SHUTDOWN(ip->i_mount))
return -EIO;
- if (size <= 0)
- return size;
+ if (error)
+ return error;
+ if (!size)
+ return 0;
* Capture amount written on completion as we can't reliably account

Privacy Policy