[rh7,07/30] fs: Pass iov_iter to ->direct_IO

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

Details

Message ID 158999062312.2234365.11502708934698117416.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:03 p.m.
In mapping_direct_IO() we used to pass iov_iter_iovec(@iter)
to ->direct_IO(). Pass @iter directrly instead of this.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/9p/vfs_addr.c       |    4 ++--
 fs/block_dev.c         |    5 +++--
 fs/btrfs/inode.c       |    5 +++--
 fs/ceph/addr.c         |    4 ++--
 fs/cifs/file.c         |    3 +--
 fs/ext2/inode.c        |    6 ++++--
 fs/ext3/inode.c        |    5 +++--
 fs/ext4/inode.c        |    5 +++--
 fs/f2fs/data.c         |    4 +++-
 fs/fat/inode.c         |    6 ++++--
 fs/fuse/file.c         |    6 ++++--
 fs/gfs2/aops.c         |    5 +++--
 fs/hfs/inode.c         |    4 +++-
 fs/hfsplus/inode.c     |    4 +++-
 fs/jfs/inode.c         |    4 +++-
 fs/libfs.c             |    4 ++--
 fs/nfs/direct.c        |    4 +++-
 fs/nilfs2/inode.c      |    6 ++++--
 fs/ocfs2/aops.c        |    7 ++++---
 fs/reiserfs/inode.c    |    5 +++--
 fs/udf/file.c          |    4 ++--
 fs/udf/inode.c         |    6 ++++--
 include/linux/fs.h     |    9 ++++-----
 include/linux/nfs_fs.h |    3 +--
 24 files changed, 71 insertions(+), 47 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 055562c580b4..ff5460b1d180 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -256,9 +256,9 @@  static int v9fs_launder_page(struct page *page)
  *
  */
 static ssize_t
-v9fs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
-	       loff_t pos, unsigned long nr_segs)
+v9fs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
 {
+	unsigned long nr_segs = iter->nr_segs;
 	/*
 	 * FIXME
 	 * Now that we do caching with cache mode enabled, We need
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 9c64fa750887..d9d5215b63b7 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -195,11 +195,12 @@  static struct inode *bdev_file_inode(struct file *file)
 }
 
 static ssize_t
-blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
-			loff_t offset, unsigned long nr_segs)
+blkdev_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = bdev_file_inode(file);
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 
 	return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
 				    nr_segs, blkdev_get_block, NULL, NULL,
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d947c5b0c46f..8afc46c2e561 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8646,13 +8646,14 @@  static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *io
 }
 
 static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
-			const struct iovec *iov, loff_t offset,
-			unsigned long nr_segs)
+			struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct btrfs_root *root = BTRFS_I(inode)->root;
 	struct btrfs_dio_data dio_data = { 0 };
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	size_t count = 0;
 	int flags = 0;
 	bool wakeup = true;
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 865cb94058f9..5b0de364bcb0 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1366,8 +1366,8 @@  static int ceph_write_end(struct file *file, struct address_space *mapping,
  * never get called.
  */
 static ssize_t ceph_direct_io(int rw, struct kiocb *iocb,
-			      const struct iovec *iov,
-			      loff_t pos, unsigned long nr_segs)
+			      struct iov_iter *iter,
+			      loff_t pos)
 {
 	WARN_ON(1);
 	return -EINVAL;
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index a0a81e5262c1..a6a5c9860b81 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -4102,8 +4102,7 @@  void cifs_oplock_break(struct work_struct *work)
  * Direct IO is not yet supported in the cached mode. 
  */
 static ssize_t
-cifs_direct_io(int rw, struct kiocb *iocb, const struct iovec *iov,
-               loff_t pos, unsigned long nr_segs)
+cifs_direct_io(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
 {
         /*
          * FIXME
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index 95bf3ba3580e..882c636c3df5 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -852,12 +852,14 @@  static sector_t ext2_bmap(struct address_space *mapping, sector_t block)
 }
 
 static ssize_t
-ext2_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
-			loff_t offset, unsigned long nr_segs)
+ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
+			loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	if (IS_DAX(inode))
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 4a9deb6bb224..917b124e1ffc 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1861,12 +1861,13 @@  static int ext3_releasepage(struct page *page, gfp_t wait)
  * VFS code falls back into buffered path in that case so we are safe.
  */
 static ssize_t ext3_direct_IO(int rw, struct kiocb *iocb,
-			const struct iovec *iov, loff_t offset,
-			unsigned long nr_segs)
+			struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct ext3_inode_info *ei = EXT3_I(inode);
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	handle_t *handle;
 	ssize_t ret;
 	int orphan = 0;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bedb7310aa09..6e7b341ea919 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3471,11 +3471,12 @@  static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
 }
 
 static ssize_t ext4_direct_IO(int rw, struct kiocb *iocb,
-			      const struct iovec *iov, loff_t offset,
-			      unsigned long nr_segs)
+			      struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	/*
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 59a5fbbbb803..69c4a35f8029 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -682,10 +682,12 @@  static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 }
 
 static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
-		const struct iovec *iov, loff_t offset, unsigned long nr_segs)
+		struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 
 	if (rw == WRITE)
 		return 0;
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index a0e0e50217a7..c0649bdd50ed 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -185,12 +185,14 @@  static int fat_write_end(struct file *file, struct address_space *mapping,
 }
 
 static ssize_t fat_direct_IO(int rw, struct kiocb *iocb,
-			     const struct iovec *iov,
-			     loff_t offset, unsigned long nr_segs)
+			     struct iov_iter *iter,
+			     loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	if (rw == WRITE) {
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 258bd78a559c..a164db9bac9c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3598,8 +3598,8 @@  static inline loff_t fuse_round_up(loff_t off)
 }
 
 static ssize_t
-fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
-			loff_t offset, unsigned long nr_segs)
+fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
+			loff_t offset)
 {
 	ssize_t ret = 0;
 	struct file *file = iocb->ki_filp;
@@ -3608,6 +3608,8 @@  fuse_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
 	loff_t pos = 0;
 	struct inode *inode;
 	loff_t i_size;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	size_t count = iov_length(iov, nr_segs);
 	struct fuse_io_priv *io;
 	bool is_sync = is_sync_kiocb(iocb);
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c
index 0b7cbf658c05..0e0c19842875 100644
--- a/fs/gfs2/aops.c
+++ b/fs/gfs2/aops.c
@@ -1069,13 +1069,14 @@  static int gfs2_ok_for_dio(struct gfs2_inode *ip, int rw, loff_t offset)
 
 
 static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
-			      const struct iovec *iov, loff_t offset,
-			      unsigned long nr_segs)
+			      struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
 	struct address_space *mapping = inode->i_mapping;
 	struct gfs2_inode *ip = GFS2_I(inode);
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	struct gfs2_holder gh;
 	int rv;
 
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 9e2fecd62f62..0db84dc50090 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -125,11 +125,13 @@  static int hfs_releasepage(struct page *page, gfp_t mask)
 }
 
 static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
-		const struct iovec *iov, loff_t offset, unsigned long nr_segs)
+		struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = file_inode(file)->i_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 4b4ae8ccc6dc..43c4874a5759 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -122,11 +122,13 @@  static int hfsplus_releasepage(struct page *page, gfp_t mask)
 }
 
 static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
-		const struct iovec *iov, loff_t offset, unsigned long nr_segs)
+		struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = file_inode(file)->i_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 6f8fe72c2a7a..409aeaacba1a 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -331,11 +331,13 @@  static sector_t jfs_bmap(struct address_space *mapping, sector_t block)
 }
 
 static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
-	const struct iovec *iov, loff_t offset, unsigned long nr_segs)
+	struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = file->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/libfs.c b/fs/libfs.c
index 50bd6b5c7171..649513db1505 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1074,8 +1074,8 @@  void noop_invalidatepage_range(struct page *page, unsigned int offset,
 }
 EXPORT_SYMBOL_GPL(noop_invalidatepage_range);
 
-ssize_t noop_direct_IO(int rw, struct kiocb *kiocb, const struct iovec *iov,
-			loff_t offset, unsigned long nr_segs)
+ssize_t noop_direct_IO(int rw, struct kiocb *kiocb, struct iov_iter *iter,
+			loff_t offset)
 {
 	/*
 	 * iomap based filesystems support direct I/O without need for
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 7775be2f4b2d..533de799b072 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -259,9 +259,11 @@  static int nfs_direct_cmp_commit_data_verf(struct nfs_direct_req *dreq,
  * shunt off direct read and write requests before the VFS gets them,
  * so this method is only ever called for swap.
  */
-ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, loff_t pos, unsigned long nr_segs)
+ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
 {
 	struct inode *inode = iocb->ki_filp->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 
 	/* we only support swap file calling nfs_direct_IO */
 	if (!IS_SWAPFILE(inode))
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 4fcb0d232962..e756fb0edfe1 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -298,12 +298,14 @@  static int nilfs_write_end(struct file *file, struct address_space *mapping,
 }
 
 static ssize_t
-nilfs_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
-		loff_t offset, unsigned long nr_segs)
+nilfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
+		loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = file->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t size;
 
 	if (rw == WRITE)
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 7fee7b2e1225..5f95455c1920 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -622,12 +622,13 @@  static int ocfs2_releasepage(struct page *page, gfp_t wait)
 
 static ssize_t ocfs2_direct_IO(int rw,
 			       struct kiocb *iocb,
-			       const struct iovec *iov,
-			       loff_t offset,
-			       unsigned long nr_segs)
+			       struct iov_iter *iter,
+			       loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file_inode(file)->i_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 
 	/*
 	 * Fallback to buffered I/O if we see an inode without
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index a3aae8634a3e..866a34ec51c5 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3073,11 +3073,12 @@  static int reiserfs_releasepage(struct page *page, gfp_t unused_gfp_flags)
 /* We thank Mingming Cao for helping us understand in great detail what
    to do in this section of the code. */
 static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb,
-				  const struct iovec *iov, loff_t offset,
-				  unsigned long nr_segs)
+				  struct iov_iter *iter, loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct inode *inode = file->f_mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 29569dd08168..85bc0000dc91 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -119,8 +119,8 @@  static int udf_adinicb_write_end(struct file *file,
 }
 
 static ssize_t udf_adinicb_direct_IO(int rw, struct kiocb *iocb,
-				     const struct iovec *iov,
-				     loff_t offset, unsigned long nr_segs)
+				     struct iov_iter *iter,
+				     loff_t offset)
 {
 	/* Fallback to buffered I/O. */
 	return 0;
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 6d9fdca3fff7..5cd00676959d 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -217,12 +217,14 @@  static int udf_write_begin(struct file *file, struct address_space *mapping,
 }
 
 static ssize_t udf_direct_IO(int rw, struct kiocb *iocb,
-			     const struct iovec *iov,
-			     loff_t offset, unsigned long nr_segs)
+			     struct iov_iter *iter,
+			     loff_t offset)
 {
 	struct file *file = iocb->ki_filp;
 	struct address_space *mapping = file->f_mapping;
 	struct inode *inode = mapping->host;
+	const struct iovec *iov = iov_iter_iovec(iter);
+	unsigned long nr_segs = iter->nr_segs;
 	ssize_t ret;
 
 	ret = blockdev_direct_IO(rw, iocb, inode, iov, offset, nr_segs,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f3ae7b9373d5..277bf8711b36 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -574,8 +574,8 @@  struct address_space_operations {
 	void (*invalidatepage) (struct page *, unsigned long);
 	int (*releasepage) (struct page *, gfp_t);
 	void (*freepage)(struct page *);
-	ssize_t (*direct_IO)(int, struct kiocb *, const struct iovec *iov,
-			loff_t offset, unsigned long nr_segs);
+	ssize_t (*direct_IO)(int, struct kiocb *, struct iov_iter *iter,
+			loff_t offset);
 	ssize_t (*direct_IO_bvec)(int, struct kiocb *, struct bio_vec *bvec,
 			loff_t offset, unsigned long bvec_len);
 	int (*get_xip_mem)(struct address_space *, pgoff_t, int,
@@ -3399,7 +3399,7 @@  extern int noop_set_page_dirty(struct page *page);
 extern void noop_invalidatepage_range(struct page *page, unsigned int offset,
 		unsigned int length);
 extern ssize_t noop_direct_IO(int rw, struct kiocb *kiocb,
-		const struct iovec *iov, loff_t offset, unsigned long nr_segs);
+		struct iov_iter *iter, loff_t offset);
 extern int simple_empty(struct dentry *);
 extern int simple_readpage(struct file *file, struct page *page);
 extern int simple_write_begin(struct file *file, struct address_space *mapping,
@@ -3658,8 +3658,7 @@  static inline ssize_t mapping_direct_IO(struct address_space *mapping, int rw,
 			         loff_t pos)
 {
 	if (iov_iter_has_iovec(iter))
-		return mapping->a_ops->direct_IO(rw, iocb, iov_iter_iovec(iter),
-						 pos, iter->nr_segs);
+		return mapping->a_ops->direct_IO(rw, iocb, iter, pos);
 	else if (iov_iter_has_bvec(iter))
 		return mapping->a_ops->direct_IO_bvec(rw, iocb,
 						      iov_iter_bvec(iter), pos,
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index a84b39cb0dba..b0a2443f80b6 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -445,8 +445,7 @@  static inline struct rpc_cred *nfs_file_cred(struct file *file)
 /*
  * linux/fs/nfs/direct.c
  */
-extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
-			unsigned long);
+extern ssize_t nfs_direct_IO(int, struct kiocb *, struct iov_iter *, loff_t);
 extern ssize_t nfs_file_direct_read(struct kiocb *iocb,
 			const struct iovec *iov, unsigned long nr_segs,
 			loff_t pos, bool uio);