[Devel] [PATCH RH8 3/8] ploop: Pass nr_deltas to parse_bat_entries()

Kirill Tkhai ktkhai at virtuozzo.com
Tue May 11 11:46:00 MSK 2021


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

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 1c2357a21673..6ac660ab8b8f 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -144,7 +144,8 @@ bool try_update_bat_entry(struct ploop *ploop, unsigned int cluster,
  * BAT_ENTRY_NONE.
  */
 static int parse_bat_entries(struct ploop *ploop, map_index_t *bat_entries,
-		     u8 *bat_levels, unsigned int nr, unsigned int page_id)
+			     u8 *bat_levels, unsigned int nr,
+			     unsigned int page_id, u8 nr_deltas)
 {
 	int i = 0;
 
@@ -171,7 +172,7 @@ static int parse_bat_entries(struct ploop *ploop, map_index_t *bat_entries,
  * Read from disk and fill bat_entries. Note, that on enter here, cluster #0
  * is already read from disk (with header) -- just parse bio pages content.
  */
-static int ploop_read_bat(struct ploop *ploop, struct bio *bio)
+static int ploop_read_bat(struct ploop *ploop, struct bio *bio, u8 nr_deltas)
 {
 	unsigned int id, entries_per_page, nr_copy, nr_all, page, i = 0;
 	map_index_t *from, *to, cluster = 0;
@@ -204,7 +205,7 @@ static int ploop_read_bat(struct ploop *ploop, struct bio *bio)
 			}
 
 			ret = parse_bat_entries(ploop, to, md->bat_levels,
-						nr_copy, id);
+						nr_copy, id, nr_deltas);
 			kunmap(md->page);
 			if (ret)
 				goto out;
@@ -257,7 +258,7 @@ static int ploop_setup_holes_bitmap(struct ploop *ploop,
  * Allocate memory for bat_entries, bat_levels and holes_bitmap,
  * and read their content from disk.
  */
-int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
+int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop, u8 nr_deltas)
 {
 	unsigned int bat_clusters, offset_clusters, cluster_log;
 	struct ploop_pvd_header *m_hdr = NULL;
@@ -315,7 +316,7 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	if (ret)
 		goto out;
 
-	ret = ploop_read_bat(ploop, bio);
+	ret = ploop_read_bat(ploop, bio, nr_deltas);
 out:
 	if (m_hdr)
 		kunmap(page);
diff --git a/drivers/md/dm-ploop-target.c b/drivers/md/dm-ploop-target.c
index a07cee3fea46..a14d0d6cab4f 100644
--- a/drivers/md/dm-ploop-target.c
+++ b/drivers/md/dm-ploop-target.c
@@ -97,7 +97,7 @@ static void ploop_destroy(struct ploop *ploop)
 	kfree(ploop);
 }
 
-static int ploop_check_origin_dev(struct dm_target *ti, struct ploop *ploop)
+static int ploop_check_origin_dev(struct dm_target *ti, struct ploop *ploop, u8 nr_deltas)
 {
 	struct block_device *bdev = ploop->origin_dev->bdev;
 	int r;
@@ -107,7 +107,7 @@ static int ploop_check_origin_dev(struct dm_target *ti, struct ploop *ploop)
 		return -EINVAL;
 	}
 
-	r = ploop_read_metadata(ti, ploop);
+	r = ploop_read_metadata(ti, ploop, nr_deltas);
 	if (r) {
 		ti->error = "Can't read ploop header";
 		return r;
@@ -259,7 +259,7 @@ static int ploop_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 		goto err;
 	}
 
-	ret = ploop_check_origin_dev(ti, ploop);
+	ret = ploop_check_origin_dev(ti, ploop, argc - 2);
 	if (ret) {
 		/* ploop_check_origin_dev() assigns ti->error */
 		goto err;
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 466f1506741e..45db3ec67950 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -524,7 +524,7 @@ extern void cleanup_backup(struct ploop *ploop);
 
 extern int ploop_read_cluster_sync(struct ploop *, struct bio *, unsigned int);
 
-extern int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop);
+extern int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop, u8 nr_deltas);
 extern int ploop_read_delta_metadata(struct ploop *ploop, struct file *file,
 				     void **d_hdr);
 




More information about the Devel mailing list