[RHEL7,COMMIT] dax: dax_iomap_rw(): switch to iov_iter

Submitted by Konstantin Khorenko on May 25, 2020, 2:52 p.m.

Details

Message ID 202005251452.04PEqVf5004640@finist-ce7.sw.ru
State New
Series "fs, direct_IO: Switch to iov_iter and allow bio_vec for ext4"
Headers show

Commit Message

Konstantin Khorenko May 25, 2020, 2:52 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.1
------>
commit 42d93460df3eba89f20d416c5bc2f286c6b808f1
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Mon May 25 17:52:31 2020 +0300

    dax: dax_iomap_rw(): switch to iov_iter
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    
    =====================
    Patchset description:
    [00/30] fs,direct_IO: Switch to iov_iter and allow bio_vec for ext4
    
    This patchset transforms direct_IO callbacks, blockdev_direct_IO
    and its underlining functions to iov_iter, and introduces complete
    support of iov_iter for ext4.
    
    Supported iov_iter subtypes for ext4 is iovec and bio_vec. The first
    is for traditional user-submitted aio, while bio_vec is the type,
    which is important for us, since we use it in ploop.
    
    bio_vec operates with pages instead of user addresses (like iovec
    does), so it requires specific callbacks in do_blockdev_direct_IO()
    and in the functions it calls.
    
    The patchset reworks do_blockdev_direct_IO() in the same manner
    as in mainstrean. The most of rest patches are prepared manually,
    since we have significant differences to ms (RHEL7 patches, our
    direct IO patches for FUSE; all they have changed many functions).
    At the end, kaio engine (resulting in direct_IO) became possible
    to be enabled for ext4.
    
    https://jira.sw.ru/browse/PSBM-99793
---
 fs/dax.c            | 13 +++++--------
 fs/ext4/file.c      | 12 ++++++++++--
 fs/xfs/xfs_file.c   | 10 ++++++++--
 include/linux/dax.h |  4 ++--
 4 files changed, 25 insertions(+), 14 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/dax.c b/fs/dax.c
