Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1285ff0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner
Browse files

xfs: stop using generic_file_read_iter for direct I/O



XFS already implement it's own flushing of the pagecache because it
implements proper synchronization for direct I/O reads.  This means
calling generic_file_read_iter for direct I/O is rather useless,
as it doesn't do much but updating the atime and iocb position for
us.  This also gets rid of the buffered I/O fallback that isn't used
for XFS.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent bbc5a740
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -289,12 +289,17 @@ xfs_file_dio_aio_read(
	struct address_space	*mapping = iocb->ki_filp->f_mapping;
	struct address_space	*mapping = iocb->ki_filp->f_mapping;
	struct inode		*inode = mapping->host;
	struct inode		*inode = mapping->host;
	struct xfs_inode	*ip = XFS_I(inode);
	struct xfs_inode	*ip = XFS_I(inode);
	loff_t			isize = i_size_read(inode);
	size_t			count = iov_iter_count(to);
	size_t			count = iov_iter_count(to);
	struct iov_iter		data;
	struct xfs_buftarg	*target;
	struct xfs_buftarg	*target;
	ssize_t			ret = 0;
	ssize_t			ret = 0;


	trace_xfs_file_direct_read(ip, count, iocb->ki_pos);
	trace_xfs_file_direct_read(ip, count, iocb->ki_pos);


	if (!count)
		return 0; /* skip atime */

	if (XFS_IS_REALTIME_INODE(ip))
	if (XFS_IS_REALTIME_INODE(ip))
		target = ip->i_mount->m_rtdev_targp;
		target = ip->i_mount->m_rtdev_targp;
	else
	else
@@ -303,7 +308,7 @@ xfs_file_dio_aio_read(
	if (!IS_DAX(inode)) {
	if (!IS_DAX(inode)) {
		/* DIO must be aligned to device logical sector size */
		/* DIO must be aligned to device logical sector size */
		if ((iocb->ki_pos | count) & target->bt_logical_sectormask) {
		if ((iocb->ki_pos | count) & target->bt_logical_sectormask) {
			if (iocb->ki_pos == i_size_read(inode))
			if (iocb->ki_pos == isize)
				return 0;
				return 0;
			return -EINVAL;
			return -EINVAL;
		}
		}
@@ -354,9 +359,15 @@ xfs_file_dio_aio_read(
		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
		xfs_rw_ilock_demote(ip, XFS_IOLOCK_EXCL);
	}
	}


	ret = generic_file_read_iter(iocb, to);
	data = *to;
	ret = mapping->a_ops->direct_IO(iocb, &data);
	if (ret > 0) {
		iocb->ki_pos += ret;
		iov_iter_advance(to, ret);
	}
	xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
	xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);


	file_accessed(iocb->ki_filp);
	return ret;
	return ret;
}
}