[Devel] [PATCH RHEL7 COMMIT] fs: Pass iov_iter to ->direct_IO
Konstantin Khorenko
khorenko at virtuozzo.com
Mon May 25 17:52:11 MSK 2020
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.1
------>
commit 86c60456490de2543c7719ec2ec1fd38d60fde6a
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Mon May 25 17:52:10 2020 +0300
fs: Pass iov_iter to ->direct_IO
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 at virtuozzo.com>
=====================
Patchset description:
[00/30] fs,direct_IO: Switch to iov_iter and allow bio_vec for ext4
This patchset transforms direct_IO callbacks, blockdev_direct_IO
and its underlining functions to iov_iter, and introduces complete
support of iov_iter for ext4.
Supported iov_iter subtypes for ext4 is iovec and bio_vec. The first
is for traditional user-submitted aio, while bio_vec is the type,
which is important for us, since we use it in ploop.
bio_vec operates with pages instead of user addresses (like iovec
does), so it requires specific callbacks in do_blockdev_direct_IO()
and in the functions it calls.
The patchset reworks do_blockdev_direct_IO() in the same manner
as in mainstrean. The most of rest patches are prepared manually,
since we have significant differences to ms (RHEL7 patches, our
direct IO patches for FUSE; all they have changed many functions).
At the end, kaio engine (resulting in direct_IO) became possible
to be enabled for ext4.
https://jira.sw.ru/browse/PSBM-99793
---
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(-)
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 055562c580b43..ff5460b1d180d 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 9c64fa7508879..d9d5215b63b72 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 d947c5b0c46f5..8afc46c2e5616 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 865cb94058f95..5b0de364bcb0b 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 a0a81e5262c1e..a6a5c9860b819 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 95bf3ba3580e7..882c636c3df59 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 4a9deb6bb2248..917b124e1ffca 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 bedb7310aa095..6e7b341ea9197 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 59a5fbbbb8039..69c4a35f80293 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 a0e0e50217a75..c0649bdd50ed7 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 258bd78a559c6..a164db9bac9ca 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 0b7cbf658c053..0e0c198428758 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 9e2fecd62f624..0db84dc50090d 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 4b4ae8ccc6dcb..43c4874a57595 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 6f8fe72c2a7ae..409aeaacba1a0 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 50bd6b5c7171c..649513db15054 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 7775be2f4b2d7..533de799b072f 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 4fcb0d232962e..e756fb0edfe1d 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 7fee7b2e12251..5f95455c1920a 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 a3aae8634a3e8..866a34ec51c5c 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 29569dd081681..85bc0000dc91c 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 6d9fdca3fff75..5cd00676959d0 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 e0dccb24e84ee..d3527067a4471 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 a84b39cb0dbab..b0a2443f80b63 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);
More information about the Devel
mailing list