[PATCH 14/18] orangefs: implement direct_IO for the read case

From: Martin Brandenburg
Date: Tue Dec 12 2017 - 13:36:39 EST


From: Martin Brandenburg <martin@xxxxxxxxxxxx>

Since orangefs_file_read_iter now calls generic_file_read_iter, O_DIRECT
now goes through direct_IO in the read case. In the write case,
orangefs_file_write_iter never calls direct_IO, but handles the direct
write manually.

Signed-off-by: Martin Brandenburg <martin@xxxxxxxxxxxx>
---
fs/orangefs/file.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c
index 1c30e9abb8cb..0223a0351d11 100644
--- a/fs/orangefs/file.c
+++ b/fs/orangefs/file.c
@@ -787,22 +787,17 @@ static int orangefs_releasepage(struct page *page, gfp_t foo)
return 0;
}

-/*
- * Having a direct_IO entry point in the address_space_operations
- * struct causes the kernel to allows us to use O_DIRECT on
- * open. Nothing will ever call this thing, but in the future we
- * will need to be able to use O_DIRECT on open in order to support
- * AIO. Modeled after NFS, they do this too.
- */
-
static ssize_t orangefs_direct_IO(struct kiocb *iocb,
struct iov_iter *iter)
{
- gossip_debug(GOSSIP_INODE_DEBUG,
- "orangefs_direct_IO: %pD\n",
- iocb->ki_filp);
-
- return -EINVAL;
+ struct file *file = iocb->ki_filp;
+ loff_t pos = *(&iocb->ki_pos);
+ /*
+ * This cannot happen until write_iter becomes
+ * generic_file_write_iter.
+ */
+ BUG_ON(iov_iter_rw(iter) != READ);
+ return do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter);
}

/** ORANGEFS2 implementation of address space operations */
--
2.15.1