[rh7,13/30] give ->direct_IO() a copy of iov_iter

Submitted by Kirill Tkhai on May 20, 2020, 4:04 p.m.

Details

Message ID 158999066676.2234365.11018115391422400653.stgit@localhost.localdomain
State New
Series "fs, direct_IO: Switch to iov_iter and allow bio_vec for ext4"
Headers show

Commit Message

Kirill Tkhai May 20, 2020, 4:04 p.m.
From: Al Viro <viro@zeniv.linux.org.uk>

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>
---
 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 1a59ee8d38c1..0346d6027eab 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);
 
 	/*