[Devel] [PATCH RH8 21/22] ploop: Add argument to ploop_read_delta_metadata()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 30 13:34:42 MSK 2021


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

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index ae6b4628d813..53a51871b0b2 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -356,7 +356,7 @@ int convert_bat_entries(u32 *bat_entries, u32 count)
 }
 
 int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
-			      void **d_hdr)
+			      void **d_hdr, u32 *delta_nr_be_ret)
 {
 	u32 size, delta_nr_be, *delta_bat_entries;
 	struct iov_iter iter;
@@ -391,6 +391,7 @@ int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
 	delta_bat_entries = *d_hdr + PLOOP_MAP_OFFSET * sizeof(map_index_t);
 	ret = convert_bat_entries(delta_bat_entries, delta_nr_be);
 
+	*delta_nr_be_ret = delta_nr_be;
 out_vfree:
 	if (ret) {
 		vfree(*d_hdr);
@@ -505,10 +506,10 @@ int ploop_add_delta(struct ploop *ploop, u32 level, struct file *file, bool is_r
 		goto out;
 
 	if (!is_raw) {
-		ret = ploop_read_delta_metadata(ploop, file, (void *)&hdr);
+		ret = ploop_read_delta_metadata(ploop, file, (void *)&hdr,
+						&size_in_clus);
 		if (ret)
 			goto out;
-		size_in_clus = le32_to_cpu(hdr->m_Size);
 	} else {
 		size_in_clus = POS_TO_CLU(ploop, file_size);
 	}
diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 0bfd759347a8..d1ed50ed4772 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -786,12 +786,10 @@ static int ploop_delta_clusters_merged(struct ploop *ploop, u8 level,
 	/* Reread BAT of deltas[@level + 1] (or [@level - 1]) */
 	file = ploop->deltas[level + forward ? 1 : -1].file;
 
-	ret = ploop_read_delta_metadata(ploop, file, (void *)&d_hdr);
+	ret = ploop_read_delta_metadata(ploop, file, (void *)&d_hdr, &size_in_clus);
 	if (ret)
 		goto out;
 
-	size_in_clus = le32_to_cpu(d_hdr->m_Size);
-
 	ret = ploop_suspend_submitting_pios(ploop);
 	if (ret)
 		goto out;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 4471c3ecb5df..8bb075b72e3f 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -552,7 +552,7 @@ extern void pio_prepare_offsets(struct ploop *, struct pio *, unsigned int);
 
 extern int ploop_setup_metadata(struct ploop *ploop, struct page *page);
 extern int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
-				     void **d_hdr);
+				     void **d_hdr, u32 *delta_nr_be);
 extern void ploop_index_wb_init(struct ploop_index_wb *piwb, struct ploop *ploop);
 extern void ploop_call_rw_iter(struct file *file, loff_t pos, unsigned rw,
 			       struct iov_iter *iter, struct pio *pio);




More information about the Devel mailing list