[Devel] [PATCH rh7 23/30] dax: dax_iomap_rw(): switch to iov_iter
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 20 19:05:38 MSK 2020
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
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(-)
diff --git a/fs/dax.c b/fs/dax.c
index 57d5b0a86a30..f22e3b32b6cc 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 3adbb7b72c5a..2808aadd4033 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 67a632f2c00f..378e8e826474 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 0195fd3db7c9..7e3a23236ec4 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);
More information about the Devel
mailing list