Ver Fonte

xfs: use ranged writeback and invalidation for direct IO

Now we are not doing silly things with dirtying buffers beyond EOF
and using invalidation correctly, we can finally reduce the ranges of
writeback and invalidation used by direct IO to match that of the IO
being issued.

Bring the writeback and invalidation ranges back to match the
generic direct IO code - this will greatly reduce the perturbation
of cached data when direct IO and buffered IO are mixed, but still
provide the same buffered vs direct IO coherency behaviour we
currently have.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Dave Chinner há 11 anos atrás
pai
commit
7d4ea3ce63
1 ficheiros alterados com 6 adições e 4 exclusões
  1. 6 4
      fs/xfs/xfs_file.c

+ 6 - 4
fs/xfs/xfs_file.c

@@ -291,7 +291,7 @@ xfs_file_read_iter(
 		if (inode->i_mapping->nrpages) {
 		if (inode->i_mapping->nrpages) {
 			ret = filemap_write_and_wait_range(
 			ret = filemap_write_and_wait_range(
 							VFS_I(ip)->i_mapping,
 							VFS_I(ip)->i_mapping,
-							pos, -1);
+							pos, pos + size - 1);
 			if (ret) {
 			if (ret) {
 				xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL);
 				xfs_rw_iunlock(ip, XFS_IOLOCK_EXCL);
 				return ret;
 				return ret;
@@ -303,7 +303,8 @@ xfs_file_read_iter(
 			 * happen on XFS. Warn if it does fail.
 			 * happen on XFS. Warn if it does fail.
 			 */
 			 */
 			ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
 			ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
-						pos >> PAGE_CACHE_SHIFT, -1);
+					pos >> PAGE_CACHE_SHIFT,
+					(pos + size - 1) >> PAGE_CACHE_SHIFT);
 			WARN_ON_ONCE(ret);
 			WARN_ON_ONCE(ret);
 			ret = 0;
 			ret = 0;
 		}
 		}
@@ -641,7 +642,7 @@ xfs_file_dio_aio_write(
 
 
 	if (mapping->nrpages) {
 	if (mapping->nrpages) {
 		ret = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
 		ret = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
-						    pos, -1);
+						    pos, pos + count - 1);
 		if (ret)
 		if (ret)
 			goto out;
 			goto out;
 		/*
 		/*
@@ -650,7 +651,8 @@ xfs_file_dio_aio_write(
 		 * happen on XFS. Warn if it does fail.
 		 * happen on XFS. Warn if it does fail.
 		 */
 		 */
 		ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
 		ret = invalidate_inode_pages2_range(VFS_I(ip)->i_mapping,
-						pos >> PAGE_CACHE_SHIFT, -1);
+					pos >> PAGE_CACHE_SHIFT,
+					(pos + count - 1) >> PAGE_CACHE_SHIFT);
 		WARN_ON_ONCE(ret);
 		WARN_ON_ONCE(ret);
 		ret = 0;
 		ret = 0;
 	}
 	}