[Devel] [PATCH RHEL7 COMMIT] ploop: Introduce possibility to use kaio engine for ext4

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

    ploop: Introduce possibility to use kaio engine for ext4
    
    This is temporary module param for test time.
    
    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/dev.c        | 4 ++++
 drivers/block/ploop/fmt_ploop1.c | 2 +-
 drivers/block/ploop/io_direct.c  | 4 +++-
 drivers/block/ploop/io_kaio.c    | 9 ++++++---
 include/linux/ploop/ploop.h      | 1 +
 5 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index da124fa50250b..f9d3eb2067aaf 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -61,6 +61,8 @@ static long user_threshold __read_mostly = 4L * 1024 * 1024; /* 4GB in KB */
 
 static int large_disk_support __read_mostly = 1; /* true */
 static int native_discard_support __read_mostly = 1;
+int kaio_backed_ext4 __read_mostly = 0;
+EXPORT_SYMBOL(kaio_backed_ext4);
 
 static struct rb_root ploop_devices_tree = RB_ROOT;
 static DEFINE_MUTEX(ploop_devices_mutex);
@@ -5831,6 +5833,8 @@ module_param(large_disk_support, int, 0444);
 MODULE_PARM_DESC(ploop_large_disk_support, "Support of large disks (>2TB)");
 module_param(native_discard_support, int, 0644);
 MODULE_PARM_DESC(native_discard_support, "Native discard support");
+module_param(kaio_backed_ext4, int, 0644);
+MODULE_PARM_DESC(kaio_backed_ext4, "kaio-backed ext4");
 
 static int __init ploop_mod_init(void)
 {
diff --git a/drivers/block/ploop/fmt_ploop1.c b/drivers/block/ploop/fmt_ploop1.c
index 326862a2fd07e..2180dfcb3580d 100644
--- a/drivers/block/ploop/fmt_ploop1.c
+++ b/drivers/block/ploop/fmt_ploop1.c
@@ -333,7 +333,7 @@ ploop1_open(struct ploop_delta * delta)
 	    ((u64)ph->bd_size + ph->l1_off) << 9)
 		delta->flags |= PLOOP_FMT_PREALLOCATED;
 
-	if (delta->io.ops->id != PLOOP_IO_DIRECT)
+	if (delta->io.ops->id != PLOOP_IO_DIRECT || kaio_backed_ext4)
 		set_bit(PLOOP_S_NO_FALLOC_DISCARD, &delta->plo->state);
 
 	return 0;
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 75edf5583e8e5..54c995411c453 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1720,7 +1720,9 @@ static int dio_autodetect(struct ploop_io * io)
 	int err;
 	mm_segment_t fs;
 	unsigned int flags;
-	
+
+	if (kaio_backed_ext4)
+		return -1;
 	if (inode->i_sb->s_magic != EXT4_SUPER_MAGIC)
 		return -1; /* not mine */
 
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index c4e64b42a657f..7ca3374cce3b5 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -185,9 +185,11 @@ static int kaio_kernel_submit(struct file *file, struct kaio_req *kreq,
 	if (!iocb)
 		return -ENOMEM;
 
-	if (rw & REQ_DISCARD)
+	if (rw & REQ_DISCARD) {
 		op = IOCB_CMD_UNMAP_ITER;
-	else if (rw & REQ_WRITE)
+		if (file_inode(file)->i_sb->s_magic == EXT4_SUPER_MAGIC)
+			return -ENOTSUPP;
+	} else if (rw & REQ_WRITE)
 		op = IOCB_CMD_WRITE_ITER;
 	else
 		op = IOCB_CMD_READ_ITER;
@@ -1155,7 +1157,8 @@ static int kaio_autodetect(struct ploop_io * io)
 	struct file  * file  = io->files.file;
 	struct inode * inode = file->f_mapping->host;
 
-	if (inode->i_sb->s_magic != FUSE_SUPER_MAGIC)
+	if (inode->i_sb->s_magic != FUSE_SUPER_MAGIC &&
+	    (inode->i_sb->s_magic != EXT4_SUPER_MAGIC || !kaio_backed_ext4))
 		return -1; /* not mine */
 
 	if (!(file->f_flags & O_DIRECT)) {
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index cdf3c36945166..24f748530f549 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -935,6 +935,7 @@ void ploop_queue_zero_request(struct ploop_device *plo, struct ploop_request *or
 int ploop_maintenance_wait(struct ploop_device * plo);
 
 extern int max_map_pages;
+extern int kaio_backed_ext4;
 
 extern void ploop_msg_once(struct ploop_device *plo, const char *, ...)
 	__attribute__ ((format (printf, 2, 3)));


More information about the Devel mailing list