[Devel] [PATCH RHEL7 COMMIT] fs: Kill ->direct_IO_bvec

Konstantin Khorenko khorenko at virtuozzo.com
Mon May 25 17:52:12 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 0afc5d6683996582cde8d07ed788488ad7f671ef
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Mon May 25 17:52:11 2020 +0300

    fs: Kill ->direct_IO_bvec
    
    Move "if (iov_iter_has_bvec()" switch to fuse_direct_IO(),
    since fuse is the only user of bvec.
    
    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
---
 drivers/block/ploop/io_kaio.c |  6 ------
 fs/fuse/file.c                | 16 ++++++++++++----
 include/linux/fs.h            | 11 +----------
 3 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 51ee627c40371..c4e64b42a657f 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -1163,12 +1163,6 @@ static int kaio_autodetect(struct ploop_io * io)
 		return -1;
 	}
 
-	if (file->f_mapping->a_ops->direct_IO_bvec == NULL) {
-		printk("Cannot run kaio over fs (%s) w/o direct_IO_bvec\n",
-		       file->f_mapping->host->i_sb->s_type->name);
-		return -1;
-	}
-
 	return 0;
 }
 
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index a164db9bac9ca..4522e219c9343 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -3597,9 +3597,9 @@ static inline loff_t fuse_round_up(loff_t off)
 	return round_up(off, FUSE_MAX_PAGES_PER_REQ << PAGE_SHIFT);
 }
 
-static ssize_t
-fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
-			loff_t offset)
+static inline ssize_t
+__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;
@@ -3689,6 +3689,15 @@ fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
 	return ret;
 }
 
+static ssize_t
+fuse_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t offset)
+{
+	if (iov_iter_has_bvec(iter))
+		return fuse_direct_IO_bvec(rw, iocb, iov_iter_bvec(iter),
+					   offset, iter->nr_segs);
+	return __fuse_direct_IO(rw, iocb, iter, offset);
+}
+
 static long fuse_file_fallocate(struct file *file, int mode, loff_t offset,
 				loff_t length)
 {
@@ -4056,7 +4065,6 @@ static const struct address_space_operations fuse_file_aops  = {
 	.set_page_dirty	= __set_page_dirty_nobuffers,
 	.bmap		= fuse_bmap,
 	.direct_IO	= fuse_direct_IO,
-	.direct_IO_bvec	= fuse_direct_IO_bvec,
 	.write_begin	= fuse_write_begin,
 	.write_end	= fuse_write_end,
 };
diff --git a/include/linux/fs.h b/include/linux/fs.h
index d3527067a4471..dfef79262fc2f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -576,8 +576,6 @@ struct address_space_operations {
 	void (*freepage)(struct page *);
 	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,
 						void **, unsigned long *);
 	RH_KABI_DEPRECATE_FN(int, get_xip_mem, struct address_space *, pgoff_t,
@@ -3657,14 +3655,7 @@ static inline ssize_t mapping_direct_IO(struct address_space *mapping, int rw,
 			         struct kiocb *iocb, struct iov_iter *iter,
 			         loff_t pos)
 {
-	if (iov_iter_has_iovec(iter))
-		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,
-						      iter->nr_segs);
-	else
-		BUG();
+	return mapping->a_ops->direct_IO(rw, iocb, iter, pos);
 }
 
 extern bool path_noexec(const struct path *path);


More information about the Devel mailing list