[Devel] [PATCH rh7 30/30] ploop: Introduce possibility to use kaio engine for ext4
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 20 19:06:29 MSK 2020
This is temporary module param for test time.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
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 da124fa50250..f9d3eb2067aa 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 326862a2fd07..2180dfcb3580 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 75edf5583e8e..54c995411c45 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 c4e64b42a657..7ca3374cce3b 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 cdf3c3694516..24f748530f54 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