[Devel] [PATCH RH8 16/18] ploop: Save level before submitting pio

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


Introduce a new field and place it there.

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

diff --git a/drivers/md/dm-ploop-map.c b/drivers/md/dm-ploop-map.c
index debd7f6968f4..4cb4ebe37f6e 100644
--- a/drivers/md/dm-ploop-map.c
+++ b/drivers/md/dm-ploop-map.c
@@ -104,6 +104,7 @@ void init_pio(struct ploop *ploop, unsigned int bi_op, struct pio *pio)
 	INIT_LIST_HEAD(&pio->endio_list);
 	/* FIXME: assign real cluster? */
 	pio->cluster = UINT_MAX;
+	pio->level = BAT_LEVEL_INVALID;
 }
 
 /* Get cluster related to pio sectors */
@@ -1015,7 +1016,7 @@ static void data_rw_complete(struct pio *pio)
 	pio_endio(pio);
 }
 
-static void submit_rw_mapped(struct ploop *ploop, struct pio *pio, u8 level)
+static void submit_rw_mapped(struct ploop *ploop, struct pio *pio)
 {
 	unsigned int rw, nr_segs;
 	struct bio_vec *bvec;
@@ -1023,7 +1024,7 @@ static void submit_rw_mapped(struct ploop *ploop, struct pio *pio, u8 level)
 	struct file *file;
 	loff_t pos;
 
-	BUG_ON(level > top_level(ploop));
+	BUG_ON(pio->level > top_level(ploop));
 
 	pio->complete = data_rw_complete;
 
@@ -1036,14 +1037,16 @@ static void submit_rw_mapped(struct ploop *ploop, struct pio *pio, u8 level)
 
 	pos = to_bytes(pio->bi_iter.bi_sector);
 
-	file = ploop->deltas[level].file;
+	file = ploop->deltas[pio->level].file;
 	ploop_call_rw_iter(file, pos, rw, &iter, pio);
 }
 
 void map_and_submit_rw(struct ploop *ploop, u32 dst_clu, struct pio *pio, u8 level)
 {
 	remap_to_cluster(ploop, pio, dst_clu);
-	submit_rw_mapped(ploop, pio, level);
+	pio->level = level;
+
+	submit_rw_mapped(ploop, pio);
 }
 
 static void initiate_delta_read(struct ploop *ploop, unsigned int level,
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 9039d6ab3c49..533249d8eea8 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -217,6 +217,7 @@ struct pio {
 	void *endio_cb_data;
 
 	unsigned int cluster;
+	u8 level;
 
 	bool is_data_alloc:1;
 	bool wants_discard_index_cleanup:1;
@@ -298,6 +299,7 @@ static inline struct pio *map_info_to_pio(union map_info *info)
 }
 
 #define BAT_LEVEL_MAX		(U8_MAX - 1)
+#define BAT_LEVEL_INVALID	U8_MAX
 static inline u8 top_level(struct ploop *ploop)
 {
 	return ploop->nr_deltas - 1;




More information about the Devel mailing list