xfs: update i_size after unwritten conversion in dio completion
Since commit d531d91d69
("xfs: always use unwritten extents for
direct I/O writes"), we start allocating unwritten extents for all
direct writes to allow appending aio in XFS.
But for dio writes that could extend file size we update the in-core
inode size first, then convert the unwritten extents to real
allocations at dio completion time in xfs_dio_write_end_io(). Thus a
racing direct read could see the new i_size and find the unwritten
extents first and read zeros instead of actual data, if the direct
writer also takes a shared iolock.
Fix it by updating the in-core inode size after the unwritten extent
conversion. To do this, introduce a new boolean argument to
xfs_iomap_write_unwritten() to tell if we want to update in-core
i_size or not.
Suggested-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
This commit is contained in:

committed by
Darrick J. Wong

parent
546e7be824
commit
ee70daaba8
@@ -274,7 +274,7 @@ xfs_fs_commit_blocks(
|
||||
(end - 1) >> PAGE_SHIFT);
|
||||
WARN_ON_ONCE(error);
|
||||
|
||||
error = xfs_iomap_write_unwritten(ip, start, length);
|
||||
error = xfs_iomap_write_unwritten(ip, start, length, false);
|
||||
if (error)
|
||||
goto out_drop_iolock;
|
||||
}
|
||||
|
Reference in New Issue
Block a user