[Devel] [PATCH RH8 3/3] ploop: Use prealloc_md_pages on ctr.
Kirill Tkhai
ktkhai at virtuozzo.com
Wed May 5 14:52:05 MSK 2021
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