[Devel] [PATCH RHEL8 COMMIT] ploop: Use prealloc_md_pages on ctr.

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 6 00:32:31 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.26
------>
commit a068858c71205ac0b4f1f6b6ad6a29aea31fd692
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Thu May 6 00:32:31 2021 +0300

    ploop: Use prealloc_md_pages on ctr.
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =====================
    Patchset description:
    
    ploop: Preparation to kill-loop from dm-ploop (series 3)
    
    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 (3):
          ploop: Move fget() code to separate function
          ploop: Move prealloc_pages()
          ploop: Use prealloc_md_pages on ctr.
    
    https://jira.sw.ru/browse/PSBM-123654
    
    Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-ploop-bat.c | 15 ++++++++++-----
 drivers/md/dm-ploop.h     |  5 -----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/md/dm-ploop-bat.c b/drivers/md/dm-ploop-bat.c
index 6ef8ec177670..5ebb05438e2a 100644
--- a/drivers/md/dm-ploop-bat.c
+++ b/drivers/md/dm-ploop-bat.c
@@ -98,7 +98,9 @@ int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
 	void *addr;
 
 	new_nr_pages = bat_clu_to_page_nr(new_nr_bat_entries - 1) + 1;
-	nr_pages = bat_clu_to_page_nr(nr_bat_entries - 1) + 1;
+	nr_pages = 0;
+	if (nr_bat_entries)
+		nr_pages = bat_clu_to_page_nr(nr_bat_entries - 1) + 1;
 
 	for (i = nr_pages; i < new_nr_pages; i++) {
 		md = alloc_md_page(i);
@@ -182,12 +184,11 @@ static int ploop_read_bat(struct ploop *ploop, struct bio *bio)
 	do {
 		for (page = 0; page < nr_pages_in_cluster(ploop); page++) {
 			id = i * sizeof(map_index_t) / PAGE_SIZE;
-			md = alloc_md_page(id);
-			if (!md) {
-				ret = -ENOMEM;
+			md = md_page_find(ploop, id);
+			if (WARN_ON_ONCE(!md)) {
+				ret = -ENOENT;
 				goto out;
 			}
-			md_page_insert(ploop, md);
 
 			nr_copy = entries_per_page;
 			if (i + nr_copy > nr_all)
@@ -310,6 +311,10 @@ int ploop_read_metadata(struct dm_target *ti, struct ploop *ploop)
 	if (ret)
 		goto out;
 
+	ret = prealloc_md_pages(&ploop->bat_entries, 0, ploop->nr_bat_entries);
+	if (ret)
+		goto out;
+
 	ret = ploop_read_bat(ploop, bio);
 out:
 	if (m_hdr)
diff --git a/drivers/md/dm-ploop.h b/drivers/md/dm-ploop.h
index 040e798fdbe7..e2af133c45a2 100644
--- a/drivers/md/dm-ploop.h
+++ b/drivers/md/dm-ploop.h
@@ -481,11 +481,6 @@ static inline struct dm_ploop_endio_hook *find_endio_hook(struct ploop *ploop,
 	return find_endio_hook_range(ploop, root, cluster, cluster);
 }
 
-static inline struct pio *bio_to_endio_hook(struct bio *bio)
-{
-	return dm_per_bio_data(bio, sizeof(struct pio));
-}
-
 extern int prealloc_md_pages(struct rb_root *root, unsigned int nr_bat_entries,
 			     unsigned int new_nr_bat_entries);
 extern void md_page_insert(struct ploop *ploop, struct md_page *md);


More information about the Devel mailing list