diff options
author | Dave Chinner <dchinner@redhat.com> | 2015-04-16 08:03:17 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2015-04-16 08:03:17 -0400 |
commit | 40c63fbc55a968383b8bb5cacad81585e80cd323 (patch) | |
tree | 0cfdfc602b33218142eddc75d3642bbc06a3bcd5 /fs/xfs/xfs_file.c | |
parent | b9d59846f73713d77f0f3fb784c7f84249fc2b93 (diff) |
xfs: direct IO EOF zeroing needs to drain AIO
When we are doing AIO DIO writes, the IOLOCK only provides an IO
submission barrier. When we need to do EOF zeroing, we need to ensure
that no other IO is in progress and all pending in-core EOF updates
have been completed. This requires us to wait for all outstanding
AIO DIO writes to the inode to complete and, if necessary, run their
EOF updates.
Once all the EOF updates are complete, we can then restart
xfs_file_aio_write_checks() while holding the IOLOCK_EXCL, knowing
that EOF is up to date and we have exclusive IO access to the file
so we can run EOF block zeroing if we need to without interference.
This gives EOF zeroing the same exclusivity against other IO as we
provide truncate operations.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_file.c')
-rw-r--r-- | fs/xfs/xfs_file.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 2323b8b63183..f6f0e9671919 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -581,6 +581,16 @@ restart: | |||
581 | xfs_rw_iunlock(ip, *iolock); | 581 | xfs_rw_iunlock(ip, *iolock); |
582 | *iolock = XFS_IOLOCK_EXCL; | 582 | *iolock = XFS_IOLOCK_EXCL; |
583 | xfs_rw_ilock(ip, *iolock); | 583 | xfs_rw_ilock(ip, *iolock); |
584 | |||
585 | /* | ||
586 | * We now have an IO submission barrier in place, but | ||
587 | * AIO can do EOF updates during IO completion and hence | ||
588 | * we now need to wait for all of them to drain. Non-AIO | ||
589 | * DIO will have drained before we are given the | ||
590 | * XFS_IOLOCK_EXCL, and so for most cases this wait is a | ||
591 | * no-op. | ||
592 | */ | ||
593 | inode_dio_wait(inode); | ||
584 | goto restart; | 594 | goto restart; |
585 | } | 595 | } |
586 | error = xfs_zero_eof(ip, *pos, i_size_read(inode)); | 596 | error = xfs_zero_eof(ip, *pos, i_size_read(inode)); |