[Devel] [PATCH RHEL8 COMMIT] ploop: Pass nr_deltas to parse_bat_entries()

Konstantin Khorenko khorenko at virtuozzo.com
Tue May 11 18:30:59 MSK 2021


The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.27
------>
commit 3e23e688bbf2cfbdbb52de0273f74b4526a44f4d
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Tue May 11 18:30:59 2021 +0300

    ploop: Pass nr_deltas to parse_bat_entries()
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Preparation to kill-loop from dm-ploop (series 4)
    
    Currently, ploop requires underlining loop for top delta. This is overkill,
    since we may submit bios directly to fs, without using it.
    
    Initially there was a possibility, we may use device-mapper format snapshots
    instead of ploop-based. But we don't do that, so we have to use loop for top
    delta and directly submit bios to the rest of deltas. So, these two ways to do
    the same actions are wrong.
    
    This is preparations #3 for further series.
    Let's this goes to testing earlier.
    
    Kirill Tkhai (8):
          ploop: Fix prealloc_md_pages() defaults
          ploop: Move alloc wq up
          ploop: Pass nr_deltas to parse_bat_entries()
          ploop: Pass @ploop to md_page_cluster_is_in_top_delta()
          ploop: Kill "message snapshot" interface
          ploop: Introduce top_level()
          ploop: Do not try to track bios on resize
          ploop: Make fields in dm_ploop_endio_hook separate
    
    https://jira.sw.ru/browse/PSBM-123654
    
    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