linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: jfs-discussion@lists.sourceforge.net, linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Christoph Hellwig <hch@infradead.org>,
	"Darrick J . Wong" <djwong@kernel.org>
Subject: [RFC PATCH 3/9] jfs: Convert direct_IO read support to use iomap
Date: Thu, 26 May 2022 20:29:04 +0100	[thread overview]
Message-ID: <20220526192910.357055-4-willy@infradead.org> (raw)
In-Reply-To: <20220526192910.357055-1-willy@infradead.org>

Use the new iomap support to handle direct IO reads.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/jfs/file.c      | 20 ++++++++++++++++++--
 fs/jfs/inode.c     |  4 ++++
 fs/jfs/jfs_inode.h |  1 +
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 1d732fd223d4..0d074a9e0f77 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -4,10 +4,12 @@
  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
  */
 
-#include <linux/mm.h>
 #include <linux/fs.h>
+#include <linux/iomap.h>
+#include <linux/mm.h>
 #include <linux/posix_acl.h>
 #include <linux/quotaops.h>
+#include <linux/uio.h>
 #include "jfs_incore.h"
 #include "jfs_inode.h"
 #include "jfs_dmap.h"
@@ -70,6 +72,20 @@ static int jfs_open(struct inode *inode, struct file *file)
 
 	return 0;
 }
+
+static ssize_t jfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+	if (!iov_iter_count(to))
+		return 0; /* skip atime */
+
+	if (iocb->ki_flags & IOCB_DIRECT) {
+		file_accessed(iocb->ki_filp);
+		return iomap_dio_rw(iocb, to, &jfs_iomap_ops, NULL, 0, NULL, 0);
+	}
+
+	return generic_file_read_iter(iocb, to);
+}
+
 static int jfs_release(struct inode *inode, struct file *file)
 {
 	struct jfs_inode_info *ji = JFS_IP(inode);
@@ -141,7 +157,7 @@ const struct inode_operations jfs_file_inode_operations = {
 const struct file_operations jfs_file_operations = {
 	.open		= jfs_open,
 	.llseek		= generic_file_llseek,
-	.read_iter	= generic_file_read_iter,
+	.read_iter	= jfs_read_iter,
 	.write_iter	= generic_file_write_iter,
 	.mmap		= generic_file_mmap,
 	.splice_read	= generic_file_splice_read,
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 1a5bdaf35e9b..22e8a5612fdc 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -294,6 +294,10 @@ int jfs_iomap_begin(struct inode *ip, loff_t pos, loff_t length,
 	return rc;
 }
 
+const struct iomap_ops jfs_iomap_ops = {
+	.iomap_begin =  jfs_iomap_begin,
+};
+
 int jfs_get_block(struct inode *ip, sector_t lblock,
 		  struct buffer_head *bh_result, int create)
 {
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index 7de961a81862..afd12de3c341 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -30,6 +30,7 @@ extern void jfs_set_inode_flags(struct inode *);
 extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 extern int jfs_setattr(struct user_namespace *, struct dentry *, struct iattr *);
 
+extern const struct iomap_ops jfs_iomap_ops;
 extern const struct address_space_operations jfs_aops;
 extern const struct inode_operations jfs_dir_inode_operations;
 extern const struct file_operations jfs_dir_operations;
-- 
2.34.1


  parent reply	other threads:[~2022-05-26 19:29 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26 19:29 [RFC PATCH 0/9] Convert JFS to use iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 1/9] IOMAP_DIO_NOSYNC Matthew Wilcox (Oracle)
2022-05-27  5:35   ` Christoph Hellwig
2022-05-27 13:20     ` Matthew Wilcox
2022-05-26 19:29 ` [RFC PATCH 2/9] jfs: Add jfs_iomap_begin() Matthew Wilcox (Oracle)
2022-05-27  5:41   ` Christoph Hellwig
2022-05-27 13:45     ` Matthew Wilcox
2022-05-27 14:58       ` [Jfs-discussion] " Dave Kleikamp
2022-05-26 19:29 ` Matthew Wilcox (Oracle) [this message]
2022-05-26 19:29 ` [RFC PATCH 4/9] jfs: Convert direct_IO write support to use iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 5/9] jfs: Remove old direct_IO support Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 6/9] jfs: Handle bmap with iomap Matthew Wilcox (Oracle)
2022-05-26 19:29 ` [RFC PATCH 7/9] jfs: Read quota through the page cache Matthew Wilcox (Oracle)
2022-05-27  5:43   ` Christoph Hellwig
2022-05-27 13:56     ` Matthew Wilcox
2022-06-03 14:40     ` generic_quota_read Matthew Wilcox
2022-06-06  7:37       ` generic_quota_read Jan Kara
2022-05-26 19:29 ` [RFC PATCH 8/9] jfs: Write quota through the page cache Matthew Wilcox (Oracle)
2022-05-27  5:46   ` Christoph Hellwig
2022-05-26 19:29 ` [RFC PATCH 9/9] jfs: Convert buffered IO paths to iomap Matthew Wilcox (Oracle)
2022-05-28  0:02 ` [RFC PATCH 0/9] Convert JFS to use iomap Dave Chinner
2022-05-28  2:15   ` Matthew Wilcox
2022-05-28  5:36     ` Dave Chinner
2022-05-28 18:59       ` Theodore Ts'o
2022-05-29 23:51         ` Dave Chinner
2022-05-31 13:51           ` [Jfs-discussion] " Dave Kleikamp
2022-05-31 15:31             ` Matthew Wilcox
2022-05-31 15:56               ` Dave Kleikamp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220526192910.357055-4-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).