[Devel] [PATCH RH7 2/2] ploop: Fix kaio_sync_io() for multy-pages case

Kirill Tkhai ktkhai at virtuozzo.com
Thu Aug 13 20:41:28 MSK 2020


@bvec is pointer to the first element of the array,
so we can't lost pointer to it.

Note, that the fix has no a visible effect, as this
function is currently called for nr_pages=1 case only
(kaio is not populating holes_bitmap on mount at
the moment).

https://jira.sw.ru/browse/PSBM-105347

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/block/ploop/io_kaio.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/ploop/io_kaio.c b/drivers/block/ploop/io_kaio.c
index 87287afcd65f..1151b862407e 100644
--- a/drivers/block/ploop/io_kaio.c
+++ b/drivers/block/ploop/io_kaio.c
@@ -793,7 +793,7 @@ kaio_sync_io(struct ploop_io * io, int op, struct page **pages,
 {
 	struct kiocb *iocb;
 	struct iov_iter iter;
-	struct bio_vec bvec_on_stack, *bvec;
+	struct bio_vec bvec_on_stack, *bvec, *tmp;
 	loff_t pos = (loff_t) sec << 9;
 	struct file *file = io->files.file;
 	struct kaio_comp comp;
@@ -814,15 +814,17 @@ kaio_sync_io(struct ploop_io * io, int op, struct page **pages,
 		return -ENOMEM;
 	}
 
+	tmp = bvec;
 	for (i = 0; i < nr_pages; i++) {
-		bvec->bv_page = pages[i];
+		tmp->bv_page = pages[i];
 		count = PAGE_SIZE - off;
 		if (count > len)
 			count = len;
-		bvec->bv_len = count;
-		bvec->bv_offset = off;
+		tmp->bv_len = count;
+		tmp->bv_offset = off;
 		off = 0;
 		len -= count;
+		tmp++;
 	}
 
 	iov_iter_init_bvec(&iter, bvec, nr_pages, bvec_length(bvec, nr_pages), 0);




More information about the Devel mailing list