[Devel] [PATCH rh7 3/4] ploop: Introduce .sync_read_many method

Kirill Tkhai ktkhai at virtuozzo.com
Tue Feb 4 17:14:19 MSK 2020


The new method to read many pages in one batch request.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_direct.c |    8 ++++++++
 drivers/block/ploop/io_kaio.c   |    8 ++++++++
 include/linux/ploop/ploop.h     |    2 ++
 3 files changed, 18 insertions(+)

diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 5b56fc59da07..1fa7bfd6a2bb 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -1207,6 +1207,13 @@ dio_sync_read(struct ploop_io * io, struct page * page, unsigned int len,
 	return dio_sync_io(io, READ_SYNC, pages, 1, len, off, pos);
 }
 
+static int dio_sync_read_many(struct ploop_io *io, struct page *pages[],
+			      unsigned int nr_pages, sector_t sec)
+{
+	return dio_sync_io(io, READ_SYNC, pages, nr_pages,
+			   PAGE_SIZE * nr_pages, 0, sec);
+}
+
 static int
 dio_sync_write(struct ploop_io * io, struct page * page, unsigned int len,
 	       unsigned int off, sector_t sec)
@@ -1774,6 +1781,7 @@ static struct ploop_io_ops ploop_io_ops_direct =
 	.write_page	=	dio_write_page,
 	.sync_read	=	dio_sync_read,
 	.sync_write	=	dio_sync_write,
+	.sync_read_many =	dio_sync_read_many,
 
 	.init		=	dio_init,
 	.destroy	=	dio_destroy,
diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index c48b80b9785f..beafc0a68c2b 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -877,6 +877,13 @@ kaio_sync_write(struct ploop_io * io, struct page * page, unsigned int len,
 	return ret;
 }
 
+static int kaio_sync_read_many(struct ploop_io *io, struct page *pages[],
+				unsigned int nr_pages, sector_t sec)
+{
+	return kaio_sync_io(io, READ_SYNC, pages, nr_pages,
+			    PAGE_SIZE * nr_pages, 0, sec);
+}
+
 static int kaio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
 {
 	int err = __kaio_truncate(io, io->files.file, pos + len);
@@ -1160,6 +1167,7 @@ static struct ploop_io_ops ploop_io_ops_kaio =
 	.write_page	=	kaio_write_page,
 	.sync_read	=	kaio_sync_read,
 	.sync_write	=	kaio_sync_write,
+	.sync_read_many =	kaio_sync_read_many,
 
 	.init		=	kaio_init,
 	.destroy	=	kaio_destroy,
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 09333e9c3453..66591623f79d 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -178,6 +178,8 @@ struct ploop_io_ops
 			     unsigned int len, unsigned int off, sector_t sec);
 	int	(*sync_write)(struct ploop_io * io, struct page * page,
 			      unsigned int len, unsigned int off, sector_t sec);
+	int	(*sync_read_many)(struct ploop_io *io, struct page *pages[],
+				  unsigned int nr_pages, sector_t sec);
 
 	int	(*init)(struct ploop_io * io);
 	void	(*destroy)(struct ploop_io * io);




More information about the Devel mailing list