index 57d5b0a86a305..f22e3b32b6cc6 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -1357,25 +1357,22 @@  dax_iomap_actor_write(struct inode *inode, loff_t pos, loff_t length, void *data
  * and evicting any page cache pages in the region under I/O.
  */
 ssize_t
-dax_iomap_rw(int rw, struct kiocb *iocb, const struct iovec *iov,
-                unsigned long nr_segs, loff_t pos,
+dax_iomap_rw(int rw, struct kiocb *iocb, struct iov_iter *iter,
+                loff_t pos,
                 size_t count, const struct iomap_ops *ops)
 {
 	struct address_space *mapping = iocb->ki_filp->f_mapping;
 	struct inode *inode = mapping->host;
 	loff_t ret = 0, done = 0;
 	unsigned flags = 0;
-	struct iov_iter iter;
-
-	iov_iter_init(&iter, iov, nr_segs, count, 0);
 
 	if (rw & WRITE)
 		flags |= IOMAP_WRITE;
 
 
-	while (iov_iter_count(&iter)) {
-		ret = iomap_apply(inode, pos, iov_iter_count(&iter), flags, ops,
-				&iter,
+	while (iov_iter_count(iter)) {
+		ret = iomap_apply(inode, pos, iov_iter_count(iter), flags, ops,
+				iter,
 				(rw & WRITE) ?
 				  dax_iomap_actor_write : dax_iomap_actor_read);
 		if (ret <= 0)
diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 3adbb7b72c5ae..2808aadd40336 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -220,6 +220,7 @@  ext4_file_dax_write(
 	struct inode *inode = file_inode(iocb->ki_filp);
 	ssize_t			ret;
 	size_t			size = iov_length(iovp, nr_segs);
+	struct iov_iter iter;
 
 	inode_lock(inode);
 	ret = ext4_write_checks(iocb, iovp, nr_segs, &pos);
@@ -232,7 +233,9 @@  ext4_file_dax_write(
 	if (ret)
 		goto out;
 
-	ret = dax_iomap_rw(WRITE, iocb, iovp, nr_segs, pos,
+	iov_iter_init(&iter, iovp, nr_segs, size, 0);
+
+	ret = dax_iomap_rw(WRITE, iocb, &iter, pos,
 					size, &ext4_iomap_ops);
 out:
 	inode_unlock(inode);
@@ -516,6 +519,8 @@  ext4_file_dax_read(
 	size_t			size = iov_length(iovp, nr_segs);
 	ssize_t			ret = 0;
 	struct inode *inode = file_inode(iocb->ki_filp);
+	struct iov_iter iter;
+
 	if (!size)
 		return 0; /* skip atime */
 
@@ -529,7 +534,10 @@  ext4_file_dax_read(
 		/* Fallback to buffered IO in case we cannot support DAX */
 		return generic_file_aio_read(iocb, iovp, nr_segs, pos);
 	}
-	ret = dax_iomap_rw(READ, iocb, iovp, nr_segs, pos,
+
+	iov_iter_init(&iter, iovp, nr_segs, size, 0);
+
+	ret = dax_iomap_rw(READ, iocb, &iter, pos,
 					size, &ext4_iomap_ops);
 	inode_unlock(inode);
 
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 67a632f2c00f1..378e8e8264744 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -318,6 +318,7 @@  xfs_file_dax_read(
 	struct xfs_inode	*ip = XFS_I(iocb->ki_filp->f_mapping->host);
 	size_t			size = 0;
 	ssize_t			ret = 0;
+	struct iov_iter iter;
 
 	size = iov_length(iovp, nr_segs);
 
@@ -326,8 +327,10 @@  xfs_file_dax_read(
 	if (!size)
 		return 0; /* skip atime */
 
+	iov_iter_init(&iter, iovp, nr_segs, size, 0);
+
 	xfs_rw_ilock(ip, XFS_IOLOCK_SHARED);
-	ret = dax_iomap_rw(READ, iocb, iovp, nr_segs, pos,
+	ret = dax_iomap_rw(READ, iocb, &iter, pos,
 			   size, &xfs_iomap_ops);
 	xfs_rw_iunlock(ip, XFS_IOLOCK_SHARED);
 
@@ -776,6 +779,7 @@  xfs_file_dax_write(
 	size_t			count = ocount;
 	int			iolock = XFS_IOLOCK_EXCL;
 	ssize_t			ret, error = 0;
+	struct iov_iter iter;
 
 	xfs_rw_ilock(ip, iolock);
 	ret = xfs_file_aio_write_checks(file, &pos, &count, &iolock);
@@ -787,7 +791,9 @@  xfs_file_dax_write(
 
 	trace_xfs_file_dax_write(ip, count, pos);
 
-	ret = dax_iomap_rw(WRITE, iocb, iovp, nr_segs, pos,
+	iov_iter_init(&iter, iovp, nr_segs, count, 0);
+
+	ret = dax_iomap_rw(WRITE, iocb, &iter, pos,
 			   count, &xfs_iomap_ops);
 	if (ret > 0 && iocb->ki_pos > i_size_read(inode)) {
 		i_size_write(inode, iocb->ki_pos);
diff --git a/include/linux/dax.h b/include/linux/dax.h
index 0195fd3db7c9f..7e3a23236ec48 100644
--- a/include/linux/dax.h
+++ b/include/linux/dax.h
@@ -144,8 +144,8 @@  int dax_memcpy_toiovecend(struct dax_device *dax_dev, pgoff_t pgoff,
 		const struct iovec *iov, void *addr, int offset, int len);
 void dax_flush(struct dax_device *dax_dev, void *addr, size_t size);
 
-ssize_t dax_iomap_rw(int rw, struct kiocb *iocb, const struct iovec *iov,
-		unsigned long nr_segs, loff_t pos,
+ssize_t dax_iomap_rw(int rw, struct kiocb *iocb, struct iov_iter *iter,
+		loff_t pos,
 		size_t count, const struct iomap_ops *ops);
 int dax_iomap_fault(struct vm_fault *vmf, enum page_entry_size pe_size,
 		pfn_t *pfnp, int *errp, const struct iomap_ops *ops);