[Devel] [PATCH RHEL9 COMMIT] dm-ploop: Fix usage of bio_vec on stack

Konstantin Khorenko khorenko at virtuozzo.com
Tue Oct 26 19:57:18 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.17
------>
commit b4f1cb3849de974dd437d5755902df05ead2db1b
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue Oct 26 19:57:18 2021 +0300

    dm-ploop: Fix usage of bio_vec on stack
    
    Previously, writing BAT page was synchronous, so
    we could use on-stack bio_vec for that.
    But after it became asynchronous, we can't do that.
    Strange, this has not fired earlier.
    
    https://jira.sw.ru/browse/PSBM-135137
    Fixes: bfc5eaaba897 "ploop: Async md writeback"
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    Tested-By: Nikita Yushchenko <nikita.yushchenko at virtuozzo.com>
---
 drivers/md/dm-ploop-map.c | 12 ++++++------
 drivers/md/dm-ploop.h     |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 79142acddecc..03c9e216cc1f 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1594,17 +1594,17 @@ void ploop_index_wb_submit(struct ploop *ploop, struct ploop_index_wb *piwb)
 {
 	loff_t pos = (loff_t)piwb->page_id << PAGE_SHIFT;
 	struct pio *pio = piwb->pio;
-	struct bio_vec bvec = {
-		.bv_page = piwb->bat_page,
-		.bv_len = PAGE_SIZE,
-		.bv_offset = 0,
-	};
+	struct bio_vec *bvec = &piwb->aux_bvec;
+
+	bvec->bv_page = piwb->bat_page;
+	bvec->bv_len = PAGE_SIZE;
+	bvec->bv_offset = 0;
 
 	pio->bi_iter.bi_sector = to_sector(pos);
 	pio->bi_iter.bi_size = PAGE_SIZE;
 	pio->bi_iter.bi_idx = 0;
 	pio->bi_iter.bi_bvec_done = 0;
-	pio->bi_io_vec = &bvec;
+	pio->bi_io_vec = bvec;
 	pio->level = top_level(ploop);
 	pio->endio_cb = md_write_endio;
 	pio->endio_cb_data = piwb;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index a7ca942c4670..0a4c6b78e20e 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -106,6 +106,7 @@ struct ploop_index_wb {
 	bool completed;
 	blk_status_t bi_status;
 	u32 page_id;
+	struct bio_vec aux_bvec;
 };
 
 /* Metadata page */


More information about the Devel mailing list