[RHEL7,COMMIT] give ->direct_IO() a copy of iov_iter

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


Message ID 202005251452.04PEqJOP004140@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 6d246a6f65152bb754433130866335e9bb742c61
Author: Al Viro <viro@zeniv.linux.org.uk>
Date:   Mon May 25 17:52:18 2020 +0300

    give ->direct_IO() a copy of iov_iter
    ms commit 26978b8b4d83
    the thing is, we want to advance what's given to ->direct_IO() as we
    are forming the request; however, the callers care about the amount
    of data actually transferred, not the amount we tried to transfer.
    It's more convenient to allow ->direct_IO() instances do use
    iov_iter_advance() on the copy of iov_iter, leaving the actual
    advancing of the original to caller.
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Note, we have some specific bvec usage in fuse_direct_IO_bvec(),
    and it looks OK for this change, since it never returns
    half-submitted request, which requires page-cache write to submit
    the rest of bvec.
    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.
 mm/filemap.c | 3 +++
 1 file changed, 3 insertions(+)

Patch hide | download patch | download mbox

diff --git a/mm/filemap.c b/mm/filemap.c
index 1a59ee8d38c13..0346d6027eabc 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -2036,6 +2036,7 @@  generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
 		retval = filemap_write_and_wait_range(mapping, pos,
 				pos + count - 1);
 		if (!retval) {
+			struct iov_iter data = *iter;
 			retval = mapping->a_ops->direct_IO(READ, iocb, &data, pos);
 		if (retval > 0) {
@@ -2770,6 +2771,7 @@  generic_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
 	ssize_t		written;
 	size_t		write_len;
 	pgoff_t		end;
+	struct iov_iter	data;
 	if (count != iov_iter_count(iter)) {
 		written = iov_iter_shorten(iter, count);
@@ -2802,6 +2804,7 @@  generic_file_direct_write(struct kiocb *iocb, struct iov_iter *iter,
 		goto out;
+	data = *iter;
 	written = mapping->a_ops->direct_IO(WRITE, iocb, &data, pos);