[RFC PATCH 4/9] jfs: Convert direct_IO write support to use iomap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the new iomap support to handle direct IO writes.

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
 fs/jfs/file.c | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 0d074a9e0f77..bf9d4475ddb5 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -4,6 +4,7 @@
  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
  */
 
+#include <linux/backing-dev.h>
 #include <linux/fs.h>
 #include <linux/iomap.h>
 #include <linux/mm.h>
@@ -86,6 +87,39 @@ static ssize_t jfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	return generic_file_read_iter(iocb, to);
 }
 
+static ssize_t jfs_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+	struct file *file = iocb->ki_filp;
+	struct inode *inode = file->f_mapping->host;
+	ssize_t ret;
+
+	inode_lock(inode);
+	current->backing_dev_info = inode_to_bdi(inode);
+
+	ret = generic_write_checks(iocb, from);
+	if (ret <= 0)
+		goto err;
+	ret = file_remove_privs(file);
+	if (ret < 0)
+		goto err;
+	ret = file_update_time(file);
+	if (ret < 0)
+		goto err;
+
+	if (iocb->ki_flags & IOCB_DIRECT)
+		ret = iomap_dio_rw(iocb, from, &jfs_iomap_ops, NULL,
+				IOMAP_DIO_NOSYNC, NULL, 0);
+	else
+		ret = __generic_file_write_iter(iocb, from);
+
+err:
+	current->backing_dev_info = NULL;
+	inode_unlock(inode);
+	if (ret > 0)
+		ret = generic_write_sync(iocb, ret);
+	return ret;
+}
+
 static int jfs_release(struct inode *inode, struct file *file)
 {
 	struct jfs_inode_info *ji = JFS_IP(inode);
@@ -158,7 +192,7 @@ const struct file_operations jfs_file_operations = {
 	.open		= jfs_open,
 	.llseek		= generic_file_llseek,
 	.read_iter	= jfs_read_iter,
-	.write_iter	= generic_file_write_iter,
+	.write_iter	= jfs_write_iter,
 	.mmap		= generic_file_mmap,
 	.splice_read	= generic_file_splice_read,
 	.splice_write	= iter_file_splice_write,
-- 
2.34.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux