[Devel] [PATCH RH7 3/3] ext4: Handle DAX case in .read_iter

Kirill Tkhai ktkhai at virtuozzo.com
Tue Aug 25 13:22:06 MSK 2020


Extract payload from ext4_file_read() to ext4_file_read_iter()
and use it as .read_iter method.

https://jira.sw.ru/browse/PSBM-105347

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/ext4/file.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/fs/ext4/file.c b/fs/ext4/file.c
index 0ed26419d61d..8f5fb6d99d5e 100644
--- a/fs/ext4/file.c
+++ b/fs/ext4/file.c
@@ -612,6 +612,16 @@ ext4_file_dax_read_iter(
 }
 #endif
 
+ssize_t
+ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
+{
+#ifdef CONFIG_FS_DAX
+	if (IS_DAX(file_inode(iocb->ki_filp)))
+		return ext4_file_dax_read_iter(iocb, iter, pos);
+#endif
+	return generic_file_read_iter(iocb, iter, pos);
+}
+
 static ssize_t
 ext4_file_read(
 	struct kiocb		*iocb,
@@ -623,11 +633,7 @@ ext4_file_read(
 	struct iov_iter iter;
 
 	iov_iter_init(&iter, iovp, nr_segs, size, 0);
-#ifdef CONFIG_FS_DAX
-	if (IS_DAX(file_inode(iocb->ki_filp)))
-		return ext4_file_dax_read_iter(iocb, &iter, pos);
-#endif
-	return generic_file_read_iter(iocb, &iter, pos);
+	return ext4_file_read_iter(iocb, &iter, pos);
 }
 
 const struct file_operations_extend  ext4_file_operations = {
@@ -649,7 +655,7 @@ const struct file_operations_extend  ext4_file_operations = {
 		.splice_read	= generic_file_splice_read,
 		.splice_write	= generic_file_splice_write,
 		.fallocate	= ext4_fallocate,
-		.read_iter	= generic_file_read_iter,
+		.read_iter	= ext4_file_read_iter,
 		.write_iter	= ext4_file_write_iter,
 	},
 	.mmap_supported_flags = MAP_SYNC,




More information about the Devel mailing list