[rh7,27/30] ext4: Introduce ext4_file_write_iter()

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

Details

Message ID 158999076565.2234365.9045908546982047259.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:06 p.m.
Move all functionality from ext4_file_write()
to separate function. ext4_file_write() now
contains only iov_iter initialization.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/ext4/file.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index b617029d3016..32b17c61b52b 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -249,34 +249,41 @@  ext4_file_dax_write(
 #endif
 
 static ssize_t
-ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
-		unsigned long nr_segs, loff_t pos)
+ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
 {
 	struct inode *inode = file_inode(iocb->ki_filp);
 	ssize_t ret;
 	int overwrite = 0;
-	struct iov_iter iter;
-
-	iov_iter_init(&iter, iov, nr_segs, iov_length(iov, nr_segs), 0);
 
-	ret = ext4_write_checks(iocb, &iter, &pos);
+	ret = ext4_write_checks(iocb, iter, &pos);
 	if (ret <= 0)
 		return ret;
 
 #ifdef CONFIG_FS_DAX
 	if (IS_DAX(inode))
-		return ext4_file_dax_write(iocb, &iter, pos);
+		return ext4_file_dax_write(iocb, iter, pos);
 #endif
 
 	iocb->private = &overwrite; /* RHEL7 only - prevent DIO race */
 	if (unlikely(io_is_direct(iocb->ki_filp)))
-		ret = ext4_file_dio_write(iocb, &iter, pos);
+		ret = ext4_file_dio_write(iocb, iter, pos);
 	else
-		ret = generic_file_write_iter(iocb, &iter, pos);
+		ret = generic_file_write_iter(iocb, iter, pos);
 
 	return ret;
 }
 
+static ssize_t
+ext4_file_write(struct kiocb *iocb, const struct iovec *iov,
+		unsigned long nr_segs, loff_t pos)
+{
+	struct iov_iter iter;
+
+	iov_iter_init(&iter, iov, nr_segs, iov_length(iov, nr_segs), 0);
+
+	return ext4_file_write_iter(iocb, &iter, pos);
+}
+
 #ifdef CONFIG_FS_DAX
 static int ext4_dax_huge_fault(struct vm_fault *vmf,
 		enum page_entry_size pe_size)