From: Dave Chinner Date: Thu, 16 Apr 2015 12:03:17 +0000 (+1000) Subject: xfs: direct IO EOF zeroing needs to drain AIO X-Git-Tag: v4.1-rc1~31^2^2~1 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=40c63fbc55a968383b8bb5cacad81585e80cd323;p=karo-tx-linux.git 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 Reviewed-by: Brian Foster Signed-off-by: Dave Chinner --- 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: xfs_rw_iunlock(ip, *iolock); *iolock = XFS_IOLOCK_EXCL; xfs_rw_ilock(ip, *iolock); + + /* + * We now have an IO submission barrier in place, but + * AIO can do EOF updates during IO completion and hence + * we now need to wait for all of them to drain. Non-AIO + * DIO will have drained before we are given the + * XFS_IOLOCK_EXCL, and so for most cases this wait is a + * no-op. + */ + inode_dio_wait(inode); goto restart; } error = xfs_zero_eof(ip, *pos, i_size_read(inode));