[Devel] [PATCH RHEL7 COMMIT] mm: Use iov_iter in __swap_writepage()
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 25 17:52:09 MSK 2020
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 ce143d2a92401b3af4f3b6b51d9f7f637699d0ec
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Mon May 25 17:52:08 2020 +0300
mm: Use iov_iter in __swap_writepage()
Pack argument into iov_iter. Move mapping_direct_IO()
to header to access it from more files.
Signed-off-by: Kirill Tkhai <ktkhai at 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
---
include/linux/fs.h | 15 +++++++++++++++
mm/filemap.c | 15 ---------------
mm/page_io.c | 7 ++++---
3 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 979cee411bfda..e0dccb24e84ee 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3653,6 +3653,21 @@ static inline iop_dentry_open_t get_dentry_open_iop(struct inode *inode)
return wrapper ? wrapper->dentry_open : NULL;
}
+static inline ssize_t mapping_direct_IO(struct address_space *mapping, int rw,
+ struct kiocb *iocb, struct iov_iter *iter,
+ loff_t pos)
+{
+ if (iov_iter_has_iovec(iter))
+ return mapping->a_ops->direct_IO(rw, iocb, iov_iter_iovec(iter),
+ pos, iter->nr_segs);
+ else if (iov_iter_has_bvec(iter))
+ return mapping->a_ops->direct_IO_bvec(rw, iocb,
+ iov_iter_bvec(iter), pos,
+ iter->nr_segs);
+ else
+ BUG();
+}
+
extern bool path_noexec(const struct path *path);
#endif /* _LINUX_FS_H */
diff --git a/mm/filemap.c b/mm/filemap.c
index 3fe13fbb85760..0619290ecd978 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1987,21 +1987,6 @@ int file_read_actor(read_descriptor_t *desc, struct page *page,
return size;
}
-static ssize_t mapping_direct_IO(struct address_space *mapping, int rw,
- struct kiocb *iocb, struct iov_iter *iter,
- loff_t pos)
-{
- if (iov_iter_has_iovec(iter))
- return mapping->a_ops->direct_IO(rw, iocb, iov_iter_iovec(iter),
- pos, iter->nr_segs);
- else if (iov_iter_has_bvec(iter))
- return mapping->a_ops->direct_IO_bvec(rw, iocb,
- iov_iter_bvec(iter), pos,
- iter->nr_segs);
- else
- BUG();
-}
-
static int file_read_iter_actor(read_descriptor_t *desc, struct page *page,
unsigned long offset, unsigned long size)
{
diff --git a/mm/page_io.c b/mm/page_io.c
index 0f29c247d64a7..d2bd82848946a 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -225,17 +225,18 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
.iov_base = kmap(page),
.iov_len = PAGE_SIZE,
};
+ struct iov_iter iter;
init_sync_kiocb(&kiocb, swap_file);
kiocb.ki_pos = page_file_offset(page);
kiocb.ki_left = PAGE_SIZE;
kiocb.ki_nbytes = PAGE_SIZE;
+ iov_iter_init(&iter, &iov, 1, PAGE_SIZE, 0);
set_page_writeback(page);
unlock_page(page);
- ret = mapping->a_ops->direct_IO(KERNEL_WRITE,
- &kiocb, &iov,
- kiocb.ki_pos, 1);
+ ret = mapping_direct_IO(mapping, KERNEL_WRITE,
+ &kiocb, &iter, kiocb.ki_pos);
kunmap(page);
if (ret == PAGE_SIZE) {
count_vm_event(PSWPOUT);
More information about the Devel
mailing list