[Devel] [PATCH RH8 12/18] ploop: Generalize submit_rw_mapped()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 16 18:47:18 MSK 2021


Add @level argument to be able to use this function
on any delta.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c |    4 ++--
 drivers/md/dm-ploop-map.c |   12 ++++++++----
 drivers/md/dm-ploop.h     |    2 +-
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 392290bb42ea..c15175917ea2 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -217,7 +217,7 @@ static int ploop_read_cluster_sync(struct ploop *ploop, struct pio *pio,
 	pio->endio_cb = wake_completion;
 	pio->endio_cb_data = &completion;
 
-	submit_rw_mapped(ploop, dst_cluster, pio);
+	submit_rw_mapped(ploop, dst_cluster, pio, top_level(ploop));
 	wait_for_completion(&completion);
 
 	if (pio->bi_status)
@@ -243,7 +243,7 @@ static int ploop_write_cluster_sync(struct ploop *ploop, struct pio *pio,
 	pio->endio_cb = wake_completion;
 	pio->endio_cb_data = &completion;
 
-	submit_rw_mapped(ploop, dst_cluster, pio);
+	submit_rw_mapped(ploop, dst_cluster, pio, top_level(ploop));
 	wait_for_completion(&completion);
 
 	if (pio->bi_status)
diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index 54eef62658a4..2525ab2a9c1d 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -1015,13 +1015,16 @@ static void data_rw_complete(struct pio *pio)
 	pio_endio(pio);
 }
 
-void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio)
+void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio, u8 level)
 {
 	unsigned int rw, nr_segs;
 	struct bio_vec *bvec;
 	struct iov_iter iter;
+	struct file *file;
 	loff_t pos;
 
+	BUG_ON(level > top_level(ploop));
+
 	pio->complete = data_rw_complete;
 
 	rw = (op_is_write(pio->bi_op) ? WRITE : READ);
@@ -1034,7 +1037,8 @@ void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio)
 	remap_to_cluster(ploop, pio, dst_clu);
 	pos = to_bytes(pio->bi_iter.bi_sector);
 
-	ploop_call_rw_iter(top_delta(ploop)->file, pos, rw, &iter, pio);
+	file = ploop->deltas[level].file;
+	ploop_call_rw_iter(file, pos, rw, &iter, pio);
 }
 
 /*
@@ -1184,7 +1188,7 @@ static void submit_cluster_write(struct ploop_cow *cow)
 	pio->endio_cb = ploop_cow_endio;
 	pio->endio_cb_data = cow;
 
-	submit_rw_mapped(ploop, dst_cluster, pio);
+	submit_rw_mapped(ploop, dst_cluster, pio, top_level(ploop));
 	return;
 error:
 	complete_cow(cow, BLK_STS_IOERR);
@@ -1393,7 +1397,7 @@ static int process_one_deferred_bio(struct ploop *ploop, struct pio *pio,
 queue:
 	link_submitting_pio(ploop, pio, cluster);
 
-	submit_rw_mapped(ploop, dst_cluster, pio);
+	submit_rw_mapped(ploop, dst_cluster, pio, top_level(ploop));
 out:
 	return 0;
 }
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 6fc3777e98cd..12ae7adb5c30 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -495,7 +495,7 @@ extern struct pio *find_lk_of_cluster(struct ploop *ploop, u32 cluster);
 extern void init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio);
 extern int ploop_rw_page_sync(unsigned rw, struct file *file,
 			      u64 index, struct page *page);
-extern void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio);
+extern void submit_rw_mapped(struct ploop *ploop, u32 dst_clu, struct pio *pio, u8 level);
 
 extern int ploop_prepare_reloc_index_wb(struct ploop *, struct ploop_index_wb *,
 					unsigned int, unsigned int *);




More information about the Devel mailing